// jQuery functions

$(document).ready(function(){





// The banner

	$("#due-diligence-banner").fadeIn();
	$("#surveillance-banner").hide();
	$("#family-banner").hide();
	$("#intellectual-property-banner").hide();
	$("#legal-support-banner").hide();
	
	$("#show-banner-1").click(function(){
		$("#due-diligence-banner").fadeIn();
		$("#surveillance-banner").hide();
		$("#family-banner").hide();
		$("#intellectual-property-banner").hide();
		$("#legal-support-banner").hide();
		
		$(this).addClass("active");
		$("#show-banner-2").removeClass("active");
		$("#show-banner-3").removeClass("active");
		$("#show-banner-4").removeClass("active");
		$("#show-banner-5").removeClass("active");
		return false;
	});
	
	$("#show-banner-2").click(function(){
		$("#due-diligence-banner").hide();
		$("#surveillance-banner").fadeIn();
		$("#family-banner").hide();
		$("#intellectual-property-banner").hide();
		$("#legal-support-banner").hide();
		
		$("#show-banner-1").removeClass("active");
		$(this).addClass("active");
		$("#show-banner-3").removeClass("active");
		$("#show-banner-4").removeClass("active");
		$("#show-banner-5").removeClass("active");
		return false;
	});
	
	$("#show-banner-3").click(function(){
		$("#due-diligence-banner").hide();
		$("#surveillance-banner").hide();
		$("#family-banner").fadeIn();
		$("#intellectual-property-banner").hide();
		$("#legal-support-banner").hide();
		
		$("#show-banner-1").removeClass("active");
		$("#show-banner-2").removeClass("active");
		$(this).addClass("active");
		$("#show-banner-4").removeClass("active");
		$("#show-banner-5").removeClass("active");
		return false;
	});
	
	$("#show-banner-4").click(function(){
		$("#due-diligence-banner").hide();
		$("#surveillance-banner").hide();
		$("#family-banner").hide();
		$("#intellectual-property-banner").fadeIn();
		$("#legal-support-banner").hide();
		
		$("#show-banner-1").removeClass("active");
		$("#show-banner-2").removeClass("active");
		$("#show-banner-3").removeClass("active");
		$(this).addClass("active");
		$("#show-banner-5").removeClass("active");
		return false;
	});
	
	$("#show-banner-5").click(function(){
		$("#due-diligence-banner").hide();
		$("#surveillance-banner").hide();
		$("#family-banner").hide();
		$("#intellectual-property-banner").hide();
		$("#legal-support-banner").fadeIn();
		
		$("#show-banner-1").removeClass("active");
		$("#show-banner-2").removeClass("active");
		$("#show-banner-3").removeClass("active");
		$("#show-banner-4").removeClass("active");
		$(this).addClass("active");
		return false;
	});


// The testimonials


$('.testimonial').fadeOut(500);
$('.testimonial:first').fadeIn(500);

$('a#prev-testimonial, a#next-testimonial').click( function (ev) {
    //prevent browser jumping to top
    ev.preventDefault();

    //get current visible item
    var $visibleItem = $('.testimonial:visible');

    //get total item count
    var total =  $('.testimonial').length;

    //get index of current visible item
    var index = $visibleItem.prevAll().length;

    //if we click next increment current index, else decrease index
    $(this).attr('href') === '#next-testimonial' ? index++ : index--;

    //if we are now past the beginning or end show the last or first item
    if (index === -1){
       index = total-1;
    }
    if (index === total){
       index = 0
    }

    //hide current show item
    $visibleItem.hide();

    //fade in the relevant item
    $('.testimonial:eq(' + index + ')').fadeIn(500);

});









// The locations 

	$("#location-1").show();
	$("#location-2").hide();
	$("#location-3").hide();
	$("#location-4").hide();
	$("#location-5").hide();
	
	$("#map-london").click(function(){
		$("#location-1").fadeIn();
		$("#location-2").hide();
		$("#location-3").hide();
		$("#location-4").hide();
		$("#location-5").hide();
		return false;
	});
	
	$("#map-southampton").click(function(){
		$("#location-1").hide();
		$("#location-2").fadeIn();
		$("#location-3").hide();
		$("#location-4").hide();
		$("#location-5").hide();
		return false;
	});
	
	$("#map-oxford").click(function(){
		$("#location-1").hide();
		$("#location-2").hide();
		$("#location-3").fadeIn();
		$("#location-4").hide();
		$("#location-5").hide();
		return false;
	});
	
	$("#map-birmingham").click(function(){
		$("#location-1").hide();
		$("#location-2").hide();
		$("#location-3").hide();
		$("#location-4").fadeIn();
		$("#location-5").hide();
		return false;
	});
	
	$("#map-manchester").click(function(){
		$("#location-1").hide();
		$("#location-2").hide();
		$("#location-3").hide();
		$("#location-4").hide();
		$("#location-5").fadeIn();
		return false;
	});


	/*Client Login*/
	$("#login a:first-child").click(function(){
		//alert("coool");
		//$("#client-login").css("display","block");
		//$("#client-login").removeClass();		
		//$("#client-login").addClass("active-login");
		if($("#client-login").css("display")=="none"){
			$("#client-login").removeClass();		
			$("#client-login").addClass("active-login");
		}else{
			$("#client-login").removeClass();		
			$("#client-login").addClass("disable-login");
		}
		
	});
	$("#client-login").mouseout(function(){
		//alert("coool");
		//$("#client-login").css("display","none");
	});
	
	

		// Login drop down box
		
				
			$("#login-drop-down").click(function()
			{
				$("#login-drop-down-box").toggle();
			});	
			
			
		});
		
		var mouse_is_inside = false;

		$(document).ready(function()
		{
			$('#login-drop-down-box').hover(function(){ 
				mouse_is_inside=true; 
			}, function(){ 
				mouse_is_inside=false; 
			});
		
			$("body").mouseup(function(){ 
				if(! mouse_is_inside) $('#login-drop-down-box').hide();
			});

	
	

}); // Document ready ends
