function validateRegistrationForm() {
	var forename = document.forms.form.forename.value;
	var surname = document.forms.form.surname.value;
	var displayName = document.forms.form.display_name.value;
	var email = document.forms.form.email.value;
	var password = document.forms.form.password.value;
	var password2 = document.forms.form.password2.value;
	var describe = document.forms.form.describe.options[document.form.describe.selectedIndex].value;
	var fund_type = document.forms.form.fund_type.options[document.form.fund_type.selectedIndex].value;
	
	var discuss = document.forms.form.discuss.checked;
	var terms = document.forms.form.agree.checked;
	var hedge = document.forms.form.hedge.checked;
	var telephone = document.forms.form.telephone.value;
	
	var country = document.forms.form.country.options[document.forms.form.country.selectedIndex].value;
	
	var formValid = true;
	var reason = "";
	
	if(!forename) {
		formValid = false;
		reason = reason + "\nplease type in your forename   ";
	}
	if(!surname) {
		formValid = false;
		reason = reason + "\nplease type in your surname   ";
	}
	if(!displayName) {
		formValid = false;
		reason = reason + "\nplease type in your report display name. We would recommend typing in your full name and company name   ";
	}
	else if(displayName.length < forename.length + surname.length) {
		formValid = false;
		reason = reason + "\nyour report display name must include your full name plus the name of the company that you work for. If you do not enter your full name, you may risk invalidating your account!   ";
	}
	if(email.indexOf("@") == -1 || email.indexOf(".") == -1) {
		formValid = false;
		reason = reason + "\nplease enter a valid email address   ";
	}
	if(!password) {
		formValid = false;
		reason = reason + "\nplease enter a password   ";
	}
	else if(password.length < 6) {
		formValid = false;
		reason = reason + "\nplease enter a password of at least 6 characters   ";
	}
	if(password != password2) {
		formValid = false;
		reason = reason + "\nyour 2 passwords do not match. Please confirm!   ";
	}
	if(hedge && !telephone) {
		formValid = false;
		reason = reason + "\nplease type in your telephone number   ";
	}
	if(!describe) {
		formValid = false;
		reason = reason + "\nplease select an option from the descriptions list   ";
	}
	if(!fund_type) {
		formValid = false;
		reason = reason + "\nplease select which type of fund you are looking for   ";
	}
	if(!country) {
		formValid = false;
		reason = reason + "\nplease select a country from the drop down list   ";
	}
	if(!terms) {
		formValid = false;
		reason = reason + "\nyou must agree to the Terms and Conditions before proceeding   ";
	}
	if(discuss && !telephone) {
		formValid = false;
		reason = reason + "\nIf you wish someone to contact you regarding our research and consultancy services please fill in your telephone number   ";
	}
		
	if(formValid){
		if(hedge) {
			//open the hedge fund approval form
			openWindow("hedge_fund_application.php?email=" + email, 1, 600, 400);
		}
		return true;
	}
	else{
		alert("The following errors have occured:   \n" + reason);
		return false;
	}
}

function validateRegistrationFormFM() {
	var forename = document.forms.form_fm.forename.value;
	var surname = document.forms.form_fm.forename.value;
	var displayName = document.forms.form_fm.display_name.value;
	var email = document.forms.form_fm.email.value;
	var company = document.forms.form_fm.company.value;
	var password = document.forms.form_fm.password.value;
	var password2 = document.forms.form_fm.password2.value;
	var describe = document.forms.form_fm.describe.options[document.forms.form_fm.describe.selectedIndex].value;
	
	var terms = document.forms.form_fm.agree.checked;
	var hedge = 1;
	var telephone = document.forms.form_fm.telephone.value;
	
	var country = document.forms.form_fm.country.options[document.forms.form_fm.country.selectedIndex].value;
	
	var formValid = true;
	var reason = "";
	
	if(!forename) {
		formValid = false;
		reason = reason + "\nplease type in your forename   ";
	}
	if(!surname) {
		formValid = false;
		reason = reason + "\nplease type in your surname   ";
	}
	if(!displayName) {
		formValid = false;
		reason = reason + "\nplease type in your report display name. We would recommend typing in your full name and company name   ";
	}
	else if(displayName.length < forename.length + surname.length) {
		formValid = false;
		reason = reason + "\nyour report display name must include your full name plus the name of the company that you work for. If you do not enter your full name, you may risk invalidating your account!   ";
	}
	if(email.indexOf("@") == -1 || email.indexOf(".") == -1) {
		formValid = false;
		reason = reason + "\nplease enter a valid email address   ";
	}
	if(!company) {
		formValid = false;
		reason = reason + "\nplease type in the name of the fund management company to which you belong    ";
	}
	if(!password) {
		formValid = false;
		reason = reason + "\nplease enter a password   ";
	}
	else if(password.length < 6) {
		formValid = false;
		reason = reason + "\nplease enter a password of at least 6 characters   ";
	}
	if(password != password2) {
		formValid = false;
		reason = reason + "\nyour 2 passwords do not match. Please confirm!   ";
	}
	if(hedge && !telephone) {
		formValid = false;
		reason = reason + "\nplease type in your telephone number   ";
	}
	if(!describe) {
		formValid = false;
		reason = reason + "\nplease select an option from the descriptions list   ";
	}
	if(!country) {
		formValid = false;
		reason = reason + "\nplease select a country from the drop down list   ";
	}
	if(!terms) {
		formValid = false;
		reason = reason + "\nyou must agree to the Terms and Conditions before proceeding   ";
	}
		
	if(formValid){
		if(hedge) {
			//open the hedge fund approval form
			//openWindow("hedge_fund_application.php?email=" + email, 1, 600, 400);
		}
		return true;
	}
	else{
		alert("The following errors have occured:   \n" + reason);
		return false;
	}
}

function registerStandard() {
	document.getElementById("regform").style.display = "block";
	document.getElementById("regtype").style.display = "none";
}

function registerFundmanager() {
	document.getElementById("regfm").style.display = "block";
	document.getElementById("regtype").style.display = "none";
}

function validateFMApplication(){
	var company = document.forms.profile_fm.company.value;
	var hedge = document.forms.profile_fm.hedge.checked;
	var hedgeBefore = document.forms.profile_fm.hedge_before.value;
	var telephone = document.forms.profile_fm.telephone.value;
	
	var email = document.forms.form.email.value;
	
	var formValid = true;
	var reason = "";
	
	if(!hedge) {
		formValid = false;
		reason = reason + "\nyou must be hedge fund accredited to manage funds on the GFA website   ";
	}
	if(!telephone) {
		formValid = false;
		reason = reason + "\nplease type in your telephone number   ";
	}
	if(!company) {
		formValid = false;
		reason = reason + "\nplease type in the name of the fund management company to which you belong    ";
	}	
		
	if(formValid){
		if(hedge && !hedgeBefore) {
			//open the hedge fund approval form
			openWindow("hedge_fund_application.php?email=" + email, 1, 600, 400);
		}
		return true;
	}
	else{
		alert("The following errors have occured:   \n" + reason);
		return false;
	}
}

function validateProfileForm() {
	var forename = document.forms.form.forename.value;
	var surname = document.forms.form.surname.value;
	var displayName = document.forms.form.display_name.value;
	
	var hedge = document.forms.form.hedge.checked;
	var hedgeBefore = document.forms.form.hedge_before.value;
	var telephone = document.forms.form.telephone.value;
	
	var email = document.forms.form.email.value;
	
	var country = document.forms.form.country.options[document.forms.form.country.selectedIndex].value;
	
	var formValid = true;
	var reason = "";
	
	if(!forename) {
		formValid = false;
		reason = reason + "\nplease type in your forename   ";
	}
	if(!surname) {
		formValid = false;
		reason = reason + "\nplease type in your surname   ";
	}
	if(!displayName) {
		formValid = false;
		reason = reason + "\nplease type in your report display name. We would recommend typing in your full name and company name   ";
	}
	else if(displayName.length < forename.length + surname.length) {
		formValid = false;
		reason = reason + "\nyour report display name must include your full name plus the name of the company that you work for. If you do not enter your full name, you may risk invalidating your account!   ";
	}
	if(!country) {
		formValid = false;
		reason = reason + "\nplease select a country from the drop down list   ";
	}
	if(hedge && !telephone) {
		formValid = false;
		reason = reason + "\nplease type in your telephone number   ";
	}
		
	if(formValid){
		if(hedge && !hedgeBefore) {
			//open the hedge fund approval form
			openWindow("hedge_fund_application.php?email=" + email, 1, 600, 400);
		}
		return true;
	}
	else{
		alert("The following errors have occured:   \n" + reason);
		return false;
	}
}

function validateExcellenceRegistrationForm() {
	var forename = document.forms.form.forename.value;
	var surname = document.forms.form.surname.value;
	var email = document.forms.form.email.value;
	var companyName = document.forms.form.company.value;
	var telephone = document.forms.form.telephone.value;
	var address = document.forms.form.address.value;
	var postcode = document.forms.form.postcode.value;
	var country = document.forms.form.country.value;
	var password = document.forms.form.password.value;
	var password2 = document.forms.form.password2.value;
	var describe = document.forms.form.describe.options[document.form.describe.selectedIndex].value;
	var fund_type = document.forms.form.fund_type.options[document.form.fund_type.selectedIndex].value;
	
	var terms = document.forms.form.agree.checked;
	
	
	var formValid = true;
	var reason = "";
	
	if(!forename) {
		formValid = false;
		reason = reason + "\nplease type in your forename   ";
	}
	if(!surname) {
		formValid = false;
		reason = reason + "\nplease type in your surname   ";
	}
	if(email.indexOf("@") == -1 || email.indexOf(".") == -1) {
		formValid = false;
		reason = reason + "\nplease enter a valid email address   ";
	}
	if(!companyName) {
		formValid = false;
		reason = reason + "\nplease enter your company name   ";
	}
	if(!telephone) {
		formValid = false;
		reason = reason + "\nplease enter your telephone number   ";
	}
	if(!address) {
		formValid = false;
		reason = reason + "\nplease enter your address   ";
	}
	if(!postcode) {
		formValid = false;
		reason = reason + "\nplease enter your postcode   ";
	}
	if(!country) {
		formValid = false;
		reason = reason + "\nplease enter a country   ";
	}
	if(!password) {
		formValid = false;
		reason = reason + "\nplease enter a password   ";
	}
	else if(password.length < 6) {
		formValid = false;
		reason = reason + "\nplease enter a password of at least 6 characters   ";
	}
	if(password != password2) {
		formValid = false;
		reason = reason + "\nyour 2 passwords do not match. Please confirm!   ";
	}
	if(!describe) {
		formValid = false;
		reason = reason + "\nplease select an option from the descriptions list   ";
	}
	if(!fund_type) {
		formValid = false;
		reason = reason + "\nplease select which type of fund you are looking for   ";
	}
	if(!terms) {
		formValid = false;
		reason = reason + "\nyou must agree to the Terms and Conditions before proceeding   ";
	}
		
	if(formValid){
		return true;
	}
	else{
		alert("The following errors have occured:   \n" + reason);
		return false;
	}
}