var hatchLock = null;
var popupImgLink = 1;

// array of large images
// in pic, text, hdr layers format
var folderArr = new Array()
folderArr["ext"] = "exterior/";
folderArr["int"] = "interior/";
folderArr["eng"] = "engine/";
folderArr["saf"] = "safety/";
folderArr["han"] = "handling/";
folderArr["pho"] = "photos/";
folderArr["mod"] = "models/";
folderArr["col"] = "colours/";


// load the two divs with images
function hatch_load(folder, num, letter)
{
	if (hatchLock == null) 
	{
		hideLyr("main");
	}
	if (folder != null) 
	{
		hatch_mon(num,"submenu");
		temp = hatchLock;
		hatchLock = num;
		if (temp != null)
		{
			hatch_moff(temp,"submenu");
		}
	}
	
	

	if (folder == "pho")
	{
		var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + ".jpg";
		loadImage('pic','pic1',i);
		popupImgLink = num;
		showLyr("popupImgButton");
	}
	else if (folder == "ext")
	{
		if (num == 2)
		{
			var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + "_e.jpg";
		}
		else
		{
			var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + ".jpg";
		}	
		loadImage('pic','pic1',i);
	}
	else if (folder == "int")
	{
		if (num == 2)
		{
			var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + ".gif";
		}
		else
		{
			var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + ".jpg";
		}	
		loadImage('pic','pic1',i);
	}
	else if (folder == "eng")
	{
		if (num == 4)
		{
			var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + "_e.gif";
		}
		else
		{
			var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + ".jpg";
		}
		loadImage('pic','pic1',i); 
	}
	else if (folder == "saf")
	{
		if (num == 4)
		{
			var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + ".gif";
		}
		else
		{
			var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + ".jpg";
		}
		loadImage('pic','pic1',i); 
	}
	else
	{
		var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder + num + ".jpg";
		loadImage('pic','pic1',i);

	}	
	
}

function hatch_load_2wd(folder, num, letter){
	
	if (hatchLock == null) 
	{
		hideLyr("main");
	}
	if (folder != null) 
	{
		hatch_mon(num,"submenu");
		temp = hatchLock;
		hatchLock = num;
		if (temp != null)
		{
			hatch_moff(temp,"submenu");
		}
	}
	
	var i = "/v3/media/rav4/" + folderArr[folder] + "i_"  + folder+ "2wd" + num + ".jpg";
	loadImage('pic','pic1',i);
}

// mouseovers
function hatch_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 hatch_moff(num,div) 
{
	if (num == hatchLock) return;
	if (nn4 && div) 
	{
		document[div].document["img"+num].src = out[num].src; 
    } 
    else 
    {
    	document["img"+num].src = out[num].src;                
    }
}

// special photos preloader
var out = new Array();	// out rollovers
var over = new Array(); // over rollovers
function hatch_preloader(path,identifier,total)
{
	totalRolloverOnPage = total;
	for(i=0; i <= total; i++)
	{
		out[i] = new Image();
		out[i].src = path + "mout_" + identifier + i + ".jpg";
		over[i] = new Image();
		over[i].src = path + "mover_" + identifier + i + ".jpg";
	}
}


// show Photos the popup
function hatch_popup()
{
	displayImageWin("/v3/media/rav4/photos/l_pho"+popupImgLink+".jpg","FFFFFF","RAV4",false);
}

// 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 hasFlash10 = false;
var hasFlash9 = false;
var hasFlash8 = false;
var hasFlash7 = false;
var hasFlash6 = false;
var hasFlash5 = false;
var hasFlash4 = false;

function flash10()
{
	return hasFlash10; //flash 10 installed?
}
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('hasFlash10 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))) \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(10.0) != -1) {
		hasFlash10 = true;
	}
	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 showRAV4Flash()
{
  if (!flash5() && !flash6() && !flash7() && !flash8() && !flash9() && !flash10())
{
	document.write('<div id="main" style="position:absolute; width:1px; height:1px; z-index:1">');
	document.write('<table width="741" border="0" cellspacing="0" cellpadding="0" class="general_table">');
	document.write('<tr>');
	document.write('<td width="560" height="274" bgcolor="#000000">');
	document.write('<img src="/v3/media/rav4/intro/static_e.jpg" width="560" height="275">');
	document.write('</td>');
	document.write('<td>');
	document.write('<img src="/v3/media/rav4/intro/right_e.gif" width="181" height="275">');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</div>');
}
else
// USER HAS FLASH ON THEIR COMPUTER
{
	document.write('<div id="main" style="position:absolute; z-index:1;height:274px;overflow:hidden;">');
	document.write('<table width="741" border="0" cellspacing="0" cellpadding="0" class="general_table">');
	document.write('<tr>');
	document.write('<td width="560" height="274" bgcolor="#000000">');
	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="560" height="274">');
	document.write('<param name="movie" value="/v3/media/rav4/intro/rav4_sb_e.swf">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="/v3/media/rav4/intro/rav4_sb_e.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="560" height="274" wmode="transparent">');
	document.write('</embed>');
	document.write('</object>');
	document.write('</td>');
	document.write('<td>');
	document.write('<img src="/v3/media/rav4/intro/right_e.gif" width="181" height="274">');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</div>');
}
}

function displayBigImageWin(imagePath, bgcolor, vehicleName) {
  window.onerror = null;
  PreView=window.open("","Preview","width=715,height=530,menubar=yes,status=yes");
  PreView.document.open();
  PreView.document.write("<HTML><HEAD>");
  PreView.document.write("<TITLE>" + vehicleName + "</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%'>");
  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();
}

