function emailvalidation(entered, alertbox)
{

	with (entered)
	{
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	lastpos=value.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2) 
	{if (alertbox) {alert(alertbox);} return false;}
	else {return true;}
	}
}

/*
function valuevalidation(entered, min, max, alertbox, datatype)
{

	with (entered)
	{
	checkvalue=parseFloat(value);
	if (datatype)
	  {smalldatatype=datatype.toLowerCase();
	   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
	  }
	if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
	{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}
*/


function digitvalidation(entered, min, max, alertbox, datatype)
{

	with (entered)
	{
	checkvalue=parseFloat(value);
	if (datatype)
	  {smalldatatype=datatype.toLowerCase();
	   if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
	  }
	if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
	{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}

function emptyvalidation(entered, alertbox)
{

	with (entered)
	{
	if (value==null || value=="")
	{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}

function formvalidation(thisform)
{
with (thisform)
	{
	if (emptyvalidation(business,"Please provide your Business Name")==false) {business.focus(); return false;};
	if (emptyvalidation(last1,"Please provide your Last Name")==false) {last1.focus(); return false;};
	if (emptyvalidation(first1,"Please provide your First Name")==false) {first1.focus(); return false;};
	if (emptyvalidation(mail_address,"Please provide your Mailing Address")==false) {mail_address.focus(); return false;};
	if (emptyvalidation(mail_city,"Please provide your City")==false) {mail_city.focus(); return false;};
	if (emptyvalidation(mail_state,"Please provide your State")==false) {mail_state.focus(); return false;};
	
	if (digitvalidation(mail_zip,4,6,"You MUST enter 4 to 6 digits Zip Code Number","I")==false) {mail_zip.focus(); return false;};
	
	if (emptyvalidation(ph1,"You MUST enter 10 to 11 digits Phone Number")==false) {ph1.focus(); return false;};
		
	if (emailvalidation(email_pri,"Please provide a valid E-mail Address")==false) {email_pri.focus(); return false;};
		
	//if (digitvalidation(txt_extension,2,4,"You MUST enter 2 to 4 digits Extension Number","I")==false) {txt_extension.focus(); return false;};	
	//if (emptyvalidation(txt_phone,"Please provide your Contact Number")==false) {txt_phone.focus(); return false;};
	//if (emptyvalidation(txt_home_addr,"Please provide your Complete Address")==false) {txt_home_addr.focus(); return false;};
	//if (emptyvalidation(txt_company_name,"Please provide your Company Name")==false) {txt_company_name.focus(); return false;};
	//if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
	//if (digitvalidation(txt_phone,10,15,"You MUST enter 10 to 15 digits Phone Number with the Area Code","I")==false) {txt_phone.focus(); return false;};
	//if (emptyvalidation(txt_msg,"Any Messages?")==false) {txt_msg.focus(); return false;};
	}
}

