// JavaScript Document
function validate(){
	var st=document.contact.email.value;
	
	if(document.contact.name.value== "")
	{
	alert("Please enter your name");
	document.contact.name.focus();
	document.contact.name.select();
	return false;
	}
	
	
	//Code for PHONE NO.
	var stripped = document.contact.phone.value.replace(/[\(\)\.\-\ ]/g, ''); 
	var illegalChars = /[\W_a-zA-Z]/;	
	if(document.contact.phone.value== "" )
	{
	alert("Contact number should not be left blank.");
	document.contact.phone.focus();
	document.contact.phone.select();
	return false;
	}else if (isNaN(parseInt(stripped)) || (illegalChars.test(document.contact.phone.value))) {
        alert("The contant number should be digit.\n");
        document.contact.phone.focus();
		document.contact.phone.select();
		return false;
    }
	
			
	if(document.contact.email.value=="")
	{
		alert("Please enter your Email");
		document.contact.email.focus();
		document.contact.email.select();
		return false;
	}
	else
	{			
		if(checkEmail(st)!=true)
		{
			alert("Invalid E-Mail  \n"+st);
			document.contact.email.focus();
			document.contact.email.select();
			return false; 
		 }
	}
	
	if(document.contact.address.value== "")
	{
	alert("Please enter your address");
	document.contact.address.focus();
	document.contact.address.select();
	return false;
	}
	
	if(document.contact.city.value== "")
	{
	alert("Please enter your city");
	document.contact.city.focus();
	document.contact.city.select();
	return false;
	}
	
		
	//Code for zip code
	var stripped = document.contact.zip.value.replace(/[\(\)\.\-\ ]/g, ''); 
	var illegalChars = /[\W_a-zA-Z]/;	
	if(document.contact.zip.value== "" )
	{
	alert("Zip should not be left blank.");
	document.contact.zip.focus();
	document.contact.zip.select();
	return false;
	}else if (isNaN(parseInt(stripped)) || (illegalChars.test(document.contact.zip.value))) {
        alert("The zip should be digit.\n");
        document.contact.zip.focus();
		document.contact.zip.select();
		return false;
    }
	
	if(document.contact.besttime.selectedIndex < 0)
	{
	alert("Please select which time is to contact?");
	document.contact.besttime.focus();
	return false;
	}
	
	if(document.contact.besttime.selectedIndex == 0)
	{
	alert("Please select which time is to contact?");
	document.contact.besttime.focus();
	return false;
	}
	
	if(document.contact.time.value == "")
	{
	alert("Please enter your desire time to finish the project");
	document.contact.time.focus();
	document.contact.time.select();
	return false;
	}
	
	
}

function checkEmail(str)
{
	if((str.indexOf("@")==-1))
	{
		fstr="Please Enter @ or .";
		return false;
	}
	else
	{
	if((str.indexOf("@") == 0) )
	{
		fstr="@  Cannot Be first";
		alert(fstr);
		return false;
	}
	if((str.indexOf("@") == (str.length-1)))
	{
		fstr="@ Cannot Be Last";
		return false;
	}

	
	if((str.indexOf("@")+1) == str.indexOf("."))
	{
		fstr="@. IS Invalid Email";
		return false;
	}
	}
	var cp=0;					
	if(cp==2)
	{
		fstr="@ cannnot be repeated";
		return false;
	}
	return true;
}

document.write('');
document.write('');