// Copyright ©2005 Amiad Filtration Systems (1997) Ltd. All rights reserved.
// Copyright ©2005 Amiad Filtration Systems Inc. All rights reserved.

// BEGIN Solution Request
// If position selected is Other then the Details input is shown or hidden
function checkSolutionRequestPosition()
{
var thePosition=document.solutionRequest.position.value;
	if(thePosition=="Other")
		{
		document.getElementById("otherPosition").style.visibility="visible";
		document.solutionRequest.otherPositionDetail.focus();
		}
		else
			{
			document.getElementById("otherPosition").style.visibility="hidden";
			}
}

// Checks the form for missing 
function checkSolutionRequestForm()
{	
var Fname=document.solutionRequest.Fname.value;
	if(Fname=="")
		{
		alert("Your First name please");
		document.solutionRequest.Fname.focus();
		}
		else
			{
			var Lname=document.solutionRequest.Lname.value;
			if(Lname=="")
				{
				alert("Your Last name please");
				document.solutionRequest.Lname.focus();
				}
				else
					{
					var company=document.solutionRequest.company.value;
					if(company=="")
						{
						alert("Your company name please");
						document.solutionRequest.company.focus();
						}
						else
							{
							var position=document.solutionRequest.position.value;
								if(position=="Choose one")
									{
									alert("Your Position please");
									document.solutionRequest.position.focus();
									}
									else
										{
										var state=document.solutionRequest.state.value;
										if(state=="")
											{
											alert("Your state please");
											document.solutionRequest.state.focus();
											}
											else
												{
												var phone=document.solutionRequest.phone.value;
												if(phone=="")
													{
													alert("Phone number please");
													document.solutionRequest.phone.focus();
													}
													else
														{
														var email=document.solutionRequest.email.value;
														if(email=="")
															{
															alert("Your E-Mail please");
															document.solutionRequest.email.focus();
															}
															else
															{
															document.getElementById("sendButton").style.visibility="hidden";
															document.solutionRequest.submit();
															}
														}
												}
										}
								}
					}
		}
}
// END Solution Request

// BEGIN Feedback Form
function checkFeedbackForm()
{	
	var Fname=document.feedbackForm.Fname.value;
	if(Fname=="")
		{
		alert("Your First name please");
		document.feedbackForm.Fname.focus();
		}
		else
			{
			var Lname=document.feedbackForm.Lname.value;
			if(Lname=="")
				{
				alert("Your Last name please");
				document.feedbackForm.Lname.focus();
				}
				else
					{
					var company=document.feedbackForm.company.value;
					if(company=="")
						{
						alert("Your company name please");
						document.feedbackForm.company.focus();
						}
						else
							{
							var phone=document.feedbackForm.phone.value;
							if(phone=="")
								{
								alert("Your phone number please");
								document.feedbackForm.phone.focus();
								}
								else
									{
									var mail=document.feedbackForm.mail.value;
									var ret=checkEMailValidation(mail)
									if(ret==0)
										{
											alert("Your E-mail address please");
											document.feedbackForm.mail.focus();
										}
									//var x=mail.indexOf("@") ;
									//alert(x)
									//if (mail=="")
									//	{
									//	alert("Your E-mail address please");
									//	document.feedbackForm.mail.focus();
									//	}
										else
											{
											var state=document.feedbackForm.state.value;
											if(state=="")
												{
												alert("state please");
												document.feedbackForm.state.focus();
												}
												else
													{
													var country=document.feedbackForm.country.value;
													if(country=="")
														{
														alert("Your Country please");
														document.feedbackForm.country.focus();
														}
														else
														{
														document.getElementById("sendButton").style.visibility="hidden";
														document.feedbackForm.submit();
														}
													}
											}
									}
							}
					}
			}
}
// END Feedback Form
// BEGINcheck emil
function checkEMailValidation(EMail2)
	{

	//	EMail2=trim(EMail2)
		var indAt=EMail2.indexOf("@")
		var indAtLast=EMail2.lastIndexOf("@")
		var indDot=EMail2.indexOf(".")
		var indDotLast=EMail2.lastIndexOf(".")
		var indSpace=EMail2.indexOf(" ")

		if(indDot==0 || indAt==0 || (indDot+1)==indAt || indAt==-1 || indDot==-1 || indAt==EMail2.length || indSpace>-1 || indAtLast!=indAt || indDotLast==EMail2.length-1  || indAtLast==EMail2.length-1 || indAt==EMail2.length-1 || (indAt+1)==indDot)
		return 0
		return 1
	}
//end check emil
// BEGIN Expert Reistration
function checkUserMail()
{
	var mAddress=document.userMailCheck.emailAddress.value;
	if(mAddress=="")
		{
		}
		else
			{
			document.userMailCheck.submit();
			}
}

function checkRegistrationFormPosition()
{
var thePosition=document.registrationForm.position.value;
	if(thePosition=="Other")
		{
		document.getElementById("otherPosition").style.visibility="visible";
		document.registrationForm.otherPositionDetail.focus();
		}
		else
			{
			document.getElementById("otherPosition").style.visibility="hidden";
			}
}

function checkRegistrationForm()
{	
var Fname=document.registrationForm.Fname.value;
	if(Fname=="")
		{
		alert("Your First name please");
		document.registrationForm.Fname.focus();
		}
		else
			{
			var Lname=document.registrationForm.Lname.value;
			if(Lname=="")
				{
				alert("Your Last name please");
				document.registrationForm.Lname.focus();
				}
				else
					{
					var company=document.registrationForm.company.value;
					if(company=="")
						{
						alert("Your company name please");
						document.registrationForm.company.focus();
						}
						else
							{
							var position=document.registrationForm.position.value;
								if(position=="Choose one")
									{
									alert("Your Position please");
									document.registrationForm.position.focus();
									}
									else
										{
										var state=document.registrationForm.state.value;
										if(state=="")
											{
											alert("Your state please");
											document.registrationForm.state.focus();
											}
											else
												{
												var phone=document.registrationForm.phone.value;
												if(phone=="")
													{
													alert("Phone number please");
													document.registrationForm.phone.focus();
													}
													else
														{
														var email=document.registrationForm.email.value;
														if(email=="")
															{
															alert("Your E-Mail please");
															document.registrationForm.email.focus();
															}
															else
															{
															document.getElementById("sendButton").style.visibility="hidden";
															document.registrationForm.submit();
															}
														}
												}
										}
								}
					}
		}
}
// END Expert Reistration