// flash detect
var ua = navigator.userAgent;
var vbIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false
var vbWIN = (navigator.platform.indexOf("Win") != -1) ? true : false
var hasFlash9 = false;
var hasFlash8 = false;
var hasFlash7 = false;
var hasFlash6 = false;
var hasFlash5 = false;
var hasFlash4 = false;

function flash9()
{
return hasFlash9; //flash 9 installed?
}
function flash8()
{
return hasFlash8; //flash 8 installed?
}
function flash7()
{
return hasFlash7; //flash 7 installed?
}
function flash6()
{
	return hasFlash6; //flash 6 installed?
}
function flash5()
{
	return hasFlash5; //flash 5 installed?
}
// write vbscript detection of flash if browser is IE on PC
if (vbIE && vbWIN)
{
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('hasFlash9 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');	
	document.write('hasFlash8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
	document.write('hasFlash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
	document.write('hasFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('hasFlash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('hasFlash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('</SCR' + 'IPT\> \n');
}

// detect flash in Netscape browser
if (navigator.plugins && navigator.plugins["Shockwave Flash"])
{
	if (navigator.plugins["Shockwave Flash"].description.indexOf(9.0) != -1) {
		hasFlash9 = true;
	}
	if (navigator.plugins["Shockwave Flash"].description.indexOf(8.0) != -1) {
		hasFlash8 = true;
	}
	if (navigator.plugins["Shockwave Flash"].description.indexOf(7.0) != -1) {
		hasFlash7 = true;
	}
	if (navigator.plugins["Shockwave Flash"].description.indexOf(6.0) != -1) {
		hasFlash6 = true;
	}
	if (navigator.plugins["Shockwave Flash"].description.indexOf(5.0) != -1) {
		hasFlash5 = true;
	}
	if (navigator.plugins["Shockwave Flash"].description.indexOf(4.0) != -1) {
		hasFlash4 = true;
	}
}

function mainICFlash()
{
if (!flash5() && !flash6() && !flash7() && !flash8() && !flash9())
{
	document.write('<div id="flashOff" style="position:absolute; left:0px; top:0px; width:1px; height:1px; z-index:3">');
	document.write('<table width="269" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr align="left">');
	document.write('<td height="155" colspan="2">');
	document.write('&nbsp;');
	document.write('</td>');
	document.write('</tr>');
	document.write('<tr align="left">');
	document.write('<td width="123">');
	document.write('&nbsp;');
	document.write('</td>');
	document.write('<td align="right">');
	document.write('<img src="/v3/media/icentre/multimedia_main.gif" width="146" height="91">');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</div>');
}
else
// USER HAS FLASH ON THEIR COMPUTER
{
	document.write('<div id="flashOn" style="position:absolute; left:123px; top:155px; width:1px; height:1px; z-index:3">');
	document.write('<table width="146" height="91" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr>');
	document.write('<td>');
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 		codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="146" height="91">');
	document.write('<param name="movie" value="/v3/media/icentre/multimedia_main.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<embed src="/v3/media/icentre/multimedia_main.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="146" height="91">');
	document.write('</embed>');
	document.write('</object>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</div>');
/***	
	document.write('<div id="flashOn" style="position:absolute; left:0px; top:0px; width:1px; height:1px; z-index:3">');
	document.write('<table width="269" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr align="left">');
	document.write('<td height="155" colspan="2">');
	document.write('&nbsp;');
	document.write('</td>');
	document.write('</tr>');
	document.write('<tr align="left">');
	document.write('<td width="123">');
	document.write('&nbsp;');
	document.write('</td>');
	document.write('<td align="right">');
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="146" height="91">');
	document.write('<param name="movie" value="/v3/media/icentre/multimedia_main.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<embed src="/v3/media/icentre/multimedia_main.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="146" height="91">');
	document.write('</embed>');
	document.write('</object>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</div>');
***/	
}
}

// Price Your Toyota rollover
var pytImg = new Array()
pytImg[0] = new Image(); pytImg[0].src = "/v3/media/shared/mout_pyt_e.gif";
pytImg[1] = new Image(); pytImg[1].src = "/v3/media/shared/mover_pyt_e.gif";
function pyt(on)
{
	if (on)
	{
		document.images["price"].src = pytImg[1].src;
	}
	else
	{
		document.images["price"].src = pytImg[0].src;
	}
}

/* Function cssFix and nnCheck performs a soft reload of the page in netscape browsers to fix the Netscape CSS positioning bug. */
function cssFix() {
  if (document.cssFix.initWindowWidth != window.innerWidth || document.cssFix.initWindowHeight != window.innerHeight) {
    history.go(0);
  }
}
function nnCheck() {
  if (document.layers) {
      document.cssFix = new Object;
      document.cssFix.initWindowWidth = window.innerWidth;
      document.cssFix.initWindowHeight = window.innerHeight;
      window.onresize = cssFix;
  }  
}
nnCheck();
// Video disclaimer text
var disclaimer = "<table border=0 cellpadding=20 cellspacing=0 width='100%' height=100%'><tr><td align='center'>\n";
disclaimer += "<font size=2 color='#FFFFFF' face='Arial,Helvetica,Sans-serif'>The Toyota Vehicle featured in this section<br>may not be a current model.<br><br>";
disclaimer += "Please wait, the movie is loading.</font>\n";
disclaimer += "</td></tr></table>\n";

var useDisclaimer = new Array('avalon','tundra','celica','echo');

// hide a layer
// Addition if statment added by Matt to stop Netscape error - Jan 3, 2003
function hideLyr(div)
{
	if (getDOM2(div)) {
		getDOM2(div).visibility = "hidden";
	}
}
// show a layer
// Addition if statment added by Matt to stop Netscape error - Jan 3, 2003
function showLyr(div)
{
	if (getDOM2(div)) {
		getDOM2(div).visibility = "visible";
	}
}

// make an object reference to a layer
// for cross browser dhtml
function lyrobj(this_lyr) {
	if (document.all && !document.getElementById) lyr = document.all[this_lyr].style;
	if (document.getElementById) lyr = document.getElementById(this_lyr).style;
	if (document.layers) lyr = document.layers[this_lyr];
	return lyr;
}

// hide show layer
function show_lyr(this_lyr) {
	lyrobj(this_lyr).visibility = "visible";
}
function hide_lyr(this_lyr) {
	lyrobj(this_lyr).visibility = "hidden";
}
function vis_menu() {
	if ((lyrobj("main").visibility == "visible") ||
	   (lyrobj("main").visibility == "show")) {
		hide_lyr("main");
	} else {
		show_lyr("main");
	}
}
function what() {
	if ((lyrobj("whatelse").visibility == "visible") ||
	   (lyrobj("whatelse").visibility == "show")) {
		hide_lyr("whatelse");
	} else {
		show_lyr("whatelse");
	}
}

// mouseovers
function mon(num,div) {
   	if(document.layers && div) {
        	document[div].document["img"+num].src = over[num].src;
      	} else {
      	 	document["img"+num].src = over[num].src;
      	}
}

// mouseouts
function moff(num,div) {
        if (document.layers && div) {
                document[div].document["img"+num].src = out[num].src;
        } else {
         	document["img"+num].src = out[num].src;
        }
}


// Quicktime movies window & vid sizes
function qt_sizes(w,h) {
	this.w  = w;
	this.h = h + 15;
}
var sz = new Array()
// Videos
sz[1] = new qt_sizes(480,270); // video's hi
sz[2] = new qt_sizes(320,180); // video's lo
sz[3] = new qt_sizes(360,270); // video's hi
sz[4] = new qt_sizes(240,180); // video's lo
sz[5] = new qt_sizes(320,180); // video's lo
// ADS movies
sz[6] = new qt_sizes(320,240); // 03corollacm_le_e_hi.mov
sz[7] = new qt_sizes(321,240); // 03corollacm_le_e_lo.mov, 03corollacm_sp_e_hi.mov
sz[8] = new qt_sizes(322,240); // 03corollacm_sp_e_lo.mov
sz[9] = new qt_sizes(320,163); // 03matrixcinema_e_hi.mov, 03matrixcinema_e_lo.mov
sz[10] = new qt_sizes(720,405); // 03matrixcinema_e_hi.mov, 03matrixcinema_e_lo.mov

// open Quicktime
function qt(movie,s,dir) {

	if (isNaN(dir) == true) {
		var path = "http://www.interactive.toyota.ca/"+dir+"/"+movie+".mov";
		
		// Search and see if we need the disclaimer.
		// We search useDisclaimer array,
		var disc = false;
		for (i=0; i<useDisclaimer.length; i++) {
			if (movie == "03echo_e_lo" || movie == "03echo_e_hi") {
				break;
			}
			if (movie.indexOf(useDisclaimer[i]) != -1) {
				disc = true;
				break;
			}
		}
		
		// Yes, add the disclaimer
		if (disc == true) {
			
			var timeIt = '<EMBED SRC="'+path+'" WIDTH="'+(sz[s].w)+'" HEIGHT="'+(sz[s].h)+'" BGCOLOR="#000000" CACHE="TRUE" PLUGINSPAGE="http://quicktime.apple.com" BORDER="0" autoplay="true" controller="true"></EMBED>';
			
			// Netscape 4 has some problems with the video so this old code is used for Netscape 4
			if (document.layers) {
				quickWin = window.open('','','left=0,top=0,status=1,resizable=1,scrollbars=0,width='+(sz[s].w)+',height='+(sz[s].h));
				quickWin.document.write('<html><head>');
				quickWin.document.write('<script>function x(){window.location.href="'+path+'";};setTimeout("x()",2000);</script>');
				quickWin.document.write('<TITLE>Multimedia Gallery</TITLE>');
				quickWin.document.write('<script language="javascript" src="/v3/src/nav.functions.js"></script></head>');
				quickWin.document.write('<BODY BGCOLOR="#000000" MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 LEFTMARGIN=0>');
				quickWin.document.write(disclaimer);
				quickWin.document.write('</body></html>');
				quickWin.document.close();
				quickWin.focus();
			} else {
				//This creates a file that is loaded after the disclaimer is shown
				afterDiscQuickWin = "<html><TITLE>Multimedia Gallery</TITLE>";
				afterDiscQuickWin += "<BODY BGCOLOR=\"#000000\" MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\">";
				afterDiscQuickWin += "<EMBED SRC=\""+path+"\" WIDTH=\""+(sz[s].w)+"\" HEIGHT=\""+(sz[s].h)+"\" BGCOLOR=\"#000000\" CACHE=\"TRUE\" PLUGINSPAGE=\"http://quicktime.apple.com\" BORDER=\"0\" autoplay=\"true\" controller=\"true\"></EMBED>";
				afterDiscQuickWin += "</body></html>";
			
				quickWin = window.open('','','left="0",top="0",status="1",resizable="1",scrollbars="0",width='+(sz[s].w)+',height='+(sz[s].h));
				quickWin.document.write('<html><head>');
				quickWin.document.write('<script language="javascript">function x(){');
				quickWin.document.write('document.write(\'' + afterDiscQuickWin + '\');};setTimeout("x()",2000);</script>');
				quickWin.document.write('<TITLE>Multimedia Gallery</TITLE>');
				quickWin.document.write('</head>');
				quickWin.document.write('<BODY BGCOLOR="#000000" MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 LEFTMARGIN=0>');
				quickWin.document.write(disclaimer);
				quickWin.document.write('</body></html>');
				quickWin.document.close();
				quickWin.focus();
			}
			
		}
		
		// No, don't add disclaimer
		else {
			
			quickWin = window.open('','','left=0,top=0,status=1,resizable=1,scrollbars=0,width='+(sz[s].w)+',height='+(sz[s].h));
			quickWin.document.write('<html><TITLE>Multimedia Gallery</TITLE>');
			quickWin.document.write('<BODY BGCOLOR="#000000" MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 LEFTMARGIN=0>');
			quickWin.document.write('<EMBED SRC="'+path+'" WIDTH="'+(sz[s].w)+'" HEIGHT="'+(sz[s].h)+'" BGCOLOR="#000000" CACHE=TRUE PLUGINSPAGE="http://quicktime.apple.com" BORDER=0 autoplay="true" controller="true"></EMBED>');
			quickWin.document.write('</body></html>');
			quickWin.document.close();
			quickWin.focus();
		}
		
	} else {
		var path = "http://www.interactive.toyota.ca/"+movie;
		quickWin = window.open('','','left=0,top=0,status=1,resizable=1,scrollbars=0,width='+s+',height='+dir);
		quickWin.document.write('<html><TITLE>Multimedia Gallery</TITLE>');
/*
		quickWin.document.write('<script language="javascript" src="/v3/english/icentre/ac_quicktime.js"></script>');
*/
		quickWin.document.write('<BODY BGCOLOR="#000000" MARGINWIDTH="0" MARGINHEIGHT="0" TOPMARGIN="0" LEFTMARGIN="0">');
/*	
		quickWin.document.write('<script language="JavaScript" type="text/javascript">');
		quickWin.document.write('QT_WriteOBJECT("'+path+'","'+s+'","'+dir+'","","autoplay","true","controller","true","cache","true","border","0","bgcolor","#000000");');
		quickWin.document.write('</script>');
		quickWin.document.write('<noscript>');
		quickWin.document.write('<object width="32" height="32">');
		quickWin.document.write('</object>');
		quickWin.document.write('</noscript>');
*/			
		quickWin.document.write('<EMBED SRC="'+path+'" WIDTH="'+s+'" HEIGHT="'+dir+'" BGCOLOR="#000000" CACHE=TRUE PLUGINSPAGE="http://quicktime.apple.com" BORDER=0 autoplay="true" controller="true"></EMBED>');
		
		quickWin.document.write('</body></html>');
		quickWin.document.close();
		quickWin.focus();
		
	}	
}

function qtime(movie,s,dir) {

	if (isNaN(dir) == true) {
		var path = "http://www.interactive.toyota.ca/"+dir+"/"+movie+".mov";
			
			quickWin = window.open('','','left=0,top=0,status=1,resizable=1,scrollbars=0,width='+(sz[s].w)+',height='+(sz[s].h));
			quickWin.document.write('<html><TITLE>Multimedia Gallery</TITLE>');
			quickWin.document.write('<BODY BGCOLOR="#000000" MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 LEFTMARGIN=0>');
			quickWin.document.write('<EMBED SRC="'+path+'" WIDTH="'+(sz[s].w)+'" HEIGHT="'+(sz[s].h)+'" BGCOLOR="#000000" CACHE=TRUE PLUGINSPAGE="http://quicktime.apple.com" BORDER=0 autoplay="true" controller="true"></EMBED>');
			quickWin.document.write('</body></html>');
			quickWin.document.close();
			quickWin.focus();
	}
	else 
	{
		var path = "http://www.interactive.toyota.ca/"+movie;
		quickWin = window.open('','','left=0,top=0,status=1,resizable=1,scrollbars=0,width='+s+',height='+dir);
		quickWin.document.write('<html><TITLE>Multimedia Gallery</TITLE>');
		quickWin.document.write('<script language="javascript" src="/v3/english/icentre/ac_quicktime.js"></script>');
		quickWin.document.write('<BODY BGCOLOR="#000000" MARGINWIDTH="0" MARGINHEIGHT="0" TOPMARGIN="0" LEFTMARGIN="0">');
		quickWin.document.write('<script language="JavaScript" type="text/javascript">');
		quickWin.document.write('QT_WriteOBJECT("'+path+'","'+s+'","'+dir+'","","autoplay","true","controller","true","cache","true");');
		quickWin.document.write('</script>');
		quickWin.document.write('<noscript>');
		quickWin.document.write('<object width="32" height="32">');
		quickWin.document.write('</object>');
		quickWin.document.write('</noscript>');	
		quickWin.document.write('<EMBED SRC="'+path+'" WIDTH="'+s+'" HEIGHT="'+dir+'" BGCOLOR="#000000" CACHE=TRUE PLUGINSPAGE="http://quicktime.apple.com" BORDER=0 autoplay="true" controller="true"></EMBED>');
		
		quickWin.document.write('</body></html>');
		quickWin.document.close();
		quickWin.focus();
		
	}	
}

function qt2(movie,size) {
	if (size) {w="717";h="398"}

	else {w="450";h="256"}

		quickWin = window.open('','','left=0,top=0,status=1,resizable=1,scrollbars=0,width='+w+',height='+h);
		quickWin.document.write('<html><TITLE>Multimedia Gallery</TITLE>');
		quickWin.document.write('<BODY BGCOLOR="#000000" MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 LEFTMARGIN=0>');
		quickWin.document.write('<EMBED SRC="http://www.interactive.toyota.ca/'+movie+'" WIDTH="'+w+'" HEIGHT="'+h+'" BGCOLOR="#000000" CACHE=TRUE PLUGINSPAGE="http://quicktime.apple.com" BORDER=0 autoplay="true" controller="true"></EMBED>');
		quickWin.document.write('</body></html>');
		quickWin.document.close();
		quickWin.focus();

}



function dtop(img) {
	w = screen.availWidth - 10;
	h = screen.availHeight;
	desktopPhoto = window.open('/v3/media/icentre/desktop/'+img,'desktopPhoto','left=0,top=0,width='+w+',height='+h+',toolbar=1,status=1,resizable=1,menubar=1,scrollbars=1');
	desktopPhoto.focus();
}


// Opens a new window at a specific height and width, with or without scrollbars
function win_open_icentre(desination, width, height, scrolling) {
	if (scrolling == true) {
		scrollbar = 1;
	} else {
		scrollbar = 0;
	}
	window.open(desination, "", "width=" + width + ",height=" + height + ",status=1,scrollbars=" + scrollbar);
}

// Opens a new window at a specific height and width, with or without scrollbars
function win_open_photos(desination, width, height, scrolling) {
	if (scrolling == true) {
		scrollbar = 1;
	} else {
		scrollbar = 0;
	}
	window.open('/v3/media/'+desination, "", "width=" + width + ",height=" + height + ",status=1,scrollbars=" + scrollbar);
}

// show Photos the popup
function hatch_popup_icentre(popupImgLink, vehName)
{
	var path = "/v3/media/"+vehName+"/photos/"+popupImgLink;
	desktopPhoto = window.open(path,'vehPhoto','left=0,top=0,width=710,height=540,toolbar=0,status=1,resizable=1,menubar=0,scrollbars=0');
	desktopPhoto.focus();
	
	/*var actualName;
	switch (vehName) {
		case "yarishb":
			actualName = "Yaris Hatchback";
		break;
		case "yaris":
			actualName = "Yaris";
		break;
		case "corolla":
			actualName = "Corolla";
		break;
		case "matrix":
			actualName = "Matrix";
		break;
		case "camry":
			actualName = "Camry";
		break;
		case "prius":
			actualName = "Prius";
		break;
		case "avalon":
			actualName = "Avalon";
		break;
		case "solara":
			actualName = "Solara";
		break;
		case "sienna":
			actualName = "Sienna";
		break;
		case "rav4":
			actualName = "RAV4";
		break;
		case "highlander":
			actualName = "Highlander";
		break;
		case "4runner":
			actualName = "4Runner";
		break;
		case "sequoia":
			actualName = "Sequoia";
		break;
		case "fj":
			actualName = "FJ Cruiser";
		break;
		case "tacoma":
			actualName = "Tacoma";
		break;
		case "tundra":
			actualName = "Tundra";
		break;
	
	}
	
	var path = "/v3/media/"+vehName+"/photos/"+popupImgLink;
	photoPop = window.open('','','left=0,top=0,status=1,resizable=1,scrollbars=0,width=701,height=521');
	photoPop.document.write('<html><TITLE>TOYOTA CANADA : Multimedia Gallery > '+actualName+'</TITLE>');
	photoPop.document.write('<BODY BGCOLOR="#FFFFFF" MARGINWIDTH="0" MARGINHEIGHT="0" TOPMARGIN="0" LEFTMARGIN="0">');
	photoPop.document.write('<script language="javascript" src="/v3/english/icentre/icentre.js"></script>');
	photoPop.document.write('<div align="center">');
	photoPop.document.write('<img src="'+path+'"><br>');
	photoPop.document.write('</body></html>');
	photoPop.document.close();
	photoPop.focus();*/
}




