
function validate_form(thisform)
	{
		with (thisform)
			{
				if (emptyvalidation(contact_name,"Please enter in your CONTACT NAME.")==false) {contact_name.focus(); return false;};
				if (lengthRestriction(contact_name,0,35,"You have entered more than 35 Characters in the CONTACT NAME field, please reduce your text.")==false) {contact_name.focus(); return false;};
				if (emptyvalidation(company,"Please enter in your COMPANY.")==false) {company.focus(); return false;};
				if (lengthRestriction(company,0,35,"You have entered more than 35 Characters in the COMPANY field, please reduce your text.")==false) {company.focus(); return false;};
//				if (emptyvalidation(shipping_addr,"Please enter in your SHIPPING ADDRESS.")==false) {shipping_addr.focus(); return false;};
//				if (lengthRestriction(shipping_addr,0,100,"You have entered more than 100 Characters in the SHIPPING ADDRESS field, please reduce your text.")==false) {shipping_addr.focus(); return false;};
				if (emptyvalidation(business_phone,"Please enter in your BUSINESS PHONE.")==false) {business_phone.focus(); return false;};
				if (lengthRestriction(business_phone,0,15,"You have entered more than 15 Characters in the BUSINESS PHONE field, please reduce your text.")==false) {business_phone.focus(); return false;};
				if (lengthRestriction(fax,0,15,"You have entered more than 15 Characters in the FAX field, please reduce your text.")==false) {fax.focus(); return false;};
//				if (emptyvalidation(fax,"Please enter in your FAX.")==false) {fax.focus(); return false;};
//				if (lengthRestriction(fax,0,15,"You have entered more than 15 Characters in the FAX field, please reduce your text.")==false) {fax.focus(); return false;};
//				if (emptyvalidation(mobile,"Please enter in your MOBILE.")==false) {mobile.focus(); return false;};
				if (lengthRestriction(mobile,0,15,"You have entered more than 15 Characters in the MOBILE field, please reduce your text.")==false) {mobile.focus(); return false;};
				if (emptyvalidation(email_addr,"Please enter in your EMAIL ADDRESS.")==false) {email_addr.focus(); return false;};
				if (emailvalidation(email_addr,"Your email address is not valid, please retype your email address.")==false) {email_addr.focus(); return false;};
				if (lengthRestriction(email_addr,0,40,"You have entered more than 40 Characters in the EMAIL ADDRESS field, please reduce your text.")==false) {email_addr.focus(); return false;};
//				if (emptyvalidation(make_model,"Please enter in your MAKE n MODEL.")==false) {make_model.focus(); return false;};
//				if (lengthRestriction(make_model,0,100,"You have entered more than 100 Characters in the MAKE n MODEL field, please reduce your text.")==false) {make_model.focus(); return false;};
//				if (emptyvalidation(serial_numb,"Please enter in your SERIAL NUMBER.")==false) {serial_numb.focus(); return false;};
//				if (lengthRestriction(serial_numb,0,50,"You have entered more than 50 Characters in the SERIAL NUMBER field, please reduce your text.")==false) {serial_numb.focus(); return false;};
//				if (emptyvalidation(part_numb,"Please enter in your PART NUMBER.")==false) {part_numb.focus(); return false;};
//				if (lengthRestriction(part_numb,0,50,"You have entered more than 50 Characters in the PART NUMBER field, please reduce your text.")==false) {part_numb.focus(); return false;};
//				if (emptyvalidation(quantity,"Please enter in your QUANTITY.")==false) {quantity.focus(); return false;};
//				if (lengthRestriction(quantity,0,5,"You have entered more than 5 Characters in the QUANTITY field, please reduce your text.")==false) {quantity.focus(); return false;};
//				if (emptyvalidation(other_info,"Please enter in your NAME.")==false) {other_info.focus(); return false;};				if (lengthRestriction(quantity,0,5,"You have entered more than 5 Characters in the QUANTITY field, please reduce your text.")==false) {quantity.focus(); return false;};
				if (lengthRestriction(other_info,0,1001,"You have entered more than 1000 Characters in the OTHER INFORMATION field, please reduce your text.")==false) {other_info.focus(); return false;};

//	--			if (emailvalidation(Email,"Illegal E-mail")==false) {Email.focus(); return false;};
//	--			if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
//	--			if (digitvalidation(Digits,4,4,"You MUST enter 4 numbers","I")==false) {Digits.focus(); return false;};
			}
	}

function emailvalidation(entered, alertbox)
	{
		with (entered)
			{
				apos=value.indexOf("@"); 
				dotpos=value.lastIndexOf(".");
				lastpos=value.length-1;
				if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
					{if (alertbox) {alert(alertbox);} return false;}
				else {return true;}
			}
	} 

// If the element's string matches the regular expression it is numbers and letters
function isAlphanumeric(entered, alertbox){
	var alphaExp = /./;
	if(entered.value.match(alphaExp)){
		return true;
	}else{
		alert(alertbox);
		entered.focus();
		return false;
	}
}

function lengthRestriction(entered, min, max,alertbox){
	var uInput = entered.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert(alertbox);
		entered.focus();
		return false;
	}
}


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)
// Emptyfield Validation 
	{
		with (entered)
			{
				if (value==null || value=="")
					{if (alertbox!="") {alert(alertbox);} return false;}
				else {return true;}
			}
	} 
