function formSubmit(formName){
	
	
		if(checkFields(formName)) {
			document.forms[formName].submit();
			return false;
		} else 

			return false;
	
	
}

function checkFields(formName) { // check if all required fields are filled
         var theForm = document.getElementById(formName);
         var rx = new RegExp('[^_]+__[^_]+');
         for (var i = 0; i < theForm.elements.length; i++) {
             if (theForm.elements[i].name)
                if (theForm.elements[i].name.match(rx)) {
                	var error = false;
                   if ((theForm.elements[i].name) && (theForm.elements[i].value == undefined))
                      error = true;
                   else
                   if ((theForm.elements[i].name) && (theForm.elements[i].value == ''))
                      error = true;
                   else
                   if ((theForm.elements[i].options) && (theForm.elements[i].options[theForm.elements[i].selectedIndex].value == 'choose'))
                      error = true;
                   if (error) {
                      alert('Please fill out: ' + theForm.elements[i].title);
                      theForm.elements[i].focus();
                      return false;
                      }
                   }
             }
         return true;
         }

function checkEmail(field) {
         if (!document.getElementById(field)) return 1;
         var rx = /^[\w][-\w._]*[@][\w][-\w._]*[.][\w][\w]{1,4}$/i;
         var e = document.getElementById(field);
         var ok = rx.test(e.value);
         if (!ok) {
            alert('Invalid email address');
            e.focus();
            }
         return ok;
       }

function requestInfo()
{

	scroll(0,0);
	document.getElementById('field__name').focus();
	return false;

}

function infoFormSubmit(formName)
{

		if(checkFields(formName)) {

			if(checkEmail('field__email'))
			{

				/*if(document.getElementById('field__email').value!=document.getElementById('field__confirm_email').value)
				{
						alert('Email addresses do not match');
							return false;
				}
				else
				{*/

					if(document.forms[formName].hash.value == hex_md5(document.forms[formName].captcha.value))
					{


						document.forms[formName].submit();
					}
					else
					{
						alert('Please enter the above code correctly');
					}
					
				//}

			}
			else
			{

				return false;

			}
		}

}

function changePassSubmit(formName)
{
	if(checkFields(formName)) {
	
		if(document.getElementById('field__new_pass').value!=document.getElementById('field__retype_new_pass').value)
		{
				alert('Passwords do not match');
					return false;
		}
		else
		{
			document.forms[formName].submit();
		}
	}

}	

function loginFormSubmit(formName){
	
	if(checkFields(formName)) {
		if(checkEmail('field__email')){
			if(document.getElementById('field__login_pass').value!=document.getElementById('field__pass2').value){
				alert('Passwords do not match');
				return false;
			}
			if(document.getElementById('accept_terms').checked==true)
		
				document.forms[formName].submit();
			else{
			
				alert('You must accept the terms and conditions before signing up');
				return false;
			
			}
		}
		return false;
	} else 
		
		return false;
}

function loggedInFormSubmit(formName){
	
	
		if(checkFields(formName)) {
					if(document.forms[formName].hash.value == hex_md5(document.forms[formName].captcha.value))
					{


						document.forms[formName].submit();
					}
					else
					{
						alert('Please enter the above code correctly');
					}
			return false;
		} else 

			return false;
	
}


function copyEmail(formName)
{
	document.forms[formName].field_login_username.value = document.forms[formName].field__email.value
}

function focusLogin()
{

	document.getElementById('username').focus();

}
