﻿function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v3.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function initialise() {
	document.form1.year.focus();		
	which_version();
}
function update_engine(obj) {
	if (obj.options.selectedIndex == "0") {
		document.form1.engine.options[0].text = "up to 1,650c.c.";	
		document.form1.engine.options[1].text = "over 1,650c.c. to 3,500c.c.";	
		document.form1.engine.options[2].text = "over 3,500c.c.";	
	}
	if (obj.options.selectedIndex == "1") {
		document.form1.engine.options[0].text = "Inapplicable";	
		document.form1.engine.options[1].text = "";	
		document.form1.engine.options[2].text = "";	
	}
}
function update_model(obj) {
	var max_items = "26";
	//	alert("obj_options_value is " + obj.options[obj.options.selectedIndex].value);
	for (i=0;i<=max_items;i++) {
		document.form1.model.options[i].value = "";		
	}
	if (obj.options[obj.options.selectedIndex].value == "0") {
		document.form1.model.options[0].selected = "true";
		document.form1.model.options[0].text = "Integra";	
		document.form1.model.options[0].value = "*";	
		document.form1.model.options[1].text = "Legend";
		document.form1.model.options[1].value = "*";		
		document.form1.model.options[2].text = "2.5 TL";	
		document.form1.model.options[3].text = "3.5 TL";
		document.form1.model.options[4].text = "RL";
		document.form1.model.options[5].text = "NSX";
		document.form1.model.options[5].value = "*";
		document.form1.model.options[6].text = "Others";
		for (i=7;i<=max_items;i++) {
		document.form1.model.options[i].text = "";		
		}
		}
		if (obj.options[obj.options.selectedIndex].value == "1") {
		document.form1.model.options[0].selected = "true";
		document.form1.model.options[0].text = "145";	
		document.form1.model.options[1].text = "155";	
		document.form1.model.options[2].text = "164";	
		document.form1.model.options[3].text = "168";	
		document.form1.model.options[4].text = "GTV";	
		document.form1.model.options[4].value = "*";
		document.form1.model.options[5].text = "Spider";	
		document.form1.model.options[5].value = "*";
		document.form1.model.options[6].text = "Others";	
		for (i=7;i<=max_items;i++) {
		document.form1.model.options[i].text = "";		
		}
		}
		if (obj.options[obj.options.selectedIndex].value == "2") {
		document.form1.model.options[0].selected = "true";
		document.form1.model.options[0].text = "A4";	
		document.form1.model.options[1].text = "A6";	
		document.form1.model.options[2].text = "Cabriolet";	
		document.form1.model.options[2].value = "*";
		document.form1.model.options[3].text = "A8";	
		document.form1.model.options[3].value = "*";
		document.form1.model.options[4].text = "Others";	
		for (i=5;i<=max_items;i++) {
		document.form1.model.options[i].text = "";		
		}
		}
		if (obj.options[obj.options.selectedIndex].value == "3") {
		document.form1.model.options[0].selected = "true";
		document.form1.model.options[0].text = "318";	
		document.form1.model.options[1].text = "328";	
		document.form1.model.options[2].text = "M3";	
		document.form1.model.options[2].value = "*";
		document.form1.model.options[3].text = "523";
		document.form1.model.options[4].text = "528";
		document.form1.model.options[5].text = "540";
		document.form1.model.options[6].text = "735";	
		document.form1.model.options[7].text = "740";	
		document.form1.model.options[8].text = "750";	
		document.form1.model.options[9].text = "840";
		document.form1.model.options[9].value = "*";
		document.form1.model.options[10].text = "Z3";
		document.form1.model.options[10].value = "*";
		document.form1.model.options[11].text = "Others";
		for (i=12;i<=max_items;i++) {
		document.form1.model.options[i].text = "";		
		}
		}
		if (obj.options[obj.options.selectedIndex].value == "4") {
		document.form1.model.options[0].selected = "true";
		document.form1.model.options[0].text = "Cielo";	
		document.form1.model.options[1].text = "Espero";	
		document.form1.model.options[2].text = "Others";	
		for (i=3;i<=max_items;i++) {
		document.form1.model.options[i].text = "";		
		}
		}
		if (obj.options[obj.options.selectedIndex].value == "5") {
		document.form1.model.options[0].selected = "true";
		document.form1.model.options[0].text = "Cuore";	
		document.form1.model.options[1].text = "Charade";	
		document.form1.model.options[2].text = "Applause";	
		document.form1.model.options[3].text = "Others";	
		for (i=4;i<=max_items;i++) {
		document.form1.model.options[i].text = "";		
		}
		}
		if (obj.options[obj.options.selectedIndex].value == "6") {
		document.form1.model.options[0].selected = "true";
		document.form1.model.options[0].text = "800";	
		document.form1.model.options[1].text = "Others";	
		for (i=2;i<=max_items;i++) {
		document.form1.model.options[i].text = "";		
		}
		}
		if (obj.options[obj.options.selectedIndex].value == "7") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Purtno";	
			document.form1.model.options[1].text = "Ulysse";	
			document.form1.model.options[2].text = "Others";	
			for (i=3;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "8") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Laser";	
			document.form1.model.options[1].text = "Mondeo";	
			document.form1.model.options[2].text = "Scorpio";	
			document.form1.model.options[3].text = "Festiva";	
			document.form1.model.options[4].text = "Taurus";	
			document.form1.model.options[5].text = "Others";	
			for (i=6;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "9") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Civic";	
			document.form1.model.options[1].text = "Accord";	
			document.form1.model.options[2].text = "Odyssey";	
			document.form1.model.options[3].text = "Prelude";
			document.form1.model.options[3].value = "*";	
			document.form1.model.options[4].text = "Taurus";	
			document.form1.model.options[5].text = "Others";	
			for (i=6;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "10") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Accent";	
			document.form1.model.options[1].text = "Elantra";	
			document.form1.model.options[2].text = "Scoupe";	
			document.form1.model.options[3].text = "Sonata";	
			document.form1.model.options[4].text = "Others";	
			for (i=5;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "11") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Q45";	
			document.form1.model.options[1].text = "Others";	
			for (i=2;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "12") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Sovereign";	
			document.form1.model.options[1].text = "Daimler";	
			document.form1.model.options[2].text = "XJR";	
			document.form1.model.options[3].text = "XJ6";	
			document.form1.model.options[4].text = "XK8";	
			document.form1.model.options[5].text = "Others";	
			for (i=6;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "13") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Sephia";	
			document.form1.model.options[1].text = "Others";	
			for (i=2;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "14") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "ES300";	
			document.form1.model.options[1].text = "GS300";	
			document.form1.model.options[2].text = "LS400";	
			document.form1.model.options[3].text = "Others";	
			for (i=4;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "15") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Demio";	
			document.form1.model.options[1].text = "121";	
			document.form1.model.options[2].text = "323";	
			document.form1.model.options[3].text = "626";	
			document.form1.model.options[4].text = "929";	
			document.form1.model.options[5].text = "Astina";	
			document.form1.model.options[6].text = "Capella";	
			document.form1.model.options[7].text = "MPV";	
			document.form1.model.options[8].text = "MX5";	
			document.form1.model.options[8].value = "*";
			document.form1.model.options[9].text = "MX6";	
			document.form1.model.options[9].value = "*";
			for (i=10;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "16") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Lancer";	
			document.form1.model.options[1].text = "Galant";	
			document.form1.model.options[2].text = "Space Runner";	
			document.form1.model.options[3].text = "Space Wagon";
			document.form1.model.options[4].text = "Diamante";
			document.form1.model.options[5].text = "3000GT";
			document.form1.model.options[5].value = "*";
			document.form1.model.options[6].text = "Pajero";	
			document.form1.model.options[7].text = "Toppo";	
			document.form1.model.options[8].text = "Chariot";	
			document.form1.model.options[9].text = "Exceed";
			document.form1.model.options[10].text = "RVR";
			document.form1.model.options[11].text = "FTO";
			document.form1.model.options[12].text = "Others";
			for (i=13;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "17") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "C200";	
			document.form1.model.options[1].text = "C230";	
			document.form1.model.options[2].text = "C280";	
			document.form1.model.options[3].text = "E230";
			document.form1.model.options[4].text = "E250";
			document.form1.model.options[5].text = "E280";
			document.form1.model.options[6].text = "E320";	
			document.form1.model.options[7].text = "S280";	
			document.form1.model.options[8].text = "S320";	
			document.form1.model.options[9].text = "S420";
			document.form1.model.options[10].text = "S420L";
			document.form1.model.options[11].text = "S500";
			document.form1.model.options[12].text = "500L";
			document.form1.model.options[13].text = "S600";	
			document.form1.model.options[14].text = "600L";	
			document.form1.model.options[15].text = "S500C";
			document.form1.model.options[15].value = "*";	
			document.form1.model.options[16].text = "S600C";
			document.form1.model.options[16].value = "*";
			document.form1.model.options[17].text = "SL280";
			document.form1.model.options[17].value = "*";
			document.form1.model.options[18].text = "SL320";
			document.form1.model.options[18].value = "*";
			document.form1.model.options[19].text = "SL500";	
			document.form1.model.options[19].value = "*";
			document.form1.model.options[20].text = "SL600";	
			document.form1.model.options[20].value = "*";
			document.form1.model.options[21].text = "C36";
			document.form1.model.options[21].value = "*";	
			document.form1.model.options[22].text = "E36";
			document.form1.model.options[22].value = "*";
			document.form1.model.options[23].text = "300GD";
			document.form1.model.options[24].text = "G300E";
			document.form1.model.options[25].text = "SLK";
			document.form1.model.options[26].text = "Others";
		}
		if (obj.options[obj.options.selectedIndex].value == "18") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Sunny";	
			document.form1.model.options[1].text = "Presea";	
			document.form1.model.options[2].text = "Silvia";	
			document.form1.model.options[3].text = "Cefiro";
			document.form1.model.options[4].text = "Pulsar";
			document.form1.model.options[5].text = "Bluebird";
			document.form1.model.options[6].text = "Cedric";	
			document.form1.model.options[7].text = "Cima";	
			document.form1.model.options[8].text = "President";	
			document.form1.model.options[9].text = "200SX";
			document.form1.model.options[9].value = "*";
			document.form1.model.options[10].text = "300ZX";
			document.form1.model.options[10].value = "*";
			document.form1.model.options[11].text = "Broughan VIP";
			document.form1.model.options[12].text = "Primera";
			document.form1.model.options[13].text = "Pathfinder";
			document.form1.model.options[14].text = "Others";
			for (i=15;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "19") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Astra";	
			document.form1.model.options[1].text = "Corsa";	
			document.form1.model.options[2].text = "Omega";	
			document.form1.model.options[3].text = "Vectra";	
			document.form1.model.options[4].text = "Tigra";	
			document.form1.model.options[5].text = "Others";	
			for (i=6;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "20") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "306";	
			document.form1.model.options[1].text = "406";	
			document.form1.model.options[2].text = "Others";	
			for (i=3;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "21") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "911";	
			document.form1.model.options[0].value = "*";
			document.form1.model.options[1].text = "928";	
			document.form1.model.options[1].value = "*";
			document.form1.model.options[2].text = "944";	
			document.form1.model.options[2].value = "*";
			document.form1.model.options[3].text = "Others";	
			document.form1.model.options[3].value = "*";
			for (i=4;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "22") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Laguna";	
			document.form1.model.options[1].text = "Safrane";	
			document.form1.model.options[2].text = "Espace";	
			document.form1.model.options[3].text = "Others";	
			for (i=4;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "23") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Mini Cooper";	
			document.form1.model.options[1].text = "623";	
			document.form1.model.options[2].text = "Sterling";	
			document.form1.model.options[3].text = "Land Rover";	
			document.form1.model.options[4].text = "Range Rover";	
			document.form1.model.options[5].text = "216";	
			document.form1.model.options[6].text = "416";	
			document.form1.model.options[7].text = "Others";	
			for (i=8;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "24") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "900";	
			document.form1.model.options[1].text = "9000";	
			document.form1.model.options[2].text = "Others";	
			for (i=3;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "25") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Impreza";	
			document.form1.model.options[0].value = "*";
			document.form1.model.options[1].text = "Domingo";	
			document.form1.model.options[2].text = "Legacy";	
			document.form1.model.options[2].value = "*";
			document.form1.model.options[3].text = "ViVio";	
			document.form1.model.options[4].text = "Others";	
			for (i=5;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "26") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Esteem";	
			document.form1.model.options[1].text = "Vitara";	
			document.form1.model.options[2].text = "X90";	
			document.form1.model.options[3].text = "Wagon R";	
			document.form1.model.options[4].text = "Balene";	
			document.form1.model.options[5].text = "Others";	
			for (i=6;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "27") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Corolla";	
			document.form1.model.options[1].text = "Corona";	
			document.form1.model.options[2].text = "Camry";	
			document.form1.model.options[3].text = "Crown";
			document.form1.model.options[4].text = "Cressida";
			document.form1.model.options[5].text = "Starlet";
			document.form1.model.options[6].text = "RAV4";	
			document.form1.model.options[7].text = "Celica";	
			document.form1.model.options[7].value = "*";
			document.form1.model.options[8].text = "MR2";	
			document.form1.model.options[8].value = "*";
			document.form1.model.options[9].text = "Super";
			document.form1.model.options[9].value = "*";
			document.form1.model.options[10].text = "Previa";
			document.form1.model.options[11].text = "Others";
			for (i=12;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "28") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "Golf";	
			document.form1.model.options[1].text = "Vento";	
			document.form1.model.options[2].text = "Passat";	
			document.form1.model.options[3].text = "Others";	
			for (i=4;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		if (obj.options[obj.options.selectedIndex].value == "29") {
			document.form1.model.options[0].selected = "true";
			document.form1.model.options[0].text = "460";	
			document.form1.model.options[1].text = "850";	
			document.form1.model.options[2].text = "940";	
			document.form1.model.options[3].text = "960";	
			document.form1.model.options[4].text = "Others";	
			for (i=5;i<=max_items;i++) {
				document.form1.model.options[i].text = "";		
			}
		}
		}
		function calculate() {
			var premium = "0";
			var minPremium = 1000;
			//estimated_value = estimated_value * 1000;
			var ncd = document.form1.ncd.options[document.form1.ncd.options.selectedIndex].value;
			var type_of_engine = document.form1.engine.options[document.form1.engine.options.selectedIndex].value;
			var estimated_value = document.form1.estimated_value.value;
			var myear = document.form1.year.value;
			//	alert("estimated_value is " + estimated_value);
			//	alert("ncd is " + ncd);
			//	alert(document.form1.coverage.options.selectedIndex);
			document.form1.premium.value = "";	
			// error checking
			if (document.form1.make.options.selectedIndex < 0){
				alert("Please select an option from Make Category!");
				return;
			}
			else if (document.form1.model.options.selectedIndex < 0){
				alert("Please select an option of model!");
				return;
			}
			else if (myear == ""){
				alert("Please enter year of manufacture!");
				document.form1.year.focus();
				return;
			}
			else if (!validateYear(document.form1.year)){
				return;
			}
			else if (estimated_value == "") {
				alert("Please enter estimated value of vehicle!");
				document.form1.estimated_value.focus();	
				return;
			}
			else if (!validate(document.form1.estimated_value)){
				return;
			}
			else if ((document.form1.model.options[document.form1.model.options.selectedIndex].text == "")) {
				alert("Please don't select empty option!");
				return;
			}
			else{
				// end of checking
				
				
				
				
				if (document.form1.coverage.options[document.form1.coverage.options.selectedIndex].value == "0") {		
					if (type_of_engine == "0") {
						premium = estimated_value * 0.084;
						if (premium < 1000) premium = 1000;
						premium = (premium + 8600) * ((1 - ncd)*100)/100 * 1.03;
						premium = Math.floor(premium);
						document.form1.premium.value = premium;
					}		 
					if (type_of_engine == "1") {
						premium = estimated_value * 0.055;
						if (premium < 1000) premium = 1000;
						premium = (premium + 9500) * ((1 - ncd)*100)/100 * 1.03;
						premium = Math.floor(premium);
						document.form1.premium.value = premium;
					}		 
					if (type_of_engine == "2") {
						premium = estimated_value * 0.0580;
						if (premium < 1000) premium = 1000;
						premium = (premium + 9700) * ((1 - ncd)*100)/100 * 1.03;
						premium = Math.floor(premium);
						document.form1.premium.value = premium;
					}	 
				}
				
				
				if (document.form1.coverage.options[document.form1.coverage.options.selectedIndex].value == "1") {		
					premium = (5000 * (1 - ncd)) * 1.03;
					//alert("premium is " + premium);
					premium = Math.floor(premium);
					document.form1.premium.value = premium;
				}
				
				
				/*
				msgWindow = window.open("","displayWindow",'toolbar=no,scrollbars=no,status=no,width=593,height=150');
				msgWindow.document.write("
					<TITLE>SHKP Insurance Message window</TITLE>");
				msgWindow.document.write("");
				msgWindow.document.write("<br>");
				msgWindow.document.write("
					<FORM>
					<table border=0 cellpadding=2 width=560>
					<tr>
					<td width=130>&nbsp;&nbsp;&nbsp;</td>");
				msgWindow.document.write("
					<td width=430>
					<ul type='square'>
					");
				msgWindow.document.write("<font face=\"Arial, Helvetica, sans-serif\" size=2 >");
				msgWindow.document.write("
					<li>Net Premium has included 30% normal discount");
				if ((document.form1.model.options[document.form1.model.options.selectedIndex].value == "*")) {
					msgWindow.document.write("
						<li>A loading premium may be applied on this vehicle");
				}
				msgWindow.document.write("
					<li>The above premium quoted is for your reference only, please contact us at 2828 7806 for further information.");
				msgWindow.document.write("</font>");
				msgWindow.document.write("
					</ul>
					");
				msgWindow.document.write("</td>
					</tr>
					<tr>
					<td width=130></td>
					<td width=430>
					<ul type='square'>
					");
				if ((document.form1.model.options[document.form1.model.options.selectedIndex].value != "*")) {
					msgWindow.document.write("</td>
						</tr>
						<tr>
						<td width=130></td>
						<td width=430 align=center>");
				}
				msgWindow.document.write("<font face=arial size=2><INPUT TYPE=button VALUE=' Close this Window ' onClick='self.close();'></font></td>
					</tr>
					</table>
					</FORM>
					");
				msgWindow.focus();
				//return;
				*/
			}
		}
		function moneyFormat(input) { 
			// if (!isNum(input)) return null;
			var dollars = Math.floor(input)
			var tmp = new String(input)
			for (var decimalAt = 0; decimalAt < tmp.length; decimalAt++) {
				if (tmp.charAt(decimalAt)==".") break
			}
		var cents  = "" + Math.round(input * 100)
		cents = cents.substring(cents.length-2, cents.length)
		dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;
		return dollars + "." + cents
		}
		function isNum(str) {
			var cnt=0;
			if (str == "N.A.") {
				return true;
			}
			else if (str.substring(0,1) == "."){
				alert("First digit should not be a single dot.");
				return false;
			}else {
				if (isNaN(str)){
					alert("Please enter a number!");
					return false;
				}
				/*
				//alert(str.length);
				for (var i = 0; i < str.length; i++) {
					var ch = str.substring(i, i + 1);
					if ((ch < "0" || "9" < ch) && ch != '.') {
						//alert("Please enter a number!");
						cnt++;
					}
				}
				if (cnt!=0){
					alert("Please enter a number!");
					return false;
				}
				*/
			}
			return true;
		}
		function validate(obj) {
			if (isNum(obj.value)) {
				return true;
				//alert(obj.value + ' is a valid decimal number');
			}
			else return false; 
			//obj.focus();
		}
		// Estimated Value of Vehicle
		function EstimatedValue(obj) {
			var k = document.form1.coverage.selectedIndex;
			if (k==0) {
				document.form1.estimated_value.value = "";
			}
			else
				document.form1.estimated_value.value = "N.A.";
		}
		//  New Content 1
		function isPureNum(str) {
			if (str == "N.A.") {
				return true;
			}
			else
			for (var i = 0; i < str.length; i++) {
				var ch = str.substring(i, i + 1);
				if ((ch < "0" || "9" < ch)) {
					alert("Please enter pure numbers!");	
					return false;
				}
				
			}return true;
		}
		function isLogicalYear(str){
			var nYear = parseInt(str);
			var d = new Date();
			var curr_year = d.getFullYear();
			if (nYear < 1900 || curr_year < nYear){
				alert("Please enter a valid manufacture year!");
				return false;
			}
			return true;
		}
		function validateYear(obj) {
			if (isPureNum(obj.value) && isLogicalYear(obj.value)) {
				return true;
				//alert(obj.value + ' is a valid decimal number');
			}
			else return false;	
			//obj.focus();
		}
		// end of new content
		
