// ======================= common functions =============================//
/*
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
*/

function createCookie(name, value, days)
{
  //alert('createCookie');
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
 }


function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  //if(navigator.appName == 'Microsoft Internet Explorer')
	 //return null;
  //else 
	return '';
}

function eraseCookie(name)
{
   createCookie(name, "", -1);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
// =============== common functions ends here ====================//

// ==================== function for show/hide row =======================//
function controlExpand(showrow,groupcount) {
	//window.location.href = "#abcd";
	collapse = "";
	show = 0;
	for (k=1; k<=groupcount; k++){
		jijo = ('tr'+k)
		if (jijo == showrow){
				collapse = showrow;
				if (document.getElementById(showrow).style.display == ''){
					show = 1;
				} else {
					show = 0;
				}
			}
		document.getElementById('tr'+k).style.display = 'none'
		//alert(jijo);
		}
		
	if (document.getElementById(showrow).style.display == ''){
			document.getElementById(showrow).style.display = 'none'
	} else {
			document.getElementById(showrow).style.display = '';
	}
	
	if (collapse == showrow){
		if (show == 1){
			document.getElementById(showrow).style.display = 'none';
		} else {
			document.getElementById(showrow).style.display = '';
		}
		}
}
// ================================================================== //
function acceDetails(acce1, acce2, acce3){
	//var strDesc = '<%=Request.QueryString("Desc")%>' [to get ?Desc=*** value]
	document.getElementById('acce_detail').innerHTML = '<span class=\"text_normal\"><strong>'+acce1+'</strong>'+'<br><br>'+acce2+'<br><br>'+'<strong>'+acce3+'</strong></span>';
	}
// ================== for choose accessories page ======================= //
function acceDiv(param) {
	if (param == 1){
		MM_showHideLayers('extacce_n','','show','extacce_h','','hide','intacce_h','','show','intacce_n','','hide','wheelacce_n','','hide','wheelacce_h','','show');
		} else if (param == 2){
			MM_showHideLayers('extacce_n','','hide','extacce_h','','show','intacce_h','','hide','intacce_n','','show','wheelacce_n','','hide','wheelacce_h','','show');
			} else if (param == 3) {
				MM_showHideLayers('extacce_n','','hide','extacce_h','','show','intacce_h','','show','intacce_n','','hide','wheelacce_n','','show','wheelacce_h','','hide');
				}
}
//========================= table highlight without radio ===============//
function hideInteriors(){
		document.getElementById('dispinteriors').style.display = 'none';
		document.getElementById('dispaccessories').style.display = 'none';
		if(document.getElementById("ModelName")!=null)
			document.getElementById("ModelName").style.display="";
		}
function color_extSelect(highlight,totalCell){
	for (l=1; l<(totalCell+1); l++){
		document.getElementById("extcol"+l).className="row_normalBorder";
		document.getElementById("extcol"+highlight).className="row_highlightBorder";
	}
}
function color_intSelect(highlight2,totalCell2){
	for (l=1; l<(totalCell2+1); l++){
		document.getElementById("intcol"+l).className="row_normalBorder";
		document.getElementById("intcol"+highlight2).className="row_highlightBorder";
	}
}
function in_d_select(me3,intdcount){
	for (l=1; l<intdcount; l++){
		document.getElementById("indcol"+l).className="normal";
		document.getElementById(me3).className="highlight";
	}
}
function dispmodel(modtag){
	document.getElementById('dispmod').innerHTML = modtag;
}
function pricePack(packtag){
	document.getElementById('pricePakText').innerHTML = 'Package Price';
	document.getElementById('pricePak').innerHTML = packtag;
}
function priceColour(colname){
	document.getElementById('priceColorText').innerHTML = 'Colour (Ext. + Int.)';
	document.getElementById('priceColor').innerHTML = colname;
}
function priceAcce(accetag){
	document.getElementById('priceAceText').innerHTML = 'Accessories';
	document.getElementById('priceAce').innerHTML = accetag;
}
// ========================== table highlight =============================//
function highlight(hitradio,count){
for(i=1; i<(count+1); i++){
	form1["hit"+i].checked = 0;
	form1[hitradio].checked = 1;
	alert('high')
}	
}
//=====================================================================
function getQueryVariable(variable) {
var query = unescape(window.location.search.substring(1));
var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
}

var oImg    = null;
var timerID = null;
var oImgObj = null;

function changePic(picname)
{
	var rj = getQueryVariable('sfl');
	var gj = getQueryVariable('in_tab');

	if ((rj !="0") && (gj=="summary"))
	{
		document.getElementById('nf').style.display = 'none';
		document.dispCar2.src='write/'+picname+'.jpg';		
	} 
	else if (rj !="0")
	{
		document.getElementById('nf').style.display = '';
		oImgObj = document.dispCar;
		SetOneImage ('write/' + picname + '.jpg');
	}
	else 
	{
		document.getElementById('sf').style.display = 'none';
		document.getElementById('nf').style.display = '';
		document.dispCar.src='write/'+picname+'.jpg';
	}
}
function SetOneImage(sPictName)
{
	//oImgObj.src = 'images/loading.gif';

	oImg = new Image(391, 210);
	oImg.src = sPictName;

	timerID = setInterval("LoadOneImage()", 10);
}
function LoadOneImage()
{
	if (oImg.readyState == 'complete')
	{
		oImgObj.src = oImg.src;
		clearInterval(timerID);
	}
}
//===================================================
function changeTwoIntPic(picname3,picname4){
	//document.int_thumb1.src='write/'+picname3+'.jpg';
	oImgObj = document.int_thumb1;
	SetOneImage ('write/' + picname3 + '.jpg');

	while (oImgObj.readyState != 'complete')
	{
	}

	//document.int_thumb2.src='write/'+picname4+'.jpg';
	oImgObj = document.int_thumb2;
	SetOneImage ('write/' + picname4 + '.jpg');
}
function changeIntPic(picname2){
	document.getElementById('dispinteriors').style.display = '';
	//document.interiorPic.src='write/'+picname2+'.jpg';
	oImgObj = document.interiorPic;
	SetOneImage ('write/' + picname2 + '.jpg');
}
function changeAccePic(picname5){
	document.getElementById('dispaccessories').style.display = '';
	//document.accessoryPic.src='write/'+picname5+'.jpg';
	oImgObj = document.accessoryPic;
	SetOneImage ('write/' + picname5 + '.jpg');
}

var currBold = "spec1";
var toBold = "spec1";
function setBold(id)
{
	toBold = id;
	document.getElementById(currBold).style.fontWeight='normal';
	document.getElementById(currBold).style.color='black';
	document.getElementById(currBold).style.textDecoration='underline';
	
	document.getElementById(toBold).style.fontWeight='bold';
	document.getElementById(toBold).style.color='red';
	document.getElementById(toBold).style.textDecoration='none';
	currBold = toBold;
}



//=================== function for open window ========================//
function fnOpenNewWindow(theURL,winName,width,height,scroll,pos) { //v2.0
			NewWindow(theURL,winName,width,height,scroll,pos);
			}

function OpenWindow(pURL)
{					
	//closeWin.Click();	
	var NewX = window.screen.availWidth;
	var NewY = window.screen.availHeight;
	var CurWidth=700;
	var CurHeight=window.screen.availHeight-80;
	var CurX = (NewX-CurWidth)/2;
	var CurY = (NewY-CurHeight)/2;
	new_window1=window.open(pURL,"AppWIN1","toolbar=no, resizable=no, directories=no, menubar=no, scrollbars=yes, width="+CurWidth+", height="+CurHeight+", Left="+CurX+", Top="+CurY+"");				
	new_window1.focus();						
}


// ================= Send Variables to Flash ===============================//

function setVar(id)
{
	window.document.gallery.SetVariable("myVar", id);
}

//===================End of Send Variables to Flash================================//		

function SetSelection()
{
	if(document.getElementById("hdnBodyType").value!="")
	{
		document.getElementById("ConfigurateMiddle").style.display="none";
		document.getElementById("Configurate").style.display="none";
		document.getElementById("YourConfigMiddle").style.display="";
		document.getElementById("YourConfig").style.display="";
	}
	else
	{
		document.getElementById("ConfigurateMiddle").style.display="";
		document.getElementById("Configurate").style.display="";
		document.getElementById("YourConfigMiddle").style.display="none";
		document.getElementById("YourConfig").style.display="none";
	}
}