<!-- This was written to provide the global javascript file for selection -->
<!-- of make, model and trim in front end. -->

    var cboYear;
    var cboMake;
    var cboModel;
    var cboTrim;

    function FillYear(cboYear, cboMake, cboModel, cboTrim, sDefaultYear){

		var sDefaultYear, sDefault, sYear;
		var foundIndex = 0, flag = false;

		cboMake.options[0] = new Option("Select Make","Select Make");
		cboModel.options[0] = new Option("Select Model","Select Model");
		cboTrim.options[0] = new Option("Select Trim","Select Trim");

		for(i=0;i<yearArray.split("|").length;i++) {
			sYear = yearArray.split("|")[i];

			if (sDefaultYear == sYear) {
				sDefault=true;
				foundIndex = i;
				flag = true;
				if (navigator.appName=="Microsoft Internet Explorer"){
					//modified by chetan
					//cboModel.focus();
				}
			}
			else {sDefault=false;}

			if (sDefault)
			{
				cboYear.options[i] = new Option(sYear,sYear,sDefault,sDefault);
			}
			else
			{
				cboYear.options[i] = new Option(yearArray.split("|")[i]);
			}
		}
		if(flag)
		{
			cboYear.options[foundIndex].selected = true;
		}
	}

	function FillMake(cboYear, cboMake, cboModel, cboTrim, sDefaultMake){

		var sDefaultMake, sDefault, sMake;
		var foundIndex = 0, flag = false;

		cboMake.options.length=0;
		cboModel.options.length=0;
		cboTrim.options.length=0;

		cboMake.options[0] = new Option("Select Make","Select Make");
		cboModel.options[0] = new Option("Select Model","Select Model");
		cboTrim.options[0] = new Option("Select Trim","Select Trim");

		for(i=0; i < makeArray[cboYear.selectedIndex].split("|").length;i++) {

			sMake = makeArray[cboYear.selectedIndex].split("|")[i];

			if (sDefaultMake == sMake) {

				sDefault=true;
				foundIndex = i;
				flag = true;
				if (navigator.appName=="Microsoft Internet Explorer"){
					//modified by chetan
					//cboModel.focus();
				}
			}
			else {sDefault=false;}

			if (sDefault) {
				cboMake.options[i]=new Option(sMake,sMake,sDefault,sDefault);
			}
			else {
				//cosmo
				cboMake.options[i]=new Option(makeArray[cboYear.selectedIndex].split("|")[i]);
				//cboMake.options[i]= new Option(sMake, sMake);
			}
		}
		if(flag)
		{
			cboMake.options[foundIndex].selected = true;
		}
	}

	function FillModel(cboYear, cboMake, cboModel, cboTrim, sDefaultModel){

		var sDefaultModel, sModel, sDefault;
		var foundIndex = 0, flag = false;

		cboModel.options.length=0;
		cboTrim.options.length=0;

		cboTrim.options[0] = new Option("Select Trim","Select Trim");
		cboModel.options[0] = new Option("Select Model","Select Model");

		for(i=0;i<modelArray[cboYear.selectedIndex][cboMake.selectedIndex].split("|").length;i++)
		{
			sModel = modelArray[cboYear.selectedIndex][cboMake.selectedIndex].split("|")[i];

			if(sDefaultModel == sModel) {
				sDefault=true;
				foundIndex = i;
				flag = true;
				if (navigator.appName=="Microsoft Internet Explorer"){
					//modified by chetan
					//cboModel.focus();
				}
			}
			else
			{
				sDefault=false;
			}

			if(sDefault)
			{
				cboModel.options[i]=new Option(sModel,sModel,sDefault,sDefault);
			}
			else
			{
				//cosmo
				//cboModel.options[i]=new Option(modelArray[cboYear.selectedIndex][cboMake.selectedIndex].split("|")[i]);
				cboModel.options[i]=new Option(sModel,sModel);
			}
		}
		if(flag)
		{
			cboModel.options[foundIndex].selected = true;
		}
	}

	function FillModel(cboModel, cboTrim, sDefaultModel, make)
	{
		var sDefaultModel, sModel, sDefault;
		var foundIndex = 0, flag = false;
		var makeIndex = 0;

		cboModel.options.length=0;
		cboTrim.options.length=0;

		cboModel.options[0] = new Option("Select Model","Select Model");
		cboTrim.options[0] = new Option("Select Trim","Select Trim");

		for(i=0; i < makeArray.split("|").length; i++)
		{
		    if(make == makeArray.split("|")[i])
		    {
		        makeIndex = i;
		    }
		}

		for(i=0; i < modelArray[makeIndex].split("|").length; i++)
		{
			sModel = modelArray[makeIndex].split("|")[i];

			if(sDefaultModel == sModel) {
				sDefault=true;
				foundIndex = i;
				flag = true;
				if (navigator.appName=="Microsoft Internet Explorer"){
					//modified by chetan
					//cboModel.focus();
				}
			}
			else
			{
				sDefault=false;
			}

			if(sDefault)
			{
				cboModel.options[i]=new Option(sModel,sModel,sDefault,sDefault);
			}
			else
			{
				//cosmo
				//cboModel.options[i]=new Option(modelArray[cboYear.selectedIndex][cboMake.selectedIndex].split("|")[i]);
				cboModel.options[i]=new Option(sModel,sModel);
			}
		}
		if(flag)
		{
			cboModel.options[foundIndex].selected = true;
		}
	}

	function FillTrim(cboModel, cboTrim, sDefaultTrim, make){

		var sDefaultTrim, sTrim, sDefault;
		var foundIndex = 0, flag = false;
		var makeIndex = 0, modelIndex = 0, sModel;

		cboTrim.options.length=0;

		cboTrim.options[0] = new Option("Select Trim","Select Trim");

		for(i=0; i < makeArray.split("|").length; i++)
		{
		    if(make == makeArray.split("|")[i])
		    {
		        makeIndex = i;
		    }
		}

		for(i=0; i < makeArray.split("|").length; i++)
		{
		    if(make == makeArray.split("|")[i])
		    {
		        makeIndex = i;
		        for(j=0; j < modelArray[makeIndex].split("|").length; j++)
		        {
		            sModel = modelArray[makeIndex].split("|")[j];
		            if(sModel == cboModel.options[cboModel.selectedIndex].value)
		            {
		                modelIndex = j;
		            }
		        }
		    }
		}

		for(i=0;i<trimArray[makeIndex][modelIndex].split("|").length;i++)
		{
			sTrim = trimArray[makeIndex][modelIndex].split("|")[i];

			if(sDefaultTrim == sTrim) {
				sDefault=true;
				foundIndex = i;
				flag = true;

				if (navigator.appName=="Microsoft Internet Explorer"){
					//modified by chetan
					//cboTrim.focus();
				}
			}
			else
			{
				sDefault=false;
			}

			if(sDefault)
			{
				cboTrim.options[i]=new Option(sTrim,sTrim,sDefault,sDefault);
			}
			else
			{
				cboTrim.options[i]=new Option(sTrim,sTrim);
			}
		}
		if(flag)
		{
			cboTrim.options[foundIndex].selected = true;
		}
	}