
/* jQuery Clear-Input plugin */
(function ($) {
	// define the initialValue() function
	$.fn.initialValue = function (value) {
		if (value) {
			return this.attr('data-initial-value', value);
		} else {
			return this.attr('data-initial-value');
		}
	};
	$.fn.clearInput = function () {
		return this
      .focus(function () {
      	if (this.value == $(this).initialValue()) {
      		this.value = '';
      		this.focus();
      	}
      })
      .blur(function () {
      	if (this.value == '') {
      		this.value = $(this).initialValue();
      	}
      })
      .each(function (index, elt) {
      	$(this).initialValue(this.value);
      });
	};
	// apply to all inputs with class ".clear-input"
	$(function () {
		$('input.clear-input').clearInput();
	});
})(jQuery);






$(document).ready(function () {


	//SG 04/08/2011 Replaced clear input as it doesn't support IE and is badly written. Used addPlaceHolder.js instead
	//clear input
	//$("input[type='text'].clear").clearInput();

	$("input[type='text'].clear").each(function (intIndex) {
		$(this).attr('placeholder', $(this).val());
		$(this).val('');
	});

	$("input[type='text'].clear").addPlaceholder();

	//$('#testModal').click(function(){ $('#hiddenModal').modal({opacity: 70});});

	$('.getInTouch').click(function () {
		$('.contactModal').modal({ opacity: 70 });
		return false
	});





	jQuery('#nav').superfish({
		autoArrows: false, // disable generation of arrow mark-up
		dropShadows: false // disable drop shadows
	});


	var wistHeight = 0

	$('#whatIsSomewhereto a.close').click(function () {
		$(this).hide();
		wistHeight = $('#whatIsSomewhereto').height();
		$('#whatIsSomewhereto').animate({ left: -252, height: 18 }, { "duration": "200", "easing": "easeOutCubic" }).children('p').fadeOut();
	});

	$('#whatIsSomewhereto a.open').click(function () {
		$('a.close').show();
		$('#whatIsSomewhereto').animate({ left: 0, height: wistHeight }, { "duration": "200", "easing": "easeOutCubic" }).children('p').fadeIn();
	});


	if ($("#videoThmbs").length > 0) {

		var liWidth = $("#videoThmbs ul li").width() + 7;

		var c = $("#videoThmbs ul li").length;

		$("#videoThmbs ul").css({ 'width': liWidth * c })

	}

	$("#testShowThanks").click(function () {
		$("#cf-foundSpace").hide();
		$("#contactThanks").show();
	});


	$(function () {

		$(".home #ourLocations .mapSpot").mouseenter(function () {

			$(".mapSpot").removeClass('activeMapSpot');
			$(this).addClass('activeMapSpot');
			var loc = $(this).attr('title');
			var link = $(this).attr('href');

			$("#activeLoc").text(loc);
			$("h4 a").attr('href', link);
		});

	});

	$(function () {

		$(".home #ourLocations .mapSpot").focus(function () {

			$(".mapSpot").removeClass('activeMapSpot');
			$(this).addClass('activeMapSpot');
			var loc = $(this).attr('title');
			var link = $(this).attr('href');

			$("#activeLoc").text(loc);
			$("h4 a").attr('href', link);
		});

	});

	$(function () {

		$("#leftContent #ourLocations .mapSpot").mouseenter(function () {
			$(this).next().show();
		});

		$('.locationInfo').mouseleave(function () {
			$(this).hide();
		});
	});




	$('.accorHead').click(function () {
		$('.accorHead').addClass('ahClosed');
		$('.accorBody').addClass('abClosed');
		$(this).toggleClass('ahClosed').next().toggleClass('abClosed');

	});

	$('.accorBody .readMore').click(function () {

		$(this).parent().next().show();
		$(this).hide();
		return false
	});

});


