


/////////////////  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 = "";
	}
	
	if (returnValue == false) {

		showErrorMessage("Please enter the required fields to complete your registration!\n\r\n\r Required fields are marked with an *");
		return false
	
	} else {
	
		choosePassword = document.account_form.choose_password.value;
		confirmPassword = document.account_form.confirm_password.value;
		
		if (choosePassword != confirmPassword) {
		
			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 {
		
			doAccountFunctions();
			return false
		
		}
	
	// end if return value
	}
	
	return false
	
// end check form values function
}











function doAccountFunctions() {
	
$w1('#ajaxloader').show();
$w1('#accountparent').hide();
var url = "account_update.php"
$w1.post(url, { title: document.account_form.title.value, firstname: document.account_form.firstname.value, surname: document.account_form.surname.value, email: document.account_form.email.value, telephone: document.account_form.telephone.value, company: document.account_form.company.value, country: document.account_form.country.value, industrytype: document.account_form.industrytype.value, choose_password: document.account_form.choose_password.value, address1:  document.account_form.address1.value, address2: document.account_form.address2.value, address3: document.account_form.address3.value, address4: document.account_form.address4.value, weburl: document.account_form.weburl.value, notes: document.account_form.notes.value, postcode: document.register_form.postcode.value }, function(data){
//$w1('#error_msg').html(data);
//$w1('#accountcopy').html(data);
	
	
	showErrorMessage(data.message, data.result);
	
	$w1('#ajaxloader').hide();
	$w1('#accountparent').show();
	
}, "json");

// 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');	
}


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






// JavaScript Document