//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 ow(theURL,winName,features){
	window.open(theURL,winName,features);
}
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;
}

function resetBadge() {
	document.getElementById('badge').value = '';
}

//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('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 getLoadSm(thePic){
	if(document.theCarMed.src != thePic){
		document.theCarMed.src=thePic;
	}
}

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($('a'+i)){
			var lnk = $('a'+i).href;
			//alert(document.getElementById('a'+i).href);
			$('nav'+i).onclick = Function('link("'+lnk+'")'); 
			if(i==8){
				$('nav'+i).onmouseover = Function('chg("nav'+i+'","on end")');
				$('nav'+i).onmouseout = Function('chg("nav'+i+'","off end")');
			}else{
				$('nav'+i).onmouseover = Function('chg("nav'+i+'","on")');
				$('nav'+i).onmouseout = Function('chg("nav'+i+'","off")');
			}
		}
	}
}

function addPagination(){ 
	for(var i=1; i<=11; i++){
		if($('p'+i)){
			//alert(document.getElementById('a'+i).href);
			//$('nav'+i).onclick = Function('link("'+lnk+'")'); 
			$('p'+i).onmouseover = Function('chg("p'+i+'","o")');
			$('p'+i).onmouseout = Function('chg("p'+i+'","")');
		}
		if($('pp'+i)){
			$('pp'+i).onmouseover = Function('chg("pp'+i+'","o")');
			$('pp'+i).onmouseout = Function('chg("pp'+i+'","")');
		}
	}
	if($('pr')){
		$('pr').onmouseover = Function('chg("pr","o")');
		$('ppr').onmouseover = Function('chg("ppr","o")');
		$('pr').onmouseout = Function('chg("pr","")');
		$('ppr').onmouseout = Function('chg("ppr","")');
	}
	if($('pn')){
		$('pn').onmouseover = Function('chg("pn","o")');
		$('ppn').onmouseover = Function('chg("ppn","o")');
		$('pn').onmouseout = Function('chg("pn","")');
		$('ppn').onmouseout = Function('chg("ppn","")');
	}
}


function showRhsForm(theDiv){

	if(document.getElementById(theDiv).style.display=='none'){
		new Effect.SlideDown(theDiv);
	}else{
		new Effect.SlideUp(theDiv);
	}
	if(theDiv != 'vehFin' && document.getElementById('vehFin').style.display!='none'){
		new Effect.SlideUp('vehFin');
	}
	if(theDiv != 'vehEnq' && document.getElementById('vehEnq').style.display!='none'){
		new Effect.SlideUp('vehEnq');
	}
	if(theDiv != 'vehCal' && document.getElementById('vehCal').style.display!='none'){
		new Effect.SlideUp('vehCal');
	}
	if(theDiv != 'vehFriend' && document.getElementById('vehFriend').style.display!='none'){
		new Effect.SlideUp('vehFriend');
	}
	
	return false;
}

function getDriveAway(){
	ow('drive-away.php','driveAway','width=300,height=145,scrolling=no')
}
