// JavaScript Document

function chkBoxValidate(chkbox)
{	
	//var maxi = document.form1.elements.typehouse.length;
	var maxi = chkbox.length;
	var count = 0 ;
	//alert("start count = "+count) ;
	//alert("max = "+maxi) ;
	
	for(j=0;j<maxi;j++)
	{
		if(chkbox[j].checked == true)
		{
			count++;
		}
	}
	//alert("end Cont = "+count) ;
	if(count > 0)
		return true ;
	else
		return false ;
}


function validate()
{
	if(!chkBoxValidate(document.form1.elements.typehouse))
	{
		alert("Select any type of House") ;		
		document.form1.typehouse[0].focus() ;
		return false ;
	}
	if(document.form1.agehome.value == "")
	{
		alert("Please enter the Age of home") ;
		document.form1.agehome.focus() ;		
		return false ;
	}
	if(!chkBoxValidate(document.form1.elements.security))
	{
		alert("Please specify whether you hae security or not") ;		
		document.form1.security[0].focus() ;
		return false ;
	}
	if(document.form1.downstairwindow.value == "")
	{
		alert("Please enter the downstairs windows in your home") ;
		document.form1.downstairwindow.focus() ;		
		return false ;
	}	
	if(document.form1.eightfoot.value == "")
	{
		alert("Please specify whether the downstairs windows are bay or over 8 foot in length") ;
		document.form1.eightfoot.focus() ;		
		return false ;
	}
	if(document.form1.upstairwindow.value == "")
	{
		alert("Please enter the No. of upstairs windows in your home those are vulnerable/accessible") ;
		document.form1.upstairwindow.focus() ;		
		return false ;
	}	
	if(!chkBoxValidate(document.form1.elements.pet))
	{
		alert("Do you have pets") ;	
		document.form1.pet[0].focus()	;
		return false ;
	}
	if(!chkBoxValidate(document.form1.elements.phone))
	{
		alert("Please specify whether you have a land line connection or not") ;		
		document.form1.phone[0].focus()	;
		return false ;
	}
	if(!chkBoxValidate(document.form1.elements.smokedetectr))
	{
		alert("Please specify whether you want a monitored smoke detector for your home or not") ;	
		document.form1.smokedetectr[0].focus()	;	
		return false ;
	}
	
	
	if(document.form1.name.value == "")
	{
		alert("Please enter Your Name") ;
		document.form1.name.focus() ;		
		return false ;
	}
	if(document.form1.address.value == "")
	{
		alert("Please enter Your Address") ;
		document.form1.address.focus() ;		
		return false ;
	}
	if(document.form1.county.value == "")
	{
		alert("Please enter County") ;
		document.form1.county.focus() ;		
		return false ;
	}
		if(document.form1.contactno.value == "")
	{
		alert("Please enter Contact No.") ;
		document.form1.contactno.focus() ;		
		return false ;
	}
		
	return true ;
}

