;(function($) {
  $(function() {
	if($.jcalendar) $('fieldset.jcalendar').jcalendar();

/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
/*
if($("#nav")) {
		$("#nav dd").hide();
		$("#nav dt b").click(function() {
			if(this.className.indexOf("clicked") != -1) {
				$(this).parent().next().slideUp(200);
				$(this).removeClass("clicked");
			}
			else {
				$("#nav dt b").removeClass();
				$(this).addClass("clicked");
				$("#nav dd:visible").slideUp(200);
				$(this).parent().next().slideDown(500);
			}
			return false;
		});
	}
*/

	//Get all the LI from the #tabMenu UL
	$('#tabMenu > li')
		.click(function(){
			//remove the selected class from all LI    
			$('#tabMenu > li').removeClass('selected');
			//Reassign the LI
			$(this).addClass('selected');
			//Hide all the DIV in .boxBody
			$('.boxBody div').slideUp('1500');
			//Look for the right DIV in boxBody according to the Navigation UL index, therefore, the arrangement is very important.
			$('.boxBody div:eq(' + $('#tabMenu > li').index(this) + ')').slideDown('1500');
		})
		.mouseover(function() {
			//Add and remove class, Personally I dont think this is the right way to do it, anyone please suggest    
			$(this).addClass('mouseover');
			$(this).removeClass('mouseout');   
		})
		.mouseout(function() {
			//Add and remove class
			$(this).addClass('mouseout');
			$(this).removeClass('mouseover');    
		});

	//Mouseover with animate Effect for Category menu list
	$('.boxBody li')
		.mouseover(function() {
			//Change background color and animate the padding
			$(this).css('backgroundColor','#f5f5f5');
			$(this).children().animate({paddingLeft:"20px"}, {queue:false, duration:300});
		})
		.mouseout(function() {
			//Change background color and animate the padding
			$(this).css('backgroundColor','');
			$(this).children().animate({paddingLeft:"0"}, {queue:false, duration:300});
		})
		.click(function(){
			window.location = $(this).find("a").attr("href");
		});  	
	
	//menu della home
/*	$('#maincontent > ul > li > ul > li')
		.mouseover(function(){$(this).find('div').show();})
		.mouseout(function(){$(this).find('div').hide();});
*/

	$('.homemenu li').hover(function(){
		var $this = $(this),
			$menu = $this.find('div');
		$menu.fadeIn('slow');
	}, function(){
		var $this = $(this);
		$this.find('div').hide();
	});
	
	//print
	$('#printlink').bind('click', function(){
		//alert(this.href);
		var w = window.open(this.href, 'printwnd', 'toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes,width=800,height=600');
		if(w)w.focus();
		return false;
	});
  });
 })(jQuery);

 