//general stuff
var supressLink = false;

function chg(theId,theClass){
	document.getElementById(theId).className=theClass;
}
function chgTabIm(theIm,isOn,theDir){
	if(isOn == 'o'){
		theImage = 'tabs1o_0'+theIm+'.gif';
	}else{
		theImage = 'tabs1_0'+theIm+'.gif';
	}
	document.getElementById('t'+theIm).src=theDir+theImage;
}
function link(url){	
	if(!supressLink){
		window.location.href=url;
		//click();
	}
}
function show(theId){
	if(document.getElementById(theId)){
		document.getElementById(theId).style.display='';
	}
}
function hide(theId){
	if(document.getElementById(theId)){
		document.getElementById(theId).style.display='none';
	}
}
function tog(theId){
	if(document.getElementById(theId)){
		if(document.getElementById(theId).style.display=='none'){
			document.getElementById(theId).style.display='';
		}else{
			document.getElementById(theId).style.display='none';
		}
	}
}
function updateDiv(theId,theValue){
	document.getElementById(theId).value=theValue;
}

//new details
function togfeat(theId){
	if(document.getElementById('feat' + theId)){
		if(document.getElementById('feat' + theId).style.display=='none'){
			document.getElementById('feat' + theId).style.display='';
			document.getElementById('feath2' + theId).className='open';
		}else{
			document.getElementById('feat' + theId).style.display='none';
			document.getElementById('feath2' + theId).className='close';
		}
	}
}

function ckFeat(theId){
	if(document.getElementById('feat' + theId).innerHTML.length < 20){
		document.getElementById('feath2' + theId).style.display='none';
	}
}
//

//home page
function hpTabs(onTab){
	document.getElementById('hp1').className='off';
	document.getElementById('hp2').className='off';
	document.getElementById('hp3').className='off';
	document.getElementById('hp4').className='off';

	document.getElementById('hp' + onTab).className='on';

	document.getElementById('hptabs').className='bg' + onTab;
}
//end home page

function sideTabs(onTab){
	document.getElementById('st1').className='';
	document.getElementById('st2').className='';
	document.getElementById('enq1').style.display='none';
	document.getElementById('enq2').style.display='none';
	document.getElementById('st' + onTab).className='o';
	document.getElementById('enq' + onTab).style.display='';
}

function suTabs(onTab){
	document.getElementById('sut1').className='';
	document.getElementById('sut2').className='';
	document.getElementById('signup1').style.display='none';
	document.getElementById('signup2').style.display='none';
	document.getElementById('sut' + onTab).className='o';
	document.getElementById('signup' + onTab).style.display='';
}

//vehicle details
function clearLoad(){
	document.getElementById('load').style.display='none';
}
function getLoad(thePic){
	if(document.theCar.src != thePic){
		document.theCar.src=thePic;
		document.getElementById('load').style.display='';
	}
}

function supress(tf){
	supressLink = tf;
}

function checkYear(){
	var sfrm = document.search;
	if(sfrm.yearMin.value.replace(/\s+/i,"")!="" && sfrm.yearMax.value.replace(/\s+/i,"")!=""){
		var yearN = sfrm.yearMin.value;
		var yearX = sfrm.yearMax.value;
		if(sfrm.yearMin.value > sfrm.yearMax.value){
			sfrm.yearMin.value=yearX;
			sfrm.yearMax.value=yearN;
		}
	}
}

function checkPrice(){
	var sfrm = document.search;
	if(sfrm.priceMin.value.replace(/\s+/i,"")!="" && sfrm.priceMax.value.replace(/\s+/i,"")!=""){
		var priceN = sfrm.priceMin.value;
		var priceX = sfrm.priceMax.value;
		if(sfrm.priceMin.value > sfrm.priceMax.value){
			sfrm.priceMin.value=priceX;
			sfrm.priceMax.value=priceN;
		}
	}
}

function flashPlay(DivID, WIDTH, HEIGHT, URL, AUTOSTART){
	var d = document.getElementById(DivID);
	d.innerHTML =
	'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
	+ 'width="' + WIDTH + '"'
	+ 'height="' + HEIGHT + '"'
	+ 'style="background-color:transparent;">'
	+ '<param name=movie value="' + URL + '">'
	+ '<param name="quality" value="high">'
	+ '<param name="SCALE" value="showall">'
	+ '<param name="wmode" value="transparent">'
	+ '<embed src="' + URL + '" quality="high"'
	+ 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash"'
	+ 'width="' + WIDTH +'"'
	+ 'height="' + HEIGHT + '"'
	+ 'wmode="transparent"'
	+ 'scale="showall" style="background-color:transparent;">'
	+ '</object>';
}

function CreateBookmarkLink(title,url){
	if (window.sidebar){
		window.sidebar.addPanel(title, url,"");
	}else if(window.external){
		window.external.AddFavorite(url, title);
	}else if(window.opera && window.print){
		return true;
	}
}



//NEW//

function $(id){
	return document.getElementById(id);
}
function addOnClick(){ 
	for(var i=1; i<=11; i++){
		if(document.getElementById('a'+i)){
			var lnk = document.getElementById('a'+i).href;
			//alert(document.getElementById('a'+i).href);
			$('nav'+i).onclick = Function('link("'+lnk+'")'); 
			$('nav'+i).onmouseover = Function('chg("nav'+i+'","on")');
			$('nav'+i).onmouseout = Function('chg("nav'+i+'","off")');
		}
	}
}

function addClickServiceHome(){
	$('serviceLink').onclick = Function('togSerParts("1")');
	$('partsLink').onclick = Function('togSerParts("2")'); 
}
function togSerParts(val){
	if(val == 1){
		$('serviceLink').className='';
		$('partsLink').className='off';
		show('serviceForm');
		hide('partsForm');
	}else{
		$('serviceLink').className='off';
		$('partsLink').className='';
		hide('serviceForm');
		show('partsForm');
	}
}

function addOnClickCars(maxNum){
	for(var i=0; i<=maxNum; i++){
		if(document.getElementById('resa'+i)){
			var lnk = document.getElementById('resa'+i).href;
			//alert(document.getElementById('a'+i).href);
			$('res'+i).onclick = Function('link("'+lnk+'")'); 
			$('res'+i).onmouseover = Function('chg("res'+i+'","no")');
			$('res'+i).onmouseout = Function('chg("res'+i+'","'+$('res'+i).className+'")');
		}
	}
}

function addOnClickPage(page){
	var prev = page - 1;
	var next = page + 1;
	if(document.getElementById('pr')){
		$('pr').onclick = Function('updateDiv("page",'+prev+');document.pagination.submit()'); 
		$('pr').onmouseover = Function('chg("pr","o")');
		$('pr').onmouseout = Function('chg("pr","")');
		$('ppr').onclick = Function('updateDiv("page",'+prev+');document.pagination.submit()'); 
		$('ppr').onmouseover = Function('chg("ppr","o")');
		$('ppr').onmouseout = Function('chg("ppr","")');
	}
	if(document.getElementById('pn')){
		$('pn').onclick = Function('updateDiv("page",'+next+');document.pagination.submit()'); 
		$('pn').onmouseover = Function('chg("pn","o")');
		$('pn').onmouseout = Function('chg("pn","")');
		$('ppn').onclick = Function('updateDiv("page",'+next+');document.pagination.submit()'); 
		$('ppn').onmouseover = Function('chg("ppn","o")');
		$('ppn').onmouseout = Function('chg("ppn","")');
	}
	for(var i=1; i<=51; i++){
		if(document.getElementById('p'+i)){
			$('p'+i).onclick = Function('updateDiv("page",'+i+');document.pagination.submit()'); 
			$('p'+i).onmouseover = Function('chg("p'+i+'","o")');
			$('p'+i).onmouseout = Function('chg("p'+i+'","")');
			$('pp'+i).onclick = Function('updateDiv("page",'+i+');document.pagination.submit()'); 
			$('pp'+i).onmouseover = Function('chg("pp'+i+'","o")');
			$('pp'+i).onmouseout = Function('chg("pp'+i+'","")');
		}
	}
	var salink = document.getElementById('saa').href;
	$('sa').onclick = Function('link("'+salink+'")'); 
	$('sa').onmouseover = Function('chg("sa","searchAgaino")');
	$('sa').onmouseout = Function('chg("sa","searchAgain")');
	$('sa1').onclick = Function('link("'+salink+'")'); 
	$('sa1').onmouseover = Function('chg("sa1","searchAgaino")');
	$('sa1').onmouseout = Function('chg("sa1","searchAgain")');
}
