// 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 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(val)
{
    //alert("Please enter a valid phone number");
    if(val==null)
    {
        //alert("Please enter your phone number");
        return false;
    }
    for (var i = 0; i < val.length; i++) 
    {
        var ch = val.charAt(i)
        if (i == 0 && ch == "-")
        {
            continue
        }
        if (ch < "0" || ch > "9")
        {
            return false
        }
    }
    return true
}	
	
function validate(){
var emailID=document.tactical.email;
var txtPhone=document.tactical.phone;

if(document.tactical.username.value==""){
		alert("Please Enter Your Full Name");
		document.tactical.username.focus();
		return false;
	}else if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address");
		emailID.focus();
		return false;
	}else if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}else if ((txtPhone.value==null)||(txtPhone.value=="")){
		alert("Please Enter your Phone Number");
		txtPhone.focus();
		return false;
	}else if (isInteger(txtPhone.value)==false){
		alert("Please Enter a Valid Phone Number");
		txtPhone.value="";
		txtPhone.focus();
		return false;
	}else if(document.tactical.usercomment.value==""){
		alert("Please Enter Your Enquiry Details");
		document.tactical.usercomment.focus();
		return false;
	}else{
	return true;
	}
}

function maillist(){
	var emailID=document.joinmail.entermail;
	if ((emailID.value==null)||(emailID.value=="")){
			alert("Please Enter your Email Address");
			emailID.focus();
			return false;
		}else if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			return false;
		}else{
			return true;
		}

	}
