    function isBlank(s)
    {

        var len=s.length
        var i

        for(i=0;i < len;i++)
        {
            if(s.charAt(i)!=" ") return false

        }
            return true
    }
    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
	}
    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 validate(fieldName,fieldValue)
    {

        if(isBlank(fieldValue))
        {
            alert(fieldName+" cannot be left blank.")
            return false
        }

        
        return true

        
    }

    function validateform1(){
    
        if(!validate("Name",document.form1.name.value))
        {
            document.form1.name.focus();
            return false;
        }
        if(!validate("E-Mail",document.form1.email.value))
        {
            document.form1.email.focus();
            return false;
        }
        if(validate("E-Mail",document.form1.email.value))
        {
            if (echeck(document.form1.email.value)==false)
            {
                    document.form1.email.value=""
                    document.form1.email.focus()
                    return false;
            }

        }
        
        if(!validate("Comments",document.form1.comments.value))
        {
            document.form1.comments.focus();
            return false;
        }
        
       

		 return true;
}



function validateform2(){
    
        if(!validate("Name",document.form2.name.value))
        {
            document.form2.name.focus();
            return false;
        }
        if(!validate("E-Mail",document.form2.email.value))
        {
            document.form2.email.focus();
            return false;
        }
        if(validate("E-Mail",document.form2.email.value))
        {
            if (echeck(document.form2.email.value)==false)
            {
                    document.form2.email.value=""
                    document.form2.email.focus()
                    return false;
            }

        }
        
        if(!validate("E-Mail",document.form2.msg_for_email.value))
        {
            document.form2.msg_for_email.focus();
            return false;
        }
        if(validate("E-Mail",document.form2.msg_for_email.value))
        {
            if (echeck(document.form2.msg_for_email.value)==false)
            {
                    document.form2.msg_for_email.value=""
                    document.form2.msg_for_email.focus()
                    return false;
            }

        }
        
        if(!validate("Comments",document.form2.comments.value))
        {
            document.form2.comments.focus();
            return false;
        }
        
       

		 return true;
}
	

