/* for backward compatibility / facelift */
function setPositions() {
	var footer = getLayer("bo-footer");
	if(footer) {footer.style.display = "block";}
}
/* some common helper functions */
function getLayer(strID)
{
	if( document.all && !window.opera )
		return document.all[ strID ];
	else
		return document.getElementById( strID );
}


/* set events, w3c-compatible and ie */
function addEvent(obj, eventType, func, useCaption)
{
	if (!obj || !eventType || !func) {
		return false;
	} else if (obj.addEventListener) {
		obj.addEventListener(eventType, func, useCaption);
		return true;
	} else if (obj.attachEvent) {
	var retVal = obj.attachEvent("on"+eventType, func);
		return retVal;
	} else {
		return false;
	}
}


/* special handling for ie 6, to place the bottom of the window */
if(document.all && !window.opera) {
	try {
		if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE")>0) {		
			var str = navigator.appVersion;
			var ind = parseInt(str.indexOf("MSIE"))+5;
			var ver = parseInt(str.substring(ind, ind+1));
			if (ver<7) {
				addEvent(window, "load", initFooterIE);
			}
		}
	} catch(e) {}
}


function initFooterIE() {
	window.onscroll = positionFooter;
	window.onresize = positionFooter;
	positionFooter();
}


function positionFooter() {
	try {
		var toolbarHeight = getLayer("cms_position") && getLayer("CFCToolBarDiv") ? getLayer("CFCToolBarDiv").offsetHeight : 0;
		var topValue = document.documentElement.clientHeight + document.documentElement.scrollTop - getLayer("bo-footer").offsetHeight - toolbarHeight;
		getLayer("bo-footer").style.position = "absolute";
		getLayer("bo-footer").style.display = "block";		
		// special value for t9091 in ie6 and only on author-instance
		if( getLayer("bo-footer").parentNode==getLayer("ms-website") && document.body.getAttribute('instance')=='Author' ) {
			topValue -= 44;
		}				
		getLayer("bo-footer").style.top = (topValue);
	} catch(e) {}
}

function toggleDivShow(featureID) {
	if(document.getElementById && document.getElementById(featureID)){
		var domEl = document.getElementById(featureID);
		if (domEl.className == "hideMe") {
			domEl.className = "showMe";
			document.getElementById(featureID + 'Title').className = "titleMinus";
		}else{
			domEl.className = "hideMe";
			document.getElementById(featureID + 'Title').className = "titlePlus";
		}
	}
	return false;
}

function toggleDivShow2(featureID) {
	if(document.getElementById && document.getElementById(featureID)){
		var domEl = document.getElementById(featureID);
		if (domEl.className == "hideMe") {
			domEl.className = "showMe";
			document.getElementById(featureID + 'Title').className = "titleMinus2";
		}else{
			domEl.className = "hideMe";
			document.getElementById(featureID + 'Title').className = "titlePlus2";
		}
	}
	return false;
}

function setDivShow() {
	for(i=1;i<13;i++){
		if(document.getElementById && document.getElementById('cBlock' + i)){
			document.getElementById('cBlock' + i).className = "hideMe";
			document.getElementById('cBlock' + i + 'Title').className = "titlePlus";
		}
	}
}

function setDivShow2() {
	for(i=2;i<13;i++){
		if(document.getElementById && document.getElementById('cBlock' + i)){
			document.getElementById('cBlock' + i).className = "hideMe";
			document.getElementById('cBlock' + i + 'Title').className = "titlePlus2";
		}
	}
}

function setDivShow3() {
	for(i=1;i<10;i++){
		if(document.getElementById && document.getElementById('cBlock' + i)){
			document.getElementById('cBlock' + i).className = "hideMe";
			document.getElementById('cBlock' + i + 'Title').className = "titlePlus";
		}
	}
}

function setDivShow4() {
	for(i=1;i<6;i++){
		if(document.getElementById && document.getElementById('cBlock' + i)){
			document.getElementById('cBlock' + i).className = "hideMe";
			document.getElementById('cBlock' + i + 'Title').className = "titlePlus2";
		}
	}
}

function getVehicleCount(){
	var theForm = document.vehicleSearchForm
	theQueryString = "model=" + theForm.model.value;
	theQueryString += "&fuel=" + theForm.fuel.value;
	theQueryString += "&transmission=" + theForm.transmission.value;
	theQueryString += "&minPrice=" + theForm.minPrice.value;
	theQueryString += "&maxPrice=" + theForm.maxPrice.value;
	theQueryString += "&age=" + theForm.age.value;
	theQueryString += "&mileage=" + theForm.mileage.value;
	theQueryString += "&style=" + theForm.style.value;
	theQueryString += "&dealer=" + theForm.dealer.value;
	var colours = "";
	if(theForm.colour){
	for (i=0; i<theForm.colour.length; i++){
		if (theForm.colour[i].checked == true){
			colours = colours + theForm.colour[i].value + ",";
		}
	}
	theQueryString += "&colour=" + colours;
	}
	
	$.ajax({
		type: "GET",
		url: "/used-car-search/returnVehicleCount2.asp",
		data: theQueryString,
		success: function(msg){
			$('#numberOfResults').text(msg);
		}
	});
}

function getVehicleCount2(){
	getVehicleCount();
}

