//

// CUV Locator Data

//


var availableProvinces = null;			// Array of string

var availableDealers = null;			// Array of string




function ArrayAppend(_Object)

{

	this[this.NElements++] = _Object;

}



function ArrayMap(_Key, _Object)

{

	this[_Key] = _Object;

}



function ArrayFind(_Object)

{



	for (var i = 0; i < this.NElements; i++) {

		if (this[i] == _Object) {

			return	i;

		}

	}

	return	-1;

}



function ArrayRemove(index)

{

	for (var i = index; i < (this.NElements - 1); i++) {

		this[i] = this[i + 1];

	}

	

	this[--this.NElements] = null;

}


function ArrayFindProvince(_Object)

{



	for (var i = 0; i < this.NElements; i++) {

		if (this[i].ProvinceCode == _Object) {

			return	i;

		}

	}

	return	-1;

}



function ArrayCreateProvince()

{

	this.NElements = 0;

	this[0] = 0;



	this.Append = ArrayAppend;

	this.Remove = ArrayRemove;

	this.Map = ArrayMap;

	this.Find = ArrayFindProvince;

}


function ArrayCreateDealer()

{

	this.NElements = 0;

	this[0] = 0;



	this.Append = ArrayAppend;

	this.Remove = ArrayRemove;

	this.Map = ArrayMap;

	this.Find = ArrayFind;

}



function ArrayCreateCity()

{

	this.NElements = 0;

	this[0] = 0;



	this.Append = ArrayAppend;

	this.Remove = ArrayRemove;

	this.Map = ArrayMap;

	this.Find = ArrayFind;

}



function Province(

  _ProvinceCode,

  _ProvinceNameEN,

  _ProvinceNameFR,

  _Dealers,
  
  _Cities)

{

	this.ProvinceCode = _ProvinceCode;

	this.ProvinceNameEN = _ProvinceNameEN;

	this.ProvinceNameFR = _ProvinceNameFR;

	this.Dealers = _Dealers;
	
	this.Cities = _Cities;

} 



function Dealer(

  _DealerCode,

  _DealerNameEN,

  _DealerNameFR)

{

	this.DealerCode = _DealerCode;

	this.DealerNameEN = _DealerNameEN;

	this.DealerNameFR = _DealerNameFR;

} 

function City(

  _City,

  _CityEN,

  _CityFR)

{

	this.City = _City;

	this.CityEN = _CityEN;

	this.CityFR = _CityFR;

} 



var theform;

function setDealerPopup() {

	theform = document.submitData;



	var theDealers;

	var theDealer;

	var idx;

	var theProvince;

	var provinceValue;



	if (theform.provincePop.selectedIndex > 0) {

		provinceValue = theform.provincePop.options[theform.provincePop.selectedIndex].value;

	

		idx = availableProvinces.Find(provinceValue);



		theProvince = availableProvinces[idx];

		theDealers = theProvince.Dealers;



//		theform.dealerPop.selectedIndex = 0;

//		if (isFrench) {

//			theform.dealerPop.options[0] = new Option("Tous les concessionnaires", "");

//		} else {

//			theform.dealerPop.options[0] = new Option("All Dealers", "");

//		}



//		alert(theform.dealerPop.options.NElements + "" + theform.dealerPop.options.length);

		theform.dealerPop.options.NElements = theDealers.NElements + 1;

		theform.dealerPop.options.length = theDealers.NElements + 1;



		for (var i=0; i < theDealers.NElements; i++) {

			theDealer = theDealers[i];

			theform.dealerPop.options[i+1] = new Option(theDealer.DealerNameEN, theDealer.DealerCode);

		}

//		alert(theform.dealerPop.options.NElements + "" + theform.dealerPop.options.length);



	} else {

		theform.dealerPop.options.NElements = 1;

		theform.dealerPop.options.length = 1;

//		theform.dealerPop.options[0] = new Option("                       ", "");

	}

}



function setProvincePopup() {

	theform = document.submitData;



	var theProvince;

	

	theform.provincePop.options.NElements = availableProvinces.NElements + 1;

	for (var i=0; i < availableProvinces.NElements; i++) {

		theProvince = availableProvinces[i];

		theform.provincePop.options[i+1]= new Option(theProvince.ProvinceNameEN, theProvince.ProvinceCode);

	}

	
	if (theform.dealerPop)
		theform.dealerPop.options.NElements = 1;
	

	if (theform.cityPop)
		theform.cityPop.options.NElements = 1;
	
}


function setCityPopup() {

	theform = document.submitData;



	var theCities;

	var theCity;

	var idx;

	var theProvince;

	var provinceValue;



	if (theform.provincePop.selectedIndex > 0) {

		provinceValue = theform.provincePop.options[theform.provincePop.selectedIndex].value;

	

		idx = availableProvinces.Find(provinceValue);



		theProvince = availableProvinces[idx];

		theCities = theProvince.Cities;



		theform.cityPop.options.NElements = theCities.NElements + 1;

		theform.cityPop.options.length = theCities.NElements + 1;



		for (var i=0; i < theCities.NElements; i++) {

			theCity = theCities[i];

			theform.cityPop.options[i+1] = new Option(theCity.CityEN, theCity.City);

		}

//		alert(theform.cityPop.options.NElements + "" + theform.cityPop.options.length);



	} else {

		theform.cityPop.options.NElements = 1;

		theform.cityPop.options.length = 1;

//		theform.cityPop.options[0] = new Option("                       ", "");

	}

}




function checkVehicles(theGroup) {

	theform = document.submitData;

	if (theGroup == "allvehicles") {

		theform.cbTercel.checked = theform.allvehicles.checked;

		theform.cbEchoSedan.checked = theform.allvehicles.checked;

		theform.cbEchoHatchback.checked = theform.allvehicles.checked;

		theform.cbYarisHatchback.checked = theform.allvehicles.checked;
		
		theform.cbYarisSedan.checked = theform.allvehicles.checked;

		theform.cbCorolla.checked = theform.allvehicles.checked;

		theform.cbMatrix.checked = theform.allvehicles.checked;

		theform.cbCamrySedan.checked = theform.allvehicles.checked;

		theform.cbPrius.checked = theform.allvehicles.checked;

		theform.cbVenza.checked = theform.allvehicles.checked;

		theform.cbCressida.checked = theform.allvehicles.checked;

		theform.cbAvalon.checked = theform.allvehicles.checked;

		theform.cbPaseo.checked = theform.allvehicles.checked;

		theform.cbCamrySolara.checked = theform.allvehicles.checked;

		theform.cbMR2.checked = theform.allvehicles.checked;

		theform.cbCelica.checked = theform.allvehicles.checked;

		theform.cbSupra.checked = theform.allvehicles.checked;

		theform.cbPrevia.checked = theform.allvehicles.checked;

		theform.cbSienna.checked = theform.allvehicles.checked;

		theform.cbRAV4.checked = theform.allvehicles.checked;

		theform.cbHighlander.checked = theform.allvehicles.checked;

		theform.cb4Runner.checked = theform.allvehicles.checked;

		theform.cbSequoia.checked = theform.allvehicles.checked;

		theform.cbCruiser.checked = theform.allvehicles.checked;

		theform.cbLandcruiser.checked = theform.allvehicles.checked;

		theform.cbTacoma.checked = theform.allvehicles.checked;

		theform.cbTundra.checked = theform.allvehicles.checked;

		theform.cbT100.checked = theform.allvehicles.checked;

		theform.cbHPrius.checked = theform.allvehicles.checked;

		theform.cbHCamry.checked = theform.allvehicles.checked;

		theform.cbHHighlander.checked = theform.allvehicles.checked;
		
		theform.allsubcompacts.checked = theform.allvehicles.checked;
		
		theform.allcompacts.checked = theform.allvehicles.checked;
		
		theform.allmidsize.checked = theform.allvehicles.checked;
		
		theform.allfullsize.checked = theform.allvehicles.checked;
		
		theform.allsports.checked = theform.allvehicles.checked;
		
		theform.allvans.checked = theform.allvehicles.checked;
		
		theform.allsuvs.checked = theform.allvehicles.checked;
		
		theform.allpickups.checked = theform.allvehicles.checked;
		
		theform.allhybrids.checked = theform.allvehicles.checked;
		

	}


	if (theGroup == "allsubcompacts") {

		theform.cbTercel.checked = theform.allsubcompacts.checked;

		theform.cbEchoSedan.checked = theform.allsubcompacts.checked;

		theform.cbEchoHatchback.checked = theform.allsubcompacts.checked;

		theform.cbYarisHatchback.checked = theform.allsubcompacts.checked;
		
		theform.cbYarisSedan.checked = theform.allsubcompacts.checked;

	}



	if (theGroup == "allcompacts") {

		theform.cbCorolla.checked = theform.allcompacts.checked;

		theform.cbMatrix.checked = theform.allcompacts.checked;

	}



	if (theGroup == "allmidsize") {

		theform.cbCamrySedan.checked = theform.allmidsize.checked;

		theform.cbVenza.checked = theform.allmidsize.checked;
		theform.cbPrius.checked = theform.allmidsize.checked;

	}



	if (theGroup == "allfullsize") {

		theform.cbCressida.checked = theform.allfullsize.checked;

		theform.cbAvalon.checked = theform.allfullsize.checked;

	}



	if (theGroup == "allsports") {

		theform.cbPaseo.checked = theform.allsports.checked;

		theform.cbCamrySolara.checked = theform.allsports.checked;

		theform.cbMR2.checked = theform.allsports.checked;

		theform.cbCelica.checked = theform.allsports.checked;

		theform.cbSupra.checked = theform.allsports.checked;

	}



	if (theGroup == "allvans") {

		theform.cbPrevia.checked = theform.allvans.checked;

		theform.cbSienna.checked = theform.allvans.checked;

	}



	if (theGroup == "allsuvs") {

		theform.cbRAV4.checked = theform.allsuvs.checked;

		theform.cbHighlander.checked = theform.allsuvs.checked;

		theform.cb4Runner.checked = theform.allsuvs.checked;

		theform.cbSequoia.checked = theform.allsuvs.checked;

		theform.cbCruiser.checked = theform.allsuvs.checked;

		theform.cbLandcruiser.checked = theform.allsuvs.checked;

	}



	if (theGroup == "allpickups") {

		theform.cbTacoma.checked = theform.allpickups.checked;

		theform.cbTundra.checked = theform.allpickups.checked;

		theform.cbT100.checked = theform.allpickups.checked;

	}


	if (theGroup == "allhybrids") {

		theform.cbHPrius.checked = theform.allhybrids.checked;

		theform.cbHCamry.checked = theform.allhybrids.checked;

		theform.cbHHighlander.checked = theform.allhybrids.checked;

	}


}




























































