	function toggleExpando(expandoName,caption) 
	{
		var element;
		var expando;
		
		/*-----------------------------------------------------------------
		 Check for the browser type so we know how to call the DIV element
		 -----------------------------------------------------------------*/
		if(document.all)
        {
			//IE & Opera browser 
			element = eval('document.all.' + caption)
			expando = eval('document.all.' + expandoName)
		}
        
        if(!document.all && document.getElementById)
        {
			//NN6+ browser
			element = eval('document.getElementById(caption)')
			expando = eval('document.getElementById(expandoName)')
		}
        /*-----------------------------------------------------------------*/
        
        
        if (element.style.visibility == 'visible' ) 
		{
			document.RegistrationSection.register.value = ""
			document.loginsection.username.focus()
			element.style.visibility = 'hidden';
		    element.style.display = 'none';
		}
		else 
		{
			element.style.visibility = 'visible';
		    element.style.display = 'block';
		    
		    document.RegistrationSection.register.value = "REGISTER"
			document.loginsection.username.value = ""
			document.loginsection.password.value = ""
			
			if (caption == "log")
				{document.RegistrationSection.Fname.focus()}
			if (caption == "home")
				{document.RegistrationSection.username.focus()}
		                
		}
	}
		
					
	
	function PopUpWindow(l_TermsLink)
	{
		document.open(l_TermsLink,"Terms_Page","width=800,height=600,scrollbars=1,resizable=-1,status=1,menubar=1,toolbar=1,location=0");
	}


	function checkEmailMatches() 
	{
		var l_FormObject = document.RegistrationSection;
		if (l_FormObject.email_orders.value != '' && l_FormObject.emailConfirm.value != '' && l_FormObject.emailConfirm.value != l_FormObject.email_orders.value) {
			alert ("Your email address and confirmation email address do not match. Please check and amend.");
			return false;
		}
	}
	
	
	function FillUsernameWithEmail()
	{
		if (document.RegistrationSection.email_orders.value == document.RegistrationSection.emailConfirm.value && document.RegistrationSection.email_orders.value != '')
			document.RegistrationSection.username.value = document.RegistrationSection.email_orders.value;	
	}
	

	function CheckUserData(l_Form)	{
		var l_ObjName = "document." + l_Form		l_ObjName = eval(l_ObjName)				//<--
		if (l_Form == "RegistrationSection") //validate registration fields
		{			
			
			if (l_ObjName.Fname.value == "") 				{
				alert("Please enter your first name.")				l_ObjName.Fname.focus()				return false;	
			}			
			if (l_ObjName.Fname.value.length > 20)
			{
				alert("You can enter a maximum of 20 characters for the first name.")
				l_ObjName.Fname.focus()				return false;	
			}			
			if (l_ObjName.Lname.value == "")
			{
				alert("Please enter your surname.")				l_ObjName.Lname.focus()				return false;
			}						if (l_ObjName.Lname.value.length > 30)
			{				alert("You can enter a maximum of 30 characters for the surname.")
				l_ObjName.Lname.focus()				return false;
			}
						if ((l_ObjName.email_orders.value == "") || (l_ObjName.email_orders.value.length > 50) || (l_ObjName.email_orders.value.length < 6))	
			{
				alert("Please enter a valid email address (not more than 50 characters long), this is required to confirm your order.")				l_ObjName.email_orders.focus()				return false;
			}
			
			//return Basic_Email_Validation(l_ObjName.email_orders,l_Form);			
			
			
			
			//Check that one of the newsletter options is selected
						
			var frmObjectNewsLetterOn = document.RegistrationSection.chkNewsLetter[0];
			var frmObjectNewsLetterOff = document.RegistrationSection.chkNewsLetter[1];
			var counter
		
			if(frmObjectNewsLetterOn.checked!= false || frmObjectNewsLetterOff.checked!= false)
			{  
				  
				for(counter = 0; counter <2; counter++)
				{
					if(document.RegistrationSection.chkNewsLetter[counter].checked == true)
					{
						document.RegistrationSection.txtNewsLetter.value = document.RegistrationSection.chkNewsLetter[counter].value
					}
				}
					
			}		
			else
			{
				alert("Please indicate if you would like to receive email notifications of special offers/promotions from Auravita.")
				frmObjectNewsLetterOn.focus();
				return false;	
			}	
				
			
			
			
					}
						//-->		
		if (l_ObjName.username.value == "")		{
			if (l_Form == "loginsection")
				{alert("Please enter your username")}
			else					{alert("Please enter a username (required for logging into the system) which must be at least 6 characters and contain no spaces.")}
			l_ObjName.username.focus()
			return false;		}	
		
		
		if (l_ObjName.password.value == "")		{			if (l_Form == "loginsection")				{alert("Your password is required to access your account, please enter the password")}			else				{alert("Please enter a password which must be at least 6 characters and must not contain any spaces.")}
			l_ObjName.password.focus()
			return false;		}
		
		if (l_Form == "RegistrationSection") //validate additional registration fields
		{			if (l_ObjName.password2.value == "")			{				alert("Please confirm the password you have entered above.")
				l_ObjName.password2.focus()
				return false;			}		}
							if ((l_ObjName.username.value.length < 6) || (l_ObjName.username.value.length > 50) ||(l_ObjName.username.value.indexOf(" ")!==-1) ) 		{			if (l_Form == "loginsection")
				{alert("You have entered an invalid username")}			else
				{alert("Your username must be between 6 and 50 characters long and must not contain any spaces.")}			l_ObjName.username.focus()			return false;
		}				if ((l_ObjName.password.value.length < 6) || (l_ObjName.password.value.length > 20) ||(l_ObjName.password.value.indexOf(" ")!==-1))		{			if (l_Form == "loginsection")				{alert("You have entered an invalid password")}
			else
				{
				alert("Your password must be between 6 and 20 characters long and must not contain any spaces.")					l_ObjName.password.value = ""
				l_ObjName.password.focus()				}
			return false;		}						if (l_Form == "RegistrationSection") //validate additional registration fields		{			if (l_ObjName.hint.value == "")			{
				alert("Please enter a password hint (used to remind you of your password).")				l_ObjName.hint.focus()				return false;
			}			
			if (l_ObjName.hint.value.length > 30)
			{				alert("Please enter a password hint with a maximum of 30 characters.")
				l_ObjName.hint.focus()				return false;
			}
			
			if (l_ObjName.greet.value == "")			{				alert("Please enter a greet name.")				l_ObjName.greet.focus()				return false;			}
						if (l_ObjName.greet.value.length > 20)			{				alert("Please enter a password greet name with a maximum of 20 characters.")				l_ObjName.greet.focus()
				return false;			}
						if (l_ObjName.password.value !== l_ObjName.password2.value)			{				{alert("Your password and confirmation password do not match please re-confirm the password.")}
				l_ObjName.password.focus()
				return false;			}
									if ((l_ObjName.password.value == "password") ||(l_ObjName.password.value == "PASSWORD"))			{				{alert("Please enter another password - you've entered 'Password' which can be very easily breached.")}
				l_ObjName.password.focus()
				return false;			}			
			if (l_ObjName.password.value == l_ObjName.hint.value)			{				{alert("Your password and password hint cannot be the same, please enter another password hint.")}
				l_ObjName.hint.focus()
				return false;			}
						if (l_ObjName.username.value.indexOf("@")!== -1) 
			{
				var bOK = Basic_Email_Validation(l_ObjName.username,l_Form);				if (bOK == false) return false;
			}
									var bOK = Basic_Email_Validation(l_ObjName.email_orders,l_Form);			if (bOK == false) return false;						
			var chkTerms =	eval(l_ObjName.chkAcceptTerms)	
		
			if (!chkTerms.checked)
			{
				alert("Tick the check box to indicate that you will abide by the the terms and conditions.")
				chkTerms.focus();
				return false;
			}												
		}				
	}
	
	
	//basic email validation
	function Basic_Email_Validation(l_EmailName,l_Msg)
	{
		if (l_EmailName.value.indexOf("@")< 0)
		{
			alert("The email address you entered is invalid - there must be an '@' character.")
			l_EmailName.focus()
			return false;
		}
				
		if (l_EmailName.value.indexOf("@")== 0) 
		{
			alert("The email address you entered is invalid.")
			l_EmailName.focus()
			return false;
		}
		
		if (l_EmailName.value.indexOf(".")< 0)
		{
			alert("The email address you entered is invalid - there must be a '.' character.")
			l_EmailName.focus()
			return false;
		}
		
		if (l_EmailName.value.indexOf(".") == 0)
		{
			alert("The email address you entered is invalid.")
			l_EmailName.focus()
			return false;
		}
		
		return true;	
	}	
	
	


	function changeNews() 
	{
		
		//**************************************************************************************************//
				
		var frmObjectNewsLetterOn = document.RegistrationSection.chkNewsLetter[0];
		var frmObjectNewsLetterOff = document.RegistrationSection.chkNewsLetter[1];
		var counter
		
		if(document.RegistrationSection.chkNewsLetter[0].checked == true)
		{
			//alert(document.RegistrationSection.chkNewsLetter[0].value)
			document.RegistrationSection.txtNewsLetter.value = document.RegistrationSection.chkNewsLetter[0].value // turn on
		}
				
		if(document.RegistrationSection.chkNewsLetter[1].checked == true)
		{
			//alert(document.RegistrationSection.chkNewsLetter[1].value)
			document.RegistrationSection.txtNewsLetter.value = document.RegistrationSection.chkNewsLetter[1].value //turn off
		}	
					
	}
	
	

	