var flashObj; //added for phase3 pop-up close
var toolboxflashobj; //added for phase3 pop-up close
var menuTimeout;
var subMenuTimeout;
var currentMenu;
var currentSubMenu;
var imgPathNav = "/images/";	// Image path location for Global Nav menu images.
var imgPath = "/images/";			// Image path location for all other text images.
// Addition by KA to cater for global and non-global images
var globalImgPath = "/images/";			// Image path location for all other global images.
var navIsLoaded = false;
var isLowRes = false;
var doneEasingloading = false;

/* Mozilla MouseWheel Function Start */

var agt=navigator.userAgent.toLowerCase();
var is_gecko = (agt.indexOf('gecko') != -1);
if (is_gecko) window.addEventListener('DOMMouseScroll', mozillaScroll, false); 
function getFlashMovieObject(movieName)
{
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      flashObj = document.embeds[movieName]; 
	  return flashObj;
  }
}
function mozillaScroll(e){
	if (flashObj != null && flashObj.PercentLoaded() == 100){
		Loader_Mc = flashObj.TCurrentFrame("/Loader_Mc");
		RamgeStrip_Mc = flashObj.TCurrentFrame("/RamgeStrip_Mc");
		if (e.detail > 0) {
			if(Loader_Mc == 5) {
				flashObj.TPlay("/Loader_Mc/mouseWheel4MozillaPlus");
			}
			if(RamgeStrip_Mc == 5) {
				flashObj.TPlay("/RamgeStrip_Mc/mouseWheel4MozillaPlus");
			}
		} else {
			if(Loader_Mc == 5) {
				flashObj.TPlay("/Loader_Mc/mouseWheel4MozillaMinus");
			}
			if(RamgeStrip_Mc == 5) {
				flashObj.TPlay("/RamgeStrip_Mc/mouseWheel4MozillaMinus");
			}
		}
	}
}

/* Mozilla MouseWheel Function End */

// Initializing the global navigation
// Initializing the global navigation
// change init() to globalNavInit()
function init() {
	DynLayerInit();
	navIsLoaded = true;	// boolean to true when initialization is complete
	rotateOnload();
}


var doneEasingloading = false;
// this  function  called from toolbox SWf completly Loaded
function initialCheck(){
	if(toolboxflashobj.PercentLoaded() == 100){
		var totFrame = toolboxflashobj.TCurrentFrame("/loadinganimation");
		if(totFrame >= 224){
			loadEasingStrip();
			
		}
	}
}

var easingExists = false;
var plpExists = false;
function hideEasing(){
   if (flashObj != null) {
		if(easingExists){
			var currentFrame = flashObj.TCurrentFrame("/Loader_Mc/Intro_Ani");
			if(currentFrame >= 22){
				flashObj.TPlay("/Loader_Mc/popupCheck_mc");
			}
		}
		if(plpExists){
			var currentFrame = flashObj.TCurrentFrame("/RamgeStrip_Mc/Intro_Ani");
			if(currentFrame >= 22){
				flashObj.TPlay("/RamgeStrip_Mc/popupCheck_mc");
			}
		}
	//alert("toolboxExists : " + toolboxExists);
		if(toolboxExists){
			flashObj.TPlay("ToolMc/toolbox_mc");
		}
    } 

	if (toolboxflashobj != null) {
		toolboxflashobj.TPlay("ToolMc/toolbox_mc");
	}
}




//added for phase3 pop-up close - End
// Display the dropdown menu.
// inputs: menuName  - name of the menu DIV layer without the Div.  ie. vehicles
// output: none
function hideEasingPopup(){
		if(easingExists){
			var currentFrame = flashObj.TCurrentFrame("/Loader_Mc/Intro_Ani");
			if(currentFrame >= 22){
				flashObj.TPlay("/Loader_Mc/popupCheck_mc");
			}
		}
}

function hideToolboxPopup(){
	if(toolboxExists){
		flashObj.TPlay("ToolMc/toolbox_mc");
	}
}



//function loadEasingStrip(){
//	if(doneEasingloading == false){
//		if(easingExists){
//			  flashObj.TPlay("/Loader_Mc/loadingCheck_mc");
//		}
//		doneEasingloading = true;
//	}
//}



//added for phase3 pop-up close - End
// Display the dropdown menu.
// inputs: menuName  - name of the menu DIV layer without the Div.  ie. vehicles
// output: none

function menuOn(menuName) {
	var theMenu;
	//easingStripPopClose(); //added for phase3 pop-up close
	//toolboxPopClose();  //added for phase3 pop-up close
	if (!navIsLoaded) {
		return;	// check if initialization is complete
	}
	if (menuTimeout) {
		clearTimeout(menuTimeout);	// clear the timeout
	}
	if (currentMenu) {			// hide the current menu
		theMenu = eval(currentMenu);
		theMenu.hide();
	}
	//KOD tweak for dual menus
	if (currentSubMenu) {			// hide the current menu
		theSubMenu = eval(currentSubMenu);
		theSubMenu.hide();
	}
	vehicles.hide();
	//End KOD tweak
	currentMenu = menuName;	
	theMenu = eval(currentMenu);
	theMenu.show();				// display menuName
	menuTimeout = setTimeout(currentMenu + '.hide()', 3000);		// set the timeout 
	//doPassVar();
	hideEasing();
}

// Hides the dropdown menus
// inputs: menuName - name of the menu DIV layer without the Div.  ie. vehicles
// outputs: none
function menuOff(menuName) {
	if (!navIsLoaded) {
		return	// check if initialization is complete
	}
	if (menuTimeout) {
		clearTimeout(menuTimeout)	// clear the current timeout
	}
	menuTimeout = setTimeout(menuName + '.hide()', 500)		// set the new timeout
	//setArrowOff('div_white_ins');
}

// Swaps the menu image to the ON state.
// input: imgName - name of the image to turn on
// output: swaps the image to the ON state

function menuLinkOn(imgName) {
	var theImage;
	if (menuTimeout) {
		clearTimeout(menuTimeout);
	}
	theImage = (is.ns4) ? eval("document.layers['" + currentMenu + "Div'].document.images['" + imgName + "']") : eval("document." + imgName);
	//theImage.src = imgPathNav + "tnav_lnk_" + imgName + "_on.gif";
	theImage.src = imgPathNav + imgName + "_on.gif";
}

// Swaps the menu image to the OFF state.
function menuLinkOff(imgName) {
	var theImage;
	theImage = (is.ns4) ? eval("document.layers['" + currentMenu + "Div'].document.images['" + imgName + "']") : eval("document." + imgName);
	//theImage.src = imgPathNav + "tnav_lnk_" + imgName + ".gif";
	theImage.src = imgPathNav + imgName + ".gif";
	menuOff(currentMenu);
}


// Swaps the link image.
// input: 	imgName - name of the image
//			ON - on or off state


function linkSwap(imgName, ON) {
	var theImage = eval("document." + imgName);
	theImage.src = imgPath + imgName + "_lnk" + ((ON) ? "_on":"") + ".gif"
}


function swapArrow(imageName, image) {
	var theImage = 'document.' ;
	theImage += 'getElementsByName('+'\''+imageName+'\''+')[0]' ;
	theImageObj = eval(theImage);
	theImageObj.src = image ;
}

// Swaps the arrow image.
// input: 	imgName - name of the image
//			ON - on or off state

function arrowSwap(linkName, ON, obj, obj2) {
	var theImage = 'document.'
	if (obj && is.ie) {
		theImage += 'all.'
	} else if (obj && is.ns) {
	 	theImage += obj + '.document.'
	} 

	if (obj2 && is.ns) {
		theImage += obj2 + '.document.'
	}

	theImage += linkName
	theImageObj = eval(theImage);
	theImageObj.src = globalImgPath + "g_arrow" + ((ON) ? "_on":"") + ".gif";
}

// Swaps the arrow image.
// input: 	imgName - name of the image
//			ON - on or off state
function arrowSwapUp(linkName, ON, obj, obj2) {
	var theImage = 'document.'
	if (obj && is.ie) {
		theImage += 'all.'
	} else if (obj && is.ns) {
	 	theImage += obj + '.document.'
	} 

	if (obj2 && is.ns) {
		theImage += obj2 + '.document.'
	}
	theImage += linkName
	theImageObj = eval(theImage);
	theImageObj.src = globalImgPath + "page_up" + ((ON) ? "_on":"") + ".gif";
}





// Added by KOD
// Display the dropdown submenu for the vehicle categories.
// inputs: menuName  - name of the menu DIV layer without the Div.  ie. vehicles
// output: none
function subMenuOn(menuName, menuId) {
	var theSubMenu;
	var winWidth = document.body.offsetWidth ;
	if (!navIsLoaded) { 
		return;	// check if initialization is complete
	}
	if (subMenuTimeout) {
		clearTimeout(subMenuTimeout);	// clear the timeout
	}
	if (currentSubMenu) {			// hide the current menu
		theSubMenu = eval(currentSubMenu);
		theSubMenu.hide();
	}
	currentSubMenu = menuName;	
	theSubMenu = eval(currentSubMenu);
	theSubMenu.show();				// display menuName
	subMenuTimeout = setTimeout(currentSubMenu + '.hide()', 3000);		// set the timeout 
	clearTimeout(menuTimeout);
}


// Hides the dropdown vehicle submenus
// inputs: menuName - name of the menu DIV layer without the Div.  ie. vehicles
// outputs: none
function subMenuOff(menuName) {
	if (!navIsLoaded) {
		return	// check if initialization is complete
	}
	if (subMenuTimeout) {
		clearTimeout(subMenuTimeout)	// clear the current timeout
	}
	menuOff('vehicles');
	subMenuTimeout = setTimeout(menuName + '.hide()', 500);		// set the new timeout
}


// Arrow swap for text based dynamic dropdowns in Global nav.  Not required if images are used
// input: 	imgName - name of the image
//			ON - on or off state
function menuArrowSwap(linkName, ON) {
	var theImage = 'document.'
	theImage += linkName
	theImageObj = eval(theImage);
	theImageObj.src = "g_arrow" + ((ON) ? "_on":"") + ".gif";
}


function subMenuMOver() {
	if (menuTimeout) clearTimeout(menuTimeout);
}


function subMenuFocus() {
	if (menuTimeout) clearTimeout(menuTimeout);
	if (subMenuTimeout) clearTimeout(subMenuTimeout);
}


// Swaps the arrow image.
// input: 	imgName - name of the image
//			ON - on or off state
function arrowSwapNav(linkName, ON) {
	var theImage = 'document.'
	theImage += linkName
	theImageObj = eval(theImage);
	theImageObj.src = "g_arrow_dark" + ((ON) ? "_on":"") + ".gif";
}


//Sets the appropriate Dealer Locator Status on the Utility bar
function dlSelect(divName) {
	var elementId = divName;
	if (elementId=="1"){ 
		var idToShow=3; 
		var idToHide=2;
	}
	if (elementId=="2") { 
		var idToShow=3; 
		var idToHide=1;
	}
	if (elementId=="3") { 
		var idToShow=1; 
		var idToHide=2;
	}
	document.getElementById('u_dealerLocator' + elementId).style.visibility = 'hidden';
	document.getElementById('u_dealerLocator' + idToHide).style.visibility = 'hidden';
	document.getElementById('u_dealerLocator' + idToShow).style.visibility = 'visible';
}

function rotateOnload(){
// Placeholder function call to prevent js errors in non-utility bar pages
}


//utility bar functions for dealer locator multimap search
// the novapage parameter is used to show that the user have gone from NOVA to multimap
function openMultiMapSearchWithParam(mmClientName,mmDbName,formName,formValue,vehValue){
	var inputName = formName ;
	var inputValue = escape(formValue);
	var vehVal = vehValue ; // Added for 1 point 1 change
	var recordlimit = 5;
	// Added for DE changes below - RP
	// Added to resolve DE search issues - RP
	if (mmDbName=="DE") {
		if (inputName=="addr3") {
			if ((formValue.toLowerCase() == "bad marienberg")) {
				inputValue = "56470"; 
				inputName="pc";
			}
			else if (formValue.toLowerCase() == "coswig") { 
				inputValue = "06869"; 
				inputName="pc"; 
			}
			else if (escape(formValue).toLowerCase() == ('%d6strich-winkel')) { 
				inputValue = "65375"; 
				inputName="pc"; 
			}
			else if (formValue.toLowerCase() == "ostrich-winkel") { 
				inputValue = "65375"; 
				inputName="pc"; 
			}
			else if (formValue.toLowerCase() == "linsengericht") { 
				inputValue = "63589"; 
				inputName="pc"; 
			}
			else if (formValue.toLowerCase() == "moers") { 
				inputValue = "47443"; 
				inputName="pc"; 
			}
			else if (formValue.toLowerCase() == "nauen") { inputValue = "14641"; inputName="pc"; }
			else if (formValue.toLowerCase() == "alfeld") { inputValue = "31061"; inputName="pc"; }
			else if (formValue.toLowerCase() == "naumburg") { inputValue = "06618"; inputName="pc"; }
			else if (formValue.toLowerCase() == "soest") { inputValue = "59494"; inputName="pc"; }
			else if (formValue.toLowerCase() == "staffelstein") { inputValue = "96231"; inputName="pc"; }
			else if (formValue.toLowerCase() == "stolberg") { inputValue = "52222"; inputName="pc"; }
			else if (formValue.toLowerCase() == "winsen") { inputValue = "21423"; inputName="pc"; }
			else if (escape(formValue).toLowerCase() == ('m%fchlhausen')) { inputValue = "99974"; inputName="pc"; }
			else if (formValue.toLowerCase() == "muhlhausen") { inputValue = "99974"; inputName="pc"; }
			else if (formValue.toLowerCase() == "oberhausen") { inputValue = "46149"; inputName="pc"; }
			else if (escape(formValue).toLowerCase() == ('%d6ttersdorf')) { inputValue = "07907"; inputName="pc"; }
			else if (formValue.toLowerCase() == "ottersdorf") { inputValue = "07907"; inputName="pc"; }
			else if (formValue.toLowerCase() == "roth") { inputValue = "91154"; inputName="pc"; }
			else if (escape(formValue).toLowerCase() == ('sch%f6nebeck')) { inputValue = "39218"; inputName="pc"; }
			else if (formValue.toLowerCase() == "schonebeck") { inputValue = "39218"; inputName="pc"; }
			else if (formValue.toLowerCase() == "singen") { inputValue = "78224"; inputName="pc"; }
			else if (formValue.toLowerCase() == "sulzbach") { inputValue = "66280"; inputName="pc"; }
			else if (formValue.toLowerCase() == "thalheim") { inputValue = "09380"; inputName="pc"; }
			else if (formValue.toLowerCase() == "wedemark") { inputValue = "30900"; inputName="pc"; }
			else if (formValue.toLowerCase() == "auerbach") { inputValue = "08209"; inputName="pc"; }
			else if (formValue.toLowerCase() == "bergen") { inputValue = "18528"; inputName="pc"; }
			else if (formValue.toLowerCase() == "brake") { inputValue = "26919"; inputName="pc"; }
			else if (formValue.toLowerCase() == "burg") { inputValue = "39288"; inputName="pc"; }
			else if (formValue.toLowerCase() == "forst") { inputValue = "03149"; inputName="pc"; }
			else if (formValue.toLowerCase() == "frankenthal") { inputValue = "67227"; inputName="pc"; }
			else if (formValue.toLowerCase() == "gronau") { inputValue = "48599"; inputName="pc"; }
			else if (formValue.toLowerCase() == "hagen") { inputValue = "58135"; inputName="pc"; }
			else if (formValue.toLowerCase() == "halle") { inputValue = "33790"; inputName="pc"; }
			else if (formValue.toLowerCase() == "hof") { inputValue = "95030"; inputName="pc"; }
			else if (escape(formValue).toLowerCase() == ('k%f6then')) { inputValue = "06366"; inputName="pc"; }
			else if (formValue.toLowerCase() == "kothen") { inputValue = "06366"; inputName="pc"; }
			else if (formValue.toLowerCase() == "krumbach") { inputValue = "86381"; inputName="pc"; }
			else if (formValue.toLowerCase() == "haren") { inputValue = "49733"; inputName="pc"; }

			// The below code has been added for DE to return missing dealers

			// This will not be required once radius search is used
			if (formValue.toLowerCase()=="berlin") {
				recordlimit = "15";
			} else if (formValue.toLowerCase()=="duisburg") {
				recordlimit = "10";			
			} else if (formValue.toLowerCase()=="hamburg") {
				recordlimit = "12";			
			} else if ( formValue.toLowerCase()=="koln") {
				recordlimit = "7";			
			} else if (escape(formValue).toLowerCase() == ('k%f6ln')) {
				recordlimit = "7";			
			}
		}	
	}


	// RP stop
	// Below if statement added for 1 point 1 code and reclimit made dynamic for DE change


	if (vehValue=='passenger' || vehValue=='lcv' || vehValue=='4x4') {
		if (vehValue=='passenger') {
			var url = "http://www.multimap.com/clients/places.cgi?place=&reclimit=" + recordlimit + "&height=290&width=408&" + "client=" + mmClientName + "&" + "db=" + mmDbName + "&" + inputName + "=" + inputValue + "&f_" + vehVal + "_vehicle=y";	
		} else {
			var url = "http://www.multimap.com/clients/places.cgi?place=&reclimit=" + recordlimit + "&height=290&width=408&" + "client=" + mmClientName + "&" + "db=" + mmDbName + "&" + inputName + "=" + inputValue + "&f_" + vehVal + "=y";			
		}	
	} else {	
		var url = "http://www.multimap.com/clients/places.cgi?place=&reclimit=" + recordlimit + "&height=290&width=408&" + "client=" + mmClientName + "&" + "db=" + mmDbName + "&" + inputName + "=" + inputValue;
	}		
	popWindow(url,'windowName',476,667,1,0,0);
}


function openURLAdvanced(mmClientName,mmDbName,vehValue){
	if (vehValue=='passenger' || vehValue=='lcv' || vehValue=='4x4') {
		if (vehValue=='passenger') {
			var url = "http://www.multimap.com/clients/places.cgi?place=&reclimit=5&" + "client=" + mmClientName + "&" + "db=" + mmDbName + "&f_" + vehValue + "_vehicle=y";
		} else {
			var url = "http://www.multimap.com/clients/places.cgi?place=&reclimit=5&" + "client=" + mmClientName + "&" + "db=" + mmDbName + "&f_" + vehValue + "=y";		
		}	
	} else {
		var url = "http://www.multimap.com/clients/places.cgi?place=&reclimit=5&" + "client=" + mmClientName + "&" + "db=" + mmDbName;		
	}	
	popWindow(url,'windowName',476,667,1,0,0);
}

//added for flash optimization

function includeToolBoxFlash(urlstr, flash_filename) {
	var langugageCode = flash_filename;

	
	var useNissanAG = false;
	if (flash_filename.indexOf('uk_UA') > 0) {
		useNissanAG = true;
	}

	if (flash_filename.indexOf('ru_UA') > 0){
		useNissanAG = true;
	}

	if (flash_filename.indexOf('ru_RU') > 0){
		useNissanAG = true;
	}

	if (flash_filename.indexOf('sk_SK') > 0) {
		useNissanAG = true;
	}

	if (flash_filename.indexOf('pl_PL') > 0) {
		useNissanAG = true;
	}

	if (flash_filename.indexOf('sv_SE') > 0) {
		useNissanAG = true;
	}

	if (flash_filename.indexOf('hu_HU') > 0) {
		useNissanAG = true;
	}

	if (flash_filename.indexOf('fi_FI') > 0) {
		useNissanAG = true;
	}

	if (flash_filename.indexOf('cs_CZ') > 0) {

		useNissanAG = true;
	}
	var dontShowEBrochure = "YES";

	var newUrlStr = "";
	
	if ( (urlstr.indexOf('vehicles/carbuilder/index.htmll') < 0)  && (urlstr.indexOf('vehicles/carbuilder/') > 0)) {
		newUrlStr = urlstr.substring(0, urlstr.indexOf('carbuilder')) + urlstr.substring( (urlstr.indexOf('carbuilder') + 11), urlstr.lastIndexOf('/') + 1 ) + "CBToolbox.html";
		urlstr = newUrlStr;
	}
	if (urlstr.indexOf('contact') > 0) {
		newUrlStr = urlstr.substring(0, urlstr.indexOf('contact')) + 
			"toolbox_" + urlstr.substring(urlstr.indexOf('contact/') + 8, 
			urlstr.indexOf('/index.htmll')) + ".html?ln=" + flash_filename;
		urlstr = newUrlStr;
	}
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="240" height="500" id="ToolboxIntegration" align="top">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/nova/global/swf/ToolboxLoader.swf?languageCode=' + langugageCode + '&tt=' + urlstr + '&NissanAG=' + useNissanAG + '&dontShowEBrochure='  + dontShowEBrochure + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="scale" value="exactfit" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/nova/global/swf/ToolboxLoader.swf?languageCode=' + langugageCode + '&tt=' + urlstr + '&NissanAG=' + useNissanAG + '&dontShowEBrochure=' + dontShowEBrochure  + '" quality="high" scale="exactfit" salign="" wmode="transparent" menu="false" width="240" height="500" name="ToolboxIntegration" align="top" swLiveConnect="true" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
	
	//added for phase-3 pop-up close
	if(navigator.appName.indexOf("Microsoft") != -1) {
		toolboxflashobj = window.ToolboxIntegration;
	}else {
		toolboxflashobj = window.document.ToolboxIntegration;
	}
}
function includeFlashObject( id, version, width, height, align, 
	movie, bgcolor, menu, loop, quality, scale, salign, flashvars, noembed, wmode) {
	document.write( '<object id="' + id + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version + '" width="' + width + '" height="' + height + '" align="' + align + '"><param name="wmode" value="' + wmode + '" /><param name="movie" value="' + movie + '" /><param name="bgcolor" value="' + bgcolor + '" /><param name="menu" value="' + menu + '" /><param name="loop" value="' + loop + '" /><param name="quality" value="' + quality + '" /><param name="scale" value="' + scale + '" /><param name="salign" value="' + salign + '" /><param name="flashvars" value="'+ flashvars + '" /><embed name="' + id + '" src="' + movie + '" wmode="' + wmode + '" width="' + width + '" height="' + height + '" swLiveConnect="true" salign="' + salign + '" align="' + align + '" flashvars="' + flashvars + '" scale="'+ scale + '" bgcolor="' + bgcolor + '" quality="' + quality + '" menu="' + menu + '" loop="'+ loop + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed><noembed>' + noembed + '</noembed></object>');
}

<!--added for PLP-->

function includeproductlanding(urlstr1,urlstr,flashname,theLocale) {
	//alert(urlstr1);
var langugageCode = theLocale;
var dontuseNissanAG = false;
 if (theLocale.indexOf('sk_SK') > 0) {
  dontuseNissanAG = true;
 }
 if (theLocale.indexOf('pl_PL') > 0) {
  dontuseNissanAG = true;
 }
 if (theLocale.indexOf('sv_SE') > 0) {
  dontuseNissanAG = true;
 }
 if (theLocale.indexOf('hu_HU') > 0) {
  dontuseNissanAG = true;
 }
 if (theLocale.indexOf('fi_FI') > 0) {
  dontuseNissanAG = true;
 }
 if (theLocale.indexOf('cs_CZ') > 0) {
  dontuseNissanAG = true;
 }
if (theLocale.indexOf('ru_RU') > 0){
  dontuseNissanAG = true;
}
 
 if (theLocale.indexOf('uk_UA') > 0) {
  
  dontuseNissanAG = true;
 }
 if (theLocale.indexOf('ru_UA') > 0) {
  
  dontuseNissanAG = true;
 }
 var dontShowEBrochure = "YES";
 var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
   myWidth = window.innerWidth;
   myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.offsetWidth || document.documentElement.offsetHeight ) ) {
   //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.offsetWidth;
    myHeight = document.documentElement.offsetHeight;
  } else if( document.body && ( document.body.offsetWidth || document.body.offsetHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.offsetWidth;
    myHeight = document.body.offsetHeight;
  }
 // window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  //+ '&plptt=' + urlstr 
 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="462" id="productlanding" align="bottom">');
 document.write('<param name="allowScriptAccess" value="sameDomain" />');
 document.write('<param name="movie" value="/nova/global/swf/productlanding.swf?bar=' + myWidth + '&tt=' + urlstr + '&languageCode=' + langugageCode + '&NissanAG=' + dontuseNissanAG  + '&dontShowEBrochure=' + dontShowEBrochure + '" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/nova/global/swf/productlanding.swf?tt=' + urlstr  + '&languageCode=' + langugageCode + '&NissanAG=' + dontuseNissanAG  + '&dontShowEBrochure=' + dontShowEBrochure + '" quality="high" scale="noscale" salign="" wmode="transparent" bgcolor="#ffffff" width="100%" height="462" name="productlanding" align="top" swLiveConnect="true" allowScriptAccess="sameDomain"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');



 document.write('</object>');                                                                                                   
 //added for phase-3 pop-up close
	if(navigator.appName.indexOf("Microsoft") != -1) {
	
		flashObj = window.productlanding;
	}else {
			flashObj = window.document.productlanding;
	}
	}
	
	<!--code ended for plp-->

function includeShowroomFlash(urlstr, flash_filename,vehicle_code,lang_code) {	
	var useNissanAG = false;
	if (flash_filename.indexOf('uk_UA') > 0) {
		useNissanAG = true;
	}
	if (flash_filename.indexOf('ru_UA') > 0){
		useNissanAG = true;
	}
	if (flash_filename.indexOf('ru_RU') > 0){
		useNissanAG = true;
	}
	if (flash_filename.indexOf('sk_SK') > 0) {
		useNissanAG = true;
	}
	if (flash_filename.indexOf('pl_PL') > 0) {
		useNissanAG = true;
	}
	if (flash_filename.indexOf('sv_SE') > 0) {
		useNissanAG = true;
	}
	if (flash_filename.indexOf('hu_HU') > 0) {
		useNissanAG = true;
	}
	if (flash_filename.indexOf('fi_FI') > 0) {
		useNissanAG = true;
	}
	if (flash_filename.indexOf('cs_CZ') > 0) {
		useNissanAG = true;
	}
	var langugageCode = lang_code;

	var dontShowEBrochure = "YES";

	/**var PassQuery = String(window.location);
	PassQuery = PassQuery.substr(PassQuery.indexOf("?")+1,PassQuery.length);
	PassQuery = PassQuery.split("=")[1];*/
	var PassQuery = myParamSplitter("vehicle");

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="462" id="ShowRoom" align="top">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/nova/global/swf/ShowRoom.swf?vehicle=' + PassQuery + '&ln=' + lang_code +'&languageCode=' + langugageCode +'&tt=' + urlstr + '&NissanAG=' + useNissanAG + '&dontShowEBrochure=' + dontShowEBrochure + '"   /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/nova/global/swf/ShowRoom.swf?vehicle=' + PassQuery + '&ln=' + lang_code +'&languageCode=' + langugageCode +'&tt=' + urlstr + '&NissanAG=' + useNissanAG + '&dontShowEBrochure=' + dontShowEBrochure + '" quality="high" scale="noscale" salign="" wmode="transparent" bgcolor="#ffffff" width="100%" height="462" name="ShowRoom" align="top" swLiveConnect="true" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>'); 
}

function myParamSplitter (name) {
  var name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

//END FOR SHOWROOM


function includeFlash( id, version, width, height, align, movie, bgcolor, menu, loop, quality, scale, salign, flashvars, noembed, wmode) {
	var allowScriptAccess =	"";
	var swLiveConnect = "";
	if ( version == "") {
		version = "";
	}
	if ( id == "") id  = "movie";
	if ( width == "") width = "980";
	if ( height == "") height = "560";
	if ( align == "") align = "middle";
	if ( allowScriptAccess == "") allowScriptAccess = "sameDomain";
	if ( movie == "") movie = "movie.swf";
	if ( movie.indexOf("?") != -1) {
		movie += "&MMPlayerType=";
	} else{
		movie += "?MMPlayerType=";
	}

	if ( loop == "") loop = "false";
	if ( menu == "") menu = "false";
	if ( quality == "") quality = "best";
	if ( scale == "") scale = "noscale";
	if ( bgcolor == "") bgcolor = "#FFFFFF";
	if ( salign == "") salign = "TL";
	if ( flashvars == "") flashvars = "";
	if ( noembed == "") noembed = "";
	if ( wmode == "") wmode = "window";
	if ( swLiveConnect == "") swLiveConnect = "false";
	var htmlCode_str = "";
	htmlCode_str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab';
	if (version != "") {
		htmlCode_str += '#version=' + version;
	}
	htmlCode_str += '" id="' + id + '" width="' + width + '" height="' + height + '" align="' + align + '">';
	htmlCode_str += '<param name="allowScriptAccess" value="' + allowScriptAccess + '">';
	htmlCode_str += '<param name="movie" value="' + movie + 'ActiveX">';
	htmlCode_str += '<param name="loop" value="' + loop + '">';
	htmlCode_str += '<param name="menu" value="' + menu + '">';
	htmlCode_str += '<param name="quality" value="' + quality + '">';
	htmlCode_str += '<param name="scale" value="' +scale + '">';
	htmlCode_str += '<param name="bgcolor" value="' + bgcolor + '">';
	htmlCode_str += '<param name="salign" value="' + salign + '">';
	htmlCode_str += '<param name="flashvars" value="' + flashvars + '">';
	htmlCode_str += '<param name="wmode" value="' + wmode + '">';	
	htmlCode_str += '<embed src="' + movie + 'PlugIn" loop="' + loop + '" menu="' + menu + '" quality="' + quality + '" scale="' + scale + '" bgcolor="' + bgcolor + '" width="' + width + '" height="' + height + '" swLiveConnect=' + swLiveConnect + ' id="' + id + '" name="' + id + '" align="' + align + '" allowScriptAccess="' + allowScriptAccess + '" flashvars="' + flashvars + '" wmode="' + wmode + '" salign="' + salign + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"><noembed>' + noembed + '</noembed>';
	htmlCode_str += '</object>';
	document.write(htmlCode_str);
}

function BrowserCheck() {
	var br = navigator.appName;
	var sbr;
	if (br=="Netscape") sbr = "ns";
	else if (br=="Microsoft Internet Explorer") sbr = "ie";
	else sbr = br;
	return sbr;
}



function includeEasingStrip(urlstr, flashname, theLocale, theCountOfToolbox) {
	var sbr = BrowserCheck();
	if (theLocale == undefined) {
		theLocale = "";
	}	

	if (urlstr.indexOf('home') > 0) {
		urlstr = urlstr.substring(0,urlstr.indexOf("home")-1);
	}
	else {
		urlstr = urlstr.substring(0, urlstr.length - 1); 
	}

	var langugageCode = "";

	var dontuseNissanAG = false;
 
	if (theLocale.indexOf('sk_SK') > 0) {
		dontuseNissanAG = true;
	}
	if (theLocale.indexOf('pl_PL') > 0) {
		dontuseNissanAG = true;
	}
	if (theLocale.indexOf('sv_SE') > 0) {
		dontuseNissanAG = true;
	}
	if (theLocale.indexOf('hu_HU') > 0) {
		dontuseNissanAG = true;
	}
	if (theLocale.indexOf('fi_FI') > 0) {
		dontuseNissanAG = true;
	}
	if (theLocale.indexOf('cs_CZ') > 0) {
		dontuseNissanAG = true;
	}
	if (theLocale.indexOf('ru_RU') > 0){
		dontuseNissanAG = true;
	}
	if (theLocale.indexOf('uk_UA') > 0) {
		dontuseNissanAG = true;
	}
	if (theLocale.indexOf('ru_UA') > 0) {
		dontuseNissanAG = true;
	}

	langugageCode = theLocale;
	var dontShowEBrochure = "YES";

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="456" id="easingStrip" align="bottom">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/nova/global/swf/easingStrip.swf?tt=' + urlstr + '&languageCode=' + langugageCode + '&path=' + flashname + '&NissanAG=' + dontuseNissanAG + '&dontShowEBrochure=' + dontShowEBrochure + '&toolBoxCount=' + theCountOfToolbox + '" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/nova/global/swf/easingStrip.swf?tt=' + urlstr + '&languageCode=' + langugageCode + '&path=' + flashname + '&NissanAG=' + dontuseNissanAG + '&toolBoxCount=' + theCountOfToolbox + '&dontShowEBrochure=' + dontShowEBrochure + '" quality="high" scale="noscale" salign=""  bgcolor="#ffffff" width="100%" height="456" name="easingStrip" align="top" swLiveConnect="true" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent"  />');
	document.write('</object>');  
	//added for phase-3 pop-up close
	if(navigator.appName.indexOf("Microsoft") != -1) {
		flashObj = window.easingStrip;
	} else {
		flashObj = window.document.easingStrip;
	}
}


function includesplash(testfile,splash_filename) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="305" id="splash" align="bottom">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/nova/global/swf/loading.swf?spfile=' + splash_filename + '" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/nova/global/swf/loading.swf?spfile=' + splash_filename + '"  quality="high" scale="noscale" salign="" wmode="transparent" bgcolor="#ffffff" width="100%" height="305" name="splash" align="top" swLiveConnect="true" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');  
}

function writeTheSpacer() {
	if (navigator.appName == "Netscape") {
		var str = '<div style="position:absolute; top:70px; width:100%"><img alt="" src="/nova/global/images/header.jpg" height="6" width="100%"/></div>';
		document.write(str);
	} else {
		var str = '<div style="position:absolute; top:69px;"><img alt="" src="/nova/global/images/header.jpg" height="6" width="100%"/></div>';
		document.write(str);
	}
}


function WriteLeftSpace() {
		var str = '<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center"><tr><td></td><td><table border="0" cellpadding="0" cellspacing="0" width="1004" align="center"><tr><td><td style="padding-left:25px;"></td><td width="999">';
		document.write(str);
}

function WritecloseSpace() {
		var str = '</td></td></tr></table></td><td></td></tr></table>';
		document.write(str);
	}
	
function headerShade() {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="6" id="headershade" align="top">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/nova/global/swf/header.swf" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="scale" value="exactfit" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="/nova/global/swf/header.swf" quality="high" scale="exactfit" salign="" wmode="transparent" bgcolor="#ffffff" menu="false" width=100% height="6" name="headershade" align="top" swLiveConnect="true" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>'); 
}


function utilityDealerSearch(messages, fromPage) {
	var submitURL3='/home/dealerlocator/browse3.html/';
	var submitURL='/home/dealerlocator/browse.html/';
	var submitURL5='/home/dealerlocator/browse4.html/';
	var count ="5";
	var element_db;
	var element_db2;
	var regEx = new RegExp (' ', 'gi');
	var inpName='';
	var inpValue='';	
		
		var inputobj = document.dealerSearch.getElementsByTagName('input');
			for (i=0;i < document.dealerSearch.elements.length ; i++ )
			{
				if (document.dealerSearch.elements[i].type == 'text')
				{
					if (document.dealerSearch.elements[i].value != '')
					{
						inpValue = document.dealerSearch.elements[i].value;
						inpName = document.dealerSearch.elements[i].name;
					}
				}
			}

		
		inpValue = inpValue.replace(regEx, '@');

		var radius = document.dealerSearch.radius.value;
		var client= document.dealerSearch.db.value;
		

		if (inpValue=="") {
			// If nothing has been entered into any of the search fields display a alert with a message.
			alert(replaceSpeChars(messages,true));
			return false;
			
		}
			else
	{
			element_db = document.getElementsByName("db");
			element_db2 = document.getElementsByName("db2");
			//alert(client);

			if(client=='nissan_xml_gb')
			{   

				radius=radius*1.609344;

				if (inpName=="addr3")
				{
					location.href=submitURL +  "client=" + element_db[0].value + "&db=" + element_db2[0].value + "&addr3=" + inpValue + "&count=" + count + "&fromPage=" + fromPage + "&radius=" + radius + "&pc=" ;
					return false;
				}
				else
				{
					location.href=submitURL3 + "client=" + element_db[0].value + "&db=" + element_db2[0].value + "&count=" + count + "&fromPage=" + fromPage + "&width=370&height=265&radius=" + radius + "&pc=" + inpValue + "&dealer_search_db=" + element_db[0].value;
					return false;
				}
					

			}
			else
			{
				inpName = changeLater(escape(inpName));
				if (inpName=="addr3")
				{
					location.href=submitURL + "client=" + element_db[0].value + "&db=" + element_db2[0].value + "&addr3=" + inpValue + "&count=" + count + "&fromPage=" + fromPage + "&radius=" + radius + "&pc=" ;
					return false;
				}
				else
				{
					location.href=submitURL3 + "client=" + element_db[0].value + "&db=" + element_db2[0].value + "&count=" + count + "&fromPage=" + fromPage + "&width=370&height=265&radius=" + radius + "&pc=" + inpValue + "&dealer_search_db=" + element_db[0].value;
					return false;
				}
			}
	}

	}
	


	function replaceSpeChars(text,bool) {
	
	fromTo = new Array('&AElig;','%C6','&Aacute;','%C1','&Acirc;','%C2','&Agrave;','%C0','&Aring;','%C5','&Atilde;', '%C3','&Auml;','%C3','&Ccedil;','%C7','&ETH;','%D0','&Eacute;','%C9','&Ecirc;','%CA','&Egrave;','%C8','&Euml;','%CB','&Iacute;','%CD','&Icirc;','%CE','&Igrave;','%CC','&Iuml;','%CF','&Ntilde;','%D1', '&Oacute;','%D3','&Ocirc;','%D4','&Ograve;','%D2','&Oslash;','%D8','&Otilde;','%D5','&Ouml;','%D6','&THORN; ','%DE','&Uacute;','%DA','&Ucirc;','%DB','&Ugrave;','%D9','&Uuml;','%DC','&Yacute;','%DD','&aacute;', '%E1','&acirc;','%E2','&aelig;','%E6','&agrave;','%E0','&aring;','%E5','&atilde;','%E3','&auml;','%E4','&brvbar;','%A6','&ccedil;','%E7','&cent;','%A2','&copy;','%A9','&deg;','%B0','&eacute;','%E9', '&ecirc;','%EA','&egrave;','%E8','&eth;','%F0','&euml;','%EB','&frac12;','%BD','&frac14;','%BC','&frac34; ','%BE','&gt;','%3E','&gt','%3E','&iacute;','%ED','&icirc;','%EE','&iexcl;','%A1','&igrave;','%EC','&iquest;','%BF','&iuml;','%EF', '&laquo;','%AB','&lt;','%3C','&lt','%3C','&mdash;','—','&micro;','%B5','&middot;','%B7','&ndash;','–','&not;','%AC','&ntilde;','%F1', '&oacute;','%F3','&ocirc;','%F4','&ograve;','%F2','&oslash;','%F8','&otilde;','%F5','&ouml;','%F6','&para;','%B6','&plusmn;','%B1','&pound;',' %A3','&quot;','\"','&raquo;','%BB','&reg;','%AE','&sect;','%A7','&shy;','%2A','&sup1;','%B9','&sup2;','%B2', '&sup3;','%B3','&szlig;','%DF','&thorn;','%FE','&tilde;','˜','&trade;','™','&uacute;','%FA','&ucirc; ','%FB','&ugrave;','%F9','&uuml;','%FC','&yacute;','%FD','&yen;','%A5','&yuml;','%FF');

		for (i=0; i < fromTo.length; i=i+2)
		{
			if (bool)
				text = text.replace(fromTo[i], fromTo[i+1]);
			else
				text = text.replace(fromTo[i+1], fromTo[i]);
		}
	
	//text = text.replace('&egrave;', '%E8');
	
		return (unescape(text));
	}     




function changeLater(text)
{
fromTo =new Array('%D6','O','%F6', 'o', '%C4', 'A', '%E4', 'a', '%FC', 'u', '%DC', 'U')
for (i=0; i < fromTo.length; i=i+2)
text = text.replace(eval('/'+fromTo[i]+'/g'), fromTo[i+1])
return text
}

