var IntTime = 9000;
	var clubname=getCookie('F4lessClub');
	// Must Keep In Order
	var Clubs = [];
	Clubs[0]='Bristol';
	Clubs[1]='Birmingham';
	Clubs[2]='Watford';
	Clubs[3]='Cambridge';
	Clubs[4]='Nottingham';
	Clubs[5]='Newport';
	Clubs[6]='Southwark';
	Clubs[7]='Sutton';
	Clubs[8]='Cardiff';
	Clubs[9]='Cheltenham';
	Clubs[10]='Chesham';

	var HTML = '';
	var SELECTi = '<span id="ClubStatusBar">:&nbsp;<select id="ChooseClub" name="ChooseClub" onchange="DropChangeClub();">';
	SELECTi += '<option value="">Please select</option>';
	var arLen=Clubs.length;
	
	for ( var i=0, len=arLen; i<len; ++i ){
	if (i === 3) {
	SELECTi +=  '<option value="' + Clubs[i] + '">London Cambridge Heath</option>';	
	} else if (i === 6) {
	SELECTi +=  '<option value="' + Clubs[i] + '">London Southwark</option>';		
	} else {
	SELECTi +=  '<option value="' + Clubs[i] + '">' + Clubs[i] +'</option>';
	}}
	SELECTi +=  '</select></span>';
	var SetId = '#club_log_box';
	if (clubname!=null && clubname!="") {
	HTML = 'You are logged into' + SELECTi + ' Club';
  	$(document).ready(function(){$(SetId).empty().append(HTML);});FindIndex(clubname);
	  } else { HTML = 'Please select your club:' + SELECTi;$(document).ready(function(){$(SetId).empty().append(HTML);}); }
	  
	$(document).ready(function(){
	ChangeMenu();
    if ($("#footer_3").length){
	if ( $("#footer_3").html().toLowerCase().indexOf('2009 (terms and conditions)</span>') > 0) {
	$("#footer_3").empty().append('<span class="BaseTerms">&copy;2009 <a class="BaseTerms" href="terms_and_conditions.html">(terms and conditions)</a></span>');
	}
	}
   });
	
	function ChangeMenu()
	{
	var replace_this = new Array('menu_item7','menu_item8','menu_item9','menu_item6','menu_item10');//,'menu_item11','menu_item12');
var with_this =    new Array('menu_item8','menu_item9','menu_item6','menu_item10','menu_item11','menu_item12','menu_item');
var count = 0;
var i=replace_this.length;
var FitClass = 'off';
while (i--){
    $("#"+replace_this[count]).html($("#"+with_this[count]).html()); count++;
}
$("#menu_item6").css("line-height","30px");$("#menu_item7").css("line-height","30px");$("#menu_item8").css("line-height","15px");
var onpage = $("div#OnPage img").attr("src");
switch (onpage) {
	case 'images/active_tanning_18.jpg':
		$("#menu_item6").html($("#OnPage").html());$("#menu_item6").css("padding-top","0px");$("#OnPage").html('<a href="questions.html">F.A.Qs</a>');$("#OnPage").addClass("faqs2011");
	break;
	case 'http://www.fitness4less.uk.net/images/active_faqs_19.jpg':
		$("#menu_item10").html($("#OnPage").html());$("#menu_item10").css("padding-top","0px");$("#OnPage").html('<a href="classes.html">Classes</a>');$("#OnPage").addClass("classes2011");
	break;
	case 'http://www.fitness4less.uk.net/images/active_club_tour_15.jpg':
		$("#menu_item7").html($("#OnPage").html());$("#menu_item7").css("padding-top","0px");$("#OnPage").html('<a href="personal-training.html">Personal<br>Training</a>');$("#OnPage").addClass("pt2011");
	break;
	case 'http://www.fitness4less.uk.net/images/active_contact_us_17.jpg':
		$("#menu_item9").html($("#OnPage").html());$("#menu_item9").css("padding-top","0px");$("#OnPage").html('<a href="tanning.html">Tanning</a>');$("#OnPage").addClass("tanning2011");
	break;
	case 'images/active_contact_us_17.jpg':
		$("#menu_item9").html($("#OnPage").html());$("#menu_item9").css("padding-top","0px");$("#OnPage").html('<a href="tanning.html">Tanning</a>');$("#OnPage").addClass("tanning2011");
	break;
	case 'http://www.fitness4less.uk.net/images/active_classes.jpg':
		$("#menu_item11").html($("#OnPage").html());$("#menu_item11").css("padding-top","0px");$("#OnPage").html('');$("#OnPage").addClass("item122011");FitClass = 'on';
	break;
	case 'http://www.fitness4less.uk.net/images/active_pt_16.jpg':
		$("#menu_item8").html($("#OnPage").html());$("#menu_item8").css("padding-top","0px");$("#OnPage").html('<a href="contact-us.html">Contact<br>Us</a>');$("#OnPage").addClass("item62011");	
	break;
	}
if (FitClass === 'off') {$("#menu_item11").empty().append("<a href=\"Fitness_Classes.html\">Classes</a>"); }
	$("#menu_item12").empty().append("&nbsp;");
	
	}
	
	function DropChangeClub()
	{
	  var DClub = document.getElementById('ChooseClub').value;
	  if (DClub !== "") {ClickSelectClub(DClub);}}
	  
	function DisplayDiv(id)
	{	
	id = '#'+id;$(document).ready(function(){
   	$(id).show("slow");});
	}
	function MailLink(rec, domain, style, id, image)
	{
	var EmailAddr = rec + '@' + domain;
	id = '#'+id;
	if (image === 'Image')
	{	
	location.href="mailto:" + EmailAddr;
	} else {
	id = '#'+id;
	var Mail = '<a class="' + style + '" href="mailto:' + EmailAddr + '">' + EmailAddr + '</a>';
	$(document).ready(function(){
    	$(id).append(Mail); }); }
	}
	
	function CookieExpiration(ExpLength)
	{
	var Weekday_array = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
	var Month_array = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	var CookieExp = 'Fri, 31 Dec 2010 23:59:59 GMT';
	var now = new Date();
	var This_Year = now.getFullYear();
	var This_Hours = now.getHours()+1 + parseFloat(ExpLength);
	var CookieExpShow = Weekday_array[now.getDay()] + ', ' + now.getDate() + ' ' + Month_array[now.getMonth()] + ' ' + This_Year + ' ' + This_Hours + ':' + now.getMinutes() + ':00 GMT';
	return CookieExpShow;
	}
	
	function FormLogin() 
	{
	$.post("http://www.fitness4less.co.uk/MemberZone/MemberFunctions.php", { EmailAddress: $("#EmailAddress").val() , MemberID: $("#MembershipNo").val(), club: $("#club").val() }, function(data){
	data = jQuery.trim(data);
	if (data !== "OK") {
	alert("Cannot login with these details. Please try again");
	} else {
	$("#LoginStatusBar").empty().append("<div style=\"position:absolute;font-size:12px;font-weight:bold;width:200px;left:-100px;\"><em>Logged in. Please wait<\/em></div>");
	$("#LoginStatusBar").css("color","#FFFFFF");
	var CookieName = 'F4LMember';
	var ClubName = document.getElementById('club').value;
	var CookieExpiryTime = CookieExpiration('1');
	SetCookie(CookieName,CookieExpiryTime,ClubName);
	//Set Memberid cookie
	var MembersID = document.getElementById('MembershipNo').value;
	SetCookie('MemberID',CookieExpiryTime,MembersID);
	// Check if this is first visit
	var t=setTimeout("window.location = 'MemberZone.php'",1200) } });
	}
	function ClubSelector()
	{
	// Check for cookie	
	clubname=getCookie('F4lessClub');
	if (clubname!=null && clubname!="") { document.write('You are currently logged on to join our :'); }
	else { document.write('Please select your club :'); }
	}
/* CLUB DROP DOWN for new clubs*/	
	function SetJoiningFee()
	{
  	if (document.getElementById("joiningfee") != null) 	{
	if ($('#ClubSelect').val() === 'Cambridge') {
	var JFee = '49.95';var x=new Date();x.setFullYear(2011,12,31);var today = new Date();
	if (x<today) { JFee = '49.95'; }
	$("#PricePresentation").empty().append("Monthly Membership Just &pound14.99 per month<br /><span class=\"small\">(1st instalment &pound"+JFee+" Includes joining fee and first month.)</span>");
	$("#q2title").empty().append("Annual Membership &pound;199");$("#q3title").empty().append("Annual off peak membership &pound;165");$("#q4title").empty().append("3 months membership &pound;99");
	}
	else if ($('#ClubSelect').val() === 'Cardiff') {
	$("#PricePresentation").empty().append("Cardiff Limited Opening Offer<p style=\"line-height:9px;margin:0px\"><span class=\"small\">Secure your membership for just &pound;14.99 - pay nothing more until 30 days after opening</p>"); //<br \/>No enrollment fee and just &pound;<span id=\"joiningfee\">14.99<\/span> a month<\/span>");
	} else if ($('#ClubSelect').val() === 'Chesham') {
	JFee = '44.95';	
	$("#q2title").empty().append("Annual Membership &pound;199");$("#q3title").empty().append("Annual off peak membership &pound;165");$("#q4title").empty().append("3 months membership &pound;99");
	$("#PricePresentation").empty().append("Monthly Membership Just &pound14.99 per month<br /><span class=\"small\">(1st instalment &pound"+JFee+" Includes joining fee and first month.)</span>");
	} else if ($('#ClubSelect').val() === 'Nottingham') {
	$("#q2title").empty().append("Annual Membership &pound;165");$("#q3title").empty().append("Annual off peak membership &pound;105");
	} else if ($('#ClubSelect').val() === 'Cheltenham') {
		$('#heard').append('<option value="4z">Member Transfer</option>');
		$("#q2title").empty().append("Annual Membership &pound;165");$("#q3title").empty().append("Annual off peak membership &pound;105");
	} else if ($('#ClubSelect').val() === 'Southwark') {
	var JFee = '59.95';var x=new Date();x.setFullYear(2011,12,31);var today = new Date();
	if (x<today) { JFee = '59.95'; }
	$("#PricePresentation").empty().append("Monthly Membership Just &pound14.99 per month<br /><span class=\"small\">(1st instalment &pound"+JFee+" Includes joining fee and first month.)</span>");
	//$("#PricePresentation").empty().append("Southwark Limited Opening Offer<p style=\"line-height:9px;margin:0px\"><span class=\"small\">Secure your membership for just &pound;14.99 - pay nothing more until 30 days after opening</p>"); //<br \/>No enrollment fee and just &pound;<span id=\"joiningfee\">14.99<\/span> a month<\/span>");
	//Disable Off Peak
	$("#q2title").empty().append("Annual Membership &pound;199");$("#q3title").empty().append("Off Peak Membership<span class=\"small\"><br \/>This membership is currently unavailable<\/span>");$("#q4title").empty().append("3 months membership &pound;99");
	$("#OffPeakRadio").empty().append("&nbsp;");
	$("#membertype").val('3');
	$('input[name=memb_type]:eq(0)').attr('checked', 'checked');
	} else if ($('#ClubSelect').val() === 'Sutton') {
	$("#PricePresentation").empty().append("Sutton Limited Opening Offer<p style=\"line-height:9px;margin:0px\"><span class=\"small\">Secure your membership for just &pound;14.99 - pay nothing more until 30 days after opening</p>");
	$("#q2title").empty().append("Annual Membership &pound;165");$("#q3title").empty().append("Annual off peak membership &pound;105");
	} else {
	$("#PricePresentation").empty().append("Monthly Membership Just &pound;14.99 per month <span class=\"small\"><br />(1st instalment &pound;<span id=\"joiningfee\">39.95</span> Includes joining fee and first month.)<\/span>");
	$("#q2title").empty().append("Annual Membership &pound;165");$("#q3title").empty().append("Annual off peak membership &pound;105");
	}} 
	}
	function CheckAvailability() 
	{
		if (($('#ClubSelect').val() === 'Sutton') || ($('#ClubSelect').val() === 'Cardiff')) {
		text = 'In Summer 2011, after '+$('#ClubSelect').val()+' Fitness4less has opened, our full range of memberships will go on sale, including:Annual, Off peak, 3 & 1 month memberships and day passes.';
		$("#NottinghamPopUp").empty().append(text);
		$("#NottinghamPopUp").show();	
		$('input[name=memb_type]:eq(0)').attr('checked', 'checked');
		$("#NottinghamPopUp").css('cursor','pointer');
		$("#NottinghamPopUp").click(function() {$("#NottinghamPopUp").hide();});
		}
	}
	function ClubDropDownODL(SelectID,ElementID)
	{
	var SelectedClub;
	var ClubCookie = getCookie('F4lessClub');
	var HTML = '<select id="'+SelectID+'" name="'+SelectID+'")>';
	HTML += '<option value="">Please select<\/option>';
	var arLen=Clubs.length;
	
	for ( var i=0, len=arLen; i<len; ++i ){
	if (i === 3) {
	HTML += '<option value="' + Clubs[i] + '"'+ SelectedClub + '>London Cambridge Heath<\/option>';	
	} else if (i === 6) {
	HTML += '<option value="' + Clubs[i] + '"'+ SelectedClub + '>London Southwark<\/option>';		
	} else {
	HTML += '<option value="' + Clubs[i] + '"'+ SelectedClub + '>' + Clubs[i] + '<\/option>';
	}
	}
	
	HTML += '<\/select>';
	var SetId = '#'+ElementID;
	$(document).ready(function(){
	 $(SetId).empty().append(HTML);
	 document.getElementById(SelectID).value=ClubCookie;
	});	
	}
	function ClubDropDown(SelectID,ElementID)
	{
	var SelectedClub;
	var ClubCookie = getCookie('F4lessClub');
	var HTML = '<select id="'+SelectID+'" name="'+SelectID+'" onchange="SetJoiningFee();")>';
	HTML += '<option value="">Please select</option>';
	var arLen=Clubs.length;
	
	for ( var i=0, len=arLen; i<len; ++i ){
	if (i === 3) {
	HTML += '<option value="' + Clubs[i] + '"'+ SelectedClub + '>London Cambridge Heath<\/option>';	
	} else if (i === 6) {
	HTML += '<option value="' + Clubs[i] + '"'+ SelectedClub + '>London Southwark<\/option>';		
	} else {
	HTML += '<option value="' + Clubs[i] + '"'+ SelectedClub + '>' + Clubs[i] + '</option>';
	}
	}
	
	HTML += '</select>';
	var SetId = '#'+ElementID;
	$(document).ready(function(){
	 $(SetId).empty().append(HTML);
	 document.getElementById(SelectID).value=ClubCookie;
	});	
	}
/* GET COOKIE */
	function getCookie(c_name)
	{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	{
	c_start=c_start + c_name.length+1;
	c_end=document.cookie.indexOf(";",c_start);
	if (c_end==-1) c_end=document.cookie.length;
	return unescape(document.cookie.substring(c_start,c_end));
	}
	  }
	return "";
	}
/* CHECK MEDICAL */
	function CheckMedical() 
	{
	var count = 0;
	var elt = "";
	var theItem = "";
	var result;
	
	for (var i=1; i<=10; i++) {
	theItem = "qs" + i;
	elt = "document.forms['check']" + "." + theItem + "[0]" + ".checked";
	elt2 = "document.forms['check']" + "." + theItem + "[1]" + ".checked";
	result = eval(elt);
	
	if (result === false) {
	if (eval(elt2) === true) {
	count++;
	}
	} else {
	window.location='sorry.html';
	return false;
	}
	}
	if (count < 10) {
	alert ("Please answer all questions.");
	return false;
	
	} else {
	window.location='https://fitness4less.co.uk/join_step2.html?medical=yes';
	return false;
	}
	}
/* JQUERY HIDE */
	function HideElement(id) 
	{
	id = "#"+id;
	$("#di").hide();
	$("#ku").hide();
	}
/* CHECK MEMBERSHIP */
	function CheckMembershipForm() 
	{
	var obj = document.forms.membership;
	
	/* Email validation */
	var ValidEmail = /^[\w_\.\-]+?@[A-Za-z0-9\-\.]{2,}?\.((\w{2})|(aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel))$/;
	if (obj.email.value.search(ValidEmail)==-1) {
	alert("A valid email address is compulsory for Fitness4less membership.");
	return false;
	}
	
	if (obj.email.value != obj.emailconfirmation.value) {
	alert("These email addresses do not match. Please re-enter your email address.");
	return false;
	}
	
	/* Over 18 Consent */
	sm = obj.dob_month.value;
	sy = obj.dob_year.value;
	sd = obj.dob_day.value;
	 
	if ((sy >= 1991) && (sm >= 10) && (sd > 9)) {
	document.getElementById('under18').style.visibility = 'visible';
	if (obj.agree18.checked === false) {
	alert("You must have parental consent to join Fitness4less");
	return false;
	}
	}
	/* Address Error */
	if (obj.town.value == "undefined") {
	alert("Sorry, we cannot process your address.\nPlease try address lookup, or manually enter your address.");
	return false;
	}
	
	/* Club Type */
	if (obj.ClubSelect.value == "") {
	alert("Please choose a Fitness4less club.");
	obj.ClubSelect.focus();
	return false;
	}
	
	/* Accept Terms & Conditions */
	if (obj.acceptterms.checked === false) {
	alert("Please tick the box to confirm to you agree with Fitness4less Terms and Conditions of membership.");
	obj.acceptterms.focus();
	return false;
	}
	/* Membership Type */
	if (obj.membertype.value == "") { alert("Please choose a membership type."); return false; }
	 
	for(var i=0; i<obj.elements.length; i++)
	{ 	if ((obj.elements[i].value == "") && (obj.elements[i] != "lookup")) {
	if (obj.elements[i].name == "house_number") {
	alert("Please enter house number or use address lookup.");
	//Show Address Form
	$('#address').show("slow");
	} else {
	obj.elements[i].focus(); 
	obj.elements[i].className='errorfield';
	alert("Please complete all sections of the form. "); // + obj.elements[i].name);
	} return false; } }
	 var ValidChars = "0123456789.+-";
	 var Char;
	 var IsNumber=true;
	 
	 for (i = 0; i < obj.telephone.value.length && IsNumber == true; i++) 
	  { 
	  Char = obj.telephone.value.charAt(i); 
	  if (ValidChars.indexOf(Char) == -1) {
	 IsNumber = false;
	 alert("Please check telephone number contains no letters");
	 obj.telephone.focus();
	 obj.telephone.className='errorfield';
	 return false;
	 }
	}	
	return true;
	}
	
/* GET ADDRESS FUNCTION */
	function getaddress() 
	{
	var id = 'lookup';
	var ref = document.udpform.street_name.value;
	var url = 'scripts/get_address.php?udp=' + ref;
	
	$.get(url, function(data){
	var addr_array=data.split("^");
	// Check if any error thrown:
	var FirstLine = addr_array[0];
	var err = 'Undefined';
	var AddChk = FirstLine.indexOf(err);
	if (AddChk != '-1') {
	FirstLine = 'N/A';
	}
	document.forms.membership.house_number.value = FirstLine;
	document.forms.membership.StreetName.value = addr_array[1];
	document.forms.membership.town.value = addr_array[2];
	document.forms.membership.county.value = addr_array[3];
	});
	}
/* DISPLAY FUNCTION */
	function display(id,status) 
	{
	obj = document.getElementById(id);
	obj.style.display = status;
	}
	$(document).ready(function(){
    
    $("#LookUpClose").click(function () {
      $("#lookup").hide("slow");
    });
	return false;
  });
/* SHOW FORM FUNCTION */
	function showform() 
	{
	var postcode = document.membership.post_code.value;
	if (postcode === '') {
	alert("Please enter a post code.");
	return false;
	}
	var url = 'scripts/get_postcode.php?postcode=' + postcode;
	
	$(document).ready(function(){
       	$('#lookup').show("slow");
	$.get(url, function(data){
 	 
	 $('#PostCodeResults').empty().append(data);});});
	}
	
	function ClickSelectClub(ClubName) 
	{
	 var date = new Date();
	 var name = 'F4lessClub';
	 var Expiry = "not set";
	 var clubcookie=getCookie(name);
	 if (clubcookie!=null && clubcookie!="")
	  {
	  	DeleteCookie(name);
	  }	
	 
	var CookieExpiryTime = ReturnTime(ClubName);
	SetCookie(name,CookieExpiryTime,ClubName);
	ClubDropDown('ChooseClub','ClubStatusBar');
	}
	
	function ReturnTime(ClubName)
	{
	url = 'scripts/SetClub.php';
	$.get(url, { club: ClubName }, function(data){
    	 return data;
   	});
	
	}
	
	function SetCookie(CookieName,Expiry,Value)
	{
	document.cookie = CookieName+"="+Value+"; expires="+Expiry+"; domain=www.fitness4less.co.uk; path=/";
	}
	function DeleteCookie(CookieName)
	{
	//document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
	}
	
	function PayPal()
	{
		// Get Code and insert into db
		if ($("#sessionid").val() === "") { alert("sorry your session appears to have timed out.");return false; }
		var code = $("#vouchercode").val();
		$.post("Sage/AddVoucher.php", {vouchercode:code, session:$("#sessionid").val()}, function(data){ if ($.trim(data) !== "OK") {
		alert(data); return false;
		} else {
		url = window.location.href; url = url.replace(/join_step_3.html/, "paypal.html");url = url.replace(/#/, ""); window.location= url;
		}
		});
	}
	function Sage() 
	{
	url = window.location.href;
	url = url.replace(/join_step_3.html/, "sagepay.html");
	url = url.replace(/#/, "");
	window.location= url;
	}
	
	function FillSageForm()
	{
	var test = 'http://www.fitness4less.co.uk/live/sagepay.html?session=F4Lessf031ddae6a02920441f0bc0adc4c1052&osm=f5f77lf7nnn4';
	var url = 'scripts/SageForm.php?' + GetUrlData();
	$.get(url, function(data){
	var sage_array=data.split("^");
	if (sage_array[0] > 3600) {
	 	alert("Your session has now timed out. Please start the registration process again.");	
	} else {
	document.forms.SagePayForm.cardholder.value = sage_array[1];
	document.forms.SagePayForm.billingaddress.value = sage_array[2].replace(',',',\n');
	document.forms.SagePayForm.postcode.value = sage_array[3];
	document.forms.SagePayForm.MemberID.value = sage_array[4];
	document.forms.SagePayForm.membertype.value = sage_array[5];
	var urlquery = location.href.split("?");
	var GetBits = urlquery[1].split("&")
	var sessionF = GetBits[0].split("=");
	var osmF = GetBits[1].split("=");
	document.forms.SagePayForm.session.value = sessionF[1];
	document.forms.SagePayForm.osm.value = osmF[1];
	}});
	// Check for Errors in SagePay.php
	var ErrorsChk = document.forms.SagePayForm.ErrorMsg.value;
	if (ErrorsChk !== '') {
	var ErrorAr = ErrorsChk.split("^");
	var ErStatus = ErrorAr[1].replace(/^\s+|\s+$/g,'');
	/* June 10th */
	if (ErrorAr[0] === ' The VendorTxCode has been used before.  All VendorTxCodes should be unique.')
	{
	var FillDDForm = '<div style="padding:10px; color:#6E6E70; font-weight:bold">Your payment has been successfully taken';
	var MemberShipType = $('#membertype').val(); 
	if (MemberShipType === '4') { 
	FillDDForm += ', however you have not been automatically directed to the next portion of the setup.<p>';	
	FillDDForm += 'Please	click <a href="http://www.fitness4less.co.uk/DirectDebit_Timeout.html">HERE</a> to complete you membership';
	} else {
	FillDDForm += ' and your membership is now complete.';
	}
	$("#news_box_4").empty().append(FillDDForm+'</div>');
	
	} else { alert(ErrorAr[0]); }
	
	switch(ErStatus) {
	case "cardholder":
	document.forms.SagePayForm.cardholder.focus();
	document.forms.SagePayForm.cardholder.style.border = '2px solid red';
	break;
	case "cardnumber":
	document.forms.SagePayForm.cardnumber.focus();
	document.forms.SagePayForm.cardnumber.style.border = '2px solid red';
	break;
	case "cardsecuritycode":
	document.forms.SagePayForm.cardsecuritycode.focus();
	document.forms.SagePayForm.cardsecuritycode.style.border = '2px solid red';
	break;
	case "cardtype":
	document.forms.SagePayForm.cardtype.focus();
	document.forms.SagePayForm.cardtype.style.border = '2px solid red';
	break;
	case "expirymonth":
	document.forms.SagePayForm.expirymonth.focus();
	document.forms.SagePayForm.expirymonth.style.border = '2px solid red';
	break;
	case "expiryyear":
	document.forms.SagePayForm.expiryyear.focus();
	document.forms.SagePayForm.expiryyear.style.border = '2px solid red';
	break;
	
	case "validfrommonth":
	document.forms.SagePayForm.validfrommonth.focus();
	document.forms.SagePayForm.validfrommonth.style.border = '2px solid red';
	break;
	
	case "issuenumber":
	document.forms.SagePayForm.issuenumber.focus();
	document.forms.SagePayForm.issuenumber.style.border = '2px solid red';
	break;
	
	default:
	//alert("Error");
	break;
	}
	}
	}
	
	function SageSubmit()
	{
	$("#SageButton").attr("src","images/JoiningFeeWaiting.gif");
	document.forms.SagePayForm.submit();
	}
	
	function GetUrlData()
	{
	//iForm = new Array();
	var CheckURL= location.href.indexOf('?');
	
	if(CheckURL  === -1) { alert("Sorry your session has timed out.\nPlease start registration again.");return false;}
	urlquery=location.href.split("?");test = urlquery[1].split("&");
	
	for (var x in test)
	{
	var Griffin = test[x];
	var GetVal1 = 'jo';
	var GetVal2 = 'matty';
	var param1 = Griffin.indexOf(GetVal1);
	var param2 = Griffin.indexOf(GetVal2);
	
	if( param1 > -1) {
	  UrlData = Griffin.split("=");
	  GetVal1 = UrlData[1]
	  alert(GetVal1);
	} 
	else if (param2 > -1) {
	  UrlData = Griffin.split("=");
	  GetVal2 = UrlData[1].replace('#','');
	  alert(GetVal2);
	}
	}
	var returnStr = urlquery[1].replace('#','');
	//GetVal1 + '^' + GetVal2;
	// 
	return returnStr;
	
	}
	function Timetables()
	{
	 // Check if club selected	
	 	clubname=getCookie('F4lessClub');
		if (clubname!=null && clubname!="") { var url = clubname + '-timetable.html'; window.location = url; }
	else { $(document).ready(function(){ $("#TSelect").show("slow"); });
	  }
	}
    function ShowClubsButtons(page,id)
	{
     var SetId = '#' + id;
	 // Check if club selected	
	 	clubname=getCookie('F4lessClub');
	if (clubname!=null && clubname!="") {
	  var url = clubname + page; window.location = url; }
	else { $(document).ready(function(){ $(SetId).show("slow"); });
	  }
	}
	
	function fullescape(txt) 
	{
	jschars = Array(':','<','/','>',',','dddd','=','"','!','&',';','\'','@','');
	phpchars = Array('%3A','%3C','%2F','%3E','%2C','%E2','%3D','%22','%21','%26','%3B','%5C%27','%40','');
	
	for (i=0;i<jschars.length-1;i++) {
	eval("txt = txt.replace(/"+ phpchars[i] + "/g,jschars[i])");
	}
	return txt;
	}
	
	function Reveal(id)
	{
    ResetOrange()
	var RightText = '<img width="480" height="60" src="images/sub_menu_faqs_22.jpg"/><img width="480" height="340" src="images/main_top_right_box_faqs_23.jpg"/>';
	$('#top_right_box').empty().append(RightText);
	var TopR = document.getElementById('top_right_box');
	TopR.style.width = '480px';
	TopR.style.height = '400px';	
	TopR.style.padding = '0px 0px 0px 0px';
	var divlist = new Array();	
	divlist[0] = 'beforeyouj'
	divlist[1] = 'payingfory'
	divlist[2] = 'planningyo'
	divlist[3] = 'onceyourea'
	divlist[4] = 'youronline'
	divlist[5] = 'leavingthe'
	//var MaxCount = divlist.length - 1;
 	
	obj = document.getElementById(id);
	
	for(i=0;i<divlist.length;i++)
	{
	if (id !== divlist[i]) {
	id2 = divlist[i];
	ChangeIDx = 'Click_'+ divlist[i];
	obj2 = document.getElementById(id2);
	obj2.style.display = 'none';
	document.getElementById(ChangeIDx).style.height = '50px';
	}
	}
	var ChangeID = 'Click_' + id;
	var TheID = '#'+id
	document.getElementById(ChangeID).style.height = '30px';
	$(document).ready(function(){
	$(TheID).show("slow");});
	}
	
	function ClubGallery(SetClub,SetDir) {
	var NumImages = 8;
	var DisplayImages = 8;
	var DisplayBoxes=4;
	
	var ImageArray = [];
	var ImgHeight = [];
	var ImgDir = 'images/' + SetClub + '/';
//Removed	
	switch (SetClub) {
	case "Random":
	var ImgDir = 'http://www.fitness4less.uk.net/images/Bristol/';
	ImageArray[0] = 'F4L_BIRMINHAM103.jpg';
	ImgHeight[0] = '400';
	ImageArray[1] = 'F4L_BIRMINHAM111.jpg'; 
	ImgHeight[1] = '400';
	ImageArray[2] = 'F4L_BRISTOL048.jpg'; //FitnessClass.jpg';
	ImgHeight[2] = '402'; // width = '602';
	ImageArray[3] = 'F4L_BRISTOL071.jpg'; // Powerzone
	ImgHeight[3] = '402'; // width = '';
	ImageArray[4] = 'F4L_BRISTOL082.jpg'; // Beefcakes
	ImgHeight[4] = '400'; // width = '';
	ImageArray[5] = 'F4L_BIRMINHAM025.jpg'; // Changing Room
	ImgHeight[5] = '400';
	ImageArray[6] = 'F4L_BRISTOL103.jpg'; // Powerzone
	ImgHeight[6] = '402'; // width = '';
	ImageArray[7] = 'F4L_BIRMINHAM035.jpg'; // treadmill
	ImgHeight[7] = '400'; 
	ImageArray[8]='F4L_BRISTOL094.jpg';ImgHeight[8]='400';
	ImageArray[9] = '2011Joining.jpg';ImgHeight[9]='400';
	ImageArray[10]='2011Joining2.jpg';ImgHeight[10]='400';
	ImageArray[11]='FrontOfClub.jpg';ImgHeight[11]='400';
	ImageArray[12]='2011Gym1.jpg';ImgHeight[12]='400';
	
	NumImages = ImageArray.length - 1;
	
	DisplayImages = NumImages;

	break;
	}
	//added
	var ImgIndex;
	
	if (SetDir === 'GoLeft')
	{
	ImgIndex = Math.ceil(document.getElementById('ImageCount').value) + 1;
	} else {
	ImgIndex = Math.ceil(document.getElementById('ImageCount').value) - 1;
	}
	
	if (ImgIndex > NumImages) {	ImgIndex = 0; }
	if (ImgIndex < 0) { ImgIndex = NumImages; }
	
	document.getElementById('ImageCount').value = ImgIndex;
	
	//added
	obj = document.getElementById('MainImage'); obj.src = ImgDir + ImageArray[ImgIndex];
	for (var x=1; x<=DisplayImages; x++) {
	var InnerCount = x-1; var NewImgIndex = ImgIndex + InnerCount;
	if (NewImgIndex < 0) {
	NewImgIndex = NewImgIndex + (DisplayImages + 1);
	}
	if (NewImgIndex>DisplayImages){NewImgIndex=NewImgIndex-(DisplayImages+1);
	}
	var id2 = 'Viewer' + x;
	if (document.getElementById(id2)) {
	var obj2= document.getElementById(id2);obj2.src = ImgDir + 'thumbs/' + ImageArray[NewImgIndex];
	}}
	var TopPadding = Math.ceil((350 - ImgHeight[1])/2 + 50);
	obj.style.paddingtop = TopPadding+'px';
	}
	
	function ResetOrange()
	{
	//alert('Reset');
	$(".whitelink").css("color","#58585a");
	}
	
	function DisplayAnswer(Answer)
	{
	Answer = '<div id="AnswersBox">' + fullescape(Answer) + '</div>';
	$('#top_right_box').empty().append(Answer);
	
	var obj = document.getElementById('top_right_box');
	obj.style.backgroundImage = 'url(images/AnswersBack.gif)';
	obj.style.width = '450px';
	obj.style.height = '300px';	
	obj.style.padding = '100px 0px 0px 30px';	
	}
	
	function FindIndex(Club) {
	var SelectID = '';
	$(document).ready(function(){
	if ($('#ChooseClub').length != 0) {
	SelectID = 'ChooseClub';
	}
	else if ($('#ClubSelect').length != 0) {
	SelectID = 'ClubSelect';
	}
	if (SelectID !== '') {
	for (var i=0; i <= document.getElementById(SelectID).options.length - 1; i++)
	{
	 var ShowVal = document.getElementById(SelectID).options[i].value
	if (Club === Clubs[i]) {
	document.getElementById(SelectID).selectedIndex = i +1;
	break;
	}}} });
	}
	
	function DropDownJobs() {
	var Jobs=[];Jobs[0] = 'Full Time Education';Jobs[1] = 'Unemployed';Jobs[2] = 'General Management';Jobs[3] = 'Office &amp; Admin';
	Jobs[4]='Media';Jobs[5] = 'Retail';Jobs[6] = 'Transportation';Jobs[7] = 'Education &amp; Training';Jobs[8] = 'Health Care &amp; Community';
	Jobs[9]='Manufacturing';Jobs[10] = 'Legal &amp; Financial';Jobs[11] = 'IT &amp; Telecoms';
	Jobs[12]='Building &amp; Construction';Jobs[13] = 'Arts &amp; Entertainment';	
	
//	Jobs.sort(randOrd);
	var arLen=Jobs.length;
	var DropDownHTML = '<select id="Occupation" name="Occupation"><option value="">Please Select</option>';
	for ( var i=0, len=arLen; i<len; ++i ){
	DropDownHTML += '<option value="'+i+'">'+Jobs[i]+'</option>';
	}
	DropDownHTML += '</select>';
	
	$(document).ready(function(){
	$('#OccupationDD').empty().append(DropDownHTML);
	});
	}
	
	function ShowQuotes(id) {
	var Quotes = [];
	Quotes[0] = 'I like its location and value for money. Overall, I loved fitness for less and would certainly recommend it to my friends.';
	Quotes[1] = 'What I like is how cheap it is, I like The Powerzone area and the classes being free ';
	Quotes[2] = 'The quality, despite the low cost it is an excellent gym';
	Quotes[3] = 'I normally hate gyms, but really enjoyed working out in the girls only gym. I also loved the cool room, I didn&rsquo;t feel self conscious at all in this room!';
	Quotes[4] = 'It&rsquo;s excellent value for money, close to work and very friendly. It&rsquo;s very convenient and good value for money and you never really had to wait around to use the equipment.';
	Quotes[5] = 'Value for money, good equipment, nice to have variety of rooms';
	Quotes[6] = 'The low membership fee. No Contract. Location.';
	Quotes[7] = 'Excellent price and very good facilities';
	Quotes[8] = 'The place is very big and I liked the fact that it had lots of space and areas to work in';
	
	var arLen=Quotes.length;
	var num = Math.floor((Math.random() * arLen));
	var Image1 = 'url(images/home_news_quotes5.gif)';
	var Image2 = 'url(images/home_news_quotes4.gif)';
	
	if ((id === 'news_box_3') || (id === 'news_box')) {
	Image1 = 'url(http://www.fitness4less.uk.net/images/home_page_bottom_left.jpg)';
	Image2 = 'url(http://www.fitness4less.uk.net/images/home_page_bottom_left.jpg)';
	}
	var obj = document.getElementById(id);
	if ((num % 3) === 0 ) {	obj.style.backgroundImage = Image1;} else { obj.style.backgroundImage = Image2; }
	
	var QuoteHTML = Quotes[num];
	
	$(document).ready(function(id){
	$('#QuoteBox').empty().append(QuoteHTML);
	});
	var TestFunc = function() { ShowQuotes(id); }
	var t = setTimeout(TestFunc,IntTime);
	}
	function randOrd()
	{
	return (Math.round(Math.random())-0.5); 
	}
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	function MM_goToURL() { //v3.0
	  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}
	function NewClubSelection()
	{
	if ($('#ClubsPopUpBox').length) { // implies *not* zero
    $("#ClubsPopUpBox").remove();
  	} else {
	var clubsHTML = '<div id="ClubsPopUpBox" style="position:absolute; width:186px; height:149px; top:-100px; left:40px; background-image:url(images/Bristol/clubsPopUp2.png); background-repeat: no-repeat; z-index:10000;"> \
	<div style="padding:30px 0px 0px 24px; width:148px; height:60px;"> \
	<div style="clear:both; width:148px; height:30px; padding:0px;"><a href="http://www.fitness4less.co.uk/Bristol_Club.html" onclick="ClickSelectClub(\'Bristol\');"><img src="images/Home_Bristol.gif" alt="Bristol Club" width="144" height="28" border="0"  /></a></div> \
	<div style="clear:both; width:148px; height:30px; padding:0px;"><a href="http://www.fitness4less.co.uk/Birmingham_Club.html" onclick="ClickSelectClub(\'Birmingham\');"><img src="images/Home_Birmingham.gif" alt="Birmingham Club" width="144" height="28"  /></a></div></div></div>';
	}}
