
function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var action = true;
	if (str.indexOf(at)==-1){
	   document.getElementById("emailresult").innerHTML = textLangArray[0];
	   action = false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   document.getElementById("emailresult").innerHTML = textLangArray[0];
	   action = false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		document.getElementById("emailresult").innerHTML = textLangArray[0];
		action = false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		document.getElementById("emailresult").innerHTML = textLangArray[0];
		action = false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		document.getElementById("emailresult").innerHTML = textLangArray[0];
		action = false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		document.getElementById("emailresult").innerHTML = textLangArray[0];
		action = false;
	 }
	
	 if (str.indexOf(" ")!=-1){
		document.getElementById("emailresult").innerHTML = textLangArray[0];
		action = false;
	 }

	 return action;					
}

function validateContactform(){
var action = true;
var isfocus = 0;
var focustext = "";
var frm=document.contactus;

if(trim(document.contactus.uname.value)=="")
{
	document.getElementById("checkuname").innerHTML = textLangArray[1];
	action = false;
	if(!isfocus)
	{
		isfocus = 1;
		focustext = document.contactus.uname;
	}
}

if(trim(document.contactus.email.value)=="")
{
	document.getElementById("emailresult").innerHTML = textLangArray[2];
	action = false;
	if(!isfocus)
	{
		isfocus = 1;
		focustext = document.contactus.email;
	}
}
if (echeck(document.contactus.email.value)==false)
{
	document.contactus.email.value="";
	action = false;
	if(!isfocus)
	{
		isfocus = 1;
		focustext = document.contactus.email;
	}
	
}
		
if(trim(document.contactus.ques.value)=="")
{
	document.getElementById("checkmessage").innerHTML = textLangArray[3];
	action = false;
	if(!isfocus)
	{
		isfocus = 1;
		focustext = document.contactus.ques;
	}
}
if(focustext){
	focustext.focus();}

if(action== true){
	document.contactus.send.value="Send";
	document.contactus.submit();}
return action;
}

function errorDiv(obj,divID)
{
	if((trim(obj.value) != '') && (obj.value != 0)){
		document.getElementById(divID).innerHTML='';
	}	
}