function openWin(url,w,h,s){
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;

	if(window.thiswin != undefined){
		thiswin.close();
	}
	thiswin = window.open(url,"popupwin",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+s+',resizable=0,width='+w+',height='+h+',left='+l+',top='+t);
}

function enquireNow(id){
	var w=520;
	var h=510;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;

	if(window.thiswin != undefined){
		thiswin.close();
	}
	thiswin = window.open("/enquirenow.php?id="+id,"popupwin",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+w+',height='+h+',left='+l+',top='+t);
}

function homepopEnquireNow(id){
	var w=520;
	var h=510;
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;

	if(window.thiswin != undefined){
		thiswin.close();
	}
	thiswin = window.open("/homepop_enquirenow.php?id="+id,"popupwin",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+w+',height='+h+',left='+l+',top='+t);
}

function viewImg(url,w,h){
	var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;

	if(window.thiswin != undefined){
		thiswin.close();
	}
	thiswin = window.open(url,"imagewin",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h+',left='+l+',top='+t);
}

function checkDelete(url,desc) {
	temp = window.confirm("Are you sure you want to delete "+desc+"?");
	if (temp == true){
		window.location=url;
	}
}

function changeQS(tab){
	if(tab == 1){
		document.getElementById("car_quicksearch").style.display="none";
		document.getElementById("van_quicksearch").style.display="";
		document.getElementById("qs-tab-car").className="qs-tab-nonsel";
		document.getElementById("qs-tab-van").className="qs-tab-sel";
	}else{
        document.getElementById("car_quicksearch").style.display="";
		document.getElementById("van_quicksearch").style.display="none";
        document.getElementById("qs-tab-car").className="qs-tab-sel";
		document.getElementById("qs-tab-van").className="qs-tab-nonsel";
	}
}

function addInterest(id,details){
	document.getElementById("interest_list").style.display = "";
	if(document.getElementById("addbutval"+id).value == 0){
		var amount = document.getElementById("nintdisp").innerHTML;
		document.getElementById("nintdisp").innerHTML = parseFloat(amount)+1;
		document.getElementById("addbut"+id).src = "/images/used_addedtolist.gif";
		document.getElementById("addbutval"+id).value = 1;
		if(details == 1){
			document.getElementById("addbut"+id).className = "";
		}else{
			document.getElementById("addbut"+id).className = "used_results_row_addint";
		}
		frames["interestlistframe"].location.href = "/used_cars/interest_add.php?id="+id;
	}
}

function removeInterest(id){
	temp = window.confirm("Are you sure you want to remove this vehicle from your Interest List?");
	if (temp == true){
		document.getElementById("introw"+id).style.display = "none";
        var amount = document.getElementById("nintdisp").innerHTML;
		document.getElementById("nintdisp").innerHTML = parseFloat(amount)-1;
		if(document.getElementById("nintdisp").innerHTML == 0){
			document.getElementById("inticons").style.display = "none";
		}
		frames["interestlistframe"].location.href = "/used_cars/interest_add.php?id="+id+"&remove=1";
		window.opener.location.reload(true);
	}
}

function clearInterest(){
    temp = window.confirm("Are you sure you want to clear your whole Interest List?");
	if (temp == true){
		window.location = "/used_cars/interest_add.php?clear=1";
	}
}

function openInterest(url){
	window.opener.location.href=url;
	window.opener.focus();
}

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

function closePopWin(id){
	document.getElementById(id).style.display='none';
	if(document.getElementById('popwindowright').style.display=='none'){
		showSelectBoxes();
	}
}