function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
	var digits = "0123456789";     // non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";   // characters which are allowed in international phone numbers
										// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";   // Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;


function isInteger(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 stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail;
	var fname=document.frmSample.txtfName;
	var lname=document.frmSample.txtlName;
	var sname=document.frmSample.txtsName;
	var addr=document.frmSample.txtsAddress;
	var city=document.frmSample.txtsCity;
	var state=document.frmSample.txtsState;
	var country=document.frmSample.txtsCountry;
	var std_no=document.frmSample.txtsStudents;
	var phone=document.frmSample.txtPhone;
	var subject=document.frmSample.txtSubject;
	var purpose=document.frmSample.optPurpose;
	var invalid = " ";
	
	if ( purpose.value == "Select" )
	  {
		    alert("Please enter your Purpose.")
			purpose.focus()	
			return false;
	  }
	  
    if ( purpose.value == "Quote" )
	{
		if ((sname.value==null)||(sname.value==""))
			{			
				alert("Please enter your School Name.")
				sname.value=""
				sname.focus()	
				return false;		
			}
			
		//if (sname.value.indexOf(invalid) > -1) 
//			{
//			alert("Sorry, spaces are not allowed in School Name.")
//			sname.value=""
//			sname.focus()
//			return false;
//			}
			
		if ((addr.value==null)||(addr.value==""))
			{			
				alert("Please enter your School Address.")
				addr.value=""
				addr.focus()	
				return false;		
			}
		
		//if (addr.value.indexOf(invalid) > -1) 
//			{
//			alert("Sorry, spaces are not allowed in School Address.")
//			addr.value=""
//			addr.focus()
//			return false;
//			}
			
		if ((city.value==null)||(city.value==""))
			{			
				alert("Please enter your School City.")
				city.value=""
				city.focus()	
				return false;		
			}
			
		//if (city.value.indexOf(invalid) > -1) 
//			{
//			alert("Sorry, spaces are not allowed in School City.")
//			city.value=""
//			city.focus()
//			return false;
//			}
			
		if ((state.value==null)||(state.value==""))
			{			
				alert("Please enter your School State.")
				state.value=""
				state.focus()	
				return false;		
			}
			
		//if (state.value.indexOf(invalid) > -1) 
//			{
//			alert("Sorry, spaces are not allowed in School State.")
//			state.value=""
//			state.focus()
//			return false;
//			}	
			
		if ((country.value==null)||(country.value==""))
			{			
				alert("Please enter your School Country.")
				country.value=""
				country.focus()	
				return false;		
			}
			
		if (country.value.indexOf(invalid) > -1) 
			{
			alert("Sorry, spaces are not allowed in School Country.")
			country.value=""
			country.focus()
			return false;
			}	
		
			
		if ((std_no.value==null)||(std_no.value==""))
			{			
				alert("Please enter No. of Students.")
				std_no.value=""
				std_no.focus()	
				return false;		
			}
			
			
		if (!isInteger(std_no.value))
			{			
				alert("Please enter No. of Students in numeric.")
				std_no.value=""
				std_no.focus()	
				return false;		
			}
			
		if (std_no.value.indexOf(invalid) > -1) 
			{
			alert("Sorry, spaces are not allowed in No of Students.")
			std_no.value=""
			std_no.focus()
			return false;
			}	
		
				
	}
	
	if ((fname.value==null)||(fname.value==""))
	{			
		alert("Please enter your First Name")
		fname.value=""
		fname.focus()	
		return false;		
	}
	
	if (fname.value.indexOf(invalid) > -1) 
			{
			alert("Sorry, spaces are not allowed in First Name.")
			fname.value=""
		    fname.focus()
			return false;
			}
			
	if ((lname.value==null)||(lname.value==""))
	{			
		
		alert("Please enter your Last Name.")
		lname.value=""
		lname.focus()	
		return false;		
	}
	
	if (lname.value.indexOf(invalid) > -1) 
			{
			alert("Sorry, spaces are not allowed.")
			lname.value=""
		    lname.focus()
			return false;
			}
		
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}

 
 if ((phone.value==null)||(phone.value=="")){
		alert("Please enter your Phone Number")
		phone.focus()
		return false
	}
	
	//if (checkInternationalPhone(phone.value)==false){
	//	alert("Please enter a Valid Phone Number")
	//	phone.value=""
	//	phone.focus()
	//	return false
	//}
	
	
	if ((subject.value==null)||(subject.value=="")){
		alert("Please enter your Message")
		subject.focus()
		return false
	}
	
		
	
		return true
	
 }