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 addInterest(type,id,details){
	if(document.getElementById("addbutval_"+type+"_"+id).value == 0){
		var amount = document.getElementById("nintdisp").innerHTML;
		document.getElementById("nintdisp").innerHTML = parseFloat(amount)+1;
		document.getElementById("addbutval_"+type+"_"+id).value = 1;
		if(details == 1){
			document.getElementById("addbut_"+type+"_"+id).className = "dt_interest_button_added";
			document.getElementById("addbut_"+type+"_"+id).onclick = openInterestFromAdded;
		}else{
			document.getElementById("intbutton").style.display = "";
			document.getElementById("addbut_"+type+"_"+id).src = "http://www.kent-vauxhall.co.uk/images/but-res-addedlist.gif";
			document.getElementById("addbut_"+type+"_"+id).className = "";
		}
		frames["interestlistframe"].location.href = "/interest_add.php?type="+type+"&id="+id;
	}
}

function printScreenUsed(id){
	openWin("/used-vehicles/details.php?id="+id+"&print=yes",100,100,'yes');
}

function printScreenNew(id){
	openWin("/new-vehicles/details.php?id="+id+"&print=yes",100,100,'yes');
}

function emailtoafriend(id){
	openWin("/emailtoafriend.php?id="+id,425,270,'yes');
}

function openInterestFromAdded(){
   openWin('/interest_view.php',820,560,1);
}

function removeInterest(type,id){
	temp = window.confirm("Are you sure you want to remove this vehicle from your Interest List?");
	if (temp == true){
		document.getElementById("introw_"+type+"_"+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 = "/interest_add.php?type="+type+"&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 = "/interest_add.php?clear=1";
	}
}

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