jQuery(function() {

	$('a[rel="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	});	
		
	var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
	$(document).keydown(function(e) {
	  kkeys.push( e.keyCode );
	  if ( kkeys.toString().indexOf( konami ) >= 0 ){
		$(document).unbind('keydown',arguments.callee);
		alert('Konami Code Detected!');
		window.location = "/konami/";
	  }
	});
	
	//slides the element with class "theStory" when li with class "newsHome" is clicked
	$("li.newsHome span a.newsLinks").click(function()
	{
	var $this = $(this).parent();
		if($this.children('div').is('.articleShown')) {
			$this.children('div').slideUp("slow");
			$this.children('div').removeClass('articleShown');
			$this.children('div').addClass('articleHidden');
		}
		else {
			$this.children('div').slideDown("slow");
			$('div.articleShown').slideUp("slow");
			$this.children('div').removeClass('articleHidden');
			$this.children('div').addClass('articleShown');
		}
		return false;

		
		/*$(this).children('div').addClass('show');
		$(this).children('div').removeClass('hide');
		$('.hide').hide('slow');
		$(this).children('div').slideToggle(300);*/
	});	
	
	//slides the element with class "leadershipLinkContents" when li with class "leadershipLink" is clicked
	$("li.leadershipLink span").click(function()
	{
		$("div#leadershipLinkContents").slideToggle(300);
	});	

  // The magic sliding panels
	jQuery('.entry-content a span.slide-title').css({
		opacity : '0.0'
	}).parent('a').append('<span class="cover-up"></span>');
	jQuery('.entry-content a').mouseover(function(e){
      jQuery(this).find('img.thumbnail').stop().animate({
	  	marginTop : '-25px'
	  }, 100).parent('a').find('span.slide-title').stop().fadeTo("slow",1.0);
	});
	jQuery('.entry-content a').mouseout(function(e){
      jQuery(this).find('img.thumbnail').stop().animate({
	  	marginTop : '0'
	  }, 100).parent('a').find('span.slide-title').stop().fadeTo("slow",0.0);
	});
	
		$("a[rel='detail']").colorbox({width:"800px", height:"600px", iframe:true});
		$("a[rel='crc']").colorbox({width:"950px", height:"600px", iframe:true});
		$("a[rel='facebook']").colorbox({width:"328px", height:"645px", iframe:true});
		$("a[rel='detailweb']").colorbox({width:"400px", height:"550px", iframe:true});
		$("a[rel='300banner']").colorbox({width:"330px", height:"330px", iframe:true});
		$("a[rel='detailweb2']").colorbox({width:"680px", height:"550px", iframe:true});
		$("a[rel='detailweb3']").colorbox({width:"500px", height:"550px", iframe:true});
		$("a[rel='detailweb4']").colorbox({width:"645px", height:"550px", iframe:true});
		$("a[rel='directmail']").colorbox({width:"900px", height:"600px", iframe:true});
		$("a[rel='detailRadio']").colorbox({width:"350px", height:"200px", iframe:true});
		$("a[rel='detailOutdoor']").colorbox({width:"950px", height:"400px", iframe:true});
		$("a[rel='brightview']").colorbox({width:"800px", height:"550px", iframe:true});
		$("a[rel='ameritox']").colorbox({width:"864px", height:"480px", iframe:true});
		$("a[rel='imageOnly']").colorbox({transition:"elastic"});
				
		$(".frame1 a.next").click(function()
		{
			$("div#frame1").fadeOut("fast");
			$("div#frame2").fadeIn("slow");
		});
		$(".frame2 a.prev").click(function()
		{
			$("div#frame2").fadeOut("fast");
			$("div#frame1").fadeIn("slow");
		});
		$(".frame2 a.next").click(function()
		{
			$("div#frame2").fadeOut("fast");
			$("div#frame3").fadeIn("slow");
		});
		$(".frame3 a.prev").click(function()
		{
			$("div#frame3").fadeOut("fast");
			$("div#frame2").fadeIn("slow");
		});
		$(".frame3 a.next").click(function()
		{
			$("div#frame4").fadeIn("slow");
			$("div#frame3").fadeOut("fast");
		});
		$(".frame4 a.prev").click(function()
		{
			$("div#frame4").fadeOut("fast");
			$("div#frame3").fadeIn("slow");
		});
		
		$("li.clients").click(function()
		{
			$("ul.clientsSubNav").slideToggle("fast");
			$("ul.clientsSubNav").removeClass("inactive");
			$("ul.clientsSubNav").addClass("active");
			$("ul.industrySubNav").removeClass("active");
			$("ul.industrySubNav").addClass("inactive");
			$("ul.industrySubNav:visible").slideToggle("fast");
		});
		
		$("li.industry").click(function()
		{
			$("ul.industrySubNav").slideToggle("fast");
			$("ul.industrySubNav").removeClass("inactive");
			$("ul.industrySubNav").addClass("active");
			$("ul.clientsSubNav").removeClass("active");
			$("ul.clientsSubNav").addClass("inactive");
			$("ul.clientsSubNav:visible").slideToggle("fast");
		});
	

/*		$('.clientLogos img').hover(function() {
			var onImage = this.src.replace("-logo.png","-logo-over.png");
			$(this).attr("src",onImage);
			
				}, function() {
			var offImage = this.src.replace("-logo-over.png","-logo.png");
			$(this).attr("src",offImage);
		});*/
		
/*		$('.clientLogos img.off').hover(function() {
			$(this).fadeTo(250, 1);
			$(this).next('img').fadeIn("slow");
				}, function() {
			$(this).fadeIn("slow");
			$(this).next('img').fadeTo(250, 1);
		});*/
		
});