/* FORM JAVASCRIPT
   Nishad E K
   Dec 29, 2006

*******************************/

/* set submit button styles
--------------------------- */
function btnOver(obj)
{
	obj.style.backgroundColor='#FFFF9B';
	obj.style.color='#333333';
	obj.style.borderColor='#FFDF04';	
	obj.style.cursor='pointer';
}
function btnOut(obj)
{
	obj.style.backgroundColor='#E4E8EB';
	obj.style.color='#1F4785';
	obj.style.borderColor='#CDD8E1';	
}


/* highlight focus textboxes
--------------------------- */
function inputFocus(obj)
{
	obj.style.backgroundColor='#FFFFC1';
	obj.style.color='#000000';
	obj.style.fontWeight='bold';
}
function inputBlur(obj)
{
	obj.style.backgroundColor='#FFFFFF';
	obj.style.color='#333333';
	obj.style.fontWeight='normal';
}



function checkForm() {

var emailID=document.form1.cemail
name = document.getElementById("name").value;
email = document.getElementById("cemail").value;
message = document.getElementById("message").value;

if (name == "") {

hideAllErrors();  

document.getElementById("name_error").style.display = "inline";
document.getElementById("name").select();
document.getElementById("name").focus();

return false;
} else if (echeck(emailID.value)==false) {
emailID.value=""
emailID.focus()
return false
} else if (message == "") {
hideAllErrors();

document.getElementById("message_error").style.display = "inline"; 
document.getElementById("message").select();
document.getElementById("message").focus();
return false;
} 
return true;
}
 
function hideAllErrors() {
document.getElementById("name_error").style.display = "none" 
document.getElementById("email_error1").style.display = "none"
document.getElementById("message_error").style.display = "none"
}

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") -->
		   hideAllErrors();
		   document.getElementById("email_error1").style.display = "inline"; 
		   document.getElementById("cemail").select();
		   document.getElementById("cemail").focus();
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   <!--alert("Invalid E-mail ID") -->
		    hideAllErrors();
		   document.getElementById("email_error1").style.display = "inline"; 
		   document.getElementById("cemail").select();
		   document.getElementById("cemail").focus();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    <!--alert("Invalid E-mail ID") -->
		     hideAllErrors();
		   document.getElementById("email_error1").style.display = "inline"; 
		   document.getElementById("cemail").select();
		   document.getElementById("cemail").focus();
			return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    <!--alert("Invalid E-mail ID") -->
		     hideAllErrors();
		   document.getElementById("email_error1").style.display = "inline"; 
		   document.getElementById("cemail").select();
		   document.getElementById("cemail").focus();
			return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    <!--alert("Invalid E-mail ID") -->
		     hideAllErrors();
		   document.getElementById("email_error1").style.display = "inline"; 
		   document.getElementById("cemail").select();
		   document.getElementById("cemail").focus();
			return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   <!-- alert("Invalid E-mail ID") -->
		     hideAllErrors();
		   document.getElementById("email_error1").style.display = "inline"; 
		   document.getElementById("cemail").select();
		   document.getElementById("cemail").focus();
			return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    <!--alert("Invalid E-mail ID") -->
		     hideAllErrors();
		   document.getElementById("email_error1").style.display = "inline"; 
		   document.getElementById("cemail").select();
		   document.getElementById("cemail").focus();
			return false
		 }

 		 return true					
	}


