// 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]+$/;
	if (!charr.match(expch))
	return 0;
	else
	return 1;
}


function chkEmpty(txt)
{
if (txt=="")
   return 0;
else
  return 1;
}

function chkNum(num)
{
	var rexp = /^[0-9]+$/;
	if (!num.match(rexp))
	return 0;
	else
	return 1;
}



function CheckForm()
{
	var  errormsg = "";
	Form = document.form1;
	
	
//	if (!chkEmpty(Form.companyname.value))
//		errormsg = errormsg + "Please Enter Company Name. \n";
	
	if (chkEmpty(Form.companyname.value))
		if(!chkText(Form.companyname.value))
			errormsg = errormsg + "Invalid input for company name. \n";
	
	if (!chkEmpty(Form.contact.value))
		errormsg = errormsg + "Please Enter Contact Name. \n";
		
		if (chkEmpty(Form.contact.value))
		if(!chkText(Form.contact.value))
			errormsg = errormsg + "Invalid input for contact name. \n";
	

	//if (!chkEmpty(Form.address.value))
//		errormsg = errormsg + "Enter Address. \n";
//		
//		if (chkEmpty(Form.address.value))
//		if(!chkText(Form.address.value))
//			errormsg = errormsg + "Invalid input for address. \n";
//	
//
//		
//	if (!chkEmpty(Form.city.value))
//		errormsg = errormsg + "Enter City. \n";
//		
//		if (chkEmpty(Form.city.value))
//		if(!chkText(Form.city.value))
//			errormsg = errormsg + "Invalid input for city. \n";
//			
//		
//	if (!chkEmpty(Form.zip.value))
//		errormsg = errormsg + "Enter Zip. \n";
//		
//		if (chkEmpty(Form.zip.value))
//		if(!chkNum(Form.zip.value))
//			errormsg = errormsg + "Zip code should be in Number. \n";

	if (!chkEmpty(Form.phone.value))
		errormsg = errormsg + "Please Enter Phone Number. \n";
		
		if (chkEmpty(Form.phone.value))
		if(!chkNum(Form.phone.value))
			errormsg = errormsg + "Phone number should be in Number. \n"; 

	if (!chkEmpty(Form.email.value))
		errormsg = errormsg + "Please Enter Email Address. \n";

	if (chkEmpty(Form.email.value))
		if (!chkEmail(Form.email.value))
			errormsg = errormsg + "Enter Valid Email Address. \n";

//	if (!chkEmpty(Form.url.value))
//		errormsg = errormsg + "Please Enter URL. \n";




	if (errormsg == "")
	{
		Form.action = "http://www.typicity.com/smallbusiness/Business.aspx" ;
		Form.submit();
	}
	else
	{
		alert ( errormsg );
	}

}
	
	function checkemail()
	{
	var  errormsg = "";
	Form = document.form2;
	
	
	if (!chkEmpty(Form.emailFld.value))
		errormsg = errormsg + "Enter E-Mail. \n";

	if (chkEmpty(Form.emailFld.value))
		if (!chkEmail(Form.emailFld.value))
			errormsg = errormsg + "Enter Valid Email Address. \n";
			
	if (!chkEmpty(Form.nameFld.value))
		errormsg = errormsg + "Enter Name. \n";
		
			if (chkEmpty(Form.nameFld.value))
				if(!chkText(Form.nameFld.value))
			errormsg = errormsg + "Invalid input for name. \n";
	
		
	if (!chkEmpty(Form.messageFld.value))
		errormsg = errormsg + "Enter Message. \n";
		
		if (chkEmpty(Form.messageFld.value))
		if(!chkText(Form.messageFld.value))
			errormsg = errormsg + "Invalid input for message. \n";
	


	if (errormsg == "")
	{
		Form.action = "http://www.typicity.com/smallbusiness/EmailArticle.aspx" ;
		Form.submit();
		alert("Thanks. The Article has been sent.");

	}
	else
	{
		alert ( errormsg );
	}

}


function CheckContact()
	{
	var  errormsg = "";
	Form = document.form1;
	
	if (!chkEmpty(Form.fName.value))
		errormsg = errormsg + "Enter First Name. \n";
		
		if (chkEmpty(Form.fName.value))
		if(!chkCharacter(Form.fName.value))
			errormsg = errormsg + "Enter Character Only. \n";
			
		
		if (chkEmpty(Form.lName.value))
		if(!chkCharacter(Form.lName.value))
			errormsg = errormsg + "Enter Character Only. \n";
		
		
	if (!chkEmpty(Form.eMail.value))
		errormsg = errormsg + "Enter E-Mail. \n";

	if (chkEmpty(Form.eMail.value))
		if (!chkEmail(Form.eMail.value))
			errormsg = errormsg + "Enter Valid Email Address. \n";
			
	if (!chkEmpty(Form.messageFld.value))
		errormsg = errormsg + "Enter Message. \n";
		
		if (chkEmpty(Form.messageFld.value))
		if(!chkText(Form.messageFld.value))
			errormsg = errormsg + "Invalid input for message. \n";
		
	if (chkEmpty(Form.phoneNo.value))
		if(!chkNum(Form.phoneNo.value))
			errormsg = errormsg + "Phone number should be in Number. \n";


	if (errormsg == "")
	{
		Form.action = "http://www.typicity.com/smallbusiness/contact.aspx" ;
		Form.submit();
		
	}
	else
	{
		alert ( errormsg );
	}

}
	
	
	
	function CheckSearch()
	{
	var  errormsg = "";
	Form = document.frm_search;
	
	if (!chkEmpty(Form.textFld.value))
		errormsg = errormsg + "Enter Keyword. \n";
		
	if (errormsg == "")
	{
		Form.action = "http://www.typicity.com/smallbusiness/search.aspx" ;
		Form.submit();
		
	}
	else
	{
		alert ( errormsg );
	}

}