function Car (model,variant,price,insurance,insurewithacts,lto,colors)

{

	this.model = model;

	this.variant = variant;

	this.price = price;

	this.insurance = insurance;

	this.insurewithacts = insurewithacts;

	this.lto = lto;

	this.colors = colors;

}



function CColor (model,color)

{

	this.model = model;

	this.color = color;

}



var cC = new Array();

var mC=0;



function addCommas(nStr)

{

	nStr += '';

	x = nStr.split('.');

	x1 = x[0];

	x2 = x.length > 1 ? '.' + x[1] : '';

	var rgx = /(\d+)(\d{3})/;

	while (rgx.test(x1)) {

		x1 = x1.replace(rgx, '$1' + ',' + '$2');

	}

	return x1 + x2;

}



function getPrice(unitId,modelId,priceId)

{

}



function getColor(field,colorId)

{

	var variant = field[field.selectedIndex].value;

	

	var colorField = document.getElementById(colorId);

	var customerModel = document.getElementById("customerModel");

	var customerModelText = customerModel[customerModel.selectedIndex].value;

	colorField.length = 1;

	

	var count = 1;

	for (var j=0; j < cA.length; j++)

	{

		//field

		if ((cA[j].variant == variant) && (customerModelText == cA[j].model))

		{

			var arr = cA[j].colors.split(",");

			

			for (var dn = 0; dn < arr.length;dn++)

			{

				colorField.options[count++] = new Option(arr[dn],arr[dn]); 

			}

		}

	}

}









function writeModel(model)

{

	if (model == undefined)

	{

		model = "";

	}

	

	

	var tempA = new Array();

	document.write ("<option value=''>Please Select One</option>");

	var buffer = "";

	var found = false;

	for (var j=0; j < cA.length; j++)

	{

		

		if (tempA[cA[j].model]==null)

		{

			buffer+= "<option value='" + cA[j].model + "'";

			if (model != "" && cA[j].model.toLowerCase().indexOf(model.toLowerCase())!=-1)

			{

				buffer += " selected='true' ";

			}

			buffer += ">" + cA[j].model + "</option>";

			document.write (buffer);

			buffer ="";

			

			tempA[cA[j].model] = cA[j].model;

		}

	}

	

}



function sortAlphabetically (a,b)

{

	if (a > b)

	{

		return 1;

	}

	else

	{

		return -1;

	}

}



function getVariant(field,variantId)

{

	var model = field[field.selectedIndex].value;

	

	var variantField = document.getElementById(variantId);

	variantField.length = 1;

	

	var count = 1;

	var tempArray = new Array();

	for (var j=0; j < cA.length; j++)

	{

		//field

		if (cA[j].model == model)

		{

			tempArray[tempArray.length] = cA[j].variant;

		}

	}

	

	if ((tempArray.length > 1))

	{

		variantField.options[0] = new Option("Please Select One","");

		for (var h=0; h < tempArray.length; h++)

		{

			variantField.options[variantField.length] = new Option(tempArray[h],tempArray[h]);

		}

	}

	else

	{

		variantField.options[0] = new Option(tempArray[0],tempArray[0]);

	}

	

	

	

}



var cA = new Array();

var c=0;

function writeInfo (model,variant)

{

 

	for (var j=0; j < cA.length; j++)

	{

		//field

		if ((cA[j].model == model) && (cA[j].variant == variant)) 

		{

			//document.write ('<tr>');

			//document.write ('<td>Unit Price:</td>');

			//document.write ('<td align="right">P '+ addCommas(cA[j].price)+'</td>');

			//document.write ('</tr>');

			

			//document.write ('<tr>');

			//document.write ('<td>LTO:</td>');

			//document.write ('<td align="right">P '+ addCommas(cA[j].lto)+'</td>');

			//document.write ('<td align="right">P '+ addCommas(cA[j].lto)+'</td>');

			//document.write ('</tr>');

			

			document.write ("<tr><td colspan=2>&nbsp;</td></tr>");

			document.write ("<tr><td colspan=2><table border=0 cellpadding=2 cellspacing=0 width=450px class='tblCashQuote'>");

			document.write ("<tr>");

			document.write ("<td>&nbsp;</td>");

			document.write ("<th>Insurance without Acts of God</th>");

			document.write ("<th>Insurance with Acts of God</th>");

			document.write ("</tr>");

			

			document.write ("<tr>");

			document.write ("<td><b>Unit Price:</b></td>");

			document.write ('<td align="right">P '+ addCommas(cA[j].price)+'</td>');

			document.write ('<td align="right">P '+ addCommas(cA[j].price)+'</td>');

			document.write ("</tr>");

			

			document.write ('<tr>');

			document.write ('<td><b>LTO:</b></td>');

			document.write ('<td align="right">P '+ addCommas(cA[j].lto)+'</td>');

			document.write ('<td align="right">P '+ addCommas(cA[j].lto)+'</td>');

			document.write ('</tr>');

			

			document.write ("<tr>");

			document.write ("<td><b>Insurance:</b></td>");

			document.write ("<td align='right'>P "+ addCommas(cA[j].insurance)+"</td>");

			document.write ("<td align='right'>P "+ addCommas(cA[j].insurewithacts)+"</td>");

			document.write ("</tr>");

			document.write ("<tr>");

			document.write ("<td><b>Total Investment:</b></td>");

			document.write ("<td align='right'>P "+ addCommas(cA[j].price + cA[j].lto +  cA[j].insurance) +"</td>");

			document.write ("<td align='right'>P "+ addCommas(cA[j].price + cA[j].lto +  cA[j].insurewithacts) +"</td>");

			document.write ("</tr>");

			//document.write ("<tr>");

			//document.write ("<td>*Insurance Type:</td>");

			//document.write ("<td align='center'><input type='radio' value='toyota' name='insurancetype'></td>");

			//document.write ("<td align='center'><input type='radio' value='withacts' name='insurancetype'></td>");

			//document.write ("</tr>");

			document.write ("</table>");

			document.write ("</td></tr>");

 

		}

	}

}


// model,variant,price,insurance,insurewithacts,lto,colors)
cA[c++] = new Car("Alphard","2.4 L (White Pearl)",2805000,108415,132863,13200,"White Pearl");
cA[c++] = new Car("Alphard","2.4 L",2709000,107854,132171,13200,"Silver Metallic,Raven Black");

cA[c++] = new Car("Avanza","1.5 G A/T",843000,35065,45577,7850,"Aqua Metallic,Champagne,Dark Gray Mica,Extreme Black,Silver");  //Champagne,Silver Metallic,Red
cA[c++] = new Car("Avanza","1.5 G M/T",803000,33569,43582,7850,"Aqua Metallic,Champagne,Dark Gray Mica,Extreme Black,Silver");
cA[c++] = new Car("Avanza","1.3 J M/T",613000,26461,34105,7850,"Aqua Metallic,Champagne,Extreme Black,Silver,White");
cA[c++] = new Car("Avanza","1.3 Taxi",593000,47897,55291,7850,"White");

cA[c++] = new Car("Camry","3.5 Q (White Pearl)",2025000,114636,139475,12850,"White Pearl");
cA[c++] = new Car("Camry","3.5 Q",2010000,113813,138465,12850,"Beige Metallic, Extreme Black, Gray Metallic, Thermalyte");
cA[c++] = new Car("Camry","2.4 V (White Pearl)",1696000,96585,117321,12850,"White Pearl");
cA[c++] = new Car("Camry","2.4 V",1681000,95761,116311,12850,"Beige Metallic, Extreme Black, Gray Metallic, Thermalyte");
cA[c++] = new Car("Camry","2.4 G (White Pearl)",1466000,83965,101833,12850,"White Pearl");
cA[c++] = new Car("Camry","2.4 G",1451000,83142,100823,12850,"Beige Metallic, Extreme Black, Gray Metallic, Thermalyte");

cA[c++] = new Car("Corolla Altis" ,"2.0 V (White Pearl)",1125000,64842,78871,13200,"White Pearl Crystal Shine");// insurance , registration , color
cA[c++] = new Car("Corolla Altis" ,"2.0 V",1110000,64019,77861,13200,"Beige,Black,Medium Silver,Thermalyte");
//cA[c++] = new Car("Corolla Altis" ,"1.8 V A/T",1035000,59904,0,6850,"Beige Metallic,Gray Metallic,Medium Silver Metallic,Silver Metallic,White Pearl");
cA[c++] = new Car("Corolla Altis" ,"1.6 V A/T (White Pearl)",940000,54692,66413,6850,"White Pearl Crystal Shine");
cA[c++] = new Car("Corolla Altis" ,"1.6 V A/T",925000,53869,65403,6850,"Beige,Black,Medium Silver,Thermalyte");
cA[c++] = new Car("Corolla Altis" ,"1.6 G M/T",833000,48821,59208,6850,"Beige,Black,Medium Silver,Thermalyte");
cA[c++] = new Car("Corolla Altis" ,"1.6 G A/T",869000,50796,61632,6850,"Beige,Black,Medium Silver,Thermalyte");
cA[c++] = new Car("Corolla Altis" ,"1.6 E M/T",784000,46132,55909,6850,"Beige,Black,Super White II,Thermalyte");

cA[c++] = new Car("Fortuner","4X4 A/T DSL",1741000,69319,90369,9350,"Black Mica, Dark Gray Mica Metallic, Grayish Brown Metallic, Silver Metallic, Super White II");
cA[c++] = new Car("Fortuner","4X2 A/T DSL",1479000,59517,77301,9350,"Black Mica, Dark Gray Mica Metallic, Grayish Brown Metallic, Silver Metallic, Super White II");
cA[c++] = new Car("Fortuner","4X2 A/T GAS",1414000,57086,74059,9350,"Black Mica, Dark Gray Mica Metallic, Grayish Brown Metallic, Silver Metallic, Super White II");
cA[c++] = new Car("Fortuner","4X2 M/T DSL", 1349000,54654,70817,9350,"Black Mica, Dark Gray Mica Metallic, Grayish Brown Metallic, Silver Metallic, Super White II");
 
cA[c++] = new Car("Hiace","HA Super Grandia 2T (Leather)",1890000,74893,97802,8850,"Extreme Black (Firm Order), Nobel Pearl 2T, White Pearl 1T");
cA[c++] = new Car("Hiace","HA Super Grandia 1T (Leather)",1875000,74332,97053,8850,"Extreme Black (Firm Order),Nobel Pearl 2T, White Pearl 1T");
cA[c++] = new Car("Hiace","HA Super Grandia 2T (Fabric)",1735000,69094,90070,8850,"Extreme Black (Firm Order), Nobel Pearl 2T, White Pearl 1T");
cA[c++] = new Car("Hiace","HA Super Grandia 1T (Fabric)",1720000,68533,89322,8850,"Extreme Black (Firm Order), Nobel Pearl 2T, White Pearl 1T");
cA[c++] = new Car("Hiace","HA GL Grandia 2T",1470000,59181,76852,8850,"Black Mica, Nobel Pearl, Silver Metallic");
cA[c++] = new Car("Hiace","HA GL Grandia 1T",1455000,58620,76104,8850,"Black Mica, Nobel Pearl, Silver Metallic");
cA[c++] = new Car("Hiace","HA COMM.VAN ",1200000,49080,63384,8850,"Dark Green,Silver Metallic,White");

cA[c++] = new Car("Hilux","4X4 G A/T GAS",1464000,58956,76553,7850,"Dark Green, Dark Red Mica Metallic, Extreme Black, Grayish Brown Metallic, Lithium");
cA[c++] = new Car("Hilux","4X4 G M/T GAS",1408000,56861,73759,7850,"Dark Green, Dark Red Mica Metallic, Extreme Black, Grayish Brown Metallic, Lithium");
//cA[c++] = new Car("Hilux","2x4 G Prerunner MT",1062000,0,7850,"");
cA[c++] = new Car("Hilux","4X2 G M/T DSL",1075000,44404,57149,7850,"Dark Green, Dark Red Mica Metallic, Extreme Black, Grayish Brown Metallic, Lithium");
cA[c++] = new Car("Hilux","4X2 E M/T GAS",910000,38231,48919,7850,"Dark Red Mica Metallic, Extreme Black, Grayish Brown Metallic, Lithium");
cA[c++] = new Car("Hilux","4X2 J M/T GAS",823000,34976,44580,7850,"Dark Red Mica Metallic, Extreme Black, Grayish Brown Metallic, Lithium");
cA[c++] = new Car("Hilux","4X2 FX M/T w/ AC",840000,35612,45428,7850,"White");
cA[c++] = new Car("Hilux","4X2 FX M/T w/o AC",810000,34490,43931,7850,"White");
cA[c++] = new Car("Hilux","4X2 CAB & CHASSIS",684000,29776,37646,7850,"White");

cA[c++] = new Car("Innova","2.5 V A/T DSL",1195000,48233,63135,7850,"Black, Bronze Mica Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.0 V A/T GAS",1400000,46176,60392,7850,"Black, Bronze Mica Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.5 G A/T DSL",1133000,45914,60042,7850,"Black, Bronze Mica Metallic, Jade Green Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.5 G M/T DSL",1068000,43482,56800,7850,"Black, Bronze Mica Metallic, Jade Green Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.0 G A/T GAS",1078000,43856,57299,7850,"Black, Bronze Mica Metallic, Jade Green Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.0 G M/T GAS",1013000,41425,54057,7850,"Black, Bronze Mica Metallic, Jade Green Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.5 E A/T DSL",1033000,42173,55054,7850,"Beige Metallic, Jade Green Metallic, Red Mica Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.5 E M/T DSL",968000,39741,51812,7850,"Beige Metallic, Jade Green Metallic, Red Mica Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.0 E A/T GAS",978000,40115,52311,7850,"Beige Metallic, Jade Green Metallic, Red Mica Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.0 E M/T GAS",913000,37684,49069,7850,"Beige Metallic, Jade Green Metallic, Red Mica Metallic, Silver Metallic");
cA[c++] = new Car("Innova","2.5 J M/T DSL",858000,35626,46325,7850,"Freedom White, Silver Metallic, Red Mica Metallic");
cA[c++] = new Car("Innova","2.0 J M/T GAS",803000,33569,43582,7850,"Freedom White, Silver Metallic, Red Mica Metallic");

cA[c++] = new Car("Innova","Sport Runner A/T DSL  ",1064000,43333,56601,7850,"Black, Bronze Mica Metallic");
cA[c++] = new Car("Innova","Sport Runner M/T DSL  ",999000,40901,53359,7850,"Black, Bronze Mica Metallic");

cA[c++] = new Car("LC 200","VX A/T",4065000,172758,228288,13200,"Beige Mica Metallic, Black, Dark Red Mica Metallic, Gold Mica Metallic, Gray Metallic, Grayish Blue, Green Mica Metallic, Silver Metallic, Super White");
cA[c++] = new Car("Prado","3.0 A/T DSL",3595000,138677,182847,10850,"Champagne,Frost White,Raven Black,Thermalyte");
cA[c++] = new Car("Prado","3.0 A/T DSL (White Pearl)",3610000,139238,183595,10850,"White Pearl");
cA[c++] = new Car("Prado","3.0 M/T DSL",3495000,134936,177859,10850,"Champagne,Frost White,Raven Black,Thermalyte");
cA[c++] = new Car("Prado","3.0 M/T DSL (White Pearl)",3510000,135497,178607,10850,"White Pearl");
 

// backup 111209 start =================
//cA[c++] = new Car("Land Cruiser","LC 200 VX AT",4506000,172758,228288,13200,"Beige Mica Metallic,Gold Mica Metallic,Silver Metallic,Super White II ");
//cA[c++] = new Car("Land Cruiser","Prado 3.0 A/T DSL",3595000,138677,182847 
//,10850,"Dark Steel Mica,Grey Metallic,Raven Black,Silver Metallic");
//cA[c++] = new Car("Land Cruiser","Prado 3.0 A/T DSL (White Pearl)",3610000,139238,183595,10850,"White Pearl");
//cA[c++] = new Car("Land Cruiser","Prado 3.0 M/T DSL",3495000,134936,177859,10850,"Dark Steel Mica,Grey Metallic,Raven Black,Silver Metallic");
//cA[c++] = new Car("Land Cruiser","Prado 3.0 M/T DSL (White Pearl)",3510000,135497,178607,10850,"White Pearl");
// backup 111209 end ==============

//cA[c++] = new Car("Prado","LC M/T",2850000,110807,10850,"Champagne,Raven Black,Thermalyte,White");
//cA[c++] = new Car("Prado","LC100 4.5L A/T Fabric",3979000,153042,10850,"Champagne,Raven Black,Thermalyte,White");
//cA[c++] = new Car("Prado","LC200 4.5 A/T Leather",4185000,160786,12850,"Champagne,Raven Black,Thermalyte,White");

cA[c++] = new Car("Prius","3rd Gen",2250000,126981,154626,13200,"Abyss Gray Metallic,Beige Metallic (Firm Order),Black (Firm Order),Dark Blue Metallic,Red Mica Metallic,Silver Metallic");
cA[c++] = new Car("Prius","3rd Gen (White Pearl)",2265000,127804,155636,13200,"White Pearl");



cA[c++] = new Car("Previa","Full Option",2422000,94795,124338,8850,"Black,Silky Gold Mica Metallic,Silver Metallic");
cA[c++] = new Car("Previa","Full Option (White Pearl)",2437000,95356,125086,8850,"White Pearl");
cA[c++] = new Car("Previa","Standard Option",2252000,88435,115858,8850,"Dark Red Mica,Silky Gold Mica Metallic,Silver Metallic");
cA[c++] = new Car("Previa","Standard Option (White Pearl)",2267000,88997,116606,8850,"White Pearl");

cA[c++] = new Car("RAV4","4X4 A/T (White Pearl)",1840000,73022,95308,9350,"White Pearl");
cA[c++] = new Car("RAV4","4X4 A/T",1825000,72461,9350,94559,"Black, Grayish Blue Metallic, Silver Metallic");
cA[c++] = new Car("RAV4","4X2 A/T (White Pearl)",1480000,59555,77351,9350,"White Pearl");
cA[c++] = new Car("RAV4","4X2 A/T",1465000,58994,76603,9350,"Black, Grayish Blue Metallic, Silver Metallic");

cA[c++] = new Car("Vios" ,"1.5 G A/T Leather",846000,48711,60059,6850,"Black,Bronze Mica Metallic,Light Blue Metallic,Thermalyte");
//cA[c++] = new Car("Vios" ,"1.5 S 4 Speed A/T",805000,47284,57323,6850,"Black,Thermalyte");
//cA[c++] = new Car("Vios" ,"1.5 S 4 Speed M/T",770000,45364,54966,6850,"Black,Thermalyte");
cA[c++] = new Car("Vios" ,"1.5 G A/T",810000,46736,57636,6850,"Black,Bronze Mica Metallic,Light Blue Metallic,Thermalyte");
cA[c++] = new Car("Vios" ,"1.5 G M/T",775000,44815,55280,6850,"Black,Bronze Mica Metallic,Light Blue Metallic,Thermalyte");
cA[c++] = new Car("Vios" ,"1.3 E A/T",720000,39877,51578,6850,"Beige Metallic,Black,Light Blue Metallic,Red Mica Metallic,Thermalyte");
cA[c++] = new Car("Vios" ,"1.3 E M/T",685000,39877,49222,6850,"Beige Metallic,Black,Light Blue Metallic,Red Mica Metallic,Thermalyte");
cA[c++] = new Car("Vios" ,"1.3 J M/T",599000,35488,43433,6850,"Light Blue Metallic,Red Mica Metallic,Thermalyte");

cA[c++] = new Car("Yaris" ,"1.5 A/T GAS",766000,45145,54697,7850,"Cosmo Red,Extreme Black,Freedom White,Medium Silver Metallic");
cA[c++] = new Car("Yaris" ,"1.5 M/T GAS",731000,43224,52340,7850,"Cosmo Red,Extreme Black,Freedom White,Medium Silver Metallic");
//cA[c++] = new Car("Others" ,"Others",553000,33381);