/***

Global JavaScript utility functions

***/

/** Javascript for Flash Configurator Pop Up START **/

function openNewWindow(URLtoOpen, windowName, windowFeatures) { 
  newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}

/** Javascript for Flash Configurator Pop Up END **/





// global variables





var ua = navigator.userAgent.toLowerCase();
var nn4 = document.layers ? 1:0
var nn6 = (document.getElementById && (ua.indexOf('netscape') != -1)) ? 1:0
var dom = document.getElementById ? 1:0
var ie = (ua.indexOf('msie') != -1) ? 1:0
var ie4 = (document.all && !document.getElementById) ? 1:0
var mac = (ua.indexOf('mac') != -1) ? 1:0
var out = new Array();	// out rollovers
var over = new Array(); // over rollovers


// dhtml DOM selector



function getDOM(div){
	if (ie4){
		return document.all[div].style; 
	}
	if (dom){
		return document.getElementById(div).style;
	}	
	if (nn4){
		return document.layers[div];
	}
}



// hide a layer
// Addition if statment added by Matt to stop Netscape error - Jan 3, 2003

function hideLyr(div){
	if (getDOM(div)) {
		getDOM(div).visibility = "hidden";
	}
}




function homeSubMenuClose() {
	for (i=0; i<homeSubMenus.length; i++){
		hideLyr(homeSubMenus[i]);
	}
}

// show a layer
// Addition if statment added by Matt to stop Netscape error - Jan 3, 2003



function showLyr(div){
	if (getDOM(div)) {
		getDOM(div).visibility = "visible";
	}
}

// return layer visibility
function getLyrVis(div){
	if ((getDOM(div).visibility == "visible") || (getDOM(div).visibility == "show")){
		return true;
	}else{
		return false;
	}	
}



// hide a bunch of layers, then show one the
// last one (last param passed)
function vis(){
	var divs = vis.arguments;
	var len = divs.length;
	if (len == 1){
		showLyr(divs[0]);
		menuOn = divs[0];
		return;
	}
	for (i=0; i<len; i++){
		hideLyr(divs[i]);
	}	
}
// mouseovers



function mon(num,div){

	if (nn4 && div){
		document[div].document["img"+num].src = over[num].src;  
    }else{
    	document["img"+num].src = over[num].src;                  
    }
}

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

// loads an image without a preloader
function loadImage(num,div,imageName){
	if (document.layers){
		document[div].document["img"+num].src = imageName;
    }else{
    	document["img"+num].src = imageName;      
    }
}

// global rollover preloader (with starting image number)
function preloaderWithStart(path,identifier,start,total,lang){
	var l = "";
	totalRolloverOnPage = total;
	if (lang){
		l = "_" + lang;
	}
	for(i=start; i <= total; i++){
		out[i] = new Image();
		out[i].src = path + "mout_" + identifier + i + l +".gif";
		over[i] = new Image();
		over[i].src = path + "mover_" + identifier + i + l + ".gif";
	}
}


// global rollover preloader
function preloader(path,identifier,total,lang){
	var l = "";
	totalRolloverOnPage = total;
	if (lang){
		l = "_" + lang;
	}
	for(i=0; i <= total; i++){
		out[i] = new Image();
		out[i].src = path + "mout_" + identifier + i + l +".gif";
		over[i] = new Image();
		over[i].src = path + "mover_" + identifier + i + l + ".gif";
	}
}

// alternative rollover preloader that accepts an array
function arrayPreloader(path, identifiers, lang){
	var l = "";
	if (lang){
		l = "_" + lang;
	}
	var otherRollovers = 0;
	while(out[otherRollovers]) {
		otherRollovers++;
	}
	total = identifiers.length - 1 + otherRollovers;
	for(i=otherRollovers; i <= total; i++){
		out[i] = new Image();
		out[i].src = path + "mout_" + identifiers[i-otherRollovers] + l +".gif";
		over[i] = new Image();
		over[i].src = path + "mover_" + identifiers[i-otherRollovers] + l + ".gif";
	}
}

//  change text in a layer
function changeText(div,text){
	if (nn4){
    	document[div].document.open();
		document[div].document.write(text);
        document[div].document.close();
        return;
    }else if (ie4){
    	eval(div + ".innerHTML = text");
    	return;
    }else if (dom){
    	document.getElementById(div).innerHTML = text;
    	return;
    }
}

// build ticker for the homepage



function addTicker(text,page,sty,popup,height,width){
	this.text = text;
	this.page = page;
	this.sty = sty;
	this.popup = popup;
	this.height = height;
	this.width = width;	
}

// make the tickers for the homepage



var tkr = new Array();
tkr[0] = new addTicker("Toyota Takes Three EnerGuide Awards","http://www.toyota.ca/cgi-bin/WebObjects/WWW.woa/wa/vp?vp=Home.WhatsNew.Energuide07&language=english","ver13blue",false,false,false);
tkr[1] = new addTicker("Camry Hybrid Wins Car of the Year","http://www.toyota.ca/cgi-bin/WebObjects/WWW.woa/wa/vp?vp=Home.WhatsNew.CamHybridAward07&language=english","ver13blue",false,false,false);
tkr[2] = new addTicker("See the all-new 2007 Tundra","http://www.toyota.ca/cgi-bin/WebObjects/WWW.woa/wa/vp?vp=Home.Vehicles.Go.Tundra&language=english","ver13blue",false,false,false); 
tkr[3] = new addTicker("Toyota Navigation System","http://www.toyota.ca/v3/english/custom/c950016e_interior.html","ver13blue",true,600,789);  


// rotate the ticker


function rotateTicker(div,num){
	var tkrLen = tkr.length;
	var tkrDiv = div;
	var tkrText = '<table width="340" height="33" border="0" cellspacing="0" cellpadding="0"><tr><td align="center">';
	if (tkr[num].popup == true){
		tkrText += "<a class='"+tkr[num].sty+"' href=javascript:openCenteredWindow('"+tkr[num].page+"','"+tkr[num].height+"','"+tkr[num].width+"','','scrollbars=0,resizable=0');history.go(0);>"+tkr[num].text+"</a>"; 
	}else{
		tkrText += "<a class='"+tkr[num].sty+"' href='"+tkr[num].page+"'>"+tkr[num].text+"</a>"; 
	}
	tkrText += "</td></tr></table>";
	var tkrNext = num + 1;
	tkrNext = (tkrNext > (tkrLen - 1)) ? 0:tkrNext;
	changeText(tkrDiv,tkrText);
	showLyr(tkrDiv);
	setTimeout("hideLyr('"+tkrDiv+"')",7000);
	setTimeout("rotateTicker('"+tkrDiv+"',"+tkrNext+")",7500);
}


// French version of the ticker
var tkrFre = new Array();
tkrFre[0] = new addTicker("Toyota remporte trois prix ÉnerGuide","http://www.toyota.ca/cgi-bin/WebObjects/WWW.woa/wa/vp?vp=Home.WhatsNew.Energuide07&language=francais","ver13blue",false,false,false);
tkrFre[1] = new addTicker("LA  CAMRY HYBRIDE DÉSIGNÉE <BR>« VOITURE CANADIENNE DE L'ANNÉE » ","http://www.toyota.ca/cgi-bin/WebObjects/WWW.woa/wa/vp?vp=Home.WhatsNew.CamHybridAward07&language=francais","ver13blue",false,false,false);
tkrFre[2] = new addTicker("Voyez le tout nouveau Tundra 2007","http://www.toyota.ca/cgi-bin/WebObjects/WWW.woa/wa/vp?vp=Home.Vehicles.Go.Tundra&language=francais","ver13blue",false,false,false);
tkrFre[3] = new addTicker("Système de navigation Toyota","http://www.toyota.ca/v3/francais/custom/c950016f_interior.html","ver13blue",true,600,789);  


function rotateTickerFrench(div,num){
	var tkrLen = tkrFre.length;
	var tkrDiv = div;
	var tkrText = '<table width="340" height="33" border="0" cellspacing="0" cellpadding="0"><tr><td align="center">';
	if (tkrFre[num].popup == true){
		tkrText += "<a class='"+tkrFre[num].sty+"' href=javascript:openCenteredWindow('"+tkrFre[num].page+"','"+tkrFre[num].height+"','"+tkrFre[num].width+"','Francais','scrollbars=0,resizable=0');history.go(0);>"+tkrFre[num].text+"</a>"; 
	}else{
		tkrText += "<a class='"+tkrFre[num].sty+"' href='"+tkrFre[num].page+"'>"+tkrFre[num].text+"</a>"; 
	}
	tkrText += "</td></tr></table>";
	var tkrNext = num + 1;
	tkrNext = (tkrNext > (tkrLen - 1)) ? 0:tkrNext;
	changeText(tkrDiv,tkrText);
	showLyr(tkrDiv);
	setTimeout("hideLyr('"+tkrDiv+"')",7000);
	setTimeout("rotateTickerFrench('"+tkrDiv+"',"+tkrNext+")",7500);
}



// open the vid
// temp function
function temp(){
	window.open("vid.html","test","left=0,top=0,width=480,height=270,status=1,resizable=1.scrollbars=0");
}



/* 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();


// Focuses on the first text element in a form if such a text element exists

function textFormFocus(){

	if (document.forms.length > 0) {
		if (document.forms[0].elements.length > 0) {
			if (document.forms[0].elements.type = "text") {
				document.forms[0].elements[0].focus();
			}
		}
	}
}


function do_nothing (){
	return true;
}


// Removes the focus from the links
function removeFocus() {
	empty_var = do_nothing();
   	for (i = 0; i < document.links.length; i++) {
        document.links[i].blur;
    }
}

//document.onmousedown = removeFocus;
//document.onmouseup = removeFocus;
//document.onfocus = removeFocus;

// Accepts an array of divs turns them all invisible
// and then makes visible one div


function switchDivs(div, arrayDivs){
	len = arrayDivs.length;
	if (len != 1) {
		for (i=0; i<len; i++) {
			hideLyr(arrayDivs[i]);
		}
		showLyr(div);
	}
}


/***** OPEN A  NEW WINDOW WITH SELECTED IMAGE AND BACKGROUND ******/
function displayImageWin(imagePath, bgcolor, vehicleName, redbar){
  if (redbar == true){

  }
  window.onerror = null;
  PreView=window.open("","Preview","width=701,height=521,menubar=yes,status=yes");
  PreView.document.open();
  PreView.document.write("<HTML><HEAD>");
  PreView.document.write("<TITLE>" + vehicleName + ": Photo</TITLE>");
  PreView.document.write("</HEAD><BODY MARGINHEIGHT='0' MARGINWIDTH='0' LEFTMARGIN='0' TOPMARGIN='0' BGCOLOR='#" + bgcolor + "' TEXT='000000'>");
  PreView.document.write("<TABLE BORDER='0' cellpadding='0' cellspacing='0' HEIGHT='100%' WIDTH='100%'>");
  if (redbar == true) {
	PreView.document.write("<TR><TD height='64' ALIGN='left' bgcolor='#D60010'><img src='/v3/media/shared/h_toyota_mtb.gif' width='181' height='63'></TD></TR>");
//  	PreView.document.write("<TR><TD height='64' ALIGN='left' bgcolor='#D60010'><img src='/v3/media/shared/ico_logo.gif' width='116' height='63'></TD></TR>");
  }
  PreView.document.write("<TR><TD ALIGN='center' VALIGN='middle'>");
  PreView.document.write("<IMG SRC='" + imagePath + "'>");
  PreView.document.write("</TD></TR></TABLE>");
  PreView.document.write("</BODY></HTML>");
  PreView.document.close();
  PreView.focus();
}



/************ OPENS PDF BROCHURE ***************/



function pdf (brochure) {
	window4=window.open(brochure,'EBrochure','status=yes,scrollbars=yes,resizable=yes,menubar=yes');
	if (navigator.appVersion.substring(0,1) >= "3") {window4.focus()};
}
// mouseovers for the bullets in the Echo & Celica sections



function bulletMon(bulletNum, div, num){
	if (!num) {
		num = 1;
	}
	if (nn4 && div){
		document[div].document["img"+bulletNum].src = over[num].src;  
    }else{
    	document["img"+bulletNum].src = over[num].src;                  
    }
}


// mouseouts for the bullets in the Echo & Celica sections



function bulletMoff(bulletNum, div, menuSelect, num){
	if (!num) {
		num = 1;
	}
	if ((bulletNum != menuSelect) && (bulletNum!=0)){
 		if (nn4 && div){
			document[div].document["img"+bulletNum].src = out[num].src; 
	    }else{
    		document["img"+bulletNum].src = out[num].src;                    
	    }
	}
}

/****** Status Message ******/
// global function sets status messages to blank (testing it by using the word Toyota)

function msg(){
   window.status='Toyota';
   return true;
}

//documentonmouseover = msg;
/**** End Status Message *****/
// randomly picks one of the images for the main page
function randomImage () {
	randomNum = -1;
//	imageArray = new Array('main_4run', 'main_ava', 'main_cam', 'main_yarisHB', 'main_sol','main_fj',  'main_cor',  'main_yaris', 'main_yarisHB', 'main_high',  'main_mat',  'main_prius', 'main_sol','main_yaris', 'main_rav',  'main_seq', 'main_sien', 'main_rav', 'main_sol',  'main_tac',  'main_tun', 'main_fj', 'main_yaris', 'main_fj');
	imageArray = new Array('main_4runner', 'main_avalon', 'main_camry', 'main_corolla', 'main_fjcruiser','main_highlander',  'main_matrix',  'main_prius', 'main_rav4', 'main_sequoia',  'main_sienna',  'main_solara', 'main_tacoma','main_tundra', 'main_yaris',  'main_yarishb');
	randomNum = Math.round(Math.random() * imageArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return imageArray[randomNum];
}


// randomly picks one of the images for the TMMC page



function tmmcRandomImage (){
	randomNum = -1;
	imageArray = new Array('i_randomImage2','i_randomImage3','i_randomImage4','i_randomImage5','i_randomImage6','i_randomImage7','i_randomImage8');
	randomNum = Math.round(Math.random() * imageArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return imageArray[randomNum];
}


// randomly picks one of the images for the custom page
function randomImageCustom () {
	randomNum = -1;
	imageArray = new Array('custom_cor', 'custom_high', 'custom_mat', 'custom_sol', 'custom_tac');
	randomNum = Math.round(Math.random() * imageArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return imageArray[randomNum];
}


// randomly picks one of the images for the TFS
function randomImageTFS () {
	randomNum = -1;
	imageArray = new Array('i_tfs_main_1', 'i_tfs_main_2', 'i_tfs_main_3');
	randomNum = Math.round(Math.random() * imageArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return imageArray[randomNum];
}


// randomly picks one of the flash files for intro_e
function randomFlashIntroE () {
	randomNum = -1;
//  For after redtag flash
//	flashArray = new Array('tacoma_mt_e','matrix_trd_e','tacoma_ajac_e','energuide_e','tacoma_e','tacoma_ajac_e', 'tacoma_mt_e', 'matrix_trd_e','tundra_dcab_e','brand_e','echohb_alien_e','sienna_leather_e', 'tacoma_mt_e', 'matrix_trd_e');
//	flashArray = new Array('woodstock_e', '05hotsummer_e', 'avalon_e', '05hotsummer_e', 'woodstock_e', '06solara_e', 'tacoma_e', 'sienna_leather_e');
	flashArray = new Array('hybrid_site_e', 'solara07_site','f1_site_e','07camry_e','yaris_intro_e','woodstock_e','07fj_cruiser_e');
	randomNum = Math.round(Math.random() * flashArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return flashArray[randomNum];
}

// randomly picks one of the flash files for intro_f
function randomFlashIntroF () {
	randomNum = -1;
//  For after redtag flash
//	flashArray = new Array('tacoma_mt_f','matrix_trd_f','tacoma_ajac_f','energuide_f','tacoma_f','tacoma_ajac_f', 'tacoma_mt_f', 'matrix_trd_f','tundra_dcab_f', 'brand_f', 'echohb_alien_f','sienna_leather_f', 'tacoma_mt_f','matrix_trd_f');
//	flashArray = new Array('woodstock_f', '05hotsummer_f', 'avalon_f', '05hotsummer_f', 'woodstock_f', '06solara_f', 'tacoma_f', 'sienna_leather_f');
	flashArray = new Array('hybrid_site_f', 'solara07_site','f1_site_e','07camry_f','yaris_intro_f', 'woodstock_f','07fj_cruiser_f');
	randomNum = Math.round(Math.random() * flashArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return flashArray[randomNum];
}



// randomly picks one of the static gif files for intro_static_e



function randomStaticIntroE(){
	randomNum = -1;
//  For after redtag animated gif
//	imageArray = new Array( 'tacoma_mt_e','matrix_trd_e','tacoma_ajac_e','energuide_e', 'tacoma_e','tacoma_ajac_e', 'echo_e', 'prius_e', 'sienna_leather_e', 'tundra_e', 'tacoma_mt_e','matrix_trd_e');
//	imageArray = new Array('woodstock_e','05hotsummer_e','avalon_e','06solara_e','woodstock_e','05hotsummer_e','tacoma_e','sienna_leather_e');
	imageArray = new Array('woodstock_e');
	randomNum = Math.round(Math.random() * imageArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return imageArray[randomNum];

}



// randomly picks one of the static gif files for intro_static_e



function randomStaticIntroF(){
	randomNum = -1;
//  For after redtag animated gif
//	imageArray = new Array('tacoma_mt_f','matrix_trd_f','tacoma_ajac_f','energuide_f','tacoma_f','tacoma_ajac_f', 'echo_f','prius_f', 'sienna_leather_f', 'tundra_f', 'tacoma_mt_f','matrix_trd_f');
//	imageArray = new Array('woodstock_f','05hotsummer_f', 'avalon_f', '06solara_f', 'woodstock_f', '05hotsummer_f', 'tacoma_f', 'sienna_leather_f');
	imageArray = new Array('woodstock_f');
	randomNum = Math.round(Math.random() * imageArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return imageArray[randomNum];
}



function randomCustomPopRav4 (){
	randomNum = -1;
	imageArray = new Array('i_06rav4_blue','i_06rav4_red');
	randomNum = Math.round(Math.random() * imageArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return imageArray[randomNum];
}



function randomCustomPopYaris (){
	randomNum = -1;
	imageArray = new Array('i_07yaris_blue','i_07yaris_red');
	randomNum = Math.round(Math.random() * imageArray.length - 1);
	if (randomNum == -1) {
		randomNum = 0;
	}
	return imageArray[randomNum];
}




// Hides a div or makes it visible depending on the current state of the div
function turnOnOrOff (div) {
	if (getLyrVis(div)) {
		hideLyr(div);
	} else {
		showLyr(div);
	}
}

// Opens a new window at a specific height and width, with or without scrollbars


function win_open(desination, width, height, scrolling) {
	if (scrolling == true) {
		scrollbar = 1;
	} else {
		scrollbar = 0;
	}
	window.open(desination, "", "width=" + width + ",height=" + height + ",status=1,resizable=1,scrollbars=" + scrollbar);
}



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

	window.open(desination, "", "width=" + width + ",height=" + height + ",menubar=1,status=1,scrollbars=" + scrollbar);
}



//Opens dealer website

function win_open_leave(desination, width, height, scrolling, url) {
	if (scrolling == true) {
    	scrollbar = 1;
    } else {
        scrollbar = 0;

    }
    leaveURL = url;
    window.open(desination, "", "width=" + width + ",height=" + height + ",status=1,resizable=1,scrollbars=" + scrollbar);
}


// Opens a new window inside the browser window with specific height and width as well as how much padding to the left and top



function win_open_inside(desination, width, height, paddingLeft, paddingTop) {
	var leftVar = 0;
	var topVar = 0;
	var extraPadding = 0;
	if (document.all) {
		topVar = window.screenTop;
		leftVar = window.screenLeft;
	} else if (document.layers) {
		topVar = window.screenY;
		leftVar = window.screenX;
		extraPadding = window.outerHeight - window.innerHeight;
		if (window.statusbar.visible = true) {
			extraPadding -= 25;
		}

		if (extraPadding < 0) {
			extraPadding = 0;
		}
	} else if (document.getElementById) {
		topVar = window.screenY;
		leftVar = window.screenX;
		extraPadding = window.outerHeight - window.innerHeight;
		if (window.statusbar.visible = true) {
			extraPadding -= 22;
		}
		if (extraPadding < 0) {
			extraPadding = 0
		}
	}

	topVar = topVar + parseInt(paddingTop) + extraPadding;
	leftVar = leftVar + parseInt(paddingLeft);
	window.open(desination, "", "left=" + leftVar + ",top=" + topVar + ",width=" + width + ",height=" + height + ",status=1,scrollbars=0");
}



/***** OPEN A  NEW WINDOW WITH SELECTED QUICKTIME MOVIE ******/
function quicktime(movie, w, h, title) {
	qtHTML = window.open("","qt","width="+w+",height="+h+",status=1,scrollbars=0");
	qtHTML.document.open();
	qtHTML.document.write('<html><head><title>' + title + '</title></head>');
	qtHTML.document.write('<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	qtHTML.document.write('<embed src="' + movie + '" width="'+w+'" height="'+h+'" controller=true autoplay=true></embed>');
	qtHTML.document.write('</body></html>');
	qtHTML.document.close();
	qtHTML.focus();
}

/***** OPEN A  NEW WINDOW WITH SELECTED QUICKTIME MOVIE FOR make things better english ******/
function qtmakeE(movie, w, h) {
	var path = "http://www.interactive.toyota.ca/"+movie+"";
	qtHTML = window.open("","qt","width="+w+",height="+h+",status=1,scrollbars=0");
	qtHTML.document.open();
	qtHTML.document.write('<html><head><title>make things better</title></head>');
	qtHTML.document.write('<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	qtHTML.document.write('<embed src="'+path+'" width="'+w+'" height="'+h+'" controller=true autoplay=true></embed>');
	qtHTML.document.write('</body></html>');
	qtHTML.document.close();
	qtHTML.focus();
}


/***** OPEN A  NEW WINDOW WITH SELECTED QUICKTIME MOVIE FOR make things better francais ******/
function qtmakeF(movie, w, h) {
	var path = "http://www.interactive.toyota.ca/"+movie+"";
	qtHTML = window.open("","qt","width="+w+",height="+h+",status=1,scrollbars=0");
	qtHTML.document.open();
	qtHTML.document.write('<html><head><title>faire toujours mieux</title></head>');
	qtHTML.document.write('<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	qtHTML.document.write('<embed src="'+path+'" width="'+w+'" height="'+h+'" controller=true autoplay=true></embed>');
	qtHTML.document.write('</body></html>');
	qtHTML.document.close();
	qtHTML.focus();
}




/***** OPEN A  NEW WINDOW WITH SELECTED QUICKTIME MOVIE FOR TMMC ******/



function qtTMMC(movie, w, h) {
	var path = "http://www.interactive.toyota.ca/movies/tmmc/"+movie+".mov";
	qtHTML = window.open("","qt","width="+w+",height="+h+",status=1,scrollbars=0");
	qtHTML.document.open();
	qtHTML.document.write('<html><head><title>TMMC</title></head>');
	qtHTML.document.write('<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	qtHTML.document.write('<embed src="'+path+'" width="'+w+'" height="'+h+'" controller=true autoplay=true></embed>');
	qtHTML.document.write('</body></html>');
	qtHTML.document.close();
	qtHTML.focus();
}


// 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); // tmmc video's hi
sz[2] = new qt_sizes(320,180); // tmmc 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




// open Quicktime
function qtTMMCMovie(movie,s) {
	var path = "http://www.interactive.toyota.ca/movies/tmmc/"+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>TMMC</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();
}


/***** OPEN A  NEW WINDOW WITH SELECTED QUICKTIME VR MOVIE ******/



function qtvr(movie, w, h, title) {
	if (parseInt(w) < 600) {
		qtsmall = window.open("","qtsmall","width="+w+",height="+h+",status=1,scrollbars=0");
		qtsmall.document.open();
		qtsmall.document.write('<html><head><title>' + title + '</title></head>');
		qtsmall.document.write('<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
		qtsmall.document.write('<embed src="' + movie + '" width="'+w+'" height="'+h+'" controller=true autoplay=true></embed>');
		qtsmall.document.write('</body></html>');
		qtsmall.document.close();
		qtsmall.focus();
	} else {
		qtbig = window.open("","qtbig","width="+w+",height="+h+",status=1,scrollbars=0");
		qtbig.document.open();
		qtbig.document.write('<html><head><title>' + title + '</title></head>');
		qtbig.document.write('<body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
		qtbig.document.write('<embed src="' + movie + '" width="'+w+'" height="'+h+'" controller=true autoplay=true></embed>');
		qtbig.document.write('</body></html>');
		qtbig.document.close();
		qtbig.focus();
	}
}







// Opens a new window to a specific location and closes the window behind it



function openAndClose (desination) {
	window.open(desination, "new", ",height=450,width=618,status=1,toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1;");
	window.self.close();
}



// This function closes a pop-up window and changes the location of the parent window

function updateParentAndClose(desination)  {
   	opener.document.location = desination;
	window.self.close();
}



function goMap(dCode,french){ 
	if (french){
		location.href="http://www.toyota.ca/cgi-bin/WebObjects.exe/WWW.woa/wa/vp?vp=Home.Dealers&language=francais&dealer="+dCode;
	}else{
		location.href="http://www.toyota.ca/cgi-bin/WebObjects.exe/WWW.woa/wa/vp?vp=Home.Dealers&dealer="+dCode;
	}	
}


// latch a rollover on nav items

function rolloverLatch(num,div,hider){	
	if (hider) {
		//alert(hider);
		for (i=0; i < hider; i++){
			if (i != num) {
				moff(i,div);
			}
		}	
	} else {
		for (i=0; i < out.length; i++){
			if (i != num) {
				moff(i,div);
			}
		}	
	}
}

// This function is for the Matrix Flash pop-up window

function matrix_popup(){
	if (nn4 && !mac) {
 		win_open_inside('/v3/english/matrix/indexNNPC.html', '715', '405', '20', '75');
	} else {
 		win_open_inside('/v3/english/matrix/index.html', '715', '405', '20', '75');
	}
}



// This function is for the French Matrix Flash pop-up window



function matrix_popup_fr(){
	if (nn4 && !mac) {
 		win_open_inside('/v3/francais/matrix/indexNNPC.html', '715', '405', '20', '75');
	} else {
 		win_open_inside('/v3/francais/matrix/index.html', '715', '405', '20', '75');
	} 
}


// This function is for the Echo Hatchback Game pop-up window

function echohb_popup(){
	if (nn4 && !mac) {
 		win_open_inside('http://www.interactive.toyota.ca/shock/echogame/echohb_game_e.html', '550', '400', '20', '75');
	} else {
 		win_open_inside('http://www.interactive.toyota.ca/shock/echogame/echohb_game_e.html', '550', '400', '20', '75');
	}
}

// This function is for the French Matrix Flash pop-up window
function echohb_popup_f(){
	if (nn4 && !mac) {
 		win_open_inside('http://www.interactive.toyota.ca/shock/echogame/echo_fr/echohb_game_f.html', '550', '400', '20', '75');
	} else {
 		win_open_inside('http://www.interactive.toyota.ca/shock/echogame/echo_fr/echohb_game_f.html', '550', '400', '20', '75');
	} 
}

// WebObject compatible version of updateParentAndClose

function updateWOParentAndClose(destination){
   do {
	slashx = document.URL.indexOf("/", 7);
    if (slashx == -1)
    	break;
        host = document.URL.substring(7, slashx);
        wourlx = document.URL.lastIndexOf("wourl=");
        if (wourlx == -1)
        	break;
            wourl = document.URL.substring(wourlx + 6)
            url = "http://" + host + wourl + "?page=" + destination
   } while (false);
       opener.location.href = url;
       window.self.close();
}

function openCenteredWindow(url, height, width, name, parms){
	var left = Math.floor( (screen.width - width) / 2);
	var top = Math.floor( (screen.height - height) / 2);
	var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
	if (parms){ 
		winParms += "," + parms; 
	}
	var win = window.open(url, name, winParms);
	if (parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
	return win;
}



//v1.0

//Copyright 2006 Adobe Systems, Inc. All rights reserved.

function AC_AddExtension(src, ext){
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}



function AC_Generateobj(objAttrs, params, embedAttrs){ 

  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';
  document.write(str);
}



function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}



function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}



function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();
    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}



//SUBHEADERS
window.onload = function () {
	if(document.getElementById("subheadH2")) { 
		if(mac) {
			document.getElementById("subheadH2").style.backgroundImage = "url(/v3/media/shared/sh_backgrnd_mac.gif)"; 
		} else {
			document.getElementById("subheadH2").style.backgroundImage = "url(/v3/media/shared/sh_backgrnd.gif)"; 
		} 
	}
}


function changeSearchOnE(that){
document.searchEntry.search.style.backgroundColor='#FFFFFF';
document.searchEntry.search.style.color='#000000' 
if(document.searchEntry.search.value=='SEARCH')document.searchEntry.search.value='';
}

function changeSearchOffE(that){
document.searchEntry.search.style.backgroundColor='#000000';
document.searchEntry.search.style.color='#FFFFFF'; 
if(document.searchEntry.search.value=='')document.searchEntry.search.value='SEARCH';
}

function changeSearchOnF(that){
document.searchEntry.search.style.backgroundColor='#FFFFFF';
document.searchEntry.search.style.color='#000000' 
if(document.searchEntry.search.value=='RECHERCHE')document.searchEntry.search.value='';
}

function changeSearchOffF(that){
document.searchEntry.search.style.backgroundColor='#000000';
document.searchEntry.search.style.color='#FFFFFF'; 
if(document.searchEntry.search.value=='')document.searchEntry.search.value='RECHERCHE';
}


// Google Maps Window
function xgmapWindow(url) {
//	var newwindow = window.open(url,'name','height=387,width=550,status=0,toolbar=0,location=0,menubar=0,scrollbars=0,resizable=0');
//	var newwindow = window.open(url,'name','height=457,width=650,status=1,toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1');
	var newwindow = window.open(url,'name','height=457,width=650,status=0,toolbar=0,location=0,menubar=0,scrollbars=0,resizable=0');
	if (window.focus)  {newwindow.focus() }
}

// ck 2008.06.26 new function to open the accessory popup window with parameters

function acsy_popup (title, name, image, text) {
var win = window.open("", "win", "width=550,height=570,resizable=yes");
  var str1 = '<html><head><title>'
  var str2 = '</title>';
  var str3 = '<style><!--/* General tbl formatting */#lside { float: left; margin-left: 50px; } #rside { float: right; margin-right: 20px; } #container { margin: 0px; background-color: #e5e5e5; width: 470px; position: relative; } #container .box { background-color: #ffffff; color: #D50017; float: left; margin: 0px; padding: 0px 4px 0px 4px; font-weight: bold; font-family: Arial, Helvetica, sans-serif; font-size: 12pt; text-align: left; width: auto; overflow: auto; } #headerbg {background-color:#FFF; width:auto; border: solid 1px #000; padding:2px 0 2px 2px; color:#d50017; font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px} </style>';
  var str4 = '<script language="JavaScript" src="/v3/src/global.functions.js"></script><script language="JavaScript" src="/v3/src/nav.functions.js"></script>';
  var str5 = '</head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#000000">';
  var str6 = '<table width="550" border="0" cellspacing="0" cellpadding="0"><tr>';
  var str7 = '<td colspan="3"><img src="/v3/';
  var str8 = '" width="550" height="387" vspace="15"></td></tr><tr><td bgcolor="#e5e5e5"><div id="lside">&nbsp;</div></td><td bgcolor="#e5e5e5"><div id="container"><div class="box">';
  var str9 = '</div></div></td><td bgcolor="#e5e5e5"><div id="rside">&nbsp;</div></td></tr><tr>  <td colspan="3"><img src="/v3/media/shared/dot.gif" width="1" height="18"></td></tr><tr><td width="56"><img src="/v3/media/shared/dot.gif" width="56" height="1"></td><td width="438" class="ver11blk">';
  var str10 = '</td><td width="56"><img src="/v3/media/shared/dot.gif" width="56" height="1"></td></tr></table></div></body></html>';
with (win.document) {
  open("text/html", "replace");
  write(str1+title+str2+str3+str4+str5+str6+str7+image+str8+name+str9+text+str10);
  close();
}
}

// jg 2007.09.13 new function to open the accessory popup window with parameters

function acsy_popup1 (title, name, image, text) {
var win = window.open("", "win", "width=550,height=570");
  var str1 = '<html><head><title>'
  var str2 = '</title>';
  var str3 = '<style><!--/* General tbl formatting */.surroundSubHead { padding: 1px 4px 0px 4px;       display: inline;        margin: 0px;    position: relative;     left: 52px;     background-color: #FFFFFF;      } .subheadText {        color: #D50017;         font-weight: bold;      font-family: Verdana, Arial, Helvetica, sans-serif;     font-size: 11pt;        background-color: #FFFFFF;} #subheadH2 {        width: 550px;   background-repeat: repeat-x; } </style>';
  var str4 = '<script language="JavaScript" src="/v3/src/global.functions.js"></script><script language="JavaScript" src="/v3/src/nav.functions.js"></script>';
  var str5 = '</head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#000000">';
  var str6 = '<table width="550" border="0" cellspacing="0" cellpadding="0"><tr>';
  var str7 = '<td colspan="3"><img src="/v3/';
  var str8 = '" width="550" height="387" vspace="15"></td></tr><tr><td colspan="3"><div id="subheadH2" name="subheadH2"><div class="surroundSubHead"><span class="subheadText">';
  var str9 = '</span></div></div></td></tr><tr>  <td colspan="3"><img src="/v3/media/shared/dot.gif" width="1" height="18"></td></tr><tr><td width="56"><img src="/v3/media/shared/dot.gif" width="56" height="1"></td><td width="438" class="ver11blk">';
  var str10 = '</td><td width="56"><img src="/v3/media/shared/dot.gif" width="56" height="1"></td></tr></table></div></body></html>';
with (win.document) {
  open("text/html", "replace");
  write(str1+title+str2+str3+str4+str5+str6+str7+image+str8+name+str9+text+str10);
  close();
}
}
