function echeck1(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 chkcontact()
{	
	var emailID=document.contact.c_email;
	if(document.contact.c_name.value == "")
	{
		alert("Name cannot be blank!");
		document.contact.c_name.focus();
		return false;
	}
	if(document.contact.c_email.value != "")
	{
		if (echeck1(emailID.value)==false)
		{
			emailID.value="";
			emailID.focus();
			return false;
		}
	}
	if(document.contact.c_phone.value!="")
	{
			var len = document.contact.c_phone.value;
			var len2 = len.length;
			for(i=0;i<len2;i++)
			{
				ch = len.substring(i, i+1);

				if(ch >= 0 && ch <= 9 || ch == '-')
				{
					al = "hh";
				}
				else
				{
					al = "gg";
					break;
				}
			}
			if(al == 'gg')
			{
				alert("Enter a valid phone number, please!");
				document.contact.c_phone.focus();
				return false;
			}
	}
	if(document.contact.c_phone.value == "")
	{
		if(document.contact.c_email.value == "")
		{
		alert("Both Phone No. and email cannot be blank!");
		document.contact.c_phone.focus();
		return false;
		}
		else
		{
			if (echeck1(emailID.value)==false)
			{
			emailID.value="";
			emailID.focus();
			return false;
			}
		}
	}
	if(document.contact.c_message.value == "")
	{
		alert("Message cannot be blank!");
		document.contact.c_message.focus();
		return false;
	}
	if(document.contact.code.value == "")
	{
		alert("Security code cannot be blank!");
		document.contact.code.focus();
		return false;
	}
		
}
function additional()
{
	document.getElementById('add').style.display = "block";
	document.getElementById('butt').style.display = "none";
}
function check_keydown(evt)
{
	a = evt.keyCode;
    if(a == 13){
        document.contact.submit();
    }
}
