 	new Image().src = "images/the_yorkshire_show_off.png";
	new Image().src = "images/digital_data_direct.png";
	new Image().src = "images/hero-bricks.png";
	new Image().src = "images/back_to_earth_slide.png";
	
$().ready(function() {
	
		$("img").hover(
		function()
		{
			this.src = this.src.replace("-off","-on");
		},
		function()
		{
			this.src = this.src.replace("-on","-off");
		});
	
	
	//About us function
	$('.aboutus li').click(
		function() 
		{
			//Find out which link was clicked
			var clicked = $(this).attr("id");
			var baseid = clicked.substring(5);
			//Now set target div to be shown by appending -details to clicked id
			var targetdiv = baseid;
			var targetlink = '#link-'+baseid+' a';
			var bannerclass = baseid;
			//removed selected class from all li elements in nav-people
			$('.aboutus li a').each(function()	{
				$(this).removeClass("active").removeClass("inactive").addClass("inactive");
			});
			//Now ensure allthe people-details subdivs are hidden
			$('#main-content-text div').each(function()	{
				$(this).hide();
			});
			//Replace the banner image
			$("#banner").removeClass().addClass(bannerclass);

			//Show the targeted div
			$("#"+targetdiv).show();
			if(baseid == "people")	{
				$("#staff_pic").show();
				$("#staff_pic2").show();
				$("#staff_pic3").show();
				$("#staff_pic4").show();
				$("#staff_pic5").show();
				$("#staff_pic6").show();
				$("#staff_pic7").show();
				$("#staff_pic8").show();
				$("#staff_pic9").show();
				$("#staff_pic10").show();
				$("#staff_pic11").show();
				$("#staff_pic12").show();
				$("#staff_pic13").show();
				$("#staff_pic14").show();
				$("#main-content-text-mid").show();
				$("#main-content-text-top").show();
				$("#main-content-text-bot").show();
				$("#ourpeople_boxer").show();
				$("#ourpeople-top").show();
				$("#ourpeople").show();
				$("#ourpeople-bot").show();
				$("#people-details").show();
				$("#nav-people li").each(function() {
					$(this).removeClass("selected");
				});
				$("#tim").addClass("selected");
				$("#tim-details").show();
			}
			if(baseid == "agency")	{
				$("#text_control_header").show();
				$("#text_control_body").show();
			}
			if(baseid == "careers")	{
				$("#text_control_header_car").show();
				$("#text_control_body_car").show();
			}
						
			$(targetlink).removeClass("inactive").addClass("active");
			return false;
		});
		
	//Our work function
	$('.worklinks li').click(
		function() 
		{
			//Find out which link was clicked
			var clicked = $(this).attr("id");
			var baseid = clicked.substring(5);
			//Now set target div to be shown by appending -details to clicked id
			var targetdiv = baseid;
			var targetlink = '#link-'+baseid+' a';
			var bannerclass = baseid;
			//removed selected class from all li elements in nav-people
			$('.worklinks li a').each(function()	{
				$(this).removeClass("active").removeClass("inactive").addClass("inactive");
			});
			//Now ensure allthe people-details subdivs are hidden
				$('#main-content-text > div').hide();
			//Replace the banner image
			$("#banner").removeClass().addClass(bannerclass);

			//Show the targeted div
			$("#"+targetdiv).show();
			if(baseid == "study-1")	{
				$("#text_control_header_work").show();
				$("#text_control_body_work").show();
				$('#scroll_container_1').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
			}
			if(baseid == "study-2")	{
				$("#text_control_header_work2").show();
				$("#text_control_body_work2").show();
				$('#scroll_container_2').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
			}
			if(baseid == "study-3")	{
				$("#text_control_header_work3").show();
				$("#text_control_body_work3").show();
				$('#scroll_container_3').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
			}
			if(baseid == "study-4")	{
				$("#text_control_header_work4").show();
				$("#text_control_body_work4").show();
				$('#scroll_container_4').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});

			}
			if(baseid == "study-5")	{
				$("#text_control_header_work5").show();
				$("#text_control_body_work5").show();
				$("#scroll_container").show();
				 $('#scroll_container_5').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
				
			}
			if(baseid == "study-6")	{
				$("#text_control_header_work6").show();
				$("#text_control_body_work6").show();
				$("#scroll_container").show();
				 $('#scroll_container_6').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
				
			}
			$(targetlink).removeClass("inactive").addClass("active");
			return false;
		});


//Clients function
	$('.clients li').click(
		function() 
		{
			//Find out which link was clicked
			var clicked = $(this).attr("id");
			var baseid = clicked.substring(5);
			//Now set target div to be shown by appending -details to clicked id
			var targetdiv = baseid;
			var targetlink = '#link-'+baseid+' a';
			var bannerclass = baseid;
			//removed selected class from all li elements in nav-people
			$('.clients li a').each(function()	{
				$(this).removeClass("active").removeClass("inactive").addClass("inactive");
			});
			//Now ensure allthe people-details subdivs are hidden
			$('#client-content-text div').each(function()	{
				$(this).hide();
			});
			//Show the targeted div
			$("#"+targetdiv).show();
			if(baseid == "client-1")	{
				$("#text_control_header_work").show();
				$("#text_control_body_work").show();
			}
			if(baseid == "client-2")	{
				$("#text_control_header_work2").show();
				$("#text_control_body_work2").show();
			}
			if(baseid == "client-3")	{
				$("#text_control_header_work3").show();
				$("#text_control_body_work3").show();
			}
			if(baseid == "client-4")	{
				$("#text_control_header_work4").show();
				$("#text_control_body_work4").show();
			}
			if(baseid == "client-5")	{
				$("#text_control_header_work5").show();
				$("#text_control_body_work5").show();
			}
			if(baseid == "client-6")	{
				$("#text_control_header_work6").show();
				$("#text_control_body_work6").show();
			}
			if(baseid == "client-7")	{
				$("#text_control_header_work7").show();
				$("#text_control_body_work7").show();
			}
			if(baseid == "client-8")	{
				$("#text_control_header_work8").show();
				$("#text_control_body_work8").show();
			}
			if(baseid == "client-9")	{
				$("#text_control_header_work9").show();
				$("#text_control_body_work9").show();
			}
			if(baseid == "client-10")	{
				$("#text_control_header_work10").show();
				$("#text_control_body_work10").show();
			}
			if(baseid == "client-11")	{
				$("#text_control_header_work11").show();
				$("#text_control_body_work11").show();
			}
			if(baseid == "client-12")	{
				$("#text_control_header_work12").show();
				$("#text_control_body_work12").show();
			}
			if(baseid == "client-13")	{
				$("#text_control_header_work13").show();
				$("#text_control_body_work13").show();
			}
			if(baseid == "client-14")	{
				$("#text_control_header_work14").show();
				$("#text_control_body_work14").show();
			}
			if(baseid == "client-15")	{
				$("#text_control_header_work15").show();
				$("#text_control_body_work15").show();
			}
			if(baseid == "client-16")	{
				$("#text_control_header_work16").show();
				$("#text_control_body_work16").show();
			}
			$(targetlink).removeClass("inactive").addClass("active");
			return false;
		});
	
	
	
	//Our services function
	$('.servicelinks li').click(
		function() 
		{
			//Find out which link was clicked
			var clicked = $(this).attr("id");
			var baseid = clicked.substring(5);
			//Now set target div to be shown by appending -details to clicked id
			var targetdiv = baseid;
			var targetlink = '#link-'+baseid+' a';
			var bannerclass = baseid;
			//removed selected class from all li elements in nav-people
			$('.servicelinks li a').each(function()	{
				$(this).removeClass("active").removeClass("inactive").addClass("inactive");
			});
			//Now ensure allthe people-details subdivs are hidden
			$('#serv-content-text > div').hide();
			//Replace the banner image
			//$("#banner").removeClass().addClass(bannerclass);

			//Show the targeted div
			$("#"+targetdiv).show();
			if(baseid == "service-1")	{
				$("#text_control_header_serv").show();
				$("#text_control_body_serv").show();
			}
			if(baseid == "service-2")	{
				$("#text_control_header_serv2").show();
				$("#text_control_body_serv2").show();
			}
			if(baseid == "service-3")	{
				$("#text_control_header_serv3").show();
				$("#text_control_body_serv3").show();
			}
			if(baseid == "service-4")	{
				$("#text_control_header_serv4").show();
				$("#text_control_body_serv4").show();
				$('#scroll_container_4').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
		

			}
			$(targetlink).removeClass("inactive").addClass("active");
			return false;
		});
	
	//Bio link functions
	$('#nav-people li').click(
		function() 
		{
			//Find out which link was clicked
			var clicked = $(this).attr("id");
			//Now set target div to be shown by appending -details to clicked id
			var target = clicked+'-details';
			//removed selected class from all li elements in nav-people
			$('#nav-people li').each(function()	{
				$(this).removeClass("selected");
			});
			//Now ensure allthe people-details subdivs are hidden
			$('#people-details div').each(function()	{
				$(this).hide();
			});
			//Show the targeted people-details div
			$("#"+target).show();
				$("#staff_pic").show();
				$("#staff_pic2").show();
				$("#staff_pic3").show();
				$("#staff_pic4").show();
				$("#staff_pic5").show();
				$("#staff_pic6").show();
				$("#staff_pic7").show();
				$("#staff_pic8").show();
				$("#staff_pic9").show();
				$("#staff_pic10").show();
				$("#staff_pic11").show();
				$("#staff_pic12").show();
				$("#staff_pic13").show();
				$("#staff_pic14").show();
			//add selected class to the clicked li element
			$(this).addClass("selected");
			return false;
		});
 

});

//url swapper
//High Street Tv
$(function(){
	if ($.url(location.href).attr("source") == "http://www.pcdagency.com/our-work.php?High-Street-Tv"){
        $("#link-study-1 a").removeClass("active").removeClass("inactive").addClass("inactive");
		$("#link-study-2 a").removeClass("inactive").removeClass("active").addClass("active");
		$('#study-1 > div').hide();
		$('#study-1').hide();
		$("#study-2").show();
		$("#text_control_header_work2").show();
		$("#text_control_body_work2").show();
				$('#scroll_container_2').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
		$("#banner").addClass('study-2');			
			}
		
});

//Epilepsy Action
$(function(){
	if ($.url(location.href).attr("source") == "http://www.pcdagency.com/our-work.php?Epilepsy_Action"){
        $("#link-study-1 a").removeClass("active").removeClass("inactive").addClass("inactive");
		$("#link-study-3 a").removeClass("inactive").removeClass("active").addClass("active");
		$('#study-1 > div').hide();
		$('#study-1').hide();
		$("#study-3").show();
		$("#text_control_header_work3").show();
		$("#text_control_body_work3").show();
				$('#scroll_container_3').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
		$("#banner").addClass('study-3');		
			}
			
});

//Back to Earth
$(function(){
	if ($.url(location.href).attr("source") == "http://www.pcdagency.com/our-work.php?Back-to-Earth"){
        $("#link-study-1 a").removeClass("active").removeClass("inactive").addClass("inactive");
		$("#link-study-6 a").removeClass("inactive").removeClass("active").addClass("active");
		$('#study-1 > div').hide();
		$('#study-1').hide();
		$("#study-6").show();
		$("#text_control_header_work6").show();
		$("#text_control_body_work6").show();
				$('#scroll_container_6').jScrollPane({
       			showArrows: true,
       			horizontalGutter: 10,
       			arrowScrollOnHover: true
   				});
		$("#banner").addClass('study-6');			
			}
		
});

//Careers
$(function(){
	if ($.url(location.href).attr("source") == "http://www.pcdagency.com/about-us.php?Careers"){
 		$("#link-agency a").removeClass("active").removeClass("inactive").addClass("inactive");
		$("#link-careers a").removeClass("inactive").removeClass("active").addClass("active");
		$('#agency > div').hide();
		$('#agency').hide();
		$("#careers").show();
		$("#banner").addClass('careers');
			}
			
});
