function validateCommentRating()
{
	if(isEmpty(document.getElementById('comment').value))
	{
		alert("Voer je mening in voor dit product");
		return false;
	}
	if(document.getElementById('comment').value.length>200)
	{
		alert("Jouw mening moet kleiner zijn dan 200 characters.");
		return false;
	}
}
	
	
	
	function validateDiv(value)
	{
		var showDiv = document.getElementById(value).style.display;
		if(showDiv == 'none')
		{
			document.getElementById(value).style.display='';
		}
		else
		{
			document.getElementById(value).style.display='none';
		}
	}
	/*function onEnterSubmitForm()
	{
		document.frmLogin.submit();
	}*/
	function changeDelivertAddress()
	{
		//alert(document.getElementById('newDeliveryAddress').value);
		if(document.getElementById('newDeliveryAddress').checked == true)
		{
			document.frmOrderStep2.deliveryFirstName.disabled=false;
			document.frmOrderStep2.deliveryName.disabled=false;
			document.frmOrderStep2.deliveryAddress.disabled=false;
			document.frmOrderStep2.deliveryPostalCode.disabled=false;
			document.frmOrderStep2.deliveryCity.disabled=false;
			document.frmOrderStep2.deliveryCountry.disabled=false;
			document.frmOrderStep2.deliveryPhoneNo.disabled=false;
		}
		if(document.getElementById('newDeliveryAddress').checked == false)
		{
			document.frmOrderStep2.deliveryFirstName.disabled=true;
			document.frmOrderStep2.deliveryName.disabled=true;
			document.frmOrderStep2.deliveryAddress.disabled=true;
			document.frmOrderStep2.deliveryPostalCode.disabled=true;
			document.frmOrderStep2.deliveryCity.disabled=true;
			document.frmOrderStep2.deliveryCountry.disabled=true;
			document.frmOrderStep2.deliveryPhoneNo.disabled=true;
		}
		//$newDeliveryAddress.vlaue ='yes';
	}
	
	function checkForDelivery(currentURL)
	{
		alert(currentURL);
	}
	
	function isNumericforUpdate(elem, helperMsg)
	{
		var numericExpression = /^[0-9]+$/;
		if(elem.value.match(numericExpression))
		{
			return true ;
		}
		else
		{
			alert(helperMsg);
			elem.focus();
			return false;
		}
	}
	
	function isNumeric(elem, helperMsg)
	{
		var numericExpression = /^[0-9]+$/;
		if(elem.value.match(numericExpression))
		{
			var r =confirm('Je stopt dit product in je winkelwagen.');
			if (r==true)
			{
				return true ;
			}
			else
			 {
				return false ;
			 }
		}
		else
		{
			alert(helperMsg);
			elem.focus();
			return false;
		}
	}
	

	
	function formSubmit() 
	{ 
		document.frmSelectDisplayOrder.submit(); 
	} 
	
	function deletedFunction(message)
	{
		var r =confirm(message);
		if (r==true)
	  	{
	  		return true ;
	  	}
		else
	 	 {
	  		return false ;
	  	 }
	}
	
	function validateSearch(fieldName)
	{
		//alert(fieldName);
		if(isEmpty(document.getElementById(fieldName).value))
		{
			alert('Geef woorden.');
			//document.frmRegister.email.focus();
			return false ;
		}
	}
	
	function validateQuantity()
	{
		if(isEmpty(document.getElementById('orderQuantity').value))
		{
			alert('Geef uw bestellen.');
			//document.frmRegister.email.focus();
			return false ;
		}
		if(isNaN(document.getElementById('orderQuantity').value))
		{
			alert('Geef uw correct bestellen.');
			//document.frmProductOrder.orderQuantity.focus();
			return false ;
		}
		var r =confirm('Je stopt dit product in je winkelwagen.');
		if (r==true)
	  	{
	  		return true ;
	  	}
		else
	 	 {
	  		return false ;
	  	 }
	}
	
	function validateUpdateQuantityStep1(key)
	{
		alert("key");
		
		var r =confirm('Je stopt dit product in je winkelwagen.');
		if (r==true)
	  	{
	  		return true ;
	  	}
		else
	 	{
	  		return false ;
	  	}
	}



//function to validate registration form 
	function validateUserReg()
	{

		if(isEmpty(document.getElementById('email').value))
			{
				alert('Geef uw email adres.');
				document.frmRegister.email.focus();
				return false ;
			}
		if(!IsValidEMail(document.getElementById('email').value))
			{
				alert('Email adres niet geldig.');
				document.frmRegister.email.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('passwrd').value))
			{
				alert('Geef uw password.');
				document.frmRegister.passwrd.focus();
				return false ;
			}
			/*else
			{
				Passwordlength=document.getElementById('passwrd').value.length;
				if(Passwordlength<6)
				{
					alert("Password must be at least: 6 characterslong.");
					document.register.passwrd.focus();
					return false;
				}
		
				/*if(!validpassword(document.getElementById('userpassword').value))
				{
					alert("Password can't accept numeric value");
					document.frmUserRegistration.userpassword.focus();
					return false;
				}*/
			//}
			
		if(isEmpty(document.getElementById('firstName').value))
			{
				alert('Geef uw voornaam.');
				document.frmRegister.firstName.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('name').value))
			{
				alert('Geef uw naam.');
				document.frmRegister.name.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('address').value))
			{
				alert('Geef uw adres.');
				document.frmRegister.address.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('postalCode').value))
			{
				alert('Geef uw Post Code.');
				document.frmRegister.postalCode.focus();
				return false ;
			}
		/*if(isNaN(document.getElementById('postalCode').value))
			{
				alert('Please enter corret Postal Code.');
				document.frmRegister.postalCode.focus();
				return false;
			}*/
		if(document.frmRegister.city.selectedIndex == 0)
			{
				alert('Selecteer een stad.');
				document.frmRegister.city.focus();
				return false;
			}
		if(document.frmRegister.state.selectedIndex==0)
			{
				alert('Selecteer een staat.');
				document.frmRegister.state.focus();
				return false;
			}
		if(document.frmRegister.country.selectedIndex==0)
			{
				alert('Selecteer een land.');
				document.frmRegister.country.focus();
				return false;
			}	
		if(isEmpty(document.getElementById('phoneNo').value))
			{
				alert('Geef uw telefoonnummer.');
				document.frmRegister.phoneNo.focus();
				return false;
			}
		if(isEmpty(document.getElementById('bankName').value))
			{
				alert('Geef uw bankrekening naam.');
				document.frmRegister.bankName.focus();
				return false;
			}
		if(isEmpty(document.getElementById('accountNo').value))
			{
				alert('Geef uw rekeningnummer.');
				document.frmRegister.accountNo.focus();
				return false;
			}
		/*if(isNaN(document.getElementById('phoneNo').value))
			{
				alert('Please enter corret Phone Number.');
				document.frmRegister.phoneNo.focus();
				return false;
			}*/
		/*if(isEmpty(document.getElementById('deliveryFirstName').value))
			{
				alert('Please enter First Name.');
				document.frmRegister.deliveryFirstName.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('deliveryName').value))
			{
				alert('Please enter Name.');
				document.frmRegister.deliveryName.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('deliveryAddress').value))
			{
				alert('Please enter your address.');
				document.frmRegister.deliveryAddress.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('deliveryPostalCode').value))
			{
				alert('Please enter Postal Code.');
				document.frmRegister.deliveryPostalCode.focus();
				return false ;
			}
		if(isNaN(document.getElementById('deliveryPostalCode').value))
			{
				alert('Please enter corret Postal Code.');
				document.frmRegister.deliveryPostalCode.focus();
				return false;
			}
		if(document.frmRegister.deliveryCity.selectedIndex == 0)
			{
				alert('Please select a city.');
				document.frmRegister.deliveryCity.focus();
				return false;
			}*/
		/*if(document.frmRegister.deliveryState.selectedIndex==0)
			{
				alert('Please select a state.');
				document.frmRegister.deliveryState.focus();
				return false;
			}*/
		/*if(isEmpty(document.getElementById('deliveryPhoneNo').value))
			{
				alert('Please enter your Phone Number.');
				document.frmRegister.deliveryPhoneNo.focus();
				return false;
			}
		if(isNaN(document.getElementById('deliveryPhoneNo').value))
			{
				alert('Please enter corret Phone Number.');
				document.frmRegister.deliveryPhoneNo.focus();
				return false;
			}*/
		if(document.getElementById('checkTerms').checked == false)
			{
				alert('Ga akkoord met voorwaarden en privacy.');
				document.frmRegister.checkTerms.focus();
				return false ;
			}
		document.frmRegister.submit();
	}
	
	//function to validate Login form 
	function validateForgotPasswordfrm()
	{

		if(isEmpty(document.getElementById('email').value))
			{
				alert('Geef uw email adres.');
				document.frmFrgtPaswrd.email.focus();
				return false ;
			}
		if(!IsValidEMail(document.getElementById('email').value))
			{
				alert('Email adres niet geldig.');
				document.frmFrgtPaswrd.email.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('confirmEmail').value))
			{
				alert('Geef uw e-mail bevestigen.');
				document.frmFrgtPaswrd.confirmEmail.focus();
				return false ;
			}	
		if(document.getElementById('email').value!=document.getElementById('confirmEmail').value)
		 {
			alert("Controleer uw e-mail.");
			document.frmFrgtPaswrd.confirmEmail.focus();
			return false;
		 }	
		
		document.frmFrgtPaswrd.submit();
	}
	
	//function to validate forgot password
	function validateLoginfrm()
	{

		if(isEmpty(document.getElementById('email').value))
			{
				alert('Geef uw email adres.');
				document.frmLogin.email.focus();
				return false ;
			}
		if(!IsValidEMail(document.getElementById('email').value))
			{
				alert('Email adres niet geldig.');
				document.frmLogin.email.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('passwrd').value))
			{
				alert('Geef een password.');
				document.frmLogin.passwrd.focus();
				return false ;
			}
		document.frmLogin.submit();
	}
	
/*
 +-------------------------------------------------------------------+
 |	PURPOSE : 	Checks if the provided field value is empty
 |	ARGUMENTS : value of the field
 |	RETURN VALUE : true or false
 +-------------------------------------------------------------------+
*/
function isEmpty(elementValue)
{
	if( (elementValue=="") || (elementValue==null) )
	{
		return true;	//if empty
	}
	else
	{
		return false;	//if not empty
	}
}

function validpassword(str)
	{
		return /^[a-zA-Z0-9_]*$/.test(str)
	}
	

function validusrname(str)
	{
		var re=/^[a-zA-Z0-9_]*$/;
		 if (!str.match(re))
		 {
		 	return true;
		 }
		 else
		 {
		 	return false;
		 }
	}

//FUNCTION: to check whether the string supplied is a valid Email value
//	 INPUT:  
//			strVal	-	parameter to be checked for validity
//	OUTPUT: 
//			true	-	if the email is valid
//			false	-	if the email is invalid or no parameter is supplied
function IsValidEMail(strValue)
	{
		nNoOfArguments = IsValidEMail.arguments.length;
		//if no parameter is supplied
		if(nNoOfArguments < 1)
		{
			return false;
		}	
		
		var strVal	= new String(strValue);
		var bReturn1 = false;
		var bReturn2 = false;
		var bReturn3 = false;
		var bReturn4 = false;
		var bReturn5 = false;
		var bReturn5 = false;
		
		//if '@' comes after first character then true
		bReturn1	=	(strValue.indexOf("@") > 0);							
		
		//if '.' comes after first character then true
		bReturn2	=	(strValue.indexOf(".") > 0);							
		
		//if single '@' exist in string then true
		bReturn3	=	(strValue.indexOf("@") == strValue.lastIndexOf("@"));	
		
		//if '.' exist after @ in string then true
		bReturn4	=	(strValue.indexOf(".",strValue.indexOf("@")) > (strValue.indexOf("@")));		
		
		//if '.' does not comes immediatly after @ then true
		bReturn5	=	(strValue.indexOf(".",strValue.indexOf("@")) != (strValue.indexOf("@")+1));		
		
		//if '.' does not comes immediatly before @ then true
		bReturn6	=	(strValue.lastIndexOf(".",strValue.indexOf("@")) != (strValue.indexOf("@")-1)); 
		
		//if all values are true return true else false.
		return(bReturn1 && bReturn2 && bReturn3 && bReturn4 && bReturn5 && bReturn6);
	}

	//function to validate edit form in myAccount.php
	function validateEditForm()
	{
		//alert("helo");
		if(isEmpty(document.getElementById('email').value))
			{
				alert('Geef uw email adres.');
				document.frmEditUserProfile.email.focus();
				return false ;
			}
		if(!IsValidEMail(document.getElementById('email').value))
			{
				alert('Email adres niet geldig.');
				document.frmEditUserProfile.email.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('passwrd').value))
			{
				alert('Geef een password.');
				document.frmEditUserProfile.passwrd.focus();
				return false ;
			}
			/*else
			{
				Passwordlength=document.getElementById('passwrd').value.length;
				if(Passwordlength<6)
				{
					alert("Password must be at least: 6 characterslong.");
					document.register.passwrd.focus();
					return false;
				}
		
				/*if(!validpassword(document.getElementById('userpassword').value))
				{
					alert("Password can't accept numeric value");
					document.frmUserRegistration.userpassword.focus();
					return false;
				}*/
			//}
			
		if(isEmpty(document.getElementById('firstName').value))
			{
				alert('Geef uw voornaam.');
				document.frmEditUserProfile.firstName.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('name').value))
			{
				alert('Geef uw achternaam .');
				document.frmEditUserProfile.name.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('address').value))
			{
				alert('Geef uw adres .');
				document.frmEditUserProfile.address.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('postalCode').value))
			{
				alert('Geef uw postalCode.');
				document.frmEditUserProfile.postalCode.focus();
				return false ;
			}
		/*if(isNaN(document.getElementById('postalCode').value))
			{
				alert('Please enter corret Postal Code.');
				document.frmEditUserProfile.postalCode.focus();
				return false;
			}*/
		if(document.frmEditUserProfile.city.selectedIndex == 0)
			{
				alert('Selecteer stad.');
				document.frmEditUserProfile.city.focus();
				return false;
			}
		if(document.frmEditUserProfile.state.selectedIndex == 0)
			{
				alert('Selecteer een staat.');
				document.frmEditUserProfile.state.focus();
				return false;
			}
		if(document.frmEditUserProfile.country.selectedIndex == 0)
			{
				alert('Selecteer the stad .');
				document.frmEditUserProfile.country.focus();
				return false;
			}	
		if(isEmpty(document.getElementById('phoneNo').value))
			{
				alert('Geef uw telefoonnummer .');
				document.frmEditUserProfile.phoneNo.focus();
				return false;
			}
		if(isEmpty(document.getElementById('bankName').value))
			{
				alert('Geef uw banknaam.');
				document.frmEditUserProfile.bankName.focus();
				return false;
			}
		if(isEmpty(document.getElementById('accountNo').value))
			{
				alert('Geef uw rekeningnummer.');
				document.frmEditUserProfile.accountNo.focus();
				return false;
			}
		/*if(isNaN(document.getElementById('phoneNo').value))
			{
				alert('Please enter correct phoneNumber.');
				document.frmEditUserProfile.phoneNo.focus();
				return false;
			}*/
		/*if(isEmpty(document.getElementById('deliveryFirstName').value))
			{
				alert('Please enter First Name.');
				document.frmEditUserProfile.deliveryFirstName.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('deliveryName').value))
			{
				alert('Please enter Name.');
				document.frmEditUserProfile.deliveryName.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('deliveryAddress').value))
			{
				alert('Please enter your address.');
				document.frmEditUserProfile.deliveryAddress.focus();
				return false ;
			}
		if(isEmpty(document.getElementById('deliveryPostalCode').value))
			{
				alert('Please enter Postal Code.');
				document.frmEditUserProfile.deliveryPostalCode.focus();
				return false ;
			}
		if(isNaN(document.getElementById('deliveryPostalCode').value))
			{
				alert('Please enter corret Postal Code.');
				document.frmEditUserProfile.deliveryPostalCode.focus();
				return false;
			}
		if(document.frmEditUserProfile.deliveryCity.selectedIndex == 0)
			{
				alert('Please select a city.');
				document.frmEditUserProfile.deliveryCity.focus();
				return false;
			}
		if(document.frmEditUserProfile.deliveryState.selectedIndex == 0)
			{
				alert('Please select a state.');
				document.frmEditUserProfile.deliveryState.focus();
				return false;
			}
		if(isEmpty(document.getElementById('deliveryPhoneNo').value))
			{
				alert('Please enter your phonenumber.');
				document.frmEditUserProfile.deliveryPhoneNo.focus();
				return false;
			}
		if(isNaN(document.getElementById('deliveryPhoneNo').value))
			{
				alert('Please enter corret phonenumber.');
				document.frmEditUserProfile.deliveryPhoneNo.focus();
				return false;
			}*/
		if(document.getElementById('checkTerms').checked == false)
			{
				alert('Ga akkoord met voorwaarden en privacy.');
				document.frmEditUserProfile.checkTerms.focus();
				return false ;
			}
	}
	
	//valiadte franchise dropdown in orderStep2.php
	function validateOrderStep2()
	{	
		if(document.frmOrderStep2.franchiser.selectedIndex == 0)
			{
				alert('kies een Haverpunt!');
				document.frmOrderStep2.franchiser.focus();
				return false;
			}
		if(document.frmOrderStep2.franchiser.selectedIndex == 2)
			{
				alert('kies een Haverpunt!');
				document.frmOrderStep2.franchiser.focus();
				return false;
			}
		//alert(document.getElementById('newDeliveryAddress').value);
		if(document.getElementById('newDeliveryAddress').checked == true)
		{
			if(isEmpty(document.getElementById('deliveryFirstName').value))
				{
					alert('Geef uw voornaam.');
					document.frmOrderStep2.deliveryFirstName.focus();
					return false ;
				}
			if(isEmpty(document.getElementById('deliveryName').value))
				{
					alert('Geef uw achternaam.');
					document.frmOrderStep2.deliveryName.focus();
					return false ;
				}
			if(isEmpty(document.getElementById('deliveryAddress').value))
				{
					alert('Geef uw adres.');
					document.frmOrderStep2.deliveryAddress.focus();
					return false ;
				}
			if(isEmpty(document.getElementById('deliveryPostalCode').value))
				{
					alert('Geef uw postcode.');
					document.frmOrderStep2.deliveryPostalCode.focus();
					return false ;
				}
			if(isEmpty(document.getElementById('deliveryCity').value))
				{
					alert('Geef uw stad.');
					document.frmOrderStep2.deliveryCity.focus();
					return false ;
				}
			/*if(document.frmEditUserProfile.deliveryCity.selectedIndex == 0)
				{
					alert('Please select a city.');
					document.frmOrderStep2.deliveryCity.focus();
					return false;
				}*/
			if(document.frmOrderStep2.deliveryCountry.selectedIndex == 0)
				{
					alert('Selecteer the land.');
					document.frmOrderStep2.deliveryCountry.focus();
					return false;
				}
			if(isEmpty(document.getElementById('deliveryPhoneNo').value))
				{
					alert('Geef uw telefoonnummer.');
					document.frmOrderStep2.deliveryPhoneNo.focus();
					return false;
				}
			/*if(isNaN(document.getElementById('deliveryPhoneNo').value))
				{
					alert('Please enter correct phonenumber.');
					document.frmOrderStep2.deliveryPhoneNo.focus();
					return false;
				}*/
				//document.frmOrderStep2.submit();
		}
	}
