 function validateEmail(addr,man,db) 
	{
	if (addr == '' && man) 
	{
	  if (db) alert('Please enter a valid email address');
	  return false;
	}
		                                
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
		                                
	for (i=0; i<invalidChars.length; i++) 
	{
	  if (addr.indexOf(invalidChars.charAt(i),0) > -1) 
	  {
	    if (db) alert('email address contains invalid characters');
	      return false;
	  }
	}
		                                
	for (i=0; i<addr.length; i++) 
	{
	  if (addr.charCodeAt(i)>127) 
	  {
	    if (db) alert("email address contains non ascii characters.");
	      return false;
	  }
	}

	var atPos = addr.indexOf('@',0);
		                                
	if (atPos == -1) 
	{
	  if (db) alert('email address must contain an @');
	    return false;
	}
	if (atPos == 0) 
	{
	  if (db) alert('email address must not start with @');
	    return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) 
	{
	  if (db) alert('email address must contain only one @');
	    return false;
	}

	if (addr.indexOf('.', atPos) == -1) 
	{
	  if (db) alert('email address must contain a period in the domain name');
	    return false;
	}
	if (addr.indexOf('@.',0) != -1) 
	{
	  if (db) alert('period must not immediately follow @ in email address');
	    return false;
	}
	if (addr.indexOf('.@',0) != -1)
	{
	  if (db) alert('period must not immediately precede @ in email address');
	    return false;
	}
	if (addr.indexOf('..',0) != -1) 
	{
	  if (db) alert('two periods must not be adjacent in email address');
	    return false;
	}

	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') 
	{
	  if (db) alert('invalid primary domain in email address');
	    return false;
	}
	return true;
} 

function validatecontactform()
{
	var error = '';
	
	if (document.contactform.telephone_number.value == ''){
		error = 'Please enter telephone number';
		document.contactform.telephone_number.focus();
	}  	
	
    if (!validateEmail(document.contactform.email.value,1,0)){
		error = 'Please enter a valid email address';
		document.contactform.email.focus();
	}
	
	if (document.contactform.address.value == ''){
		error = 'Please enter your address';
		document.contactform.address.focus();
	}  
	
	if (document.contactform.company_name.value == ''){
		error = 'Please enter company name';
		document.contactform.company_name.focus();
	}  
	
	if (document.contactform.contact_name.value == ''){
		error = 'Please enter contact name';
		document.contactform.contact_name.focus();
	} 
	
	if (error == '')
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}

	           		
function validatemezzanine()
{
	var error = '';
	
	if (document.mezzaninequote.telephone_number.value == ''){
		error = 'Please enter telephone number';
		document.mezzaninequote.telephone_number.focus();
	}  	
	
    if (!validateEmail(document.mezzaninequote.email.value,1,0)){
		error = 'Please enter a valid email address';
		document.mezzaninequote.email.focus();
	}
	
	if (document.mezzaninequote.address.value == ''){
		error = 'Please enter your address';
		document.mezzaninequote.address.focus();
	}  
	
	if (document.mezzaninequote.company_name.value == ''){
		error = 'Please enter company name';
		document.mezzaninequote.company_name.focus();
	}  
	
	if (document.mezzaninequote.contact_name.value == ''){
		error = 'Please enter contact name';
		document.mezzaninequote.contact_name.focus();
	} 
	
	// Quote Details 
	
	if (document.mezzaninequote.handrail_kicker_plate.value == ''){
		error = 'Please enter handrail kicker plate';
		document.mezzaninequote.handrail_kicker_plate.focus();
	}  
	
	if (document.mezzaninequote.pallet_gate.value == ''){
		error = 'Please enter pallet gate';
		document.mezzaninequote.pallet_gate.focus();
	}  
	
	if (document.mezzaninequote.staircases.value == ''){
		error = 'Please enter staircases';
		document.mezzaninequote.staircases.focus();
	}  
	
	if (document.mezzaninequote.floor_loading[0].checked == '' && document.mezzaninequote.floor_loading[1].checked == '' && document.mezzaninequote.floor_loading[2].checked == ''){
		error = 'Please select floor loading';
	}  
	
	if (document.mezzaninequote.height.value == ''){
		error = 'Please enter height';
		document.mezzaninequote.height.focus();
	}  
	
	if (document.mezzaninequote.height.value == ''){
		error = 'Please enter height';
		document.mezzaninequote.height.focus();
	}  
	
	if (document.mezzaninequote.floor_width.value == ''){
		error = 'Please enter floor width';
		document.mezzaninequote.floor_width.focus();
	}  
		
	if (document.mezzaninequote.floor_length.value == ''){
		error = 'Please enter floor length';
		document.mezzaninequote.floor_length.focus();
	}
	
	if (error == '')
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}


function validatecantilever()
{
	var error = '';
	
	if (document.cantileverquote.telephone_number.value == ''){
		error = 'Please enter telephone number';
		document.cantileverquote.telephone_number.focus();
	}  	
	
    if (!validateEmail(document.cantileverquote.email.value,1,0)){
		error = 'Please enter a valid email address';
		document.cantileverquote.email.focus();
	}
	
	if (document.cantileverquote.address.value == ''){
		error = 'Please enter your address';
		document.cantileverquote.address.focus();
	}  
	
	if (document.cantileverquote.company_name.value == ''){
		error = 'Please enter company name';
		document.cantileverquote.company_name.focus();
	}  
	
	if (document.cantileverquote.contact_name.value == ''){
		error = 'Please enter contact name';
		document.cantileverquote.contact_name.focus();
	}  
	
	// Quote Details
	
	if (document.cantileverquote.product_details.value == ''){
		error = 'Please enter product details';
		document.cantileverquote.product_details.focus();
	}  
	
	if (document.cantileverquote.arm_capacity.value == ''){
		error = 'Please enter capacity';
		document.cantileverquote.arm_capacity.focus();
	}  
	
	if (document.cantileverquote.length_of_arms.value == ''){
		error = 'Please enter length of arms';
		document.cantileverquote.length_of_arms.focus();
	}  
	
	if (document.cantileverquote.no_of_arms.value == ''){
		error = 'Please enter no. of arms per side';
		document.cantileverquote.no_of_arms.focus();
	}  
	
	if (document.cantileverquote.overall_height.value == ''){
		error = 'Please enter overall height';
		document.cantileverquote.overall_height.focus();
	}  
	
    if (document.cantileverquote.double_sided_runs_length.value == ''){
		error = 'Please enter LENGTH for DOUBLE sided runs';
		document.cantileverquote.double_sided_runs_length.focus();
	}  
	
	if (document.cantileverquote.double_sided_runs_quantity.value == ''){
		error = 'Please enter QUANTITY for DOUBLE sided runs';
		document.cantileverquote.double_sided_runs_quantity.focus();
	}  
	
	if (document.cantileverquote.single_sided_runs_length.value == ''){
		error = 'Please enter LENGTH for SINGLE sided runs';
		document.cantileverquote.single_sided_runs_length.focus();
	}  
		
	if (document.cantileverquote.single_sided_runs_quantity.value == ''){
		error = 'Please QUANTITY for SINGLE sided runs';
		document.cantileverquote.single_sided_runs_quantity.focus();
	}
	
	if (error == '')
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}


function validatepallet()
{
	var error = '';
	
	if (document.palletquote.telephone_number.value == ''){
		error = 'Please enter telephone number';
		document.palletquote.telephone_number.focus();
	}  	
	
    if (!validateEmail(document.palletquote.email.value,1,0)){
		error = 'Please enter a valid email address';
		document.palletquote.email.focus();
	}
	
	if (document.palletquote.address.value == ''){
		error = 'Please enter your address';
		document.palletquote.address.focus();
	}  
	
	if (document.palletquote.company_name.value == ''){
		error = 'Please enter company name';
		document.palletquote.company_name.focus();
	}  
	
	if (document.palletquote.contact_name.value == ''){
		error = 'Please enter contact name';
		document.palletquote.contact_name.focus();
	}  
	
	// Quote Details
	
	if (document.palletquote.upright_protectors[0].checked == '' && document.palletquote.upright_protectors[1].checked == ''){
		error = 'Please select upright protectors';
	}
	
	if (document.palletquote.decking[0].checked == '' && document.palletquote.decking[1].checked == '' && document.palletquote.decking[2].checked == ''){
		error = 'Please select decking';
	}
	
	if (document.palletquote.double_sided_runs_length.value == ''){
		error = 'Please enter LENGTH for DOUBLE sided runs';
		document.palletquote.double_sided_runs_length.focus();
	}  
	
	if (document.palletquote.double_sided_runs_quantity.value == ''){
		error = 'Please enter QUANTITY for DOUBLE sided runs';
		document.palletquote.double_sided_runs_quantity.focus();
	}  
	
	if (document.palletquote.single_sided_runs_length.value == ''){
		error = 'Please enter LENGTH for SINGLE sided runs';
		document.palletquote.single_sided_runs_length.focus();
	}  
		
	if (document.palletquote.single_sided_runs_quantity.value == ''){
		error = 'Please QUANTITY for SINGLE sided runs';
		document.palletquote.single_sided_runs_quantity.focus();
	}  
	
	if (document.palletquote.beam_capacity.value == ''){
		error = 'Please enter beam capacity';
		document.palletquote.beam_capacity.focus();
	}  
	
	if (document.palletquote.pallet_levels.value == ''){
		error = 'Please enter number of pallet levels';
		document.palletquote.pallet_levels.focus();
	}  
	
    if (document.palletquote.pallet_weight.value == ''){
		error = 'Please enter pallet weight';
		document.palletquote.pallet_weight.focus();
	}  
	
	if (document.palletquote.bay_depth.value == ''){
		error = 'Please enter bay depth';
		document.palletquote.bay_depth.focus();
	}
	
	if (document.palletquote.bay_width.value == ''){
		error = 'Please enter bay width';
		document.palletquote.bay_width.focus();
	}  
		
	if (document.palletquote.bay_height.value == ''){
		error = 'Please enter bay height';
		document.palletquote.bay_height.focus();
	}
	
	if (error == '')
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}


function validateshelving()
{
	var error = '';
	
	if (document.shelvingquote.telephone_number.value == ''){
		error = 'Please enter telephone number';
		document.shelvingquote.telephone_number.focus();
	}  	
	
    if (!validateEmail(document.shelvingquote.email.value,1,0)){
		error = 'Please enter a valid email address';
		document.shelvingquote.email.focus();
	}
	
	if (document.shelvingquote.address.value == ''){
		error = 'Please enter your address';
		document.shelvingquote.address.focus();
	}  
	
	if (document.shelvingquote.company_name.value == ''){
		error = 'Please enter company name';
		document.shelvingquote.company_name.focus();
	}  
	
	if (document.shelvingquote.contact_name.value == ''){
		error = 'Please enter contact name';
		document.shelvingquote.contact_name.focus();
	}  
	
	// Quote Details
	
	if (document.shelvingquote.closed_sides[0].checked == '' && document.shelvingquote.closed_sides[1].checked == ''){
		error = 'Please select closed backs or extreme ends only';
	}
	
	if (document.shelvingquote.closed_backs[0].checked == '' && document.shelvingquote.closed_backs[1].checked == ''){
		error = 'Please select closed backs or single sided runs only';
	}
	
	if (document.shelvingquote.double_sided_runs_length.value == ''){
		error = 'Please enter LENGTH for DOUBLE sided runs';
		document.shelvingquote.double_sided_runs_length.focus();
	}  
	
	if (document.shelvingquote.double_sided_runs_quantity.value == ''){
		error = 'Please enter QUANTITY for DOUBLE sided runs';
		document.shelvingquote.double_sided_runs_quantity.focus();
	}  
	
	if (document.shelvingquote.single_sided_runs_length.value == ''){
		error = 'Please enter LENGTH for SINGLE sided runs';
		document.shelvingquote.single_sided_runs_length.focus();
	}  
		
	if (document.shelvingquote.single_sided_runs_quantity.value == ''){
		error = 'Please QUANTITY for SINGLE sided runs';
		document.shelvingquote.single_sided_runs_quantity.focus();
	}  
	
	if (document.shelvingquote.shelves[0].checked == '' && document.shelvingquote.shelves[1].checked == '' && document.shelvingquote.shelves[2].checked == ''){
		error = 'Please select shelves';
	}
	
	if (document.shelvingquote.no_of_shelves.value == ''){
		error = 'Please enter total number of shelves';
		document.shelvingquote.no_of_shelves.focus();
	}  
	
    if (document.shelvingquote.shelf_capacity.value == ''){
		error = 'Please enter shelf capacity';
		document.shelvingquote.shelf_capacity.focus();
	}  
	
	if (document.shelvingquote.bay_depth.value == ''){
		error = 'Please enter bay depth';
		document.shelvingquote.bay_depth.focus();
	}
	
	if (document.shelvingquote.bay_width.value == ''){
		error = 'Please enter bay width';
		document.shelvingquote.bay_width.focus();
	}  
		
	if (document.shelvingquote.bay_height.value == ''){
		error = 'Please enter bay height';
		document.shelvingquote.bay_height.focus();
	}
	
	if (error == '')
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}
