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 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 changeSearch(){
	if(document.getElementById("header_search_advanced").style.display=="none"){
		$("header_search_advanced").slideDown({ duration: 1 });
		document.getElementById("header_search_type").innerHTML="Simple Search";
		document.forms.searchForm.search.value=1;
	}else{
    	$("header_search_advanced").slideUp({ duration: 1 });
		document.getElementById("header_search_type").innerHTML="Advanced Search";
		document.forms.searchForm.search.value=0;
		document.forms.searchForm.mileage.selectedIndex=0;
		get_makes("any");
		get_range(models[document.forms.searchForm.make.selectedIndex]);
	}
}

function changeThumbSet(){
	var lastclicked = document.getElementById("lastclicked").value;
    var currentTime = new Date();
	var secsval = currentTime.getTime();
	var secsdif = secsval - lastclicked;
	if(secsdif > 1100){
		var nextset = document.getElementById("nextset").value;
		var nsets = document.getElementById("nsets").value;
	    var nextlevel = document.getElementById("nextlevel").value;
		var newnextlevel = parseFloat(nextlevel)+1;
		document.getElementById("thumbset"+nextset).style.zIndex = newnextlevel;
		$("thumbset"+nextset).slideDown({ duration: 1 });
		var newnextset = parseFloat(nextset)+1;
		if(newnextset > nsets){
			newnextset = 1;
		}
	    for(var i=1;i<=nsets;i++){
			if(i != nextset){
				$("thumbset"+i).slideUp({ duration: 1 });
			}
		}
		document.getElementById("nextlevel").value = newnextlevel;
		document.getElementById("nextset").value = newnextset;
		document.getElementById("lastclicked").value = secsval;
	}
}

function printScreen(reg){
	window.open("/used_vehicles/print-details.php?reg="+reg);
}

function printNewScreen(id){
	window.open("/new_vehicles/print-details.php?id="+id);
}

function getDirections(){
	if(document.getElementById("yourpostcode").value==""){
		window.alert("Please enter your postcode!");
		document.getElementById("yourpostcode").focus();
	}else{
		window.open("http://maps.google.co.uk/maps?f=d&amp;hl=en&amp;geocode=&amp;time=&amp;date=&amp;ttype=&amp;daddr="+document.getElementById("destpostcode").value+"&amp;sll=50.973965,0.25849&amp;sspn=0.019402,0.057077&amp;ie=UTF8&amp;z=12&amp;om=1&amp;saddr="+document.getElementById("yourpostcode").value,"openDirWin","width="+screen.width+",height="+screen.height+",menubar=1,resizable=1,location=1,status=1,scrollbars=1,toolbar=1");
	}
}

function sendContact(contact){
	var w = 520;
	var h = 410;
    var l=(screen.width-w)/2;
	var t=(screen.height-h)/2;

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