


/////////////////  account


var passed_validation = false;
 

function doAccountCheck() {


	var returnValue = true;
	
	if (document.account_form.title.value == "") {
	document.account_form.title.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.title.style.backgroundColor = "";
	}
	if (document.account_form.firstname.value == "") {
	document.account_form.firstname.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.firstname.style.backgroundColor = "";
	}
	if (document.account_form.surname.value == "") {
	document.account_form.surname.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.surname.style.backgroundColor = "";
	}
	if (document.account_form.email.value == "") {
	document.account_form.email.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.email.style.backgroundColor = "";
	}
	if (document.account_form.telephone.value == "") {
	document.account_form.telephone.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.telephone.style.backgroundColor = "";
	}
	if (document.account_form.company.value == "") {
	document.account_form.company.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.company.style.backgroundColor = "";
	}
	if (document.account_form.address1.value == "") {
	document.account_form.address1.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.address1.style.backgroundColor = "";
	}
	if (document.account_form.address3.value == "") {
	document.account_form.address3.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.address3.style.backgroundColor = "";
	}
	if (document.account_form.postcode.value == "") {
	document.account_form.postcode.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.postcode.style.backgroundColor = "";
	}
	if (document.account_form.choose_password.value == "") {
	document.account_form.choose_password.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.choose_password.style.backgroundColor = "";
	}
	if (document.account_form.confirm_password.value == "") {
	document.account_form.confirm_password.style.backgroundColor = "#ED2024";
	returnValue = false
	} else {
	document.account_form.confirm_password.style.backgroundColor = "";
	}
	//console.log(1);
	if (returnValue == false) {


                //console.log(2);
		showErrorMessage("Please enter the required fields to complete your registration!\n\r\n\r Required fields are marked with an *");
		return false
	
	} else {

                //console.log(3);
		choosePassword = document.account_form.choose_password.value;

		confirmPassword = document.account_form.confirm_password.value;

                //console.log(choosePassword + " :-:"  + confirmPassword);
		if (choosePassword != confirmPassword) {

                        //console.log(4);
			document.account_form.choose_password.style.backgroundColor = "#ED2024";
			document.account_form.confirm_password.style.backgroundColor = "#ED2024";
			showErrorMessage("Your passwords don't match please re-enter them!");
			return false
		
		} else {

                        //console.log(5);
			doAccountFunctions();
			return false
		
		}
	
	// end if return value
	}
	
	return false
	
// end check form values function
}











function doAccountFunctions() {
	
//$w1('#ajaxloader').show();
//$w1('#accountparent').hide();

    //console.log(6);

    $w1.post("/account_update.php", $w1("#account_form").serialize(), function(data){

        //console.log(data);
        showErrorMessage(data.message, data.result);

	//$w1('#ajaxloader').hide();
	//$w1('#accountparent').show();
        
    }, "json");

//console.log($w1("#account_form").serialize());
// end do db n mail functions

}				
				
function showErrorMessage(message, result){
	
	$w1("#popup_title").text("Your Details");
	$w1("#popup_content").html(message);
	
	if(result){
		
		$w1("#popup_close").bind("click", function(){
			location.href = "/";
		});
		
		setTimeout('location.href = "/"', 10000);
		
	}
	
	// hide player cos it pokes thru		
	//$w1('#control_area').css('visibility','hidden');		
	$w1('#popup_page').fadeIn('fast');
    //console.log(message);
}


function validateEmail(elementValue){  
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    return emailPattern.test(elementValue);  
} 






// JavaScript Document