$(document).ready(function()
{
	
    // Animate hovers fortes
//	$("#fortes div.box a").hover(function()
//	{
//		$(this).parents('div.box').stop().fadeTo(0, 0.7);
//	}, function() {
//	    $(this).parents('div.box').stop().fadeTo(300, 1);
//	});

	// Animate links with this class
	$("a.fadeMeOut, h1.logo a").hover(function()
	{
		$(this).stop().fadeTo(0, 0.7);
    }, function() {
        $(this).stop().fadeTo(300, 1);
    });
    
			// Animate open function
			function openAnimation()
			{
				$("#searchBox").css({background:"#fff"}).animate({width:"270px"},300);
				$(".activateOpen").hide();
				$("div#searchBox").addClass("active");
			}
		
			// Give the effect when clicked on
			$(".activateOpen").click(function()
			{
				openAnimation();
				return false;
			});
			
			// Footer search button animation
			$('.searchButtonFooter').click(function()
			{
				$("#searchBox").animate({width:"84px"},200);
				$('html, body').animate({scrollTop:0},500,function()
				{
					openAnimation();
				});
				return false;
			});
			
			// Close button
			$(".close").click(function()
			{
				$("#searchBox").animate({width:"84px"},300, function()
				{
					$("#searchBox").css({background:"transparent"});
					$("div#searchBox").removeClass("active");
				});
				$(".activateOpen").show();
				return false;
			});
		
			// Clear the search field on-click
			defaultValue = jQuery('.searchField').val();	
			jQuery('.searchField').click(function() {
				if( this.value == defaultValue ) { 
					jQuery(this).val("");
				} 
			});
			
			// Make search button work
			$("a.searchButton").click(function() {
				$("form#searchfield").submit();
				return false;
			});
	

	// Menu large hover stuff
 	function addDropBox(){
        $(this).addClass("hovering");
        $(this).children("a").addClass("hover");
        }

      function removeDropBox(){
        $(this).removeClass("hovering");
        $(this).children("a").removeClass("hover");
        }

    var dropConfig = {
         interval: 0,
         sensitivity: 5,
         over: addDropBox,
         timeout: 0,
         out: removeDropBox
    };
    $("li.dropbox").hoverIntent(dropConfig)

	// Add class to last menu child
	$("ul#menu li li:last-child").addClass("last");
	
	
	// Sliding boxes for IT Consultancy
	$(".slidebox a.drawer").click(function() {
	    $(this).parent().parent().parent().find('.opening').slideToggle(400);
		if($(this).parent().find('span.button').hasClass('.open')){ 
			$(this).parent().find('span.button').removeClass('open'); 
		} else { 
			$(this).parent().find('span.button').addClass('open');
		}
	    return false;
	});

});

// Update the number of items of a particular kind in the cart.
function setNumItems(id, n) {
    $.getJSON("http://www.treshna.com/gym/buy/checkout?event=set_num_items&id="+id+"&n="+n,
	      function(data, textStatus) {
		  return true;
	      });
}
