
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

function checkDetails()
{	
	
	theForm = window.document.frmcontact;
	if (isEmpty(theForm.productname, 'Please Enter the Product Name') || isEmpty(theForm.productcode, 'Please enter the product code') || isEmpty(theForm.purchased, 'Please Enter the Retailer Purchased From') || isEmpty(theForm.date, 'Please Enter the Date Purchased') || isEmpty(theForm.name, 'Please Enter your Name') || isEmpty(theForm.address, 'Please Enter the Your Address') || isEmpty(theForm.email, 'Please Enter the Your Email')) {
			return;
		} else {
		
			
				var x = theForm.email.value;
				var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				if (!(filter.test(x))){
					alert('Incorrect email address format');

				} else {
					theForm.submit();
				}
			 
		}
	
	
}

function checkTradeDetails()
{	
	
	theForm = window.document.frmcontact;
	if (isEmpty(theForm.firstname, 'Please Enter Your First Name') || isEmpty(theForm.lastname, 'Please enter Last Name') || isEmpty(theForm.company, 'Please Enter Your Company Name') || isEmpty(theForm.hear, 'Please Enter Your Trading Type') || isEmpty(theForm.address, 'Please Enter your Address') || isEmpty(theForm.tele, 'Please Enter Your Telephone Number') || isEmpty(theForm.email, 'Please Enter the Your Email')) {
			return;
		} else {
		
			
				var x = theForm.email.value;
				var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
				if (!(filter.test(x))){
					alert('Incorrect email address format');

				} else {
					theForm.submit();
				}
			 
		}
	
	
}
