function MM_openBrWindow(theURL,winName,features) { file://v2.0
  window.open(theURL,winName,features);
}

function writelogo(){document.write('<img src="images/mini-logo.jpg" alt="Mini Logo" id="logo" />')}
function writefuelinfo(){document.write('Further information on official Fuel consumption and on the specific emission of CO2 for new passenger car models is available from www.vcacarfueldata.org.uk')}

/* handles the 3 thumbnails etc etc */
function showHide(targetName) {
	if (typeof document.body.style.maxHeight != "undefined") {
	  // IE 7, mozilla, safari, opera 9
	  hideall();
	} else {
	  // IE6, older browsers
	  document.getElementById('thumb1').style.visibility = 'hidden';
	  document.getElementById('thumb2').style.visibility = 'hidden'; 
	  document.getElementById('thumb3').style.visibility = 'hidden'; 	  
	}

	document.getElementById(targetName).style.visibility = 'visible';
}

function hideall()
{
	document.getElementById('thumb1').style.visibility = 'hidden';
	document.getElementById('thumb1').style.height = 0;
	document.getElementById('thumb2').style.visibility = 'hidden';
	document.getElementById('thumb2').style.height = 0;
	document.getElementById('thumb3').style.visibility = 'hidden';
	document.getElementById('thumb3').style.height = 0;	
}

/* handles hw search */
function dosearch(howmany){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	/* check for special or used page listings - set thestring as a default blank */
	var thestring =""
	
	try {
		if (document.forms.thesearch.used.value) {
			var thestring = "&used="+document.forms.thesearch.used.value
		}
	} catch (err) {}
	
	try {
		if (document.forms.thesearch.special.value) {
			var thestring = "&special="+document.forms.thesearch.special.value
		}
	} catch (err) {}
	
	try {
		if (document.forms.thesearch.the_dealername.value) {
			var thestring = "&the_dealername="+document.forms.thesearch.the_dealername.value
		}
	} catch (err) {}	
	
	var thecolours = ""
	
	/* build a string of colour selections */
	for (i=0; i<document.forms.thesearch.chosencolours.length; i++){
	if (document.forms.thesearch.chosencolours[i].checked==true)
		var thecolours = thecolours+document.forms.thesearch.chosencolours[i].value+",";
	}
	
	// does the search nhave colours? if so append to thestring
	if (thecolours.length) {
		var thestring = thestring+"&colours="+thecolours
	}
	
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReq.open("GET","dosearch.html?page="+document.forms.thesearch.type.value
					   +"&type="+document.forms.thesearch.type.value
					   +"&reg_date="+document.forms.thesearch.reg_date.value
					   +"&max_price="+document.forms.thesearch.max_price.value
					   +"&min_price="+document.forms.thesearch.min_price.value
					   +"&transmission="+document.forms.thesearch.transmission.value
					   +"&fuel="+document.forms.thesearch.fuel.value
					   +"&max_miles="+document.forms.thesearch.max_miles.value
					   +"&avail_status="+document.forms.thesearch.avail_status.value
					   +"&rows="+howmany
					   +thestring
					   +thetime
					   ,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("carlists");
		res.innerHTML = liveSearchReq.responseText;
	}
	resetshowsperpagenosearch();
}

function compare(id){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReq.open("GET","compared.html?id="+id+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("compared");
		var  res2 = document.getElementById("comparedlist");
		res.innerHTML = '';
		res2.innerHTML = liveSearchReq.responseText;
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","compare_list.html"+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var res = document.getElementById("comparelist");
		res.innerHTML = liveSearchReq.responseText;
	}
}

function refreshcomparison(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","compare_bottomrule.html"+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("carlists");
		res.innerHTML = liveSearchReq.responseText;
	}
}

function clearcomparisonlist(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReq.open("GET","compared.html?clear=clear"+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("comparelist");
		res.innerHTML = '';
	}
	refreshcomparison();
}

function removefromlist(id){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReq.open("GET","compare_list.html?REMOVE="+id+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("comparelist");
		res.innerHTML = liveSearchReq.responseText;
	}
	refreshcomparison();
	
	try {
		if (document.getElementById("comparedlist")) {
			var  res = document.getElementById("comparedlist");
			res.innerHTML = ''
		}
	} catch (err) {}
}

function changesort(){
	if (window.XMLHttpRequest) {
		liveSearchReqcounter = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReqcounter = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReqcounter.open("GET","resetsort.html?sort="+document.forms.sortby.sortbyint.value+thetime,false);
	liveSearchReqcounter.send(null);
	dosearch(1);
}


function resetshowsperpage(recordcount){
	if (window.XMLHttpRequest) {
		liveSearchReqcounter = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReqcounter = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	try {
		if (document.forms.repage.toshow) {
			var  showthis = document.forms.repage.toshow.value
		} else {
			var  showthis = '10'
		}
	} catch (err) {}
	
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReqcounter.open("GET","resetshowsperpage.html?shows="+showthis
					   +"&records="+recordcount
					   +thetime
					   ,false);
	liveSearchReqcounter.send(null);
	/*
	if (liveSearchReqcounter.readyState == 4) {
		var  resultbox = document.getElementById("pageslist");
		resultbox.innerHTML = liveSearchReqcounter.responseText;
	}
	*/
	dosearch(1);
}


function resetshowsperpagenosearch(){
	if (window.XMLHttpRequest) {
		liveSearchReqcounter = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReqcounter = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	try {
		if (document.forms.repage.toshow) {
			var  showthis = document.forms.repage.toshow.value
		} else {
			var  showthis = '10'
		}
	} catch (err) {}	
	
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReqcounter.open("GET","resetshowsperpage.html?shows="+showthis
					   +"&records="+document.forms.sortby.recordcount.value
					   +thetime
					   ,false);
	liveSearchReqcounter.send(null);

	if (liveSearchReqcounter.readyState == 4) {
		var  resultbox = document.getElementById("pageslist");
		resultbox.innerHTML = liveSearchReqcounter.responseText;
	}
}


/* WTF?? 2 divs at once - then be able to go back to search results without losing them */
function dotheimpossible(carreg,approved){
	if (window.XMLHttpRequest) {
		liveSearchReqcounter = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReqcounter = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReqcounter.open("GET","view_bottomrule.html?the_carreg="+carreg+thetime,false);
	liveSearchReqcounter.send(null);

	if (liveSearchReqcounter.readyState == 4) {
		var  resultbox = document.getElementById("carlists");
		resultbox.innerHTML = liveSearchReqcounter.responseText;
	}
	
	/* offers panel */
	if (window.XMLHttpRequest) {
		liveSearchReqoffers = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReqoffers = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReqoffers.open("GET","3_offers.cfm?page=view&getinfo.approved="+approved+thetime,false);
	liveSearchReqoffers.send(null);

	if (liveSearchReqoffers.readyState == 4) {
		var  resultbox = document.getElementById("topoffers");
		resultbox.innerHTML = liveSearchReqoffers.responseText;
	}
	
}


function resetall(){
	var  resultbox = document.getElementById("topoffers");
	resultbox.innerHTML = '';
	dosearch(1);
}


function updateprefs() {
	if (window.XMLHttpRequest) {
		liveSearchReqcounter = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReqcounter = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReqcounter.open("GET","store_colprefs.html?colby="+document.forms.colprefs.colby.value+"&orderby="+document.forms.colprefs.orderby.value+"&theid="+document.forms.colprefs.theid.value+thetime,false);
	liveSearchReqcounter.send(null);
	
	if (liveSearchReqcounter.readyState == 4) {
		document.forms.colprefs.submit();
	}
}

function gotodealership() {
		document.location.href='http://www.coopermini.co.uk/dealerships.html';
}