/* 	######################
	if a page needs a js variable, it can define it in its own js file and use it here.
	pages that dont define it, will set it to empty string, thanks to the next declarations...
	######################
*/
if (typeof vehicle == "undefined") var vehicle = "";
if (typeof site == "undefined") var site = "";
if (typeof menuType == "undefined") var menuType = "";
if (typeof superCat == "undefined") var superCat = "";
if (typeof superItem == "undefined") var superItem = "";
if (typeof modelId == "undefined") var modelId = "";
if (typeof deeplink == "undefined") var deeplink = "";

/* 	######################
	hash of uri's and corresponding flash replacement values
	######################
*/

var siteDir = (typeof site != "undefined" && site == "lightduty") ? "lightduty/" : "es/";
var lcid = new Date().getTime();

var URIs = new Array();

//Spanish
URIs['/es/index.jsp'] = new Array("gPageWrapper","/es/flash/homepage/homeStage.swf","1000","890","smenu=" + menuType + "&site=" + site + "&lcid=" + lcid + "");

URIs['/' + siteDir + brand + '/' + vehicle + '/index.jsp'] = new Array("gContent","/es/flash/vehicleHome/modelPages.swf","840","860","brand=" + brand + "&section=masthead&site=" + site + "&deeplink="+ deeplink + "&lcid=" + lcid + "&vehicle=" + vehicle + "" );
URIs['/' + siteDir + brand + '/' + vehicle + '/colors.jsp'] = new Array("gContent","/es/flash/vehicleHome/modelPages.swf","840","860","brand=" + brand + "&section=colors&site=" + site + "&deeplink=" + deeplink + "&lcid=" + lcid + "&vehicle=" + vehicle + "" );
URIs['/' + siteDir + brand + '/' + vehicle + '/gallery.jsp'] = new Array("gContent","/es/flash/vehicleHome/modelPages.swf","840","860","brand=" + brand + "&section=gallery&site=" + site + "&deeplink=" + deeplink + "&lcid=" + lcid + "&vehicle=" + vehicle + "" );
URIs['/' + siteDir + brand + '/' + vehicle + '/accessories.jsp'] = new Array("gContent","/es/flash/vehicleHome/modelPages.swf","840","860","brand=" + brand + "&section=accessories&site=" + site + "&deeplink=" + deeplink + "&lcid=" + lcid + "&vehicle=" + vehicle + "" );
URIs['/' + siteDir+ brand +'/safety.jsp'] = new Array("gContent","/es/flash/vehicleHome/modelPages.swf","840","860","page=safety&brand=" + brand+ "&site="+site + "&deeplink=" + deeplink + "&lcid=" + lcid + "&vehicle=" + vehicle + "" );
URIs['/' + siteDir + brand +'/index.jsp'] = new Array("cfamilyContent","/es/flash/family/masthead.swf","840","151");



URIs['/acadia/acadiaexperience.jsp'] = new Array("pAcadiaContent","flash/newvehicles/acadia/stage.swf","1000","650","");
URIs['/2007sierra/2007sierraexperience.jsp'] = new Array("pSierraContent","flash/newvehicles/2007sierra/Sierra07.swf","1000","650","");

URIs['/popup/' + brand + '/' + superCat + '.jsp'] = new Array("gContent","/es/flash/divisional/superpop.swf","605","580","brand=" + brand + "&superCat=" + superCat + "&site=" + site + "&superItem=gspMenu" + superItem);
URIs['/' + brand + '/' + vehicle + '/locate.jsp'] = new Array("gContent","/es/flash/locate.swf","840","790","brand=" + brand + "&site=" + site + "&section=masthead&modelId=" + modelId + "&year=2007");


/* 	######################
	flash replacement
	######################
*/

function gReplaceFlash() {

if(typeof sIFR == "function" && URIs[uri] != undefined && useFlash == "Y"){
	// if flash is present && uri is listed above && and we want to use flash, replace flash
	var replaceNode = getElemRefs(URIs[uri][0]);
	var swfName = URIs[uri][1];
	var width = URIs[uri][2];
	var height = URIs[uri][3];
	var params = URIs[uri][4];
	var bgColor = "#292C33";
	if (uri == "/currentoffers/index.jsp") bgColor="#2C2F38";
	if (uri == "/acadia/acadiaexperience.jsp") bgColor="#ffffff";
	if (uri == "/yukonhybrid/index.jsp") bgColor="#2C2F38";

	
	if (typeof(lcId) != "undefined") {
		if (lcId != null) { 
			params += "&lcId="+ lcId;
		}
	}

	//sIFR.replaceElement(named({nWidth:width,nHeight:height,oNodeRef: replaceNode, sFlashSrc:swfName, sColor:"#FFFFFF", sLinkColor:"#000000", sBgColor:bgColor, sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:params + '&allowscriptaccess=always'}));
	var so = new SWFObject(swfName, "flashReplaced", width, height, "8", bgColor);
	so.addVariable("allowscriptaccess", "always");
	
	if (params) {
		var pp = params.split("&");
		for (var q = 0; q < pp.length; q++) so.addVariable(pp[q].split("=")[0], pp[q].split("=")[1]);
	}
	so.addVariable("txtCount", 1);
	var ihtml = sIFR.myInnerHTML(replaceNode);
	ihtml = ihtml.split("\"").join(escape("\""));
	ihtml = ihtml.split("&").join(escape("&"));
	
	so.addVariable("txt0", ihtml);
	so.addParam("align","top");
	so.addParam("scale","noorder");
	so.addParam("salign","left");
	
	so.write(replaceNode.id);
	
} else if( (uri.indexOf( brand + '/' + vehicle ) > -1) && (brand != "")){
	
	var obj = getElemRefs("gContent");
	obj.className = "noFlash";
}
else{
	// otherwise, make XHTML display:block (with a special case for homepage
		if(uri == '/es/index.jsp') {
			document.getElementById('gNav').style.display = 'block';
			document.getElementById('gContent').style.display = 'block';
		}
	
		 else {
			document.getElementById('gXHTMLContent').style.display = 'block';
		}
		if(uri == '/yukonhybrid/index.jsp') {
			document.getElementById('gNav').style.display = 'block';
			document.getElementById('gContent').style.display = 'block';
			document.getElementById('gXHTMLContent').style.display = 'block';
		}		
}

if (uri == "/currentoffers/index.jsp") document.getElementById('gXHTMLContent').style.display = 'block';
if (uri == "/yukonhybrid/index.jsp") document.getElementById('gXHTMLContent').style.display = 'block';
}

AttachEvent(window, "load", gReplaceFlash);