function validateName(){
	name = document.getElementById("name").value
	if (isEmpty(name)){
		document.getElementById("nameError").style.color="#FF0000"
		document.getElementById("nameError").innerHTML = " * Name is required."
		fadeNameError();
		document.getElementById("namerow").bgColor="#5A828B"
		return false;
	}else{
		document.getElementById("nameError").innerHTML = ""
		document.getElementById("namerow").bgColor="#FF0000"
		return true;
	}
}

hex=125 // Initial color value.
function fadeNameError(){ 
if(hex>0) { //If color is not black yet
hex-=11; // increase color darkness
document.getElementById("nameError").style.color="rgb(255,"+hex+","+hex+")";
setTimeout("fadeNameError()",40); 
}
else
hex=125 //reset hex value
}

function validateMessage(){
	message = document.getElementById("message").value
	if (isEmpty(message)){
		document.getElementById("messageError").style.color="#FF0000"
		document.getElementById("messageError").innerHTML = " * Message is required."
		fadeMessageError();
		<!--document.getElementById("messagerow").bgColor="#43494f"-->
		document.getElementById("messagerow").bgColor="#5A828B"
		return false;
	}else{
		document.getElementById("messageError").innerHTML = ""
		document.getElementById("messagerow").bgColor="#FF0000"
		return true;
	}
}

hex=125 // Initial color value.
function fadeMessageError(){ 
if(hex>0) { //If color is not black yet
hex-=11; // increase color darkness
document.getElementById("messageError").style.color="rgb(255,"+hex+","+hex+")";
setTimeout("fadeMessageError()",40); 
}
else
hex=125 //reset hex value
}

function validateEmail(){
	if (!validateEmailAction()){
		return
	}
}
function isEmpty(astring){
	if (astring=="") return true;
	else{
		for(var i=0;i<astring.length;i++){
			if (astring[i] != " ") return false;
		}
	}
	return true;
}
function validateEmailAction(){
	var emailID=document.getElementById("email")
	if ((emailID.value==null)||(emailID.value=="")){
		document.getElementById("emailError").style.color="#FF0000"
		document.getElementById("emailError").innerHTML = " * Email is required."
		fadeEmailError();
		document.getElementById("emailrow").bgColor="#5A828B"
		//emailID.focus()
		return false
	}else if (echeck(emailID.value)==false){
		//emailID.value=""
		//emailID.focus()
		return false
	}else{
		document.getElementById("emailError").innerHTML = ""
		document.getElementById("emailrow").bgColor="#FF0000"
		return true
	}
	//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){
		   //document.getElementById("emailError").innerHTML = " * Invalid E-Mail address."
		   fadeInvalidEmail()
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //document.getElementById("emailError").innerHTML = " * Invalid E-Mail address."
		   fadeInvalidEmail()
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //document.getElementById("emailError").innerHTML = " * Invalid E-Mail address."
		    fadeInvalidEmail()
			return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //document.getElementById("emailError").innerHTML = " * Invalid E-Mail address."
		    fadeInvalidEmail()
			return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //document.getElementById("emailError").innerHTML = " * Invalid E-Mail address."
		    fadeInvalidEmail()
			return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //document.getElementById("emailError").innerHTML = " * Invalid E-Mail address."
		    fadeInvalidEmail()
			return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //document.getElementById("emailError").innerHTML = " * Invalid E-Mail address."
		 	fadeInvalidEmail()
		    return false
		 }

 		 return true					
	}
function fadeInvalidEmail(){
		document.getElementById("emailError").style.color="#FF0000"
		document.getElementById("emailError").innerHTML = " *  Invalid email address."
		fadeEmailError();
		document.getElementById("emailrow").bgColor="#5A828B"
}

function fadeEmailError(){ 
if(hex>0) { //If color is not black yet
hex-=11; // increase color darkness
document.getElementById("emailError").style.color="rgb(255,"+hex+","+hex+")";
setTimeout("fadeEmailError()",40); 
}
else
hex=255 //reset hex value
}

function checkMsg1(){
	msglen = document.getElementById("message").value.length
	if (msglen<1){
		document.getElementById("messagerow").bgColor="#FFFFCC"
		document.getElementById("messageError").innerHTML = " *  Please type your message."
		document.getElementById("messageError").style.color="#CCFFCC"
		return false;
	}else{
		document.getElementById("messagerow").bgColor="#FFFFCC"
		document.getElementById("messageError").innerHTML = ""
		return true;
	}
}

function sendMailCheck(){
	message = document.getElementById("message").value
	if (validateName() && validateEmailAction() && checkMsg1()){
		sendMailAction()
	}else{
		return
	}
}


function sendMailCheck(){
	message = document.getElementById("message").value
	if (validateName() && validateEmailAction() && checkMsg1()){
		sendMailAction()
	}else{
		return
	}
}


function sendMailAction(){
	//alert(transfer_no);	
	name=document.getElementById("name").value;
	email=document.getElementById("email").value;
	message=document.getElementById("message").value;
	contact=document.getElementById("about").value;

				document.getElementById("send").innerHTML="Sending..."
				xmlHttp=GetXmlHttpObject();
				if (xmlHttp==null){
					alert ("Browser does not support HTTP Request");
					return;
				}
				var url="send.php";
				url=url+"?action=send&name="+name+"&email="+email+"&message="+message+"about="+about;
				url=url+"&sid="+Math.random();
				xmlHttp.onreadystatechange=stateChangedSendEmail
				xmlHttp.open("GET",url,true)
				xmlHttp.send(null)
			
}

function stateChangedSendEmail(){ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			document.getElementById("send").innerHTML=xmlHttp.responseText
			
		}
	}
	
function GetXmlHttpObject(){
		var xmlHttp=null;
		try
 		{
 			// Firefox, Opera 8.0+, Safari
 		xmlHttp=new XMLHttpRequest();
 		}
		catch (e)
 		{
 			//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}