// JavaScript Document

function supp_Validation(){
	if ((s_validName()==true) && (s_emailLength()==true) && (s_emailValid(document.form1.email.value)==true) && (sub_textValid()==true) && (s_textValid()==true)){
		return true;
	}else{
		return false;
	}
}

function s_validName(){
	if ((document.form1.name.value=="") || (document.form1.name.value==null)){
		alert("Please enter your Name.");
		document.form1.name.focus();
		return false;
	}
	return true;
}  
 
function s_emailLength(){
	var emailID=document.form1.email.value;
	if ((emailID==null)||(emailID=="")){
		alert("Please enter your Email address.");
		document.form1.email.focus();
		return false;
	}
	
	if ((emailID.length < 5)){
		alert("Email address should be a valid one and more than 5 characters.");
		document.form1.email.focus();
		return false;
	}
	return true;
}
 
function s_emailValid(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 Email address. Please try again.");
	   document.form1.email.focus();
	   return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}
	if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}
	if (str.indexOf(" ")!=-1){
		alert("Invalid Email address. Please try again.");
	  	document.form1.email.focus();		
		return false;
	}
 	return true;
}

function sub_textValid(){
	if ((document.form1.subject.value=="") || (document.form1.subject.value==null)){
		alert("Please enter subject.");
		document.form1.subject.focus();
		return false;
	}
	return true;
}

function s_textValid(){
	if ((document.form1.content.value=="") || (document.form1.content.value==null)){
		alert("Please enter your Questions/Comments.");
		document.form1.content.focus();
		return false;
	}
	return true;
}