// JavaScript Document
function chkEmail(eml)
{
	var re = /^[0-9a-zA-Z\-\.\_]+@[0-9a-zA-Z\-]+\.[0-9a-zA-Z\-\.]+$/;
	if (!eml.match(re)) 
	return 0;
	else
	return 1;

}

function chkText(text)
{
var rexpr =/^[0-9a-zA-Z\s]+$/;
if (!text.match(rexpr))
return 0;
else
return 1;
}

function chkCharacter(charr)
{
	var expch =/^[a-zA-Z\s]+$/;
	if (!charr.match(expch))
	return 0;
	else
	return 1;
}
function chkNum(num)
{
	var rexp = /^[0-9\(\)\+\-\ \\]+$/;
	if (!num.match(rexp))
	return 0;
	else
	return 1;
}


function chkEmpty(txt)
{
if (txt=="")
   return 0;
else
  return 1;
}


function CheckContact()
	{
	var  errormsg = "";
	Form = document.frm_mail;
//---------------------Name-------------------------------		
	if (!chkEmpty(Form.name.value))
		errormsg = errormsg + "Error: Please Enter Name. \n";
		
		if (chkEmpty(Form.name.value))
		if(!chkCharacter(Form.name.value))
			errormsg = errormsg + "Error: Invalid Input For Name Please Enter Character Only. \n";
//--------------------------------------------------------------

//---------------------Company Name-------------------------------	
	if (chkEmpty(Form.cname.value))
		if(!chkText(Form.cname.value))
			errormsg = errormsg + "Error: Invalid input for Company Name. \n";
//--------------------------------------------------------------

//---------------------phone------------------------------------	
	if (chkEmpty(Form.phone.value))
		if(!chkNum(Form.phone.value))
			errormsg = errormsg + "Error: Phone number should be in Number. \n";
//--------------------------------------------------------------

//---------------------Email-------------------------------	
	if (!chkEmpty(Form.email.value))
		errormsg = errormsg + "Error: Please Enter Email Address. \n";

	if (chkEmpty(Form.email.value))
		if (!chkEmail(Form.email.value))
			errormsg = errormsg + "Error: Please Enter Valid Email Address. \n";
//--------------------------------------------------------------

//---------------------comments-------------------------------			
	if (!chkEmpty(Form.comments.value))
		errormsg = errormsg + "Error: Please Enter Comments. \n";
		
/*		if (chkEmpty(Form.comments.value))
		if(!chkText(Form.comments.value))
			errormsg = errormsg + "Error: Invalid input for Comments. \n";
			
			
	if (chkEmpty(Form.comments.value))
		{
		inputStr = Form.comments.value;
		strlength= inputStr.length;
			if (strlength > 600)
			{
				Form.comments.value=inputStr.substring(0,600);
				errormsg =errormsg + "Error: The character limit is 600.";
				
			}
		}*/
//--------------------------------------------------------------



	if (errormsg == "")
	{
		Form.action = "contact_mail.php" ;
		Form.submit();
		
	}
	else
	{
		alert ( errormsg );
	}

}