var bName = navigator.appName;
var bUser = navigator.userAgent;
var bVer = navigator.appVersion;
var pathname = location.href;
var isLogoOff = false;

if(pathname.indexOf("?") > 0) 
{
	pathname = pathname.substring(0,pathname.indexOf("?"));
}

if((pathname.indexOf(".com/html/index1.html") > 0) || (pathname.indexOf(".com/html/index2.html") > 0) || (pathname.indexOf(".com/html/index3.html") > 0) || (pathname.indexOf(".com/index1.html") > 0) || (pathname.indexOf(".com/index2.html") > 0) || (pathname.indexOf(".com/index3.html") > 0)){
   isLogoOff = true;
}
var browser;
var classText = "";
var subclassText = "";

function swapLogo(getLogo){
    document.images["logo"].src = eval(getLogo + ".src");
}

if(bName == "Netscape") {
	browser = "nn";
}

if (bName == "Netscape" && document.getElementById && (bUser.indexOf("Netscape6") < 1)) {
   browser = "ns6";
   classText = "class=\"navText\"";
   subclassText = "class=\"subnavText\"";
} 

var mainSwitch = 0;
var isVehiclesOn = false;
var isCarsOn = false;
var isSuvOn = false;
var isTrucksOn = false;
var isBrochureOn = false;
var isBatOn = false;
var isDealersOn = false;
var isFinancialOn = false;
var isAboutOn = false;
var isEspanolOn = false;
var isChineseOn = false;
var lastLayer;
var lastImgLayer;
var lastImg;
var x1,x2,y1,y2;

function turnOn() {
	mainSwitch = 1;
}


if (window.captureEvents) {
        window.captureEvents(Event.MOUSEMOVE);
        window.onmousemove = mouseTracker;
} else {
        document.onmousemove = mouseTracker;
        
}

function mouseTracker(e) {
	e = e || window.Event || window.event;
    window.pageX = e.pageX || e.clientX;
    window.pageY = e.pageY || e.clientY;
	
	setTimeout("",2000);

			y1 = 5;	    //pixels above nav
			x1 = 35;	//pixels to left of nav
			y2 = 510;	//pixels below nav
			x2 = 760;	//pixels to right of nav
	
			vy1 = 1;	//pixels above vehicles nav
			vx1 = 48;	//pixels to left of vehicles nav
			vy2 = 216;	//pixels below vehicles nav
			vx2 = 250;	//pixels to right of vehicles nav	
			
			ay1 = 1;	//pixels above about nav
			ax1 = 656;	//pixels to left of about nav
			ay2 = 190;	//pixels below about nav
			ax2 = 760;	//pixels to right of about nav	
			
			by1 = 1;	//pixels above bat nav
			bx1 = 138;	//pixels to left of bat nav
			by2 = 32;	//pixels below bat nav
			bx2 = 229;	//pixels to right of bat nav	
			
			dy1 = 1;	//pixels above dealers nav
			dx1 = 229;	//pixels to left of dealers nav
			dy2 = 32;	//pixels below dealers nav
			dx2 = 333;	//pixels to right of dealers nav	
			
			fy1 = 1;	//pixels above financial nav
			fx1 = 333;	//pixels to left of financial nav
			fy2 = 32;	//pixels below financial nav
			fx2 = 458;	//pixels to right of financial nav	
			
			ey1 = 1;	//pixels above espanol nav
			ex1 = 458;	//pixels to left of espanol nav
			ey2 = 32;	//pixels below espanol nav
			ex2 = 543;	//pixels to right of espanol nav	
			
			sy1 = 1;	//pixels above Chinese nav
			sx1 = 543;	//pixels to left of Chinese nav
			sy2 = 32;	//pixels below Chinese nav
			sx2 = 656;	//pixels to right of Chinese nav	
			
			
		if (isVehiclesOn == true) {
			if((window.pageX < (vx1-10) || window.pageX > vx2 || window.pageY < (vy1-5) || window.pageY > vy2) ) {
				hide('vehicles');
				hide(lastLayer);
				changeImage(lastImg,lastImg + 'off','false');
				lastLayer = null;
				if (isCarsOn == true){
				hide('cars');
				}
				if (isSuvOn == true){
				hide('suv');
				}
				if (isTrucksOn == true){
				hide('trucks');
				}
				if (isBrochureOn == true){
				hide('brochure');
				}
			}
		}
		if (isAboutOn == true) {
			if((window.pageX < (ax1-10) || window.pageX > ax2 || window.pageY < (ay1-5) || window.pageY > ay2) ) {
				hide('about');
				hide(lastLayer);
				changeImage(lastImg,lastImg + 'off','false');
				lastLayer = null;
			}
		}
		
		if (isBatOn == true) {
			if((window.pageX < (bx1-10) || window.pageX > bx2 || window.pageY < (by1-5) || window.pageY > by2) ) {
				hide('bat');
				hide(lastLayer);
				changeImage(lastImg,lastImg + 'off','false');
				lastLayer = null;
			}
		}
		
		if (isDealersOn == true) {
			if((window.pageX < (dx1-10) || window.pageX > dx2 || window.pageY < (dy1-5) || window.pageY > dy2) ) {
				hide('dealers');
				hide(lastLayer);
				changeImage(lastImg,lastImg + 'off','false');
				lastLayer = null;
			}
		}
		
		if (isFinancialOn == true) {
			if((window.pageX < (fx1-10) || window.pageX > fx2 || window.pageY < (fy1-5) || window.pageY > fy2) ) {
				hide('financial');
				hide(lastLayer);
				changeImage(lastImg,lastImg + 'off','false');
				lastLayer = null;
			}
		}
		
		if (isEspanolOn == true) {
			if((window.pageX < (ex1-10) || window.pageX > ex2 || window.pageY < (ey1-5) || window.pageY > ey2) ) {
				hide('espanol');
				hide(lastLayer);
				changeImage(lastImg,lastImg + 'off','false');
				lastLayer = null;
			}
		}
		
		if (isChineseOn == true) {
			if((window.pageX < (sx1-10) || window.pageX > sx2 || window.pageY < (sy1-5) || window.pageY > sy2) ) {
				hide('chinese');
				hide(lastLayer);
				changeImage(lastImg,lastImg + 'off','false');
				lastLayer = null;
			}
		}
		
		 else if ((window.pageX < (x1-10) || window.pageX > x2 || window.pageY < (y1-5) || window.pageY > y2) && lastLayer != null) {
				hide(lastLayer);
				changeImage(lastImg,lastImg + 'off','false');
				lastLayer = null;
				if (isCarsOn == true){
				hide('cars');
				}
				if (isSuvOn == true){
				hide('suv');
				}
				if (isTrucksOn == true){
				hide('trucks');
				}
				if (isBrochureOn == true){
				hide('brochure');
				}
		}
}

function menuSwitch(aLayer,imgName) {
	if (mainSwitch == 1) {
		if (lastLayer != null) {
			hide(lastLayer);
			changeImage(lastImg,lastImg + 'off','false');
		}
		if (isCarsOn == true) {
			hide('cars');
		}
		if (isSuvOn == true) {
			hide('suv');
		}
		if (isTrucksOn == true) {
			hide('trucks');
		}
		if (isBrochureOn == true) {
			hide('brochure');
		}
		changeImage(imgName,imgName + 'on','false');
          show(aLayer)
          if(isVehiclesOn){		
          }
		  
		  if(!isVehiclesOn){		
          }
		lastLayer = aLayer;
		lastImg = imgName;
	}
}

function changeImage(imgName,imgObj,isLayerOn) {
	if (mainSwitch == 1) {
		if (isLayerOn == 'true' && lastLayer != null) {
			hide(lastLayer);
			lastLayer = null;
			window.document.images[lastImg].src = eval(lastImg + "off.src");
		}
		window.document.images[imgName].src = eval(imgObj + ".src");
	}
}

// hide element  
function hide(aLayer) {
	if (aLayer == 'vehicles') {
		isVehiclesOn = false;
	}
	if (aLayer == 'cars') {
		isCarsOn = false;
	}
	if (aLayer == 'suv') {
		isSuvOn = false;
	}
	if (aLayer == 'trucks') {
		isTrucksOn = false;
	}
	if (aLayer == 'brochure') {
		isBrochureOn = false;
	}
	if (aLayer == 'bat') {
		isBatOn = false;
	}
	if (aLayer == 'dealers') {
		isDealersOn = false;
	}
	if (aLayer == 'about') {
		isAboutOn = false;
	}
	if (aLayer == 'financial') {
		isFinancialOn = false;
	}
	if (aLayer == 'espanol') {
		isEspanolOn = false;
	}
	if (aLayer == 'chinese') {
		isChineseOn = false;
	}
  	theobjs[aLayer].objHide();
}

// show element
function show(aLayer) {
	if (aLayer == 'vehicles') {
		isVehiclesOn = true;
	}
	if (aLayer == 'cars') {
		isCarsOn = true;
		isSuvOn = false;
		isTrucksOn = false;
		isBrochureOn = false;
		hide('suv');
		hide('trucks');
		hide('brochure');
	}
	if (aLayer == 'suv') {
		isSuvOn = true;
		isCarsOn = false;
		isTrucksOn = false;
		isBrochureOn = false;
		hide('cars');
		hide('trucks');
		hide('brochure');
	}
	if (aLayer == 'trucks') {
		isTrucksOn = true;
		isSuvOn = false;
		isCarsOn = false;
		isBrochureOn = false;
		hide('cars');
		hide('suv');
		hide('brochure');
	}

	if (aLayer == 'brochure') {
		isBrochureOn = true;
		isSuvOn = false;
		isCarsOn = false;
		isTrucksOn = false;
		hide('cars');
		hide('suv');
		hide('trucks');
	}

	if (aLayer == 'bat') {
		isBatOn = true;
	}
	if (aLayer == 'dealers') {
		isDealersOn = true;
	}
	if (aLayer == 'about') {
		isAboutOn = true;
	}
	if (aLayer == 'financial') {
		isFinancialOn = true;
	}
	if (aLayer == 'espanol') {
		isEspanolOn = true;
	}
	if (aLayer == 'chinese') {
		isChineseOn = true;
	}
   	theobjs[aLayer].objShow();
}


//image rollover for sub navs.
function subOn(subNav, img) {
	if (browser == 'nn') {
		document.layers[subNav].document.images[img].src = eval(img + "on.src");
	} else {
		window.document.images[img].src = eval(img + "on.src");
	}
	//this is to change the arrow from 'on' to 'off'
	if (isCarsOn == false){
	}
	if (isSuvOn == false){
	}
	if (isTrucksOn == false){
	}
	if (isBrochureOn == false){
	}
}

function subOff(subNav, img) {
	if (browser == 'nn') {
		document.layers[subNav].document.images[img].src = eval(img + "off.src");
	} else {
		window.document.images[img].src = eval(img + "off.src");
	}
}
//turns off model subnavs on link rollover
function divHide(aLayer) {
	if (isTrucksOn == true){
	aLayer = 'trucks';
	theobjs[aLayer].objHide();
	}
	else if (isSuvOn == true){
	aLayer = 'suv';
	theobjs[aLayer].objHide();
	}
	else if (isBrochureOn == true){
	aLayer = 'brochure';
	theobjs[aLayer].objHide();
	}
	else if (isCarsOn == true){
	aLayer = 'cars';
	theobjs[aLayer].objHide();
	}
}

//popup window function
//pass the url, the width, and the height
var theWin

function popup(theURL, width, height) {

	if(theWin == null || theWin.closed) {
		theWin = window.open(theURL, "popup", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height + ",top=100,left=100");
	} else {
		theWin.close()
		theWin = window.open(theURL, "popup", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height + ",top=100,left=100");
	}
}


function openDisclaimer(disc,scrollval){
if(scrollval == "yes"){
	theWin = window.open("/vehicles/disclaimers/" + disc , "disclaimer", "location=0,menubar=1,status=0,toolbars=0,scrollbars=1,width=440,height=320,top=10,left=10");
}
else {
	theWin = window.open("/vehicles/disclaimers/" + disc , "disclaimer", "location=0,menubar=1,status=0,toolbars=0,scrollbars=0,width=420,height=320,top=10,left=10");
}
theWin.focus();
}

function openUpdates(disc){
theWin = window.open("https://gotoyota.programhq.com/IEZ007/main.asp", "updates", "menubar=1,scrollbars=1,resizable=1,width=640,height=400,top=10,left=10");
 theWin.focus();
}

function openAccessories(acc){
theWin = window.open("accessories_large.html?=" + acc , "accwin", "width=495,height=414,top=10,left=10,resizable=0,scrollbars=0,menubar=0");
theWin.focus();
}

function openPDFs(pdfURL){
   pdfWin = window.open(pdfURL,'pdfWin','height=400,width=700,top=10,left=10,resizable=1,scrollbars=1,menubar=1');
   pdfWin.focus();
}

function openSEMA(){     
    winSEMA = window.open('/vehicles/sema/index.html','winSEMA','height=500,width=743,status=1,scrollbars=1,toolbar=1,menubar=1,resizable=1,top=10,left=10');
    winSEMA.focus();       
}

function openWebcamHigh(){     
    camHigh = window.open("/html/das/dasloop300k.html","camHigh","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camHigh.focus();       
}

function openWebcamLow(){     
    camLow = window.open("/html/das/dasloop56k.html","camLow","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camLow.focus();       
}

function openWCHHHigh(){     
    camHigh = window.open("/html/das/dashybrid300k.html","camHigh","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camHigh.focus();       
}

function openWCHHLow(){     
    camLow = window.open("/html/das/dashybrid56k.html","camLow","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camLow.focus();       
}

function openWCFTXHigh(){     
    camHigh = window.open("/html/das/dasftx300k.html","camHigh","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camHigh.focus();       
}

function openWCFTXLow(){     
    camLow = window.open("/html/das/dasftx56k.html","camLow","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camLow.focus();       
}

function openHybrid(){
	hyWin = window.open('/vehicles/2004/highlander/minisite/index.html','hyWin','height=420,width=760,top=10,left=10,resizable=0,scrollbars=0,menubar=0');
	hyWin.focus();
}

function openHighMinisite(){
	hyWin = window.open('/vehicles/2004/highlander/minisite/index.html','hyWin','height=420,width=760,top=10,left=10,resizable=0,scrollbars=0,menubar=0');
	hyWin.focus();
}

function openHybridNoParent(){
	hyWin = window.open('/vehicles/2004/highlander/minisite/index2.html','hyWin','height=420,width=760,top=10,left=10,resizable=0,scrollbars=0,menubar=0');
	hyWin.focus();
}

function openCASHigh(){     
    camHigh = window.open("/html/cas/casreplay300k.html","camHigh","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camHigh.focus();       
}

function openCASLow(){     
    camLow = window.open("/html/cas/casreplay56k.html","camLow","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camLow.focus();       
}

function openSCLow(){     
    camLow = window.open("/html/cas/cassolaraconv.html","camLow","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camLow.focus();       
}

function openSCHigh(){     
    camLow = window.open("/html/cas/cassolaraconv.html","camLow","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camLow.focus();       
}

function openXRLow(){     
    camLow = window.open("/html/cas/casxrunner.html","camLow","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camLow.focus();       
}

function openXRHigh(){     
    camLow = window.open("/html/cas/casxrunner.html","camLow","height=425,width=600,top=10,left=10,resizable=0,scrollbars=no,menubar=no");
    camLow.focus();       
}

function openAuction() {
winAuc = window.open("http://members.ebay.com/ws2/eBayISAPI.dll?ViewUserPage&userid=toyota-by-kompolt","win","height=500,width=700,top=10,left=10,location=1,directories=0,menubar=1,status=1,titlebar=0,toolbar=1,scrollbars=1,resizable=1");
winAuc.focus();
 }

var lcwin;
if (document.all){
var wide = window.screen.availWidth;
var high = window.screen.availHeight;
var middlePlace = (wide-1010)/2;
var middleVert = (high-748)/2;
if(wide<1000) var smallTime = true;
}
function launchWindowed() {
lcwin =window.open('/landcruiser/minisite/flash.html','lcwin','height=748,width=1010,navigation=0,scrollbars=0,menubar=0,toolbar=0,status=0');
lcwin.moveTo(10,10);
lcwin.focus();
if(document.all) lcwin.moveTo(middlePlace,middleVert);
if(smallTime==true) lcwin.moveTo(-90,-90);
}


function openInterstitial(URL){
  instWin = window.open('/html/interstitial/interstitial.html?targetURL='+URL, "instWin", "height=460,width=800,scrollbars=1,toolbar=1,location=1,menubar=1,resizable=1,top=10,left=10")
  instWin.focus();
}