
function validateEmail(email) {
	var matches = email.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
	return (matches != null && email == matches[0]);
}
function strTrim(str){
  str=str.replace(/(^\s*)|(\s*$)/g, "");
  if (str.length==0){
    return false;
  }
  return true;
} 
 
function checkForm(){
  if(!strTrim(document.all['FromName'].value) || !validateEmail(document.all['email'].value) ||  !validateEmail(document.all['to'].value)){
    alert(' *Please, fill in all mandatory fields and correct Email address');
    return false;
  }   
return true;
}

function SendInquiryForm(formname)
{
	if (document.all['FirstName'].value=="")
	{
			alert('Please, fill in First Name');
			document.all['FirstName'].focus();		
			return;
	}
	else if (document.all['LastName'].value=="")
	{
			alert('Please, fill in Last Name');
			document.all['LastName'].focus();		
			return;
	}
	else if (document.all['CompanyOrganization'].value=="")
	{
			alert('Please, fill in Company/Organization');
			document.all['CompanyOrganization'].focus();		
			return;
	}
	if (document.all['EmailAddress'].value=="")
		{
			alert('Please, fill in Email');
			document.all['EmailAddress'].focus();		
			return;
		}
		
		else if((document.all['EmailAddress'].value).match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==null)	
		{
		alert('Please fill in correct Email');
			document.all['EmailAddress'].focus();		
			return;
		}
		//else if ((document.all['InquiryTopic'][0].checked==false)&&(document.all['InquiryTopic'][1].checked==false)&&(document.all['InquiryTopic'][2].checked==false)&&(document.all['InquiryTopic'][3].checked==false)&&(document.all['InquiryTopic'][4].checked==false)&&(document.all['InquiryTopic'][5].checked==false)&&(document.all['InquiryTopic'][6].checked==false)&&(document.all['InquiryTopic'][7].checked==false))
		//{
		//alert('Please check inquiry topic');
		//	document.all['InquiryTopic'][0].focus();		
		//	return;
		//}	
	else
	{
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}


function SendRequestForm(formname)
{
	if ((document.all['Substrate'][0].checked==false)&&(document.all['Substrate'][1].checked==false)&&(document.all['Substrate'][2].checked==false))
		{
		alert('Please check substrate');
			document.all['Substrate'][0].focus();		
			return;
		}	
	else if (document.all['ReflectanceWavelengthRange'].value=="")
	{
			alert('Please, fill in Reflectance Wavelength Range');
			document.all['ReflectanceWavelengthRange'].focus();		
			return;
	}	
	else if (document.all['FirstName'].value=="")
	{
			alert('Please, fill in First Name');
			document.all['FirstName'].focus();		
			return;
	}
	else if (document.all['LastName'].value=="")
	{
			alert('Please, fill in Last Name');
			document.all['LastName'].focus();		
			return;
	}
	else if (document.all['CompanyOrganization'].value=="")
	{
			alert('Please, fill in Company/Organization');
			document.all['CompanyOrganization'].focus();		
			return;
	}
	else if (document.all['EmailAddress'].value=="")
		{
			alert('Please, fill in Email');
			document.all['EmailAddress'].focus();		
			return;
		}
		
		else if((document.all['EmailAddress'].value).match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==null)	
		{
		alert('Please fill in correct Email');
			document.all['EmailAddress'].focus();		
			return;
		}
	else if (document.all['FullShippingAddress'].value=="")
		{
			alert('Please, fill in Full Shipping Address');
			document.all['FullShippingAddress'].focus();		
			return;
		}	
	else if (document.all['YourOrganizationInternationalAccount'].value=="")
		{
			alert('Please, fill in Your Organization International Account');
			document.all['YourOrganizationInternationalAccount'].focus();		
			return;
		}		
	else
	{
		//alert ('xxx');
		eval("document.forms['"+formname+"'].submit()");
	}
}
