// remap jQuery to $
(function($){
})(window.jQuery);


$(document).ready(function(){
		// unhide any elements that are marked hidden until load
		$('.hidden-until-load').removeClass('hidden-until-load');
		// Set the search box to empty upon click
		$('.search-box').bind('click', function(){
			var field =  $(this);							   
			if (field.val()=="Search") field.val("");
		});
	
		// Click handler for each category
		$('.category > a').bind('click',function(event){
			var categoryname = $(this).parent().attr('id');
			$('.category ul').hide('fast').addClass('hiddencategory'); // hide all ceategories
			$('#' + categoryname + ' > ul').show('slow').removeClass('hiddencategory'); // Show the clicked category by finding sibling ul (~) to the selected category and remove the class
			$('.currentcategory').removeClass('currentcategory');
			$('#' + categoryname + ' > a').show('slow').addClass('currentcategory');
			return false;
	
		});

		// Blog drop down menus
		$('.blog-menu ul li').hover(	  	
			function()
			{
				$(this).addClass('visible');
	  		},
			function()
			{ 
	  			$(this).removeClass('visible');
	   		}
	  	);
	  	
	
	$(".case-studies div.scrollable").scrollable({
		size: 3}			   
	); 
	
	/* Services Section */
	/*-----------------*/
	// Bind the call to action button to lets talk
	$('#copy').delegate('a.cta','mouseenter',function(){	
		_gaq.push(['_trackEvent', 'letstalk_mouse', window.location.pathname]);
		$('#letstalk_popup').hide();
		$('#letstalk_popup').fadeIn();	
		return false;
	});
	// Bind mouse leave on the cta button
	$('#letstalk_popup').bind('mouseleave',function(){
		$('#letstalk_popup').fadeOut("slow");
	}); 	
	
	// Thmbnail gallery - select the thumbnails and make them trigger our overlay
	EnableGallery = function(){
	if ($("#thumbs a").length > 0){
		$("#thumbs a").overlay({
			target: '#gallery',
			expose: '#f1f1f1',
			top: '5%',
			onBeforeLoad: function() {
			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".contentWrap");
			// load the page specified in the trigger
			wrap.html("<img src='" + this.getTrigger().attr("href") + "' />");
			$('.info').html(this.getTrigger().attr("title"));
		}});
	};

	// Article image gallery
	$("ul.gallery-thumbs").tabs(".gallery > div");
	/*$(".gallery-thumbs > li a").tabs(".gallery .gallery-item", {

		// enable "cross-fading" effect
		effect: 'fade',
		fadeOutSpeed: "slow"

		// start from the beginning after the last tab
		

	// use the slideshow plugin. It accepts its own configuration
	});*/
};
EnableGallery(); 
  	
     /* Contact Form UX enhancements */
	/*------------------------------*/
	// Set focus on the first name field
    $("#Name").focus().addClass('focus').siblings('label').addClass('focus');

    // Highlight active input
    $('form input, form select, form textarea, form input').bind("focus", function () {
        var field = $(this);
        field.addClass('focus').siblings('label').addClass('focus');
    }).bind("blur", function () {
       $('.focus').removeClass('focus');
    });
   
    // Display the Other box if the user selects other for their referral source
    $("#Found").bind("click", function () {
        var field = $(this);
        if (field.val() == "Other") {
            $('#FoundNote').removeClass('hidden').show('fast').addClass('visible').addClass('focus').siblings('label').addClass('focus');
            $('#FoundNote').focus().addClass('focus');
        } else {
            $('#FoundNote').hide('fast').removeClass('visible');
        }
    });
});
// -->
