/**
* Pickfords
* Javascript
*
* Javascript developed by Bloom Media Ltd. | www.bloommedia.co.uk
* Contributors: Dominic Kelly. 
*/

/**-------------------------------- */
/** GENERAL FUNCTIONS	            */

	/*************************************************************************************/
	/** page name
	/************************************************************************************/
	
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	var sPage = sPage.split(".");
	
	/**
	 * A simple querystring parser.
	 * Example usage: var q = $.parseQuery(); q.foo returns "bar" if query contains "?foo=bar"; multiple values are added to an array. 
	 * Values are unescaped by default and plus signs replaced with spaces, or an alternate processing function can be passed in the params object .
	 *
	 **/

	jQuery.parseQuery = function(qs,options) {
		var q = (typeof qs === 'string'?qs:window.location.search), o = {'f':function(v){return unescape(v).replace(/\+/g,' ');}}, options = (typeof qs === 'object' && typeof options === 'undefined')?qs:options, o = jQuery.extend({}, o, options), params = {};
		jQuery.each(q.match(/^\??(.*)$/)[1].split('&'),function(i,p){
			p = p.split('=');
			p[1] = o.f(p[1]);
			params[p[0]] = params[p[0]]?((params[p[0]] instanceof Array)?(params[p[0]].push(p[1]),params[p[0]]):[params[p[0]],p[1]]):p[1];
		});
		return params;
	}
	
	/************************************************************************************/
	/** self store enquiry calculator
	/************************************************************************************/
	
	function calculateSelfStoreVolume(ddl){
		
		// read form values		 
		
		var homesize = $('#home-size').val();
		var vehiclesize = $('#vehicle-size').val();
		var noboxes = $('#no-boxes').val();
		
		// read form labels
		
		var homesizeLbl = $("#home-size option:selected").text();
		var vehiclesizeLbl = $("#vehicle-size option:selected").text();
		var noboxesLbl = $("#no-boxes option:selected").text();
		
		// on select change, disabled the other options
		// also update the span with the selected text
		
		switch(ddl) {
			case "home-size":
			
				$('#home-size').css("display","none");
				$('#home-size').next().css("display","block");
				
				$('#vehicle-size').attr("disabled","disabled");
				$('#no-boxes').attr("disabled","disabled");
				$('#home-size').next().html(homesizeLbl + '<a href="javascript:clearSelfStoreVolume();" id="clear-home-size" class="clear-selection">clear</a>');
				break;
				
			case "vehicle-size":
			
				$('#vehicle-size').css("display","none");
				$('#vehicle-size').next().css("display","block");
				
			    $('#home-size').attr("disabled","disabled");
				$('#no-boxes').attr("disabled","disabled");
				$('#vehicle-size').next().html(vehiclesizeLbl + '<a href="javascript:clearSelfStoreVolume();" id="clear-vehicle-size" class="clear-selection">clear</a>');
				break;
				
			case "no-boxes":
			
				$('#no-boxes').css("display","none");
				$('#no-boxes').next().css("display","block");
				
			    $('#home-size').attr("disabled","disabled");
				$('#vehicle-size').attr("disabled","disabled");
				$('#no-boxes').next().html(noboxesLbl + '<a href="javascript:clearSelfStoreVolume();" id="clear-no-boxes" class="clear-selection">clear</a>');
				break;
				
			default: 
				$('#home-size').attr("disabled","disabled");
				$('#vehicle-size').attr("disabled","disabled");
				$('#no-boxes').attr("disabled","disabled");				
		}
		
		// concatinate form values into single comma seperated value	
		
		var tmpStr = homesize + "," + vehiclesize + "," + noboxes;

		// split the string and store values in an array	
		
		var tmpArr = tmpStr.split(",");		
		
		var Hmin = tmpArr[0];
		var Hmax = tmpArr[1];
		var Vmin = tmpArr[2];
		var Vmax = tmpArr[3];
		var Bmin = tmpArr[4];
		var Bmax = tmpArr[5];

		// calculate the volume
				
		var minVol = parseInt(Hmin) + parseInt(Vmin) + parseInt(Bmin);
		var maxVol = parseInt(Hmax) + parseInt(Vmax) + parseInt(Bmax);
		
		var htmlStr = minVol - maxVol;
	  
		// print the volume to the screen
		
		$('#volume').html(minVol + " - " + maxVol + " Sq.ft");
		
		// change the colour of the div and update the volume
		
		$("#self-store-volume-container").animate({ backgroundColor: "#b40023" },200, function () {
		
			$("#self-store-volume-container").animate({ backgroundColor: "#ffffff" },300);
			
		});
		
		// if the form is located on the self storage page then also update the volume field
		
		if(sPage == "self-storage-enquiry"){
		
			$('#SKFCE_14_UserInput').val(minVol + " - " + maxVol + " Sq.ft");	

			
		}

	}
	
	function clearSelfStoreVolume(){
				
				$('#home-size').css("display","block");
				$('#home-size').next().css("display","none");
				$('#home-size').attr("disabled", false);
				$('#home-size option:first-child').attr("selected", "selected");

				
				$('#vehicle-size').css("display","block");
				$('#vehicle-size').next().css("display","none");
				$('#vehicle-size').attr("disabled", false);
				$('#vehicle-size option:first-child').attr("selected", "selected");
				
				$('#no-boxes').css("display","block");
				$('#no-boxes').next().css("display","none");
				$('#no-boxes').attr("disabled", false);	
				$('#no-boxes option:first-child').attr("selected", "selected");							
			
		}	

	/************************************************************************************/
	/** small move estimate calculator
	/************************************************************************************/
	
	function calculateSmallMoveEstimate(){

		// pEstimate is the estimate in UK pounds (Â£)
		// pd is the base price determined by the Move distance
		// pi is the supplement price linked to the number of items
		// pm is the 20% supplement added if the collection or delivery is within the M25

		// is collection or delivery within M25?

		if($("#SKFCE_16_ElementID_Yes").attr('checked')){

			// add 20% suppliment

			pm = 1.2;

		}else{

			// no suppliment required

			pm = 1;

		}
		
		// number of items
		
		var selectedNumItems = $("#SKFCE_15_UserInput").attr('selectedIndex');
		
		if(selectedNumItems <= 3){
		
			n = 0;
			
		}else{
		
			n = selectedNumItems - 3;
			
		}
		
		// move distance
		
		var selectedMoveDistance = $("#SKFCE_1_UserInput").attr('selectedIndex');
		
		switch(selectedMoveDistance)
		{
		case 1:
		  pd = 149;
		  pi = 7;
		  break;
		case 2:
		  pd = 199;
		  pi = 10;
		  break;
		case 3:
		  pd = 249;
		  pi = 14;
		  break;
		default:
		}
		
		pEstimate = Math.floor(pm * (pd + (n * pi))); // round down to nearest pound
		
		// At least the first two drop downs must be selected for the calculator to run
		
		if(selectedNumItems == 0 || selectedMoveDistance == 0){
			
			$('#estimate-total').hide(); // hide the output
				
		}else{

			$('#estimate-total').html('<span class="copy"><p>Your small move price estimate: </p></span><span class="estimate"><p>&pound;' + pEstimate + '</p></span>');
			
			$('#estimate-total').show();
			
			$("#estimate-total").animate({ backgroundColor: "#b40023" },200, function () {

			$("#estimate-total").animate({ backgroundColor: "#D79F11" },300);

				// update hidden field, which is passed to the web service
		
				$('#SKFCE_17_UserInput').val(pEstimate);

			});

		}

	}

	/************************************************************************************/
	/** marketing referrer
	/************************************************************************************/
	
	function marketingReferrer(marketing_ref){

		// the marketing referrer cookie is destroyed after 1 day (expires: 1)

		if($.cookie("Marketing_Referrer")){

			// if there is a cookie, then the user has already visited a previous page, so
			// do NOT update the cookie
		
		}else{

			// if there isn't a cookie, then this is the users first visit to the page, so create
			// a new cookie and store the referrer URL
			
			// get the query string
			
			var q = $.parseQuery();
			
			// get the campaign ID (if it is there)
			
			var CID = q.CID;
			
			if(typeof CID != 'undefined'){
			
				// PPC
				// set marketing referrer to current location
				
				$.cookie("Marketing_Referrer", document.location,{ expires: 1 });
			
			}else{
			
				// Organic, Directory, Direct				
				// check to see if referrer is null, and default it to pickfords domain
				
				if(document.referrer == "") {
				
					$.cookie("Marketing_Referrer", "http://www.pickfords.co.uk",{ expires: 1 });
				
				}else{
				
					$.cookie("Marketing_Referrer", document.referrer,{ expires: 1 });
				
				}
			
			}
		
		}
	
	}

	/************************************************************************************/
	/** form validation
	/************************************************************************************/

	// default form validation error message
	
	var message = "";

	// validation functions
	
	function checkMinChar(el,min){

		// generic check for minimum field lengths
		
		if(el.val().length < min ){
		
			// read the label associated with the textfield (lowercase it and replace the colon with a full stop.)
					
			labelTxt = $('label[for=' + el.attr("id") + '] span').text().toLowerCase().replace(":", ".").replace("*", "");
		
			var error = "<p>Please enter at least " + min +  " characters for the " + labelTxt + "</p>";
			
			// highlight field
			
			$(el).addClass("highlightError");
			
		}else{
		
			var error = "";

			// de-highlight field
			
			$(el).removeClass("highlightError");		
			
		}
		
		return error;
		
	}
	
	function isValidTown(el){
		
		// get the field value
	
		val = el.val();
		
		if(el.val().length < 3){
		
			var error = "<p>Please enter 3 or more characters for the town you are moving to.</p>";
			
			// highlight field
			
			$(el).addClass("highlightError");
			
		}else{
		
			var error = "";

			// de-highlight field
			
			$(el).removeClass("highlightError");		
			
		}
		
		return error;
	
	}
	
	function isValidNumberOfStaff(el){	
			
		// get the selected index
		
		selected = el.attr("selectedIndex");
		
		// do not allow the first (default) value to be selected
		
		if(selected == 0){
				
			var error = "<p>Please select the number of employees at your business.</p>";
			
			// highlight field
			
			$(el).addClass("highlightError");	
			
		}else{
		
			var error = "";

			// de-highlight field
			
			$(el).removeClass("highlightError");				
			
		}
		
		return error;	
	
	}
	
	function isValidEmail(el){
	
		// get the field value
	
		val = el.val();
		
		// email reg ex
	
		//pattern = /^(\w+\.)*\w+@(\w+\.)+[A-Za-z]+$/; // old
		
		pattern = /^\w+([\.\-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			
		if(!pattern.test(val)){
		
			var error = "<p>Please enter a valid email address.</p>";
			
			// highlight field
			
			$(el).addClass("highlightError");
			
		}else{
		
			var error = "";	

			// de-highlight field
			
			$(el).removeClass("highlightError");

		}

		return error;

	}
	
	function isValidPayingForYourMove(el){	
			
		// get the selected index
		
		selected = el.attr("selectedIndex");
		
		// do not allow the first (default) value to be selected
		
		if(selected == 0){
				
			var error = "<p>Please select who is paying for your move.</p>";
			
			// highlight field
			
			$(el).addClass("highlightError");	
			
		}else{
		
			var error = "";

			// de-highlight field
			
			$(el).removeClass("highlightError");				
			
		}
		
		return error;	
	
	}
	function isTelephone(tel){ 
	
		if(tel.val() == ""){
		
			var error = "<p>Please enter a telephone number.</p>";
			
			// highlight field
			
			$(tel).addClass("highlightError");
			
		}else{
			
			var error = "";
			
			// de-highlight field
			
			$(tel).removeClass("highlightError");
			
			if(tel.val() != ""){
			
				error += checkMinChar($(tel),11);
				
			}		
			
		}
				
		return error;

	}
	
	function isTelephoneOrMobile(tel,mob){ 

		if(tel.val() == "" && mob.val() == ""){
		
			var error = "<p>Please enter a telephone OR a mobile.</p>";
			
			// highlight field
			
			$(tel).addClass("highlightError");
			
			$(mob).addClass("highlightError");	
			
		}else{
			
			var error = "";
			
			// de-highlight field
			
			$(tel).removeClass("highlightError");
			$(mob).removeClass("highlightError");	
			
			if(tel.val() != ""){
			
				error += checkMinChar($(tel),11);
				
			}
			
			if(mob.val() != ""){
			
				error += checkMinChar($(mob),10);
			
			}
		
			
		}
				
		return error;

	}

	function checkIsNotFirstSelect(el,iA){
	
		// get the selected index
		
		selected = el.attr("selectedIndex");
		
		// do not allow the first (default) value to be selected
		
		if(selected == 0){
				
			// read the label associated with the textfield (lowercase it and replace the colon with a full stop.)
					
			labelTxt = $('label[for=' + el.attr("id") + '] span').text().toLowerCase().replace(":", ".").replace("*", "");
		
			// check for indefinite article
			
			if(iA == "Y"){
			
				var error = "<p>Please select an " + labelTxt + "</p>";
			
			}else{
			
				var error = "<p>Please select a " + labelTxt + "</p>";
			
			}
			
			// highlight field
			
			$(el).addClass("highlightError");	
			
		}else{
		
			var error = "";

			// de-highlight field
			
			$(el).removeClass("highlightError");				
			
		}
		
		return error;	
	
	}
	
	function checkChecboxIsSelected(el){
			
		// check checkbox is selected
		
		if (el.is(':checked')) {
		
			var error = "";
		
			$(el).removeClass("highlightError");	
		  
		}else{
		
			var error = "<p>Please agree to our terms and conditions</p>";
			
			// highlight field
			
			$(el).addClass("highlightError");			

		}		
		
		return error;	
	
	}	
	
	
	function checkDate(dd,mm,yyyy,msg){
	
		// check dates are in correct format
		
		if(isNaN(dd.val()) || isNaN(mm.val()) || isNaN(yyyy.val())){
		
			// notify user
		
			var error = "<p>" + msg; + "</p>";
			
			// highlight field
			
			$(dd).addClass("highlightError");	
			$(mm).addClass("highlightError");	
			$(yyyy).addClass("highlightError");	
		
		}else{
		
			var error = "";
			
			// de-highlight field
			
			$(dd).removeClass("highlightError");	
			$(mm).removeClass("highlightError");	
			$(yyyy).removeClass("highlightError");	
			
		}
		
		return error;	
		
		
	}
	
			
	function checkTelephoneSpecialChars(el){
	
		// on keyup - allow only 0-9, brackets, plus, space

		reg = /[^a-zA-Z0-9 \(\)\+]/g;
		
		el.val(el.val().replace(reg,""));
			
	}
	
	function checkRegularSpecialChars(el){
	
		// on keyup - allow only numbers, a-z, dash, hyphen, comma, space

		reg = /[^a-zA-Z0-9 \'\-\,]/g;
		
		el.val(el.val().replace(reg,""));
					
	}
	
	
	function checkNoSpecialChars(el){
	
		// on keyup - allow only letters

		reg = /[^a-zA-Z ]/g;
		
		el.val(el.val().replace(reg,""));
			
	}
	
	function checkOnlyNumbers(el){
	
		// on keyup - allow only letters

		reg = /[^0-9]/g;
		
		el.val(el.val().replace(reg,""));
			
	}
	
	function checkEmailSpecialChars(el){
	
		// on keyup - allow only letters, numbers, email symbols

		reg = /[^a-zA-Z0-9\@\-\,\.\_]/g;
		
		el.val(el.val().replace(reg,""));
			
	}
	
	function checkPostcodeSpecialChars(el){
	
		// on keyup - allow only letters,numbers

		reg = /[^a-zA-Z0-9]/g;
		
		el.val(el.val().replace(reg,""));
			
	}
	
	
	function checkEntireForm(){
		
		// update the error messages
		
		$('#form-error').html(message);
		
		// submit the form (return true) if there are no validation errors
				
		if (message != "") {

			// change the colour of the error message
		
			$("#form-error").fadeIn("fast");	
	
			return false;
			   
		}else{
		
			// change the colour of the error message
		
			$("#form-error").fadeOut("fast");

			return true;
			
		}	
		
	}
		
/****************************/
/** TIP FOR IN YOUR AREA MAP */
/****************************/
	
/* Add the class "tooltipred" and a title to add a red pop up tip */

	this.tooltipred = function(xOffset,yOffset){	

		// popup's distance from the cursor
			
		xOffset2 = xOffset;
			
		yOffset2 = yOffset;

		// attach a hover state to every matching anchor element
	
		
		$(".tooltipred").hover(function(e){	
			
			this.t = this.title;
		
			// create the tooltip
			
			$("body").append("<div id='tooltipred'><p >"+ this.t +"</p></div>");
			
			// position and fade in the tool tip
			
			$("#tooltipred")
				
				.css("top",(e.pageY - xOffset2) + "px")
				
				.css("left",(e.pageX + yOffset2) + "px")
				
				.fadeIn("fast");	
				
		},
		
		// remove tooltip
		
		function(){
		
			this.title = this.t;	
			
			$("#tooltipred").remove();
			
		});	
		
		$(".tooltipred").mousemove(function(e){
		
			$("#tooltipred")
			
				.css("top",(e.pageY - xOffset2) + "px")
				
				.css("left",(e.pageX + yOffset2) + "px");
				
		});
		
	};

function mapover(rolloverloc,rollovertitle) {
$("#mapbackarea").attr("src","/map/"+rolloverloc);
}

function mapout() {
$("#mapbackarea").attr("src","/map/mapback.jpg");
}

jQuery.preloadImages = function(){
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
	
/************************************************************************************/
/** window events
/************************************************************************************/

$(window).load(function() {

	// get the URL referrer for marketing purposes
	
	var marketing_ref = document.referrer;
	
	// set a cookie to track the marketing referrer
	
	marketingReferrer(marketing_ref);

	// initialise top menu drop down
	
	jQuery(function(){
					
		jQuery('ul#level1').superfish();
		
	});
	
	// when a text box gains focus, clear the default value
	// when a text box loses focus, set the default value if empty

	$('input[type="text"]').focus(function() {
	  if(this.value == this.defaultValue){
		this.value = '';
	  }	  
	});

	$('input[type="text"]').blur(function() {
	  if (this.value == '') this.value = (this.defaultValue ? this.defaultValue : '');
	});
	
	// self store volume calculator - attach events to drop downs
	
	$('#home-size').change(function() {
		calculateSelfStoreVolume('home-size');
	});
	
	//$('#clear-home-size').change(function() {
	//	clearSelfStoreVolume();
	//});	

	$('#vehicle-size').change(function() {
		calculateSelfStoreVolume('vehicle-size');
	});
	
	//$('#clear-vehicle-size').change(function() {
	//	clearSelfStoreVolume();
	//});		

	$('#no-boxes').change(function() {
		calculateSelfStoreVolume('no-boxes');
	});
	
	//$('#clear-no-boxes').change(function() {
	//	clearSelfStoreVolume();
	//});		
	
	// find the self store volume calculator submit button
	
	if($("#btn-self-store").length > 0){
	
		$('#btn-self-store').click(function() {
		
			// save volume to temporary cookie (destroyed on browser exit)
			
			$.cookie("volume", $('#volume').html());
			
			// if the form is located on the self storage page do not submit the form
			
			if(sPage == "self-storage-enquiry"){
			
				return false;				
			}
			
		});
	
	}	
		
	// find the storage enquiry submit button

	if($("#btn-storage-enquiry").length > 0){
	
	$('#btn-storage-enquiry').click(function() {
	
	// save all form data to temporary cookie (destroyed on browser exit)
		
	frmData = $('#title').val() + ',' + $('#first-name').val() + "," + $('#last-name').val() + "," + $('#telephone').val() + "," + $('#email').val() + "," + $('#postcode').val() + "," + $('#send-info').attr('checked');

	$.cookie("storage-enquiry", frmData);
		
	});
	
	}

	/************************************************************************************/
	/** form events
	/************************************************************************************/
	
	// check each page for specific form id and apply validation to it
	
	// generate unique GUID for form submissions

	var frmGuid = jQuery.uuid();

	$("#instanceID").val(frmGuid);
	
	// hide the validation error message
	
	$("#form-error").hide();
	
	/************************************************************************************/
	/** call me back
	/************************************************************************************/
		
	if($("#form_left_content #Sitekit_Form_3476").length > 0){
			
		// add env vars to hidden field
		
		$("#SKFCE_8_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
		
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); //title
			
			message += checkMinChar($("#SKFCE_1_UserInput"),3);	// first name
			
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // last name
			
			message += checkMinChar($("#SKFCE_3_UserInput"),11); // telephone
			
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			
			message += isValidEmail($("#SKFCE_4_UserInput")); // email	

			message += checkIsNotFirstSelect($("#SKFCE_5_UserInput"),"Y"); // enquiry		
			
			// hidden postcode field
			
			selected = $("#SKFCE_5_UserInput").get(0).selectedIndex;
			
			if(selected == 1 || selected == 2 || selected == 3){
			
				message += checkMinChar($("#SKFCE_6_UserInput"),5);	// postcode
			
			}
				
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}			
			
			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {
				
				message = "";		
								
				return true;
				
			}
			
			else {
						
				message = "";
				
				return false;
				
			}
			

			
			

			
		});
				

		// unique
		
		// only show postcode if enquiry type is move, storage, self store
		
		$('#form_outer #SKFCE_6_UserInput').parent().hide(); // hide by default
				
		$('#form_outer #SKFCE_5_UserInput').change(function() {	
				
			// get the selected index		
			
			selected = this.selectedIndex;
			
			if(selected == 1 || selected == 2 || selected == 3){
			
				$('#form_outer #SKFCE_6_UserInput').parent().fadeIn('fast');
				
			}else{
			
				$('#form_outer #SKFCE_6_UserInput').parent().fadeOut('fast');
				
			}
			
		});
		
	}
	
	/************************************************************************************/
	/** call me back - quick fill
	/************************************************************************************/
	
	if($("#right-content-form #Sitekit_Form_3476").length > 0){
	
		
	
		// the quick-form-home-moving-international-section has slightly different
		// javascript validation on it. Check for presense of the hidden field
		// which identifies it

			identify = $("#right-content-form #Sitekit_Form_3476 #identify").val();

			if(identify == "quick-form-home-moving-international-section"){
							
				// HOME MOVING INTERNATIONAL CALL ME BACK QUICK FILL
				
				// only show postcode if enquiry type is move, storage, self store
								
				$('#SKFCE_5_UserInput').change(function(){
				
				// get the selected value
				
				selectedVal = $('#SKFCE_5_UserInput').val();
								
				if(selectedVal == "1" || selectedVal == "4"){
				
					// do not send a value company name
					
					$('#SKFCE_11_UserInput').val('');
													
					$('#call-me-company-name').fadeOut('fast');
					
					$('#SKFCE_11_UserInput').fadeOut('fast');						
				
					// default value
					
					$('#SKFCE_6_UserInput').val('Enter your postcode*');
				
					$('#call-me-back-postcode').fadeIn('fast');
					
					$('#SKFCE_6_UserInput').fadeIn('fast');
					
					//console.log('postcode: ' + $('#SKFCE_6_UserInput').val());
					//console.log('company: ' + $('#SKFCE_11_UserInput').val());					
					
				}else if (selectedVal == "2" || selectedVal == "3"){
					
					// do not send a value for postcode				
			
					$('#call-me-back-postcode').hide()
					
					$('#SKFCE_6_UserInput').hide()
					
					// send a value company name

					$('#SKFCE_6_UserInput').val('');

					$('#SKFCE_11_UserInput').val('Enter your company name*');
				
					$('#call-me-company-name').fadeIn('fast');
					
					$('#SKFCE_11_UserInput').fadeIn('fast');

					//console.log('postcode: ' + $('#SKFCE_6_UserInput').val());
					//console.log('company: ' + $('#SKFCE_11_UserInput').val());					
					
				} else{
									
					// do not send a value for postcode
					
					$('#SKFCE_6_UserInput').val('');
				
					$('#call-me-back-postcode').hide()
					
					$('#SKFCE_6_UserInput').hide()
					
					// do not send a value company name
					
					$('#SKFCE_11_UserInput').val('');
				
					$('#call-me-company-name').hide()
					
					$('#SKFCE_11_UserInput').hide()					
										
				}
				
			});
			
		}else{
					
			// REGULAR CALL ME BACK QUICK FILL 
			
			// only show postcode if enquiry type is move, storage, self store
							
			$('#SKFCE_5_UserInput').change(function() {
								
				// get the selected value
				
				selectedVal = $('#SKFCE_5_UserInput').val();
									
				if(selectedVal == "1" || selectedVal == "2" || selectedVal == "3" || selectedVal == "99"){
				
					// default value
					
					$('#SKFCE_6_UserInput').val('Enter your postcode*');
				
					$('#call-me-back-postcode').fadeIn('fast');
					
					$('#SKFCE_6_UserInput').fadeIn('fast');		
					
				}else{
					
					// do not send a value
					
					$('#SKFCE_6_UserInput').val('');
				
					$('#call-me-back-postcode').fadeOut('fast');
					
					$('#SKFCE_6_UserInput').fadeOut('fast');
					
				} 
				
			});
		
		}
		
		// record the call back source
		
		$('#SKFCE_9_UserInput').val(document.location);		
	
	}
	
	/************************************************************************************/
	/** moving in the UK
	/************************************************************************************/
		
	if($("#Sitekit_Form_3477").length > 0){

		// add env vars to hidden field
		
		$("#SKFCE_8_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
								
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); // title
			message += checkMinChar($("#SKFCE_1_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // last name
			message += isTelephoneOrMobile($("#SKFCE_3_UserInput"),$("#SKFCE_23_UserInput")); // telephone or mobile
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			message += checkMinChar($("#SKFCE_11_UserInput"),3); // address 1
			message += checkMinChar($("#SKFCE_16_UserInput"),5); // postcode
			message += isValidTown($("#SKFCE_17_UserInput")); // town		

			// hidden company name field
			
			selected = $("#SKFCE_18_UserInput").get(0).selectedIndex;
					
			
			if(selected == 2 || selected == 3){
						
				message += checkMinChar($("#SKFCE_19_UserInput"),3);	
			
			}
			
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}		
			
			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {	
			
				message = "";
				
				return true;
			
			}
			
			else {
			
				message = "";
				
				return false;
			
			}			
			
		});
		
		// unique
		
		// if paying for your move 2nd.3rd option is selected - company name becomes available and mandatory
		
		$('#form_outer #SKFCE_19_UserInput').parent().hide(); // hide by default
				
		$('#form_outer #SKFCE_18_UserInput').change(function() {	
		
			// get the selected index		
			
			selected = this.selectedIndex;
			
			if(selected == 2 || selected == 3){
			
				$('#form_outer #SKFCE_19_UserInput').parent().fadeIn('fast');
				
			}else{
			
				$('#form_outer #SKFCE_19_UserInput').parent().fadeOut('fast');
				
			}
			
		});
	
	
	}





	/************************************************************************************/
	/** business moving enquiry
	/************************************************************************************/
		
	if($("#Sitekit_Form_3483").length > 0){

		// add env vars to hidden field
		
		$("#SKFCE_8_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
						
			// check minimum chars
					
			message += checkMinChar($("#SKFCE_11_UserInput"),3); //company name
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); // title
			message += checkMinChar($("#SKFCE_1_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // last name
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += isTelephoneOrMobile($("#SKFCE_3_UserInput"),$("#SKFCE_9_UserInput")); // telephone or mobile
			message += checkMinChar($("#SKFCE_7_UserInput"),5); // postcode			
			message += isValidNumberOfStaff($("#SKFCE_12_UserInput"),"N"); // number of staff
			
			// copy and concatenate date fields to hidden field			
			
			$('#SKFCE_14_UserInput').val(copyDateToField());
			
			// check date
			
			message += checkDate($("#date-1-dd"),$("#date-1-mm"),$("#date-1"),"Please enter a date.");

			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}	

			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {	
			
				message = "";
			
				return true;
			
			}
			
			else {
			
				message = "";
			
				return false;
			
			}			
			
		});
		
		// unique		
	
	}
	
	/************************************************************************************/
	/** business moving guide
	/************************************************************************************/
		
	if($("#Sitekit_Form_3486").length > 0){

		// add env vars to hidden field
		
		$("#SKFCE_8_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
						
			// check minimum chars

			message += checkMinChar($("#SKFCE_11_UserInput"),3); //company name
			//message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); // title
			message += checkMinChar($("#SKFCE_1_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // last name
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			message += isValidEmail($("#SKFCE_4_UserInput")); // email	
			//message += isTelephone($("#SKFCE_3_UserInput")); // telephone
			//message += isValidNumberOfStaff($("#SKFCE_12_UserInput"),"N"); // number of staff
			
			// copy and concatenate date fields to hidden field			
			
			$('#SKFCE_14_UserInput').val(copyDateToField());
			
			// check date
			
			//message += checkDate($("#date-1-dd"),$("#date-1-mm"),$("#date-1"),"Please enter a date.");

			if(message != ""){
			
				// scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}	

			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {	
			
				message = "";
			
				return true;
			
			}
			
			else {
			
				message = "";
			
				return false;
			
			}			
			
		});
		
		// unique		
	
	}	


	/************************************************************************************/
	/** international moving enquiry
	/************************************************************************************/
		
	if($("#Sitekit_Form_3479").length > 0){

		// add env vars to hidden field
		
		$("#SKFCE_8_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
						
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); // email					
			message += checkMinChar($("#SKFCE_1_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // last name
			message += isTelephoneOrMobile($("#SKFCE_3_UserInput"),$("#SKFCE_23_UserInput")); // telephone or mobile
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += checkIsNotFirstSelect($("#SKFCE_15_UserInput"),"N"); // country
			message += checkMinChar($("#SKFCE_16_UserInput"),2); // postcode (from)
			message += checkIsNotFirstSelect($("#SKFCE_29_UserInput"),"N"); // country
			message += isValidPayingForYourMove($("#SKFCE_18_UserInput")); // paying for move					
			
			
			// check radio buttons
	
			radioselect=$("input[@name='SKFCE_6_UserInput']:checked").val();

			if(!radioselect) {
			
				message += "<p>Please select a type of move.</p>";
			
			}	
			
			// hidden company name field
			
			selected2=$("#SKFCE_18_UserInput").get(0).selectedIndex;
			
			if(selected2 == 2 || selected2 == 3){
			
				message += checkMinChar($("#SKFCE_19_UserInput"),3); //company name
			
			}		
			
			// copy and concatenate date fields to hidden field
			// dd/mm/yyyy
			
			$('#SKFCE_5_UserInput').val(copyDateToField());
			
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}				// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {
			
				message = "";
			
				return true;
			
			}
			
			else {
			
				message = "";
			
				return false;
			
			}
			
		});
		
		// unique
		
		// if paying for your move 2nd.3rd option is selected - company name becomes available and mandatory
		
		$('#form_outer #SKFCE_19_UserInput').parent().hide(); // hide by default
				
		$('#form_outer #SKFCE_18_UserInput').change(function() {	
		
			// get the selected index		
			
			selected = this.selectedIndex;
			
			if(selected == 2 || selected == 3){
			
				$('#form_outer #SKFCE_19_UserInput').parent().fadeIn('fast');
				
			}else{
			
				$('#form_outer #SKFCE_19_UserInput').parent().fadeOut('fast');
				
			}
			
		});
		

	
	}





	/************************************************************************************/
	/** storage enquiry
	/************************************************************************************/
		
	if($("#Sitekit_Form_3480").length > 0){
		
		
		
		// user may have completed the quick form previously, which is stored in a temporary cookie
		
		if($.cookie("storage-enquiry")){
		
	
			 //make an array from the comma delimited options string
			 
			var allDataArray = $.cookie("storage-enquiry").split(",");
			
			$('#SKFCE_0_UserInput').val(allDataArray[0]);
			$('#SKFCE_2_UserInput').val(allDataArray[1]);
			$('#SKFCE_3_UserInput').val(allDataArray[2]);
			$('#SKFCE_5_UserInput').val(allDataArray[3]);
			$('#SKFCE_4_UserInput').val(allDataArray[4]);
			$('#SKFCE_6_UserInput').val(allDataArray[5]);
			
			if(allDataArray[6] == "true"){
				
				$('#SKFCE_11_UserInput').attr('checked', true);
				
			}	
			
		}

		// add env vars to hidden field
		
		$("#SKFCE_12_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {	
						
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); // title					
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_3_UserInput"),3); // last name
			message += isTelephoneOrMobile($("#SKFCE_5_UserInput"),$("#SKFCE_8_UserInput")); // telephone or mobile
			message += checkMinChar($("#SKFCE_4_UserInput"),7); //email
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += checkMinChar($("#SKFCE_6_UserInput"),5); // postcode	
			
			// copy and concatenate date fields to hidden field
			// dd/mm/yyyy
			
			$('#SKFCE_14_UserInput').val(copyDateToField());
			
			message += checkDate($("#date-1-dd"),$("#date-1-mm"),$("#date-1"),"Please enter the date you would like your goods collected.");
			
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}				
			
			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {
			
				message = "";
				
				return true;
				
			}
			
			else {
			
				message = "";
				
				return false;
			
			}			
			
		});
	
	}




	/************************************************************************************/
	/** self storage enquiry
	/************************************************************************************/
	
	if($("#Sitekit_Form_3481").length > 0){

		// user may have calculated a volume previously, which is stored in a temporary cookie
	
		$('#SKFCE_14_UserInput').val($.cookie("volume"));
		
		// add env vars to hidden field
		
		$("#SKFCE_12_UserInput").val($.cookie("Marketing_Referrer"));
		
		// destroy cookie after the field has been populated
		
		$.cookie("volume", "");
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
						
			// check radio buttons (self store)
	
			radioselect = $("input[@name='SKFCE_0_UserInput']:checked").val();
			
			if(!radioselect) {
			
				message += "<p>Please select your self store.</p>";
				
			}

			message += checkIsNotFirstSelect($("#SKFCE_7_UserInput"),"N"); // title
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_3_UserInput"),3); // last name
			message += isTelephoneOrMobile($("#SKFCE_5_UserInput"),$("#SKFCE_8_UserInput")); // telephone or mobile
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += checkMinChar($("#SKFCE_6_UserInput"),5); // postcode

			// check radio buttons (enquiry type)
						
			radioselect = $("input[@name='SKFCE_18_UserInput']:checked").val();
			
			if(!radioselect){
			
				message += "<p>Please select the type of your enquiry</p>";
				
			}
			
			message += checkIsNotFirstSelect($("#SKFCE_17_UserInput"),"N"); // service required
			
			// copy and concatenate date fields to hidden field
			// dd/mm/yyyy
			
			$('#SKFCE_15_UserInput').val(copyDateToField());
			
			radioselect2 = $('#SKFCE_18_ElementID_Make_an_Enquiry:radio:checked').val();
			
			radioselect3 = $('#SKFCE_18_ElementID_Reserve_Storage:radio:checked').val();
			
			servicesrequired = $("#SKFCE_10_UserInput").attr("selectedIndex");
			
			//console.log(radioselect2);
			
			//console.log(servicesrequired);
			
			if(radioselect3 == "Reserve Storage") {	
			
				message += checkDate($("#date-1-dd"),$("#date-1-mm"),$("#date-1"),"Please enter the date you would like your goods collected."); // check date
			
			}

			if(radioselect2 == "Make an Enquiry") {					
			
				if(servicesrequired == 1){
				
					message += checkDate($("#date-1-dd"),$("#date-1-mm"),$("#date-1"),"Please enter the date you would like your goods collected."); // check date
				
				}
			
			}
						
			
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}				
			
			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {	
			
				message = "";
			
				return true;
			
			}
			
			else {
			
				message = "";
			
				return false;
			
			}
			
			
		});
		
		
		// unique
		
		$('#form_outer #SKFCE_15_UserInput').parent().hide(); // hide by default
		$('#form_outer #SKFCE_16_UserInput').parent().hide(); // hide by default
        $('#form_outer #collection-date').hide(); // hide by default
		
		// if reserve storage selected, date and how long fields visible	
				
		$("#SKFCE_18_ElementID_Reserve_Storage").click(function() {	
			$('#date-1-dd').parent().fadeIn('fast');
			$('#date-1-mm').parent().fadeIn('fast');
			$('#date-1').parent().fadeIn('fast');
			$('#dateFrmLbl').parent().fadeIn('fast');
			$('#form_outer #SKFCE_16_UserInput').parent().fadeIn('fast');
            $('#form_outer #collection-date').show();			
		});
		
		$('#date-1-dd').parent().hide(); // hide by default
		$('#date-1-mm').parent().hide(); // hide by default
		$('#date-1').parent().hide(); // hide by default
		$('#dateFrmLbl').parent().hide(); // hide by default
				
		// if make an enquiry and self storage selected, date and how long fields visible
		
		$("#SKFCE_18_ElementID_Make_an_Enquiry").click(function() {	
		
			// clear DDMMYYYY
			$('#SKFCE_15_UserInput').val("");

			var servicesrequired = $("#SKFCE_10_UserInput").get(0).selectedIndex;
			
			//console.log(servicesrequired);
			
			if (servicesrequired == 1) {
				$('#collection-date').fadeIn('fast');
				$('#date-1-dd').parent().fadeIn('fast');
				$('#date-1-mm').parent().fadeIn('fast');
				$('#date-1').parent().fadeIn('fast');
				$('#dateFrmLbl').parent().fadeIn('fast');
				$('#form_outer #SKFCE_16_UserInput').parent().fadeIn('fast');
			}else{

				$('#collection-date').fadeOut('fast');
				$('#date-1-dd').parent().fadeOut('fast');
				$('#date-1-mm').parent().fadeOut('fast');
				$('#date-1').parent().fadeOut('fast');
				$('#dateFrmLbl').parent().fadeOut('fast');			
				$('#form_outer #SKFCE_16_UserInput').parent().fadeOut('fast');					
		}
		
		});
		
		$("#SKFCE_10_UserInput").change(function() {
	
			var servicesrequired = $("#SKFCE_10_UserInput").attr("selectedIndex");
			
			radioselect2 = $('#SKFCE_18_ElementID_Make_an_Enquiry:radio:checked').val();

			if(radioselect2 == "Make an Enquiry") {

				if (servicesrequired == 1) {
					$('#collection-date').fadeIn('fast');
					$('#date-1-dd').parent().fadeIn('fast');
					$('#date-1-mm').parent().fadeIn('fast');
					$('#date-1').parent().fadeIn('fast');
					$('#dateFrmLbl').parent().fadeIn('fast');
					$('#form_outer #SKFCE_16_UserInput').parent().fadeIn('fast');

				} else {
					$('#collection-date').fadeOut('fast');			
					$('#date-1-dd').parent().fadeOut('fast');
					$('#date-1-mm').parent().fadeOut('fast');
					$('#date-1').parent().fadeOut('fast');
					$('#dateFrmLbl').parent().fadeOut('fast');
					$('#form_outer #SKFCE_16_UserInput').parent().fadeOut('fast');
					$('#form_outer #collection-date').hide(); // hide by default	
				}
				
			}
		
		});

	}







	/************************************************************************************/
	/** small move
	/************************************************************************************/
		
	if($("#Sitekit_Form_3475").length > 0){

		// add env vars to hidden field
		
		$("#SKFCE_12_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
						
			message += checkIsNotFirstSelect($("#SKFCE_14_UserInput"),"N");		 // title					
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_3_UserInput"),3); // second name
			message += isTelephoneOrMobile($("#SKFCE_5_UserInput"),$("#SKFCE_8_UserInput")); // telephone or mobile
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += checkMinChar($("#SKFCE_18_UserInput"),3); // address
			message += checkMinChar($("#SKFCE_6_UserInput"),5); // postcode
			
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}				

			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {
			
				message = "";
				
				return true;
				
			}
			
			else {
			
				message = "";
				
				return false;
				
			}			
			
		});

	}






	/************************************************************************************/
	/** corporate moving enquiry form
	/************************************************************************************/
		
	if($("#Sitekit_Form_3482").length > 0){

		// add env vars to hidden field
		
		$("#SKFCE_8_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
			
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); // title						
			message += checkMinChar($("#SKFCE_1_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // last name
			message += isTelephoneOrMobile($("#SKFCE_3_UserInput"),$("#SKFCE_11_UserInput")); // telephone or email
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += checkMinChar($("#SKFCE_12_UserInput"),3); // company
			message += checkMinChar($("#SKFCE_6_UserInput"),2); // postcode
			
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}				
			
			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {	
			
				message = "";
				
				return true;
				
			}
			
			else {
			
				message = "";
				
				return false;
				
			}
			
			
		});

	}
	
	
	if($("#quick-form-price-your-move").length > 0){
		//alert('s');
		$("#marketingReferrer").val($.cookie("Marketing_Referrer"));
	
	}
	
	
	
	/************************************************************************************/
	/** promotion
	/************************************************************************************/
		
	if($("#form_left_content #Sitekit_Form_3488").length > 0){
			
		// add env vars to hidden field
		
		$("#SKFCE_12_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
		
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); //title
			
			message += checkMinChar($("#SKFCE_2_UserInput"),3);	// first name
			
			message += checkMinChar($("#SKFCE_3_UserInput"),3); // last name
			
			message += checkMinChar($("#SKFCE_5_UserInput"),11); // telephone
		
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			
			message += isValidEmail($("#SKFCE_4_UserInput")); // email	

			message += checkMinChar($("#SKFCE_6_UserInput"),2); // postcode
			
		//	message += checkChecboxIsSelected($("#SKFCE_20_UserInput")); // agree terms
			
			//message += checkDate($("#date-1-dd"),$("#date-1-mm"),$("#date-1"),"Please enter the date you would like to move."); // check date
			
			// copy and concatenate date fields to hidden field
			// dd/mm/yyyy
			
			$('#SKFCE_17_UserInput').val(copyDateToField());			
				
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}			
			
			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {
				
				message = "";		
								
				return true;
				
			}
			
			else {
						
				message = "";
				
				return false;
				
			}		

			
		});
				

		// unique
		
	}	


	/************************************************************************************/
	/** eBay Promotion
	/************************************************************************************/
		
	if($("#Sitekit_Form_3489").length > 0){

		// add env vars to hidden field
		
		$("#SKFCE_8_UserInput").val($.cookie("Marketing_Referrer"));
		
		$("#SKFCE_21_UserInput").keyup(function(event){	
		
			checkOnlyNumbers($("#SKFCE_21_UserInput"));	
			
		});	
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
						
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); // title					
			message += checkMinChar($("#SKFCE_1_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // second name
			
			message += checkMinChar($("#SKFCE_25_UserInput"),3); // collection address 1			
			message += checkMinChar($("#SKFCE_30_UserInput"),3); // collection posdcode
			
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += checkMinChar($("#SKFCE_3_UserInput"),3); // telephone num
			message += checkChecboxIsSelected($("#SKFCE_7_UserInput")); // t&c's		
			   
			
			message += checkMinChar($("#SKFCE_11_UserInput"),3); // delivery address 1
			//message += checkMinChar($("#SKFCE_16_UserInput"),5); // delivery postcode		
			
			message += checkIsNotFirstSelect($("#SKFCE_22_UserInput"),"N"); // book vs enquire
			
			//message += checkDate($("#date-1-dd"),$("#date-1-mm"),$("#date-1"),"Please enter the date you would like to move."); // check date
			
			// copy and concatenate date fields to hidden field
			// dd/mm/yyyy
			
			$('#SKFCE_5_UserInput').val(copyDateToField());			
				
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}			
			
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}				

			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {
			
				message = "";
				
				return true;
				
			}
			
			else {
			
				message = "";
				
				return false;
				
			}			
			
		});

	}
	
	/************************************************************************************/
	/** Affiliates
	/************************************************************************************/
		
	if($("#Sitekit_Form_3492").length > 0){

		// add env vars to hidden field
		
		$("#SKFCE_12_UserInput").val($.cookie("Marketing_Referrer"));
		
		$("#SKFCE_5_UserInput").keyup(function(event){	
		
			checkOnlyNumbers($("#SKFCE_21_UserInput"));	
			
		});	
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
						
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); // title					
			message += checkMinChar($("#SKFCE_2_UserInput"),3); // first name
			message += checkMinChar($("#SKFCE_3_UserInput"),3); // second name
			message += checkMinChar($("#SKFCE_5_UserInput"),3); // telephone num			
			message += isValidEmail($("#SKFCE_4_UserInput")); // email
			message += checkMinChar($("#SKFCE_1_UserInput"),3); // address 1
			message += checkMinChar($("#SKFCE_6_UserInput"),3); // postcode
			
			
			var q = $.parseQuery(); 
			
			// if the query string does not include a terms parameter,
			// add validation to the terms Checkbox
			
			if(!q.terms){
			
				message += checkChecboxIsSelected($("#SKFCE_20_UserInput")); // t&c's		
			}
			
			   
			// copy and concatenate date fields to hidden field
			// dd/mm/yyyy
			
			$('#SKFCE_17_UserInput').val(copyDateToField());			
				
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}			
			
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}				

			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {
			
				message = "";
				
				return true;
				
			}
			
			else {
			
				message = "";
				
				return false;
				
			}			
			
		});

	}	

	
	/************************************************************************************/
	/** storage promotion
	/************************************************************************************/
		
	if($("#form_left_content #Sitekit_Form_3491").length > 0){
			
		// add env vars to hidden field
		
		$("#SKFCE_12_UserInput").val($.cookie("Marketing_Referrer"));
		
		// add button click event handler
		
		$('#PostEnquiry').click(function() {
		
			message += checkIsNotFirstSelect($("#SKFCE_0_UserInput"),"N"); //title
			
			message += checkMinChar($("#SKFCE_2_UserInput"),3);	// first name
			
			message += checkMinChar($("#SKFCE_3_UserInput"),3); // last name
			
			message += checkMinChar($("#SKFCE_5_UserInput"),11); // telephone
		
			message += checkMinChar($("#SKFCE_4_UserInput"),7); // email
			
			message += isValidEmail($("#SKFCE_4_UserInput")); // email	

			message += checkMinChar($("#SKFCE_6_UserInput"),2); // postcode
			
			message += checkChecboxIsSelected($("#SKFCE_20_UserInput")); // agree terms
			
			//message += checkDate($("#date-1-dd"),$("#date-1-mm"),$("#date-1"),"Please enter the date you would like to move."); // check date
			
			// copy and concatenate date fields to hidden field
			// dd/mm/yyyy
			
			$('#SKFCE_17_UserInput').val(copyDateToField());			
				
			if(message != ""){
			
				//scroll to top of page
				
				$('html, body').animate({scrollTop: '0px'}, 500);
				
			}			
			
			// check the entire form
			
			checkEntireForm();
									
			// reset the error message and submit form by sending a return value
				
			if(checkEntireForm()==true) {
				
				message = "";		
								
				return true;
				
			}
			
			else {
						
				message = "";
				
				return false;
				
			}		

			
		});
				

		// unique
		
	}	


	/************************************************************************************/
	/** ALL FORMS - trap keystroke to prevent invalid characters
	/************************************************************************************/
	
	// read every label element on the page and apply the necessary validation rules based on the label name
	
	$("label").each(function() {
		
		// label name (also the id of the associative html control)
		
		lblName = this.htmlFor;

		// label text (used to apply necessary validation) *remove special characters* *lowercase* *remove brackets* *remove question mark*
		
		lblText = $(this).children(":first").text().replace(":", "").replace(/ /g,'').replace("*",'').replace("(",'').replace(")",'').replace("?",'').toLowerCase();
		
		switch(lblText){
			
			// First Name			
			case "firstname":								
				$("#" + lblName).keyup(function(event){			
					checkNoSpecialChars($("#"+this.id));					
				});	
			break;
			// Last Name			
			case "lastname":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});				
			break;
			// Telephone		
			case "telephone":								
				$("#" + lblName).keyup(function(event){				
					checkTelephoneSpecialChars($("#"+this.id));					
				});				
			break;
			// Telephone		
			case "telephonenumber":								
				$("#" + lblName).keyup(function(event){				
					checkTelephoneSpecialChars($("#"+this.id));					
				});				
			break;
			// Mobile		
			case "mobilenumber":								
				$("#" + lblName).keyup(function(event){				
					checkTelephoneSpecialChars($("#"+this.id));					
				});				
			break;
			// Email		
			case "email":								
				$("#" + lblName).keyup(function(event){				
					checkEmailSpecialChars($("#"+this.id));					
				});				
			break;			
			// Address 1		
			case "address1":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});				
			break;
			// Address 2		
			case "address2":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});				
			break;
			// Address 3		
			case "address3":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});				
			break;
		
			// Town	
			case "town":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});
			// County	
			case "county":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});					
			break;			
			// Postcode	
			case "postcode":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});
				
			// Postcode	/ Zipcode
			case "postcode/zipcode":								
				$("#" + lblName).keyup(function(event){				
					checkPostcodeSpecialChars($("#"+this.id));					
				});
			// Company Name
			case "companyname":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});					
			break;
			// Moving To (Town)	
			case "movingtotown":								
				$("#" + lblName).keyup(function(event){				
					checkNoSpecialChars($("#"+this.id));					
				});				
			break;
			// Who is paying for your move?
			case "whoispayingforyourmove":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars ($("#"+this.id));					
				});				
			break;
			// Tell us about your move
			case "tellusaboutyourmove":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});				
			break;					
			
			// how long do you want to store		
			case "howlongdoyouwanttostore":								
				$("#" + lblName).keyup(function(event){				
					checkRegularSpecialChars($("#"+this.id));					
				});				
			break;
			
			default:
			
		}
		
	});
	
	// also check all the form calendar controls
	
	if($("#form_outer #date-1-dd").length > 0){ // only need to check for presense of the first date field

		$("#date-1-dd").keyup(function(event){	
		
			checkOnlyNumbers($("#date-1-dd"));	
			
		});
		
		$("#date-1-mm").keyup(function(event){	
		
			checkOnlyNumbers($("#date-1-mm"));	
			
		});
		
		$("#date-1").keyup(function(event){	
		
			checkOnlyNumbers($("#date-1"));	
			
		});
	
	}
	
			
});

/***************************/
/** TIP FOR FORM VALIDATION */
/***************************/


/* Add the class "tooltip2" and a title to add a pop up tip */

this.tooltip2 = function(){	

	// popup's distance from the cursor
	ffversion=3;	
	xOffset2 = -20;
		
	yOffset2 = -150;

	// attach a hover state to every matching anchor element
	

// get the version of firefox for ff2 fixes
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
 var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number

}

// if ie6, moves the box more to the left to avoid it going under select box.
isIE6 = /msie|MSIE 6/.test(navigator.userAgent); 
if(isIE6==true) {
yOffset2 = -220;
}


 // hide the tool tip on focus 
 
	$(".tooltip2").focus(function(e){
		this.t = this.title;						  
		this.title = this.t;	
		
		$("#tooltip2").remove();
								  })
	
	$(".tooltip2").click(function(e){
		this.t = this.title;						  
		this.title = this.t;	
		
		$("#tooltip2").remove();
								  })
		
		$("#tooltip2").remove();
								
	
	
	$(".tooltip2").hover(function(e){	
	
		this.t = this.title;

		// create the tooltip
		
		$("body").append("<div id='tooltip2'><p >"+ this.t +"</p></div>");
		
		// position and fade in the tool tip
		
		$("#tooltip2")
			
			.css("top",(e.pageY - xOffset2) + "px")
			
			.css("left",(e.pageX + yOffset2) + "px")
			
			.fadeIn("fast");	
			
	},
	
	// remove tooltip
	
	function(){
	
		this.title = this.t;	
		
		$("#tooltip2").remove();
		
	});	
	
	$(".tooltip2").mousemove(function(e){
	
	 if (ffversion>2) {
		$("#tooltip2")
		
			.css("top",(e.pageY - xOffset2) + "px")
			
			.css("left",(e.pageX + yOffset2) + "px");
	 }
			
	});			
	
};



var errors=0;


function validateblank(fieldid,starttext) {

// checks to see if the field id contains the starting text or no text, and if so clears it when the field is clicked 

	if ($(fieldid).val()==starttext || $(fieldid).val()=="" ){
		$(fieldid).addClass("tooltip2");
		errors++;
		return false;
	}
	else {
		$(fieldid).removeClass("tooltip2");
		$(fieldid).unbind();
		return true;
	};	
	
}



function validateemail(fieldid,starttext) {
	
// checks to see if the field id contains a valid email
	
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = $(fieldid).val();
   if(reg.test(address) == false) {
	$(fieldid).addClass("tooltip2");
	errors++;
	return false;
   }
   else {
	 $(fieldid).removeClass("tooltip2");  
	 $(fieldid).unbind();
	 return true;
   }
}

function validateenquirytype(el) {

	selectedVal = $(el).val();
	
	if (selectedVal == 0){
		$(el).addClass("tooltip2");
		errors++;
		return false;
	}
	else {
		$(el).removeClass("tooltip2");
		return true;
	};
	
}

function validateMileage(el) {

	selectedVal = $(el).val();
	
	if (selectedVal == 0){
		$(el).addClass("tooltip2");
		errors++;
		return false;
	}
	else {
		$(el).removeClass("tooltip2");
		$(el).unbind();
		return true;
	};
	
}

function validateProperty(el) {

	selectedVal = $(el).val();
	
	if (selectedVal == 0){
		$(el).addClass("tooltip2");
		errors++;
		return false;
	}
	else {
		$(el).removeClass("tooltip2");
		$(el).unbind();
		return true;
	};
	
}




function validatetelephone(fieldid,starttext) {
	
// checks to see if the field id contains a valid telephone number

   var reg = /([^0123456789()+ ])/;
   var address = $(fieldid).val();
   
   
   if(address.length<10) {
	errors++; 
	$(fieldid).addClass("tooltip2");
	return false;
   };
   
   if ($(fieldid).val()==starttext || $(fieldid).val()=="" ){
		$(fieldid).addClass("tooltip2");
		errors++;
		return false;
	}
	else {
   if(reg.test(address) == true) {
	$(fieldid).addClass("tooltip2");
	return false;
   }
   else {
	 $(fieldid).removeClass("tooltip2");  
	 $(fieldid).unbind();
	 return true;
   }
	}
}

// copy and concatenate date fields to hidden field
// dd/mm/yyyy

function copyDateToField(el){

	date = $('#form_outer #date-1-dd').val() + "/" + $('#form_outer #date-1-mm').val() + "/" + $('#form_outer #date-1').val();
	
	return date;
	
}

function highlightdate(onoroff) {
// highlights date boxes on price your UK move form

	if (onoroff>0) {
	$("#right-content-form #date-1-mm").addClass("tooltip2");
	$("#right-content-form #date-1-dd").addClass("tooltip2");
	$("#right-content-form #date-1").addClass("tooltip2");
	errors++;
	}
	else {
	$("#right-content-form #date-1-mm").unbind();
	$("#right-content-form #date-1-dd").unbind();
	$("#right-content-form #date-1").unbind();
	}
}


$(document).ready(function(){

		if($("#quick-form-price-your-move").length > 0){

			$('#mileage').change(function() {

				if(this.selectedIndex == 0){
				
					// mileage is not specified, so validate for postcode
				
					validateblank("#right-content-form #distance-from","Postcode");
				
					validateblank("#right-content-form #distance-to","Postcode");
					
				}else{
				
					// mileage is spcified, so blank the postcode fields
				
					$("#distance-to").val("");
					
					$("#distance-from").val("");
					
					$("#distance-to").removeClass("tooltip2");
					
					$("#distance-from").removeClass("tooltip2");
				
				}

			});
			
			$('#distance-from').blur(function() {
				
				if($('#distance-from').val() == "" || $('#distance-to').val() == "Postcode"){
									
					$("#mileage").get(0).selectedIndex = 0;
					
				}else{
				
				
					$("#distance-to").removeClass("tooltip2");
					
					$("#distance-from").removeClass("tooltip2");
					
					$("#mileage").removeClass("tooltip2");
				
				}
			
			});
			
			$('#distance-to').blur(function() {
			
				if($('#distance-to').val() == "" || $('#distance-from').val() == "Postcode"){					

					$("#mileage").get(0).selectedIndex = 0;
					
					$("#mileage").removeClass("tooltip2");
					
				}else{
				
				
					$("#distance-to").removeClass("tooltip2");
					
					$("#distance-from").removeClass("tooltip2");
				
				}

			});

		}
	
		$("#right-content-form .submit-quick-form").click(function(e){

		/* reset errors to 0 */
		
		errors = 0;
		
		errormessage = 0;

		/*price your move form */

		if($("#quick-form-price-your-move").length > 0){
			
			validatetelephone("#right-content-form #telephone","Enter your telephone no.");
			validateemail("#right-content-form #email","Enter your email*");
			validateblank("#right-content-form #date-1-dd","DD");	
			validateblank("#right-content-form #date-1-mm","MM");	
			validateblank("#right-content-form #date-1","YYYY");
			
		
			if($('#distance-from').val() == "Postcode" || $('#distance-to').val() == "Postcode"){
			
				validateblank("#right-content-form #distance-from","Postcode");	// narayan's validation

				validateblank("#right-content-form #distance-to","Postcode");	// narayan's validation					
			
			}else{
			
				$("#distance-from").removeClass("tooltip2");
				
				$("#distance-to").removeClass("tooltip2");
			
			}
			
			
			// checks if the mileage value has been selected, but then deselected.
			if($('#mileage').val() <1 ){
			
			validateblank("#right-content-form #distance-from","Postcode");
			validateblank("#right-content-form #distance-to","Postcode");
			
			}
						
			validateProperty("#property");				
			
			/* Check date on price your move is a valid date */	
			
			var d = new Date();
			errormessage=0;

			var date=new Date();
            var currentDate;
            var strValue=document.getElementById('date-1-dd').value +"/" + document.getElementById('date-1-mm').value +"/" + document.getElementById('date-1').value;
            var month = date.getMonth();
            month++;
            var moveDate = new Date(document.getElementById('date-1').value, document.getElementById('date-1-mm').value, document.getElementById('date-1-dd').value); 
            var currentDate = new Date(date.getFullYear(), month, date.getDate()); 
            if(moveDate <= currentDate)
            {
               errormessage++;
			}
            var objRegExp = /^(((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00|[048])))$/

          //check to see if in correct format

          if(!objRegExp.test(strValue))

            //return false; //doesn't match pattern, bad date

           errormessage++;

          else{
                
              } 


			highlightdate(errormessage);			
			
		}


		/*call me back form */

		if($("#Sitekit_Form_3476").length > 0){
		
			// record the call back source
		
			$('#SKFCE_9_UserInput').val(document.location);	
		
			validateblank("#right-content-form #SKFCE_1_UserInput","Enter first name");	
			validateblank("#right-content-form #SKFCE_2_UserInput","Enter last name");
			validatetelephone("#right-content-form #SKFCE_3_UserInput","Enter your telephone No.");
			validateemail("#right-content-form #SKFCE_4_UserInput","Enter your email*");
			validateenquirytype("#right-content-form #SKFCE_5_UserInput");
			
			// the quick-form-home-moving-international-section has slightly different
			// javascript validation on it. Check for presense of the hidden field
			// which identifies it

			identify = $("#right-content-form #Sitekit_Form_3476 #identify").val();

			if(identify == "quick-form-home-moving-international-section"){

				selectedVal = $("#SKFCE_5_UserInput").val();
				
				if(selectedVal == "1" || selectedVal == "4"){
					
					validateblank("#right-content-form #SKFCE_6_UserInput","Enter your postcode*");
				
				}else if(selectedVal == "2" || selectedVal == "3"){
				
					validateblank("#right-content-form #SKFCE_11_UserInput","Enter your company name*");
				}				

			}else{

				// the other call me back quickfills have the same validation profiles			
			
				// only validate the postcode if the enquiry type is move,storage,selfstore or business - 			
				// which have values of 1,2,3,99 respectively
				
				selectedVal = $("#SKFCE_5_UserInput").val();
				
				if(selectedVal == "1" || selectedVal == "2" || selectedVal == "3" || selectedVal == "99"){
					
					validateblank("#right-content-form #SKFCE_6_UserInput","Enter your postcode*");
				
				}	
				
				validateblank("#right-content-form #SKFCE_11_UserInput","Enter company name*");
			
			}
						
			
		}


		/*storage enquiry form */

		if($("#quick-form-storage-enquiry").length > 0){
			validateblank("#right-content-form #first-name","Enter first name");	
			validateblank("#right-content-form #last-name","Enter last name");	
			validatetelephone("#right-content-form #telephone","Enter your telephone No.");
			validateemail("#right-content-form #email","Enter your email*");
			validateblank("#right-content-form #postcode","Enter your postcode*")
		}
			
		// set up rollover tooltip on invalid fields

		if (errors>0) {
		tooltip2();
		errors=0;	
		return false;
		} else {
		errors=0;
		return true;
		}
		
	});

	/*Can't find an answer form validation*/
	
	if($("#Sitekit_Form_3484").length > 0){

	// add env vars to hidden field
	
		$("#Sitekit_Form_3484 #SKFCE_12_UserInput").val($.cookie("Marketing_Referrer"));
	
	}

	$("#Sitekit_Form_3484 .SubmitButtonElement").click(function(e){

		/* reset errors to 0 */
	errors=0;
	errormessage=0;

	if($("#Sitekit_Form_3484").length > 0){
		/*validateblank("#SKFCE_1_UserInput","Ask a question");	*/
		validateblank("#SKFCE_2_UserInput","Enter your name");	
		validateemail("#SKFCE_4_UserInput","Enter your email*");
		/*validateblank("#SKFCE_0_UserInput","Enter your telephone");*/
	}
	
	
		
	  // set up rollover tooltip on invalid fields

		if (errors>0) {
		tooltip2();
		errors=0;	
		return false;
		} else {
		errors=0;
		return true;
		}

	});

	/* small move form - estimator calculator */

	if($("#Sitekit_Form_3475").length > 0){
	
		$('#estimate-total').hide(); // hide the output
	
		$('#SKFCE_1_UserInput').change(function() {
		
			calculateSmallMoveEstimate();
			
		});
		
		$('#SKFCE_15_UserInput').change(function() {
		
			calculateSmallMoveEstimate();
			
		});
		
		$('#SKFCE_16_ElementID_Yes').click(function() {
		
			calculateSmallMoveEstimate();
			
		});
		
		$('#SKFCE_16_ElementID_No').click(function() {
		
			calculateSmallMoveEstimate();
			
		});

	}


/****************************/
/** TIP FOR IN YOUR AREA MAP */
/****************************/

	$("#small_map_go").click(function(e){								  
		top.location=$("#small_map_options").val();							  											
	});

	
	if($("#mapbackarea").length > 0){
		$.preloadImages("/map/map1.gif", "/map/map2.gif","/map/map3.gif", "/map/map4.gif","/map/map5.gif", "/map/map6.gif","/map/map7.gif", 		"/map/map8.gif","/map/map9.gif", "/map/map10.gif");
		tooltipred(-20,20);
	}

	if($("#smallmap").length > 0){
		tooltipred(-20,-80);	
	}


});
