function changeModels(intSelectIndex,model)

{

    var varModelsArray = varModels[intSelectIndex];

    var intModelCount  = varModelsArray.length;



	document.carsearch.model.length = intModelCount;



    for (i=1; i<intModelCount; i++)

	{

		document.carsearch.model[i] = new Option(varModelsArray[i]);

	}



	if(model>0)

	{

		document.carsearch.model.options[model].selected = true;

	}

}

function changeModelsUpload(intSelectIndex,imageno,model)
{


    var varModelsArray = varModels[intSelectIndex];
    var intModelCount  = varModelsArray.length;

	var testdocsearch = "document.carsearch.model_"+imageno+".length";
	var testdocsearchother = "document.carsearch.model_"+imageno;

	
	//testdocsearch = intModelCount;
	eval( "document.carsearch.model_" + imageno + ".length= intModelCount;" )

    for (i=1; i<intModelCount; i++)
	{
		//testdocsearchother[i] = new Option(varModelsArray[i]);
		eval( "document.carsearch.model_" + imageno + "[i]= new Option(varModelsArray[i]);" ) 
		
	}


	if(model>0)
	{
		testdocsearchother.options[model].selected = true;
		//eval( "document.carsearch.model_" + imageno + "[i]" ) = new Option(varModelsArray[i]);
	}
//alert(testdocsearchother);
}


function changeNewModels(intSelectIndex,model)

{

    var varModelsArray = varNewModels[intSelectIndex];

    var intModelCount  = varModelsArray.length;



	document.newcarsearch.model.length = intModelCount;



    for (i=1; i<intModelCount; i++)

	{

		document.newcarsearch.model[i] = new Option(varModelsArray[i]);

	}



	if(model>0)

	{

		document.newcarsearch.model.options[model].selected = true;

	}

}



function changeModels2(intSelectIndex2,model2)

{

    var varModelsArray = varModels2[intSelectIndex2];

    var intModelCount  = varModelsArray.length;



	document.carsearch2.model.length = intModelCount;



    for (i=1; i<intModelCount; i++)

	{

		document.carsearch2.model[i] = new Option(varModelsArray[i]);

	}



	if(model>0)

	{

		document.carsearch2.model.options[model].selected = true;

	}

}



function changeModelsNew(intSelectIndex,model)

{

    var varModelsArray = varModels[intSelectIndex];

    var intModelCount  = varModelsArray.length;



	document.carsearch_new.model.length = intModelCount;



    for (i=1; i<intModelCount; i++)

	{

		document.carsearch_new.model[i] = new Option(varModelsArray[i]);

	}



	if(model>0)

	{

		document.carsearch_new.model.options[model].selected = true;

	}

}



function sanityCheck(form)

{

	if(!document.getElementById) return;



	var manufacturer = document.carsearch.manufacturer.selectedIndex;

	var model = document.carsearch.model.selectedIndex;

	var minPrice = document.carsearch.minPrice.options[document.carsearch.minPrice.selectedIndex].text;

	var minPrice_index = document.carsearch.minPrice.selectedIndex;

	var maxPrice = document.carsearch.maxPrice.options[document.carsearch.maxPrice.selectedIndex].text;

	var maxPrice_index = document.carsearch.maxPrice.selectedIndex;



	minPrice=parseInt(minPrice);

	maxPrice=parseInt(maxPrice);



	if(manufacturer==0)

	{

		alert('Error : Please select a manufacturer');

		return false;

	}

	else if(model==0)

	{

		alert('Error : Please select a model');

		return false;

	}



	if((minPrice > maxPrice) && ((minPrice_index!=0) && (maxPrice_index!=0)))

	{

		alert('Error : Minimum price is greater than maximum price');

		return false;

	}



	googleSearchString();



	return true;

}



function sanityCheckNew(form)

{

	if(!document.getElementById) return;



	var manufacturer = document.carsearch.manufacturer.selectedIndex;

	var model = document.carsearch.model.selectedIndex;

	var minPrice = document.carsearch.minPrice.options[document.carsearch.minPrice.selectedIndex].text;

	var minPrice_index = document.carsearch.minPrice.selectedIndex;

	var maxPrice = document.carsearch.maxPrice.options[document.carsearch.maxPrice.selectedIndex].text;

	var maxPrice_index = document.carsearch.maxPrice.selectedIndex;



	minPrice=parseInt(minPrice);

	maxPrice=parseInt(maxPrice);



	if(manufacturer==0)

	{

		alert('Error : Please select a manufacturer');

		return false;

	}

	else if(model==0)

	{

		alert('Error : Please select a model');

		return false;

	}



	if((minPrice > maxPrice) && ((minPrice_index!=0) && (maxPrice_index!=0)))

	{

		alert('Error : Minimum price is greater than maximum price');

		return false;

	}



	googleSearchStringNew();



	return true;

}



function sanityCheckUsed(form)

{

	if(!document.getElementById) return;



	var manufacturer = document.carsearch.manufacturer.selectedIndex;

	var model = document.carsearch.model.selectedIndex;

	var minPrice = document.carsearch.minPrice.options[document.carsearch.minPrice.selectedIndex].text;

	var minPrice_index = document.carsearch.minPrice.selectedIndex;

	var maxPrice = document.carsearch.maxPrice.options[document.carsearch.maxPrice.selectedIndex].text;

	var maxPrice_index = document.carsearch.maxPrice.selectedIndex;



	minPrice=parseInt(minPrice);

	maxPrice=parseInt(maxPrice);



	if(manufacturer==0)

	{

		alert('Error : Please select a manufacturer');

		return false;

	}

	else if(model==0)

	{

		alert('Error : Please select a model');

		return false;

	}



	if((minPrice > maxPrice) && ((minPrice_index!=0) && (maxPrice_index!=0)))

	{

		alert('Error : Minimum price is greater than maximum price');

		return false;

	}



	googleSearchStringUsed();



	return true;

}



function googleSearchString()

{

	var manufacturer = document.UsedManForm.manufacturer.options[document.UsedManForm.manufacturer.selectedIndex].text;


	var googleString="Used "+manufacturer;



	document.UsedManForm.q.value=googleString;

document.forms['UsedManForm'].submit();

}

function googleSearchStringMOD()

{

	var manufacturer = document.carsearch.manufacturer.options[document.carsearch.manufacturer.selectedIndex].text;

	var model = document.carsearch.model.options[document.carsearch.model.selectedIndex].text;



	var googleString="new "+manufacturer;

	if(model)

	{

		googleString=googleString+"+"+model;

	}



	document.carsearch.q.value=googleString;

}




function googleSearchStringNew()

{

	var manufacturer = document.carsearch.manufacturer.options[document.carsearch.manufacturer.selectedIndex].text;

	var model = document.carsearch.model.options[document.carsearch.model.selectedIndex].text;



	var googleString="new "+manufacturer;

	if(model)

	{

		googleString=googleString+"+"+model;

	}



	document.carsearch.q.value=googleString;

}


function googleSearchStringUsedOnlyMan()
{

	var manufacturer = document.carsearch.manufacturer.options[document.carsearch.manufacturer.selectedIndex].text;

	var googleString="used "+manufacturer;

	document.carsearch.q.value=googleString;

}

function googleSearchStringNewOnlyMan()
{

	var manufacturer = document.newcarsearch.manufacturer.options[document.newcarsearch.manufacturer.selectedIndex].text;

	var googleString="new "+manufacturer;

	document.newcarsearch.q.value=googleString;

}


function googleSearchStringNewDealer()
{
	var manufacturer = document.newcarsearch.manufacturer.options[document.newcarsearch.manufacturer.selectedIndex].text;
	var model = document.newcarsearch.model.options[document.newcarsearch.model.selectedIndex].text;

	var googleString="new "+manufacturer;
	if(model)
	{
		googleString=googleString+"+"+model;
	}

	document.newcarsearch.q.value=googleString;

}


function googleSearchStringUsed()
{
	var manufacturer = document.carsearch.manufacturer.options[document.carsearch.manufacturer.selectedIndex].text;
	var model = document.carsearch.model.options[document.carsearch.model.selectedIndex].text;

	var googleString="used "+manufacturer;
	if(model)
	{
		googleString=googleString+"+"+model;
	}

	document.carsearch.q.value=googleString;

}

function googleSearchString_new(form_name,type)
{
	var manufacturer = document.forms[form_name].manufacturer.options[document.forms[form_name].manufacturer.selectedIndex].text;


	var googleString=type+" "+manufacturer;


	document.forms[form_name].q.value=googleString;
}


function googleSearchString_mod(form_name,type,manufact)
{
	var manufacturer = document.forms[form_name].model.options[document.forms[form_name].model.selectedIndex].text;


	var googleString=type+" "+manufact+" "+manufacturer;


	document.forms[form_name].q.value=googleString;
}

function googleSearchString_price(form_name,type,manufact)
{
	var manufacturer = document.forms[form_name].model.options[document.forms[form_name].model.selectedIndex].text;


	var googleString=type+" "+manufact;


	document.forms[form_name].q.value=googleString;
}

function googleSearchString_modUsedMid(form_name,type,manufact)
{
	var model = document.forms[form_name].model.options[document.forms[form_name].model.selectedIndex].text;
	var manufacturer = document.forms[form_name].manufacturer.options[document.forms[form_name].manufacturer.selectedIndex].text;

	var googleString=type+" "+manufacturer+" "+model;


	document.forms[form_name].q.value=googleString;
}


function googleSearchString_man(form_name,type,manufact)
{
	var manufacturer = document.forms[form_name].manufacturer.options[document.forms[form_name].manufacturer.selectedIndex].text;


	var googleString=type+" "+manufact+" "+manufacturer;


	document.forms[form_name].q.value=googleString;
}

function googleSearchString_manManIndex(UsedManIndexForm,type,manufact)
{
	var manufacturer = document.forms[UsedManIndexForm].manufacturer.options[document.forms[UsedManIndexForm].manufacturer.selectedIndex].text;


	var googleString=type+" "+manufact+" "+manufacturer;


	document.forms[UsedManIndexForm].q.value=googleString;
}


function googleSearchString_body(form_name,type,manufact)
{
	var cat = document.forms[form_name].cat.options[document.forms[form_name].cat.selectedIndex].text;


	var googleString=type+" "+manufact+" "+cat;


	document.forms[form_name].q.value=googleString;
}


function trackWeb(carID,userID) {

	var date = new Date();

	date.setTime(date.getTime()+(60*24*60*60*1000));

	document.cookie = "CAR_ID_HISTORY="+carID+"; expires="+date.toGMTString();

	

	document.getElementById("trackWebsite").src="http://www.motoring.co.uk/cgi-bin/trackwebsite.cgi?carID="+carID+"&userID="+userID;



	return true;

}


function trackWebUsed(carID,userID) {

	var date = new Date();

	date.setTime(date.getTime()+(60*24*60*60*1000));

	document.cookie = "CAR_ID_HISTORY="+carID+"; expires="+date.toGMTString();

	

	document.getElementById("trackWebsite").src="http://www.motoring.co.uk/cgi-bin/trackwebsite.cgi?src=used&carID="+carID+"&userID="+userID;



	return true;

}


function trackWebListers(carID,userID) {

	var date = new Date();

	date.setTime(date.getTime()+(60*24*60*60*1000));

	document.cookie = "CAR_ID_HISTORY="+carID+"; expires="+date.toGMTString();

	

	document.getElementById("trackWebsite").src="http://www.motoring.co.uk/cgi-bin/trackwebsite.cgi?src=used&carID="+carID+"&userID="+userID;



	return true;

}


function trackWebJardine(carID,userID) {

	var date = new Date();

	date.setTime(date.getTime()+(60*24*60*60*1000));

	document.cookie = "CAR_ID_HISTORY="+carID+"; expires="+date.toGMTString();

	

	document.getElementById("trackWebsite").src="http://www.motoring.co.uk/cgi-bin/trackwebsite.cgi?src=jardine&carID="+carID+"&userID="+userID;



	return true;

}



function trackWebLease(carID,userID) {

	var date = new Date();

	date.setTime(date.getTime()+(60*24*60*60*1000));

	document.cookie = "LEASE_ID_HISTORY="+carID+"; expires="+date.toGMTString();

	

	document.getElementById("trackWebsite").src="http://www.motoring.co.uk/cgi-bin/trackwebsite.cgi?carID="+carID+"&userID="+userID+"&src=leasing";

	return true;

}

function trackWebFinance(carID,userID) {

	var date = new Date();
	date.setTime(date.getTime()+(60*24*60*60*1000));
	document.cookie = "LEASE_ID_HISTORY="+carID+"; expires="+date.toGMTString();

	document.getElementById("trackWebsite").src="http://www.motoring.co.uk/cgi-bin/trackwebsite.cgi?carID="+carID+"&userID="+userID+"&src=finance";

	return true;

}



function clearHidden() {

	document.carsearch.keyword.value='Keyword Search';

	document.carsearch.bodystyle.value='';

	document.carsearch.fuel.value='';

	document.carsearch.transmission.value='';

	document.carsearch.doors.value='';

	document.carsearch.colour.value='';

}

function popupMerc()
{
	var url="/cgi-bin/approved-mercedes.cgi?action=video";
	var newwindow=window.open(url, "popup", "scrollbars=no,resizable=yes,width=960,height=500", 1);
	newwindow.focus();
	return;
}

