function clearForm() {
	if(search_form.area.value=='Postcode'){
		search_form.area.value='';
	}
}
function search_form_text_click(textinput) {
	if(textinput.name=='search' && textinput.value=='What?') { textinput.value=''; }
	else if(textinput.name=='search_name' && textinput.value=='or Who?') { textinput.value=''; }
	else if(textinput.name=='area' && textinput.value=='Postcode') { textinput.value=''; }
}
function check_feedback_form() {
	var error = '';
	var emailregex = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;		
	var firstname = document.feedback_form.firstname.value;
	var surname = document.feedback_form.surname.value;
	var email = document.feedback_form.email.value;
	var suggestion = document.feedback_form.suggestion.value;

	if(firstname == ''){error = error + "You must enter a first name\n";}
	if(surname == ''){error = error + "You must enter a surname\n";}
	if(email == ''){error = error + "You must enter an e-mail address\n";}
	if(!email.match(emailregex)){error = error + "You must enter a valid e-mail address\n";}
	if(suggestion == ''){error = error + "You must enter a suggestion\n";}
	if(error != ''){
		alert(error);
		return false;
	}else{
		return true;
	}
}
function check_sms_info_form() {
	var error = '';

	var full_name = document.sms_info_form.full_name.value;
	var full_name_regex = /^[a-zA-Z0-9\s.,]{3,}$/;
	if(full_name == ''){error = error + "You must enter your name\n";}
	else if(!full_name.match(full_name_regex)){error = error + "You must enter a valid name (min 3 chars)\n";}

	var telephone = document.sms_info_form.telephone.value;
	var phone_regex = /^[0-9\+(]?[0-9( -)]*?$/;
	if(telephone == ''){error = error + "You must enter a phone number\n";}
	if(!telephone.match(phone_regex)){error = error + "You must enter a valid phone number\n";}

	var town = document.sms_info_form.town.value;
	if(town == ''){error = error + "You must enter your town of residence\n";}

	if(error != ''){
		alert(error);
		return false;
	}else{
		return true;
	}
}
function CheckRadio(theElement) {
	for(i = 0; i<theElement.length; i++) {
		if(theElement[i].checked) {
			return true;
		}
	}
	alert("Please select one answer");
	return false;
}

function fv_sign_up_basic() {
	var error = '';
	var company_phone = document.sign_up_form.company_phone.value;
	var phone_regex = /^[0-9+(]?[0-9( -)]*?$/;
	if(company_phone == ''){error = error + "You must enter a phone number\n";}
	if(!company_phone.match(phone_regex)){error = error + "You must enter a valid phone number\n";}
	if(error != ''){
		alert(error);
		return false;
	}else{
		return true;
	}
}
function fv_sign_up_phone_search() {
	var error = '';
	var company_postcode_r = document.sign_up_form.company_postcode_r.value;
	var company_postcode_l = document.sign_up_form.company_postcode_l.value;
	var postcode_r_regex = /^[a-zA-Z]{1,2}[0-9]{1,2}[a-zA-Z]?$/;
	var postcode_l_regex = /^[0-9]{1}[a-zA-Z]{2}$/;
	if(company_postcode_r == ''){error = error + "You must enter a postcode region\n";}
	if(!company_postcode_r.match(postcode_r_regex)){error = error + "You must enter a valid postcode region\n";}
	if(company_postcode_l == ''){error = error + "You must enter a postcode localiser\n";}
	if(!company_postcode_l.match(postcode_l_regex)){error = error + "You must enter a valid postcode localiser\n";}
	if(error != ''){
		alert(error);
		return false;
	}else{
		return true;
	}
}
function fv_sign_up_add_mod(){
	var error = '';

	var company_phone = document.sign_up_form.company_phone.value;
	var phone_regex = /^[0-9\+(]?[0-9( -)]*?$/;
	if(company_phone == ''){error = error + "You must enter a phone number\n";}
	if(!company_phone.match(phone_regex)){error = error + "You must enter a valid phone number\n";}

	var uk_biz_check = document.sign_up_form.uk_biz_check.value;
	if(uk_biz_check == 1){
		var company_postcode_r = document.sign_up_form.company_postcode_r.value;
		var postcode_r_regex = /^[a-zA-Z]{1,2}[0-9]{1,2}[a-zA-Z]?$/;
		if(company_postcode_r == ''){error = error + "You must enter a postcode region\n";}
		if(!company_postcode_r.match(postcode_r_regex)){error = error + "You must enter a valid postcode region\n";}

		var company_postcode_l = document.sign_up_form.company_postcode_l.value;
		var postcode_l_regex = /^[0-9]{1}[a-zA-Z]{2}$/;
		if(company_postcode_l == ''){error = error + "You must enter a postcode localiser\n";}
		if(!company_postcode_l.match(postcode_l_regex)){error = error + "You must enter a valid postcode localiser\n";}
	}

	var company_name = document.sign_up_form.company_name.value;
	var name_regex = /^[a-zA-Z0-9., '\!\&\(\)-]*?$/;
	if(company_name == ''){error = error + "You must enter a company name\n";}
	if(!company_name.match(name_regex)){error = error + "You must enter a valid company name\n";}

	var contact_name = document.sign_up_form.contact_name.value;
	var cname_regex = /^[a-zA-Z0-9., '-]*?$/;
	if(contact_name == ''){error = error + "You must enter a contact name\n";}
	if(!contact_name.match(cname_regex)){error = error + "You must enter a valid contact name\n";}

	var company_address = document.sign_up_form.company_address.value;
	var address_regex = /^[a-zA-Z0-9., '-]*?$/;
	if(company_address == ''){error = error + "You must enter a company address\n";}
	if(!company_address.match(address_regex)){error = error + "You must enter a valid company address\n";}

	var company_town = document.sign_up_form.company_town.value;
	var town_regex = /^[a-zA-Z. '-]*?$/;
	if(company_town == ''){error = error + "You must enter a company town\n";}
	if(!company_town.match(town_regex)){error = error + "You must enter a valid company town\n";}

	var company_mobile = document.sign_up_form.company_mobile.value;
	var mobile_regex = /^[0-9\+(]?[0-9( -)]*?$/;
	if(company_mobile != '' && !company_mobile.match(mobile_regex)){error = error + "You must enter a valid company mobile\n";}

	var company_fax = document.sign_up_form.company_fax.value;
	var fax_regex = /^[0-9\+(]?[0-9( -)]*?$/;
	if(company_fax != '' && !company_fax.match(fax_regex)){error = error + "You must enter a valid company fax\n";}

	var company_county = document.sign_up_form.company_county.value;
	var county_regex = /^[a-zA-Z '-]*?$/;
	if(company_county == ''){error = error + "You must enter a company county\n";}
	if(!company_county.match(county_regex)){error = error + "You must enter a valid company county\n";}

	var company_email = document.sign_up_form.company_email.value;
	var email_regex = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	if(company_email == ''){error = error + "You must enter a company email\n";}
	if(!company_email.match(email_regex)){error = error + "You must enter a valid company email\n";}

	if(error != ''){
		alert(error);
		return false;
	}else{
		return true;
	}
}
startList = function() {
	if (document.all&&document.getElementById) {
		for (j=0; j<=3; j++) {
			elementId = "nav" + j;
			navRoot = document.getElementById(elementId);
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}
function RemoveContent(d) {
	document.getElementById(d).style.display = "none";
}
function InsertContent(d) {
	document.getElementById(d).style.display = "";
}
//window.onload=startList;


if (document.images) 
{
  img1 = new Image();
  img2 = new Image();
  img3 = new Image();
  img4 = new Image();
  img5 = new Image();
  img6 = new Image();
  img7 = new Image();
  img8 = new Image();
  img9 = new Image();
  img10 = new Image();
  img11 = new Image();
  img12 = new Image();

  img1.src = "/resources/images/before_test_over.jpg";
  img2.src = "/resources/images/theory_test_over.jpg"
  img3.src = "/resources/images/practical_test_over.jpg"
  img4.src = "/resources/images/after_test_over.jpg"
  img5.src = "/resources/images/home_link_over.jpg"
  img6.src = "/resources/images/help_link_over.jpg"
  img7.src = "/resources/images/site_map_link_over.jpg"
  img8.src = "/resources/images/home_page_over.jpg"
  img9.src = "/resources/images/feedback_over.jpg"
  img10.src = "/resources/images/get_listed_over.jpg"
  img11.src = "/resources/images/terms_conditions_over.jpg"
  img12.src = "/resources/images/site_map_over.jpg"
}

function link_length_check(link) {
		if (link.length>30)
			{
				document.write('Click Here!')
			}
		else
		{
			document.write(link)
		}
}

function fade_In(path, id)
{
	var target = document.getElementById(id);
	if (target.filters){
	target.style.filter="blendTrans(duration=0.25)";
  target.filters.blendTrans(duration=0.25).Apply();
  target.filters.blendTrans.Play();
	target.style.backgroundImage = "url("+path+")";
	}
}

function fade_Out(path, id)
{
	var target = document.getElementById(id);
	if (target.filters){
	target.style.filter="blendTrans(duration=0.25)";
  target.filters.blendTrans(duration=0.25).Apply();
  target.filters.blendTrans.Play();
	target.style.backgroundImage = "url("+path+")";
	}
}
