// JavaScript Document
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")
		   return false
		}

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

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

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

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

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

 		 return true					
	}
	
function ValidateForm(){
	var emailID=document.form1.emailinput
	var msgID=document.form1.msginput
        var phoneID=document.form1.phoneinput
        var companyID=document.form1.companyinput
	var check1=document.form1.check1.checked
	var check2=document.form1.check2.checked
	var check3=document.form1.check3.checked
	var check4=document.form1.check4.checked

	
	if((check1==false)&&(check2==false)&&(check3==false)&&(check4==false)){
		alert("Please Select One or More of the Checkboxes")
		return false
	}
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter a Valid Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
        emailstr = emailID.value
        msgstr = msgID.value
        if ((emailstr.indexOf("seo")!=-1) && (emailstr.indexOf("traffic")!=-1)) {
                alert("You are a SPAMMER!! Your IP has been recorded and reported. Please do not return to this site!")
		emailID.focus()
		return false
        }
        if (msgstr.indexOf("increase traffic")!=-1) {
                alert("You are a SPAMMER!! Your IP has been recorded and reported. Please do not return to this site!")
		msgID.focus()
		return false
        }
        if (msgstr.indexOf("SEO ")!=-1) {
                alert("You are a SPAMMER!! Your IP has been recorded and reported. Please do not return to this site!")
		msgID.focus()
		return false
        }
        if ((msgstr.indexOf("optimization")!=-1) || (msgstr.indexOf("Optimization")!=-1)) {
                alert("You are a SPAMMER!! Your IP has been recorded and reported. Please do not return to this site!")
		msgID.focus()
		return false
        }
        if ((msgstr.indexOf("Google")!=-1) || (msgstr.indexOf("google")!=-1)) {
                alert("You are a SPAMMER!! Your IP has been recorded and reported. Please do not return to this site!")
		msgID.focus()
		return false
        }
        if ((msgstr.indexOf("search engine")!=-1)|| (msgstr.indexOf("Search Engine")!=-1)) {
                alert("You are a SPAMMER!! Your IP has been recorded and reported. Please do not return to this site!")
		msgID.focus()
		return false
        }
        if (msgstr.indexOf("first page")!=-1) {
                alert("You are a SPAMMER!! Your IP has been recorded and reported. Please do not return to this site!")
		msgID.focus()
		return false
        }

        if ((phoneID.value=="0000000000") || (phoneID.value=="000-000-0000")){
		alert("Please Enter a Valid Phone Number")
		phoneID.focus()
		return false
	}
        if (companyID.value=="SEO Company"){
		alert("You are a SPAMMER!! Your IP has been recorded and reported. Please do not return to this site!")
		companyID.focus()
		return false
	}
        if ((msgID.value==null)||(msgID.value=="")){
		alert("Please Enter a Message")
		msgID.focus()
		return false
	}

	return true
 }
