if (navigator.appName.indexOf("WebTV") != -1) { 
	window.location.href = "/html/help/misc/webtv.html"; 
}
logoon = new Image();
logoon.src = "tegu.JPG";
showroomon = new Image();
showroomon.src = "ajalugu2.JPG";
ownerson = new Image();
ownerson.src = "tegu2.JPG";
dealeron = new Image();
dealeron.src = "/images/top_nav/dealer_loc_h.gif";
financialon = new Image();
financialon.src = "/images/top_nav/financial_services_h.gif";
abouton = new Image();
abouton.src = "/images/top_nav/about_h.gif";

logooff = new Image();
logooff.src = "/images/top_nav/clear_logo.gif";
showroomoff = new Image();
showroomoff.src = "ajalugu.JPG";
ownersoff = new Image();
ownersoff.src = "tegu.JPG";
dealeroff = new Image();
dealeroff.src = "/images/top_nav/dealer_loc.gif";
financialoff = new Image();
financialoff.src = "/images/top_nav/financial_services.gif";
aboutoff = new Image();
aboutoff.src = "/images/top_nav/about.gif";


//preload models images
//m0on = new Image();
//m0on.src = "/images/top_nav/m_all_h.gif";
m1on = new Image();
m1on.src = "/images/top_nav/m_echo_h.gif";
m2on = new Image();
m2on.src = "/images/top_nav/m_matrix_h.gif";
m3on = new Image();
m3on.src = "/images/top_nav/m_celica_h.gif";
m4on = new Image();
m4on.src = "/images/top_nav/m_mr2_h.gif";
m5on = new Image();
m5on.src = "/images/top_nav/m_corolla_h.gif";
m6on = new Image();
m6on.src = "/images/top_nav/m_camry_h.gif";
m7on = new Image();
m7on.src = "/images/top_nav/m_solara_h.gif";
m8on = new Image();
m8on.src = "/images/top_nav/m_avalon_h.gif";
m9on = new Image();
m9on.src = "/images/top_nav/m_rav4_h.gif";
m10on = new Image();
m10on.src = "/images/top_nav/m_highlander_h.gif";
m11on = new Image();
m11on.src = "/images/top_nav/m_sienna_h.gif";
m12on = new Image();
m12on.src = "/images/top_nav/m_4runner_h.gif";
m13on = new Image();
m13on.src = "/images/top_nav/m_sequoia_h.gif";
m14on = new Image();
m14on.src = "/images/top_nav/m_land_cruiser_h.gif";
m15on = new Image();
m15on.src = "/images/top_nav/m_tacoma_h.gif";
m16on = new Image();
m16on.src = "/images/top_nav/m_tundra_h.gif";
m17on = new Image();
m17on.src = "/images/top_nav/m_prius_h.gif";
m18on = new Image();
m18on.src = "/images/top_nav/m_rav4_ev_h.gif";

//m0off = new Image();
//m0off.src = "/images/top_nav/m_all.gif";
m1off = new Image();
m1off.src = "/images/top_nav/m_echo.gif";
m2off = new Image();
m2off.src = "/images/top_nav/m_matrix.gif";
m3off = new Image();
m3off.src = "/images/top_nav/m_celica.gif";
m4off = new Image();
m4off.src = "/images/top_nav/m_mr2.gif";
m5off = new Image();
m5off.src = "/images/top_nav/m_corolla.gif";
m6off = new Image();
m6off.src = "/images/top_nav/m_camry.gif";
m7off = new Image();
m7off.src = "/images/top_nav/m_solara.gif";
m8off = new Image();
m8off.src = "/images/top_nav/m_avalon.gif";
m9off = new Image();
m9off.src = "/images/top_nav/m_rav4.gif";
m10off = new Image();
m10off.src = "/images/top_nav/m_highlander.gif";
m11off = new Image();
m11off.src = "/images/top_nav/m_sienna.gif";
m12off = new Image();
m12off.src = "/images/top_nav/m_4runner.gif";
m13off = new Image();
m13off.src = "/images/top_nav/m_sequoia.gif";
m14off = new Image();
m14off.src = "/images/top_nav/m_land_cruiser.gif";
m15off = new Image();
m15off.src = "/images/top_nav/m_tacoma.gif";
m16off = new Image();
m16off.src = "/images/top_nav/m_tundra.gif";
m17off = new Image();
m17off.src = "/images/top_nav/m_prius.gif";
m18off = new Image();
m18off.src = "/images/top_nav/m_rav4_ev.gif";



//get browser type
var bName = navigator.appName;
var browser;

if(bName == "Netscape") {
	browser = "nn";
}

//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");
	}
}

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");
	}
}

var mainSwitch = 0;
var isModelsOn = 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 = 0;				//pixels above nav
			x1 = 0;				//pixels to left of nav
			y2  = 100;			//pixels below nav
			x2 =  800;			//pixels to right of nav

			my1 = 0;			//pixels above model nav
			mx1 = 125;			//pixels to left of model nav
			my2  = 400;			//pixels below model nav
			mx2 =  250;			//pixels to right of model nav
		
		if (isModelsOn == true) {
			if((window.pageX < (mx1-10) || window.pageX > mx2 || window.pageY < (my1-5) || window.pageY > my2) ) {
				hide('models');
			}
		} 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;
		}
}

function menuSwitch(aLayer,imgName) {
	if (mainSwitch == 1) {
		if (lastLayer != null) {
			hide(lastLayer);
			changeImage(lastImg,lastImg + 'off','false');
		}
		changeImage(imgName,imgName + 'on','false');
		show(aLayer)
		lastLayer = aLayer;
		lastImg = imgName;
	}
}

function changeImage(imgName,imgObj,isLayerOn) {
	if (mainSwitch == 1) {
		if (isModelsOn == true) {
			hide('models');
		}
		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 (mainSwitch == 1) {
		if (aLayer == 'models') {
			isModelsOn = false;
			subOff('showroom', 'shop2');
		}
	  	theobjs[aLayer].objHide();
	}
}

// show element
function show(aLayer) {
	if (mainSwitch == 1) {
		if (aLayer == 'models') {
			isModelsOn = true;
			subOn('showroom', 'shop2');
		}
	   	theobjs[aLayer].objShow();
	}
}

//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");
	}
}
