// JavaScript Document

  	jQuery(document).ready(function($) {
		var closed = true;
	
		$("#show-more-link").click(function() {
			if(closed) {
				$("#show-more").slideDown('slow', function() {
					closed = false;
					$("#show-more-link").text('Click to show less links!');
				});
			} else {
				$("#show-more").slideUp('slow', function() {
					closed = true;
					$("#show-more-link").text('Click to show more links!');
				});
			}
		});
		
		$("#case1tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case1tog").addClass("caseStudySelected");
			$("#case1").show("slow");
			/*$("#case1").animate(
                { right: 1000 }, {
                   duration: 'slow',
                   easing: 'easeOutBounce'
                });*/
			/*$("#case1").animate({"left": "10000px"}, "slow");*/
			/*$("#case1").animate({ width: 'show' }); */ 
		});
		
		$("#case2tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case2tog").addClass("caseStudySelected");
			$("#case2").show("slow");
			/*var $marginLefty = $("case2").next();
			$marginLefty.animate({
			  marginLeft: parseInt($marginLefty.css('marginLeft'),10) == 0 ? 
				$marginLefty.outerWidth() :
				0
			});*/
		});
		
		$("#case3tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case3").show("slow");
			$("#case3tog").addClass("caseStudySelected");
		});
		
		$("#case4tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case4").show("slow");
			$("#case4tog").addClass("caseStudySelected");
		});
		
		$("#case5tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case5").show("slow");
			$("#case5tog").addClass("caseStudySelected");
		});
		
		$("#case6tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case6").show("slow");
			$("#case6tog").addClass("caseStudySelected");
		});
		
		$("#case7tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case7").show("slow");
			$("#case7tog").addClass("caseStudySelected");
		});
		
		$("#case8tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case8").show("slow");
			$("#case8tog").addClass("caseStudySelected");
		});
		
		$("#case9tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case9").show("slow");
			$("#case9tog").addClass("caseStudySelected");
		});
		
		$("#case10tog").click(function(){
			$(".caseStudy").hide();
			$("#caseStudyNav a").removeClass("caseStudySelected");
			$("#case10").show("slow");
			$("#case10tog").addClass("caseStudySelected");
		});
		
		
		// Inline Modal Window tut - START - http://www.sohtanaka.com/web-design/inline-modal-window-w-css-and-jquery/ 
		
		//When you click on a link with class of poplight and the href starts with a # 
		$('a.poplight[href^=#]').click(function() {
			$(this).popOpen();
			return false;
		});
		
		//Close Popups and Fade Layer
		
		$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
			$('#fade , .popup_block').fadeOut(function() {
				$('#fade, a.close').remove();  //fade them both out
			});
			return false;
		});
		
		$.fn.popOpen = function(){
			var popID = $(this).attr('rel'); //Get Popup Name
			var popURL = $(this).attr('href'); //Get Popup href to define size
		
			//Pull Query & Variables from href URL
			var query= popURL.split('?');
			var dim= query[1].split('&');
			var popWidth = dim[0].split('=')[1]; //Gets the first query string value
		
			//Fade in the Popup and add close button
			$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="../../../images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');
		
			//Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
			var popMargTop = ($('#' + popID).height() + 80) / 2 - 20;
			var popMargLeft = ($('#' + popID).width() + 80) / 2;
		
			//Apply Margin to Popup
			$('#' + popID).css({
				'margin-top' : -popMargTop,
				'margin-left' : -popMargLeft
			});
		
			//Fade in Background
			$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
			$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 
		};

		// Inline Modal Window tut - END	
		
		
		$('#sliders a')
			.css( {backgroundPosition: "0 0"} )
			.mouseover(function(){
				$(this).stop().animate(
					{backgroundPosition:"(3 0)"}, 
					{duration:500,easing:'easeOutBounce'})
				})
			.mouseout(function(){
				$(this).stop().animate(
					{backgroundPosition:"(0 0)"}, 
					{duration:500})
				});
		
		
		$('.icon img').mouseover(function(){ 
			  //moving the div left a bit is completely optional 
			  //but should have the effect of growing the image from the middle. 
			  $(this).stop().animate({"width": "83%","left":"0px","top":"0px"},100,'swing'); 
			}).mouseout(function(){  
			  $(this).stop().animate({"width": "80%","left":"0px","top":"0px"},200,'swing'); 
		}); 	


		
	});



$(function() {
	$('#gallery a').lightBox();
});



function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

	
