function calcCoverage(){
var area=document.getElementById("Area").value;
var cost=document.getElementById("Construction").value;

var totalcoverage=area*cost;

if(totalcoverage.value==0){
	totalcoverage=0;
}
if(totalcoverage>0){
document.getElementById('homecoverage').value=totalcoverage; 
}
else{
	document.getElementById('homecoverage').value=0; 
}
}

function call(value){
//var fireVal=0;
if(value==true){
document.getElementById("fireCount").value=1;
}
if(value==false){
document.getElementById("fireCount").value=0;
}

}

function callTheft(value){
//var fireVal=0;
if(value==true){
document.getElementById("theftCount").value=1;
}
if(value==false){
document.getElementById("theftCount").value=0;
}

}

function callRep(value){
//var fireVal=0;
if(value==true){
document.getElementById("repairCount").value=1;
}
if(value==false){
document.getElementById("repairCount").value=0;
}

}

function validate(){
var homeTypeOwn=document.getElementById("homeowned");
var homeTypeRent=document.getElementById("homerented");

if(document.getElementById("standardPlan").checked==false && document.getElementById("customPlan").checked==false){
	alert("Please select a PlanType. Standard Or Custom");
	return false;
}

if(document.getElementById("standardPlan").checked==true){
	if(homeTypeOwn.checked==false && homeTypeRent.checked==false)
		{
		alert("Please Select Your Home is Owned or Rented");
			return false;
		}
	if(homeTypeOwn.checked==true){
	if(document.getElementById("stdBoth").checked==false && document.getElementById("stdContents").checked==false){
	alert("Please select Insure type. Building & Contents Or Contents");
	return false;
	}
	}
	document.getElementById("SearchHomePlansForm").action="searchStandardPlans.do";
	return true;
}else{
	document.getElementById("SearchHomePlansForm").action="searchHomePlans.do";
}


var homeBuilding=document.getElementById("homestructure").checked;
var homeContent=document.getElementById("homecontent").checked;
var homeArea=document.getElementById("Area");
var homeConstCost=document.getElementById("Construction");
var valuable=document.getElementById("Jewelry");
var tv=document.getElementById("Tv");
var dvd=document.getElementById("Dvd");
var music=document.getElementById("Music");
var pc=document.getElementById("customPC");
var ac=document.getElementById("AC");
var refrig=document.getElementById("Refrigerator");
var wm=document.getElementById("WashingMachine");
var micro=document.getElementById("Microwave");
var other=document.getElementById("OthersDom");
var addCoveryes=document.getElementById("AddYes");
var addCoverno=document.getElementById("AddNo");

//Checkbox Values
//var jChk1=document.getElementById("JewelFire").checked;
//var jChk2=document.getElementById("JewelTheft").checked;
//var jChk3=document.getElementById("JewelRepair").checked;

//var tvChk1=document.getElementById("TvFire").checked;
//var tvChk2=document.getElementById("TvTheft").checked;
//var tvChk3=document.getElementById("TvRepair").checked;

//var dvdChk1=document.getElementById("DvdFire").checked;
//var dvdChk2=document.getElementById("DvdTheft").checked;
//var dvdChk3=document.getElementById("DvdRepair").checked;

//var mChk1=document.getElementById("MusicFire").checked;
//var mChk2=document.getElementById("MusicTheft").checked;
//var mChk3=document.getElementById("MusicRepair").checked;

//var pcChk1=document.getElementById("PcFire").checked;
//var pcChk2=document.getElementById("PcTheft").checked;
//var pcChk3=document.getElementById("PcRepair").checked;

var acChk1=document.getElementById("AcFire").checked;
//var acChk2=document.getElementById("AcTheft").checked;
var acChk3=document.getElementById("AcRepair").checked;

var fChk1=document.getElementById("RefFire").checked;
//var fChk2=document.getElementById("RefTheft").checked;
var fChk3=document.getElementById("RefRepair").checked;

var wChk1=document.getElementById("WmFire").checked;
//var wChk2=document.getElementById("WmTheft").checked;
var wChk3=document.getElementById("WmRepair").checked;

var mwChk1=document.getElementById("MwFire").checked;
//var mwChk2=document.getElementById("MwTheft").checked;
var mwChk3=document.getElementById("MwRepair").checked;

var otChk1=document.getElementById("OtFire").checked;

if((acChk1==false) && (fChk1==false) && (wChk1==false) && (mwChk1==false) && (otChk1==false)){
document.getElementById("fireCount").value=0;
}
else{
document.getElementById("fireCount").value=1;
}
if((acChk3==false) && (fChk3==false) && (wChk3==false) && (mwChk3==false)){
document.getElementById("repairCount").value=0;
}
else{
document.getElementById("repairCount").value=1;
}

var firecount=document.getElementById("fireCount");
var theftcount=document.getElementById("theftCount");
var repaircount=document.getElementById("repairCount");

//Additional Covers
var baggage=document.getElementById("BagLoss");
var pa=document.getElementById("Personal");
var liability=document.getElementById("PublicLiability");
var glass=document.getElementById("PlateGlass");
var pedalcycle=document.getElementById("PedalCycle");
var money=document.getElementById("Money");
var purchase=document.getElementById("Purchase");
var fg=document.getElementById("Fidelity");
var workmen=document.getElementById("WC");
var rent=document.getElementById("Rent");
var terrorYes=document.getElementById("TerYes").checked;
var terrorNo=document.getElementById("TerNo").checked;

//To Count the products entered
var countPro=0;

//To Validate Home Type
if(homeTypeOwn.checked==false && homeTypeRent.checked==false)
		{
		alert("Please Select Your Home is Owned or Rented");
			return false;
		}

/* To Validate Term
if((homeTerm=="select") || (homeTerm==0) || (homeTerm==""))
		{
			alert("Select Your PolicyTerm");
			return false;
		}
*/
//To Validate Type Of Insurance
if(homeTypeOwn.checked==true){
if(homeBuilding==false && homeContent == false){

			alert("Please select the type you want to insure");
			return false;
			}

}

//Validate Area

if((homeTypeOwn.checked==true) && (homeBuilding==true)){
	if(isEmpty(homeArea.value)==true){
		alert("Please enter area of your house");
		homeArea.focus();
		homeArea.select();
		return false;
	}else if(homeArea.value.length >5){
		alert("Area Should be less than or equal to 5 Digits");
		homeArea.focus();
		homeArea.select();
		return false;
	}
	if(isIntegers(homeArea.value)==false)
	{
	    alert("Enter Valid Area");
		homeArea.focus();
		homeArea.select();
		return false;
	}


//Validate Construction Cost
	if(isEmpty(homeConstCost.value)==true){
		alert("Please enter construction cost of your house");
		homeConstCost.focus();
		homeConstCost.select();
		return false;
	}
	if(homeConstCost.value.length >5){
		alert("Construction Cost Should be less than or equal to 5 Digits");
		homeConstCost.focus();
		homeConstCost.select();
		return false;
	}
	if(isIntegers(homeConstCost.value)==false)
	{
	    alert("Please enter a valid construction cost");
		homeConstCost.focus();
		homeConstCost.select();
		return false;
	}

}


if((homeTypeRent.checked==true) || (homeContent==true)){

//valuables

if(ac.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		ac.focus();
		ac.select();
		return false;
	}
	if(isIntegers(ac.value)==false)
	{
	    alert("Please enter a valid amount");
		ac.focus();
		ac.select();
		return false;
	}
	if(ac.value.length >0){
		countPro++;
		if(acChk1==false && acChk3==false){
		alert("Please Select the type of cover whether Fire,Theft or Repair");
		ac.focus();
		return false;
		}
	}

//To Validate Domestic Appliances

 if(refrig.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		refrig.focus();
		refrig.select();
		return false;
	}
	if(isIntegers(refrig.value)==false)
	{
	    alert("Please enter a valid amount");
		refrig.focus();
		refrig.select();
		return false;
	}
	if(refrig.value.length >0){
		countPro++;
		if(fChk1==false && fChk3==false){
		alert("Please Select the type of cover whether Fire,Theft or Repair");
		refrig.focus();
		return false;
		}
	}

	
    if(wm.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		wm.focus();
		wm.select();
		return false;
	}
	if(isIntegers(wm.value)==false)
	{
	    alert("Please enter a valid amount");
		wm.focus();
		wm.select();
		return false;
	}
	if(wm.value.length >0){
		countPro++;
		if(wChk1==false && wChk3==false){
		alert("Please Select the type of cover whether Fire,Theft or Repair");
		wm.focus();
		return false;
		}
	}


 if(micro.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		micro.focus();
		micro.select();
		return false;
	}
	if(isIntegers(micro.value)==false)
	{
	    alert("Please enter a valid amount");
		micro.focus();
		micro.select();
		return false;
	}
	if(micro.value.length >0){
		countPro++;
		if(mwChk1==false && mwChk3==false){
		alert("Please Select the type of cover whether Fire,Theft or Repair");
		micro.focus();
		return false;
		}
	}



  if(other.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		other.focus();
		other.select();
		return false;
	}
	if(isIntegers(other.value)==false)
	{
	    alert("Please enter a valid amount");
		other.focus();
		other.select();
		return false;
	}
	if(other.value.length >0){
		countPro++;
		if(otChk1==false){
		alert("Please Select the type of cover whether Fire,Theft or Repair");
		other.focus();
		return false;
		}
	}
	

if((valuable.value.length==0) && (tv.value.length==0) && (dvd.value.length==0) && (music.value.length==0) && (pc.value.length==0) && (ac.value.length==0) && (refrig.value.length==0) && (wm.value.length==0) && (micro.value.length==0) && (other.value.length==0)){
	alert("Minimum Two Products must be Insured");
	return false;
}

 if(valuable.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		valuable.focus();
		valuable.select();
		return false;
	}
	if(isIntegers(valuable.value)==false)
	{
	    alert("Please enter a valid amount");
		valuable.focus();
		valuable.select();
		return false;
	}
	
	
	
//alert(countPro);
//To Validate Electronic Appliances

 if(tv.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		tv.focus();
		tv.select();
		return false;
	}
	if(isIntegers(tv.value)==false)
	{
	    alert("Please enter a valid amount");
		tv.focus();
		tv.select();
		return false;
	}
	
	

	
 if(dvd.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		dvd.focus();
		dvd.select();
		return false;
	}
	if(isIntegers(dvd.value)==false)
	{
	    alert("Please enter a valid amount");
		dvd.focus();
		dvd.select();
		return false;
	}
	
 if(music.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		music.focus();
		music.select();
		return false;
	}
	if(isIntegers(music.value)==false)
	{
	    alert("Please enter a valid amount");
		music.focus();
		music.select();
		return false;
	}
	


	 if(pc.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		pc.focus();
		pc.select();
		return false;
	}
	if(isIntegers(pc.value)==false)
	{
	    alert("Please enter a valid amount");
		pc.focus();
		pc.select();
		return false;
	}
	
	
	if(countPro < 2){
	alert("Mimimum Two Products Must Be Insured");
	return false;
	}
	
	 if((firecount.value <= 0 || firecount.value.length == 0) || (repaircount.value <= 0 || repaircount.value.length ==0))
		{
				alert("Minimum Two Coverage among Fire,Theft or Repair is Mandatory");
				return false;
		}


	if(addCoveryes.checked==false && addCoverno.checked==false){
	alert("Please Select Additional Cover");
	return false;
	}

if(addCoveryes.checked==true){
	if((baggage.value.length==0) && (pa.value.length==0) && (liability.value.length==0) && (glass.value.length==0) && (pedalcycle.value.length==0) && (money.value.length==0) && (purchase.value.length==0) && (fg.value.length==0) && (workmen.value.length==0) && (rent.value.length==0) &&(terrorYes==false)){
	alert("If You Select Additional Cover as Yes.Coverage Amount for One Cover is Compulsory");
	return false;
	}

	//Baggage Loss
	if(baggage.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		baggage.focus();
		baggage.select();
		return false;
	}
	if(isIntegers(baggage.value)==false)
	{
	    alert("Please enter a valid amount");
		baggage.focus();
		baggage.select();
		return false;
	}

	//PA Cover
	if(pa.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		pa.focus();
		pa.select();
		return false;
	}
	if(isIntegers(pa.value)==false)
	{
	    alert("Please enter a valid amount");
		pa.focus();
		pa.select();
		return false;
	}

	//Liability 
	if(liability.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		liability.focus();
		liability.select();
		return false;
	}
	if(isIntegers(liability.value)==false)
	{
	    alert("Please enter a valid amount");
		liability.focus();
		liability.select();
		return false;
	}

	//Glass
	if(glass.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		glass.focus();
		glass.select();
		return false;
	}
	if(isIntegers(glass.value)==false)
	{
	    alert("Please enter a valid amount");
		glass.focus();
		glass.select();
		return false;
	}

	//Pedal Cycle
	if(pedalcycle.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		pedalcycle.focus();
		pedalcycle.select();
		return false;
	}
	if(isIntegers(pedalcycle.value)==false)
	{
	    alert("Please enter a valid amount");
		pedalcycle.focus();
		pedalcycle.select();
		return false;
	}

	//Money
	if(money.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		money.focus();
		money.select();
		return false;
	}
	if(isIntegers(money.value)==false)
	{
	    alert("Please enter a valid amount");
		money.focus();
		money.select();
		return false;
	}

	//Purchase Protection
	if(purchase.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		purchase.focus();
		purchase.select();
		return false;
	}
	if(isIntegers(purchase.value)==false)
	{
	    alert("Please enter a valid amount");
		purchase.focus();
		purchase.select();
		return false;
	}

	//Fidelity
	if(fg.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		fg.focus();
		fg.select();
		return false;
	}
	if(isIntegers(fg.value)==false)
	{
	    alert("Please enter a valid amount");
		fg.focus();
		fg.select();
		return false;
	}

	//Workmen
	if(workmen.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		workmen.focus();
		workmen.select();
		return false;
	}
	if(isIntegers(workmen.value)==false)
	{
	    alert("Please enter a valid amount");
		workmen.focus();
		workmen.select();
		return false;
	}


	//Rent
	if(rent.value.length >7){
		alert("Coverage Value Should be less than or equal to 7 digits");
		rent.focus();
		rent.select();
		return false;
	}
	if(isIntegers(rent.value)==false)
	{
	    alert("Please enter a valid amount");
		rent.focus();
		rent.select();
		return false;
	}

}

}

}

//Validate Common Method

function isIntegers(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function isEmpty(s){ 
	return ((s == null) || (s.length == 0))
}