

$(function() {
		   
	$("#expertiseMenu").hide();

	$('#footerMenu').hide()
		$('#upArrow').click(function(){
			 $('#upContainer').hide()
			 $('#footerMenu').animate({
			height: 'toggle',
			marginTop: '-295px'
		  }, 1000, function() {
		  });
	});

	$('#downArrow').click(function(){
						
		 $('#footerMenu').animate({
			height: 'toggle',
			marginTop: '5px'
		  }, 1000, function() {

			$('#upContainer').slideDown('slow')
			$('#footerMenu').css("marginTop","0px")	

		});

	});
	
	$('.subscribeWhitePaper').qtip({
		  content: '<div class="subscribeBox"><p class="subscribeTitle">Email contact</p><input type="text" id="subscribeEmail" size="20" class="subscribeInput"><a href="javascript:submitSubscribe($(\'#subscribeEmail\').val());" class="subscribeSubmit" >Submit</a></div>',
		  show: { 
				when: 'mouseover', 
				solo: true, // Only show one tooltip at a time
				 effect: { type: 'fade', length: 150 }
			 },
		   hide: { when: 'mouseout', fixed: true },
		   position: {
			adjust: {screen: true, x:-2 },
		  corner: {
			 target: 'leftMiddle',
			 tooltip: 'rightMiddle'
		  }},
		  style: { 
		  padding: 0,
			 tip: {
				corner: 'topMiddle',
				size: {
					x: 8, 
					y : 20 
				}
			 },
		  border: {
			color: '#B8B9BB',
			 width: 0
		  }
	   }
	});
	
	
	  $(".creativeExpertise").each(function(){

			$(this).qtip({
			   content: $(this).attr("alt"),
			  show: { 
					when: 'mouseover', 
					solo: true, // Only show one tooltip at a time
					 effect: { type: 'fade', length: 150 }
				 },
			   hide: 'mouseout',
			   position: {
				adjust: {screen: true, x:0 },
			  corner: {
				 target: 'bottomMiddle',
				 tooltip: 'topMiddle'
			  }},
			  style: { 
			 background: '#95B2D8', 
				 tip: {
					corner: 'topMiddle',
					size: {
						x: 20, 
						y : 8
					}
				 },
			  border: {
				color: '#95B2D8',
				 width: 1
			  }
		   }
		});
	});

	  $(".interactiveExpertise").each(function(){

			$(this).qtip({
			   content: $(this).attr("alt"),
			  show: { 
					when: 'mouseover', 
					solo: true, // Only show one tooltip at a time
					 effect: { type: 'fade', length: 150 }
				 },
			   hide: 'mouseout',
			   position: {
				adjust: {screen: true, x:0 },
			  corner: {
				 target: 'bottomMiddle',
				 tooltip: 'topMiddle'
			  }},
			  style: { 
				 background: '#FFCE9E', 
				 tip: {
					corner: 'topMiddle',
					size: {
						x: 20, 
						y : 8 
					}
				 },
				  border: {
					color: '#FFCE9E',
					 width: 1
				  }
			   }
		});
	});

	  $(".healthcareExpertise").each(function(){

			$(this).qtip({
			   content: $(this).attr("alt"),
			  show: { 
					when: 'mouseover', 
					solo: true, // Only show one tooltip at a time
					 effect: { type: 'fade', length: 150 }
				 },
			   hide: 'mouseout',
			   position: {
				adjust: {screen: true, x:0 },
			  corner: {
				 target: 'bottomMiddle',
				 tooltip: 'topMiddle'
			  }},
			  style: { 
			 background: '#A9D6D4', 
			 tip: {
				corner: 'topMiddle',
				size: {
					x: 20,
					y : 8
				}
			 },
			  border: {
				color: '#A9D6D4',
				 width: 1
			  }
		   }
		});
	});


			$('div.back').show();
			$('#person-list li').hover(function(){
				$(this).find('.front').animate({marginTop:'-128px'},{queue:false,duration:250});
			}, function(){
				$(this).find('.front').animate({marginTop:'0px'},{queue:false,duration:250});
			});


});

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function submitSubscribe(emailAddress){
	
	if(isValidEmailAddress(emailAddress)){
		$.ajax({
			  url: 'http://www.whitecommsgroup.co.uk/ajax/subscribe.aspx?strEmail=' + emailAddress,
			  success: function(data) {
				if(data.length>0){
					if(data=='Error'){
						 alert("Error submitting your request, please try again.");
					 }else{
						 alert("Thank you for subscribing to the whitepaper.");
					 }
				}else{
						 alert("Error submitting your request, please try again.");
				}
			  },
			  error : function(data) { alert("Error submitting your request, please try again.");
			 }
		});
	}else{
		alert("Invalid email address, please try again.");
	}

}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}

