numImages=0;
currentImage=1;
currentPanel="none";

// Wait for everything to load prior to running
//Display what we do page after page is loaded
$(window).load(function() {
	

	var url = $.url(); // parse the current page URL
	//alert(url.attr('relative'));
	if (url.attr('relative') == "/seminars" || url.attr('relative') == "/seminars/")
	{
		ShowPanel("seminars");
		}
	else if (url.attr('relative') == "/careers" || url.attr('relative') == "/careers/")
	{
		ShowPanel("careers");
		}
	else if (url.attr('relative') == "/seminar" || url.attr('relative') == "/seminar/")
	{
		ShowPanel("seminars");
		}
	else if (url.attr('relative') == "/SEMINARS" || url.attr('relative') == "/SEMINARS/")
	{
		ShowPanel("seminars");
		}
	else if (url.attr('relative') == "/SEMINAR" || url.attr('relative') == "/SEMINAR/")
	{
		ShowPanel("seminars");
		}
	else if (url.attr('relative') == "/services" || url.attr('relative') == "/services/")
	{
		ShowPanel("welcome");
		}
	else if (url.attr('relative') == "/our-approach" || url.attr('relative') == "/our-approach/")
	{
		ShowPanel("pubs");
		}
	else if (url.attr('relative') == "/portfolio" || url.attr('relative') == "/portfolio/")
	{
		ShowPanel("thematic");
		}
	else if (url.attr('relative') == "/about" || url.attr('relative') == "/about/")
	{
		ShowPanel("team");
		}
	
	//else
		//ShowPanel("welcome");

});


// Start when DOM is finished loading
$(document).ready(function(){	
	$('#wes_container').mouseover(function() {  
	  $('#wes_container span').animate({
		left:0
	  }, 150)
	});
	
	$('#wes_container').mouseleave(function() {  
	  $('#wes_container span').animate({
		left:-80
	  }, 150)
	});
	
	$('#mashell_container').mouseover(function() {  
	  $('#mashell_container span').animate({
		left:0
	  }, 150)
	});
	
	$('#mashell_container').mouseleave(function() {  
	  $('#mashell_container span').animate({
		left:-80
	  }, 150)
	});
	
	$('#danny_container').mouseover(function() {  
	  $('#danny_container span').animate({
		left:0
	  }, 150)
	});
	
	$('#danny_container').mouseleave(function() {  
	  $('#danny_container span').animate({
		left:-80
	  }, 150)
	});
	
	
	//Careers Page
	$('#marketing').click(function() {
	 $.scrollTo( '690px', 800 );
	});
	
	$('#webdeveloper').click(function() {
	 $.scrollTo( '1300px', 800 );
	});
					   
	// Initializes FancyBox Lightbox
	$("a.sliderImage").fancybox({
		'zoomSpeedIn':200, 
		'zoomSpeedOut':200, 
		'overlayShow':true,
		'padding':4
	});
	
	SelectButton("none");
	$("#arrow").fadeOut(0);
	$("#champion").fadeIn(1200);
	
	/*if (navigator.appVersion.indexOf("MSIE 7.0")!=-1){
		$("input").css({"height":13});
		$("#name").css({"width":155});
	};*/
	
	$("#title").click(function(){
		ShowPanel("none");
	});
						   	
		
	// Handles Rollover and Click For the Nav Buttons
	$("#welcomeButton").mouseenter(function(){
		SelectButton("welcome");
	});
	$("#pubsButton").mouseenter(function(){
		SelectButton("pubs");
	});
	$("#thematicButton").mouseenter(function(){
		SelectButton("thematic");
	});
	$("#teamButton").mouseenter(function(){
		SelectButton("team");
	});
	$("#careersButton").mouseenter(function(){
		SelectButton("careers");
	});
	$("#seminarsButton").mouseenter(function(){
		SelectButton("seminars");
	});
	
	
	$("#welcomeButton,#pubsButton,#thematicButton,#teamButton,#careersButton,#seminarsButton").mouseleave(function(){
		SelectButton("none");
	});
	$("#welcomeButton").click(function(){
		ShowPanel("welcome");	
		
	});
	$("#pubsButton").click(function(){
		ShowPanel("pubs");
		
	});
	$("#thematicButton").click(function(){
		ShowPanel("thematic");		
		
	});
	$("#teamButton").click(function(){
		ShowPanel("team");	
		
	});
	$("#careersButton").click(function(){
		ShowPanel("careers");	
		
	});
	$("#seminarsButton").click(function(){
		ShowPanel("seminars");	
		
	});
	
	$('.viewworkbutton').click(function(e) {
			e.preventDefault();
		});
	
	 	//Rollover and Active Class State
		$("img.rollover:not(.active)").hover(
		function(){this.src = this.src.replace("_off","_on");},
		function(){
			if(!$(this).hasClass('active')){
				this.src = this.src.replace("_on","_off");
			}
		});
		$("img.rollover, .navButton").click(function(){
			$("img.rollover.active").each(function(){
				this.src = this.src.replace("_on","_off");
				$(this).removeClass('active');
			});
		$(this).toggleClass('active');
		});
		
		
		$("#name").attr("value", "name");
		$("#mjlutt-mjlutt").attr("value", "email address");
		$("#phone").attr("value", "phone number");
		$("#biz").attr("value", "type of business");
		$("#zip").attr("value", "zip code");
		
		$("#myuklj-myuklj").attr("value", "enter email address");

		var nametext = "name";
		var emailtext = "email address";
		var biztext = "type of business";
		var phonetext = "phone number";
		var ziptext = "zip code";
		
		var connectemailtext = "enter email address"
		
	
		$("#name").focus(function() {
			$(this).addClass("active");
			if($(this).attr("value") == nametext) $(this).attr("value", "");
		});
	
		$("#name").blur(function() {
			$(this).removeClass("active");
			if($(this).attr("value") == "") $(this).attr("value", nametext);
			if($(this).attr("value") != "" && $(this).attr("value") != "name") $(this).addClass("darktext");
		});
		
		$("#mjlutt-mjlutt").focus(function() {
			$(this).addClass("active");
			if($(this).attr("value") == emailtext) $(this).attr("value", "");
		});
	
		$("#mjlutt-mjlutt").blur(function() {
			$(this).removeClass("active");
			if($(this).attr("value") == "") $(this).attr("value", emailtext);
			if($(this).attr("value") != "" && $(this).attr("value") != "email address") $(this).addClass("darktext");;
		});
		
		$("#phone").focus(function() {
			$(this).addClass("active");
			if($(this).attr("value") == phonetext) $(this).attr("value", "");
		});
	
		$("#phone").blur(function() {
			$(this).removeClass("active");
			if($(this).attr("value") == "") $(this).attr("value", phonetext);
			if($(this).attr("value") != "" && $(this).attr("value") != "phone number") $(this).addClass("darktext");;
		});
		
		$("#biz").focus(function() {
			$(this).addClass("active");
			if($(this).attr("value") == biztext) $(this).attr("value", "");
		});
	
		$("#biz").blur(function() {
			$(this).removeClass("active");
			if($(this).attr("value") == "") $(this).attr("value", biztext);
			if($(this).attr("value") != "" && $(this).attr("value") != "type of business") $(this).addClass("darktext");;
		});
		
		$("#zip").focus(function() {
			$(this).addClass("active");
			if($(this).attr("value") == ziptext) $(this).attr("value", "");
		});
	
		$("#zip").blur(function() {
			$(this).removeClass("active");
			if($(this).attr("value") == "") $(this).attr("value", ziptext);
			if($(this).attr("value") != "" && $(this).attr("value") != "zip code") $(this).addClass("darktext");;
		});
		
		
		//Email newsletter on the connect page
		$("#myuklj-myuklj").focus(function() {
			$(this).addClass("active");
			if($(this).attr("value") == connectemailtext) $(this).attr("value", "");
		});
	
		$("#myuklj-myuklj").blur(function() {
			$(this).removeClass("active");
			if($(this).attr("value") == "") $(this).attr("value", connectemailtext);
			if($(this).attr("value") != "" && $(this).attr("value") != "name") $(this).addClass("lighttext");
		});
	
	
	
	//What we do page	
	$('#arrowicon').click(function() {
	  
	  $("#whatwedo_arrow").fadeIn(50);	  
	  $('#whatwedo_arrow').animate({
		left:47
	  }, 150, function() {
		$("#whatwedo_arrow").fadeIn(50)
	  });
	});
	
	$('#chaticon').click(function() {
	  
	  $("#whatwedo_arrow").fadeIn(50);	  
	  $('#whatwedo_arrow').animate({
		left:132
	  }, 150, function() {
		$("#whatwedo_arrow").fadeIn(50)
	  });
	});

	
	$('#creativeicon').click(function() {
	  
	  $("#whatwedo_arrow").fadeIn(50);	  
	  $('#whatwedo_arrow').animate({
		left:221
	  }, 150, function() {
		$("#whatwedo_arrow").fadeIn(50)
	  });
	});
	
	$('#searchicon').click(function() {
	  
	  $("#whatwedo_arrow").fadeIn(50);	  
	  $('#whatwedo_arrow').animate({
		left:308
	  }, 150, function() {
		$("#whatwedo_arrow").fadeIn(50)
	  });
	});
	
	$('#emailicon').click(function() {
	  
	  $("#whatwedo_arrow").fadeIn(50);	  
	  $('#whatwedo_arrow').animate({
		left:394
	  }, 150, function() {
		$("#whatwedo_arrow").fadeIn(50)
	  });
	});
	
	$('#communityicon').click(function() {
	  
	  $("#whatwedo_arrow").fadeIn(50);	  
	  $('#whatwedo_arrow').animate({
		left:490
	  }, 150, function() {
		$("#whatwedo_arrow").fadeIn(50)
	  });
	});
	
	
	//thematic content base height
	$baseheight = $("#thematicContent").height();
	
	//TLU
	$('#tluicon').click(function() {
	  
	  $("#arrow").fadeIn(50);
	  
	  $(".depthcontent").fadeOut(10);
	  $("#tlu_indepth").fadeIn(200);
	
	  $.scrollTo( '575px', 800 );
	  $("#contentPanelWrapper").height($baseheight + $("#tlu_indepth").height()-100);
	  
	  
	  $('#arrow').animate({
		left:117
	  }, 150, function() {
		$("#arrow").fadeIn(50)
	  });
	});
	
	//SEP
	$('#sepicon').click(function() {
	  $("#arrow").fadeIn(50);
	   $(".depthcontent").fadeOut(200);
	  $("#sep_indepth").fadeIn(50);
	
	  $.scrollTo( '575px', 800 );
	  $("#contentPanelWrapper").height($baseheight + $("#sep_indepth").height()-140);
	  
	  
	  $('#arrow').animate({
		left:467
	  }, 150, function() {
		$("#arrow").fadeIn(50)
	  });
	});
	
		
	//Forde-Ferrier
	$('#fordeicon').click(function() {
	  $("#arrow").fadeIn(50);
	  $(".depthcontent").fadeOut(10);
	  $("#forde_indepth").fadeIn(200);
	
	  $.scrollTo( '575px', 800 );
	   $("#contentPanelWrapper").height($baseheight + $("#forde_indepth").height()-100);
	  
	  $('#arrow').animate({
		left:289
	  }, 150, function() {
		$("#arrow").fadeIn(50)
	  });
	});
	
});



function ShowPanel(panel){
	currentPanel=panel;
	SelectButton(panel);
	$(".content").fadeOut(250);
		switch(panel){
			case "none":
				$("#contentPanelWrapper").animate({"left":"100%"},500);
				$("#champion").fadeIn();
				$("#agency").fadeIn();
				
			break;
			case "welcome":
				$("#contentPanelWrapper").stop().animate({"left":"100%"},500,function(){
					
					$("#contentPanelWrapper").height($("#welcomeContent").height()+100);
					//alert($("#contentPanelWrapper").height());
					$("#welcomeContent").show();
					$("#champion").fadeOut();
					
					//Rollover and Active Class State
					 $("#whatwedo_arrow").fadeIn(50);	  
					  $('#whatwedo_arrow').animate({
						left:47
					  }, 150, function() {
						$("#whatwedo_arrow").fadeIn(50)
					  });
					 
					
						
						$("#arrowicon").each(function(){
							this.src = this.src.replace("_off","_on");
							$(this).removeClass('active');
						});
						$("#arrowicon").toggleClass('active');
					
					$("#contentPanelWrapper").animate({"left":"39%"},500);
					//$("#contentPanelWrapper").height()
					//window.followAlong = followAlong;
					$.scrollTo( '0px', 800 );
					
					
				});
				
			break;
			case "pubs":
				$("#contentPanelWrapper").stop().animate({"left":"100%"},500,function(){
					$("#contentPanelWrapper").height($("#pubsContent").height()+100);
					//alert($("#contentPanelWrapper").height());
					
					$("#pubsContent").show();
					$("#champion").fadeOut();
					
					$("#contentPanelWrapper").animate({"left":"39%"},500);
					//$("#contentPanelWrapper").height()
					$.scrollTo( '0px', 800 );
					
				});
				
			break;
			case "thematic":
				$("#contentPanelWrapper").stop().animate({"left":"100%"},500,function(){
					$("#contentPanelWrapper").height($("#thematicContent").height()-10);
					//alert($("#contentPanelWrapper").height());														   
					$("#thematicContent").show();
					$("#champion").fadeOut();
					
					$("#contentPanelWrapper").animate({"left":"39%"},500);
					//window.followAlong = followAlong;
					$.scrollTo( '0px', 800 );
				});
				
			break;
			case "team":
				$("#contentPanelWrapper").stop().animate({"left":"100%"},500,function(){
					$("#contentPanelWrapper").height($("#teamContent").height()+100);
					//alert($("#contentPanelWrapper").height());	
					$("#teamContent").show();
					$("#champion").fadeOut();
					
					$("#contentPanelWrapper").animate({"left":"39%"},500);
					//window.followAlong = followAlong;
					$.scrollTo( '0px', 800 );
				});
				
			break;
			case "careers":
				$("#contentPanelWrapper").stop().animate({"left":"100%"},500,function(){
					$("#contentPanelWrapper").height($("#careersContent").height()+100);
					//alert($("#contentPanelWrapper").height());	
					$("#careersContent").show();
					$("#champion").fadeOut();
					
					$("#contentPanelWrapper").animate({"left":"39%"},500);
					//window.followAlong = followAlong;
					$.scrollTo( '0px', 800 );
				});
				
			break;
			case "seminars":
				$("#contentPanelWrapper").stop().animate({"left":"100%"},500,function(){
					$("#contentPanelWrapper").height($("#seminarsContent").height()+100);
					//alert($("#contentPanelWrapper").height());	
					$("#seminarsContent").show();
					$("#champion").fadeOut();
					
					$("#contentPanelWrapper").animate({"left":"39%"},500);
					//window.followAlong = followAlong;
					$.scrollTo( '0px', 800 );
				});
				
			break;
			
		};
};

function SelectButton(button){
	if (currentPanel!="welcome"){
		//$("#welcomeCaption").animate({"left":50},{queue:false, duration:250});
		//$("#welcomeCaption").animate({"opacity":0},{queue:false, duration:250});
		$("#welcomeButton").css({"background-position":"0px -8px"});
	};
	if (currentPanel!="pubs"){
		//$("#pubsCaption").animate({"left":50},{queue:false, duration:250});
		//$("#pubsCaption").animate({"opacity":0},{queue:false, duration:250});
		$("#pubsButton").css({"background-position":"0px -42px"});
	};
	if (currentPanel!="thematic"){
		//$("#thematicCaption").animate({"left":50},{queue:false, duration:250});
		//$("#thematicCaption").animate({"opacity":0},{queue:false, duration:250});
		$("#thematicButton").css({"background-position":"0px -76px"});
	};
	if (currentPanel!="team"){
		//$("#teamCaption").animate({"left":50},{queue:false, duration:250});
		//$("#teamCaption").animate({"opacity":0},{queue:false, duration:250});
		$("#teamButton").css({"background-position":"0px -110px"});
	};
		
	switch(button){
		case "none":
		break;
		case "welcome":
			//$("#welcomeCaption").animate({"left":70},{queue:false, duration:250});
			//$("#welcomeCaption").animate({"opacity":1},{queue:false, duration:250});
			$("#welcomeButton").css({"background-position":"368px -8px"});
		break;
		case "pubs":
			//$("#pubsCaption").animate({"left":70},{queue:false, duration:250});
			//$("#pubsCaption").animate({"opacity":1},{queue:false, duration:250});
			$("#pubsButton").css({"background-position":"368px -42px"});
		break;
		case "thematic":
			//$("#thematicCaption").animate({"left":70},{queue:false, duration:250});
			//$("#thematicCaption").animate({"opacity":1},{queue:false, duration:250});
			$("#thematicButton").css({"background-position":"368px -76px"});
		break;
		case "team":
			//$("#teamCaption").animate({"left":70},{queue:false, duration:250});
			//$("#teamCaption").animate({"opacity":1},{queue:false, duration:250});
			$("#teamButton").css({"background-position":"368px -110px"});
		break;
		
	};

};
