$(document).ready(function() {	
	$('ul.product_list').hide();
	$('span.full_news, a.news_backtoggler').hide();
	$('div.newsticker:last').css('margin-bottom','12px');
	
	/*$('a.toggler').toggle(
			function() {
					$(this).parent().find('ul.product_list').animate({ height: 'show', opacity: 'show' }, 'slow');
					$(this).addClass('active');
					},
			function(){		
					$(this).parent().find("ul").animate({ height: 'hide', opacity: 'hide' }, 'slow');
					$(this).removeClass('active');
	});*/
	
	var mySubCategory = $.getURLParam("id_sotto_categoria");
	$('#'+mySubCategory).parent().show();
	$('#'+mySubCategory).parent().parent().find('a.toggler').addClass('active');
	$('#'+mySubCategory).find('a').addClass('current');
	
	$('a.toggler').click(
		function() {
		var checkElement = $(this).parent().find('ul.product_list');
            if(checkElement.is(':visible')) {
			checkElement.animate({ height: 'hide', opacity: 'hide' }, 'slow');
			$(this).removeClass('active');
            return false;
            }
			if(!checkElement.is(':visible')) {
			$('ul.product_list').animate({ height: 'hide', opacity: 'hide' }, 'slow');
			checkElement.animate({ height: 'show', opacity: 'show' }, 'slow');
			$('a.toggler').removeClass('active');
			$(this).addClass('active');
			return false;
			}
		}
	);
	
		
/*	var thumbOpacity = '0.7';
	
	$('div.product_family').css({opacity:thumbOpacity});	
	
	$('a.void').hoverIntent(function() {
		$(this).parent().animate({ opacity: 1 }, "normal");
	},
	function() {
		$(this).parent().animate({ opacity: thumbOpacity }, "fast");
	});*/

	
	
	$(function() {
			$("a.blank").attr("target","_blank");
	});
	
	$('a.news_toggler').click(
			function() {
					$(this).parent().find('span.full_news').animate({ height: 'show', opacity: 'show' }, 'normal');
					$(this).hide();
					$(this).parent().find('a.news_backtoggler').show();
					return false;
					});
	
	$('a.news_backtoggler').click(
			function() {
					$(this).parent().animate({ height: 'hide', opacity: 'hide' }, 'slow');
					$(this).hide();
					$(this).parent().parent().find('a.news_toggler').show();
					return false;
					});
	
	/*$('p.item_description').hover(
			  function() {
				  $(this).addClass('item_rollover');
			  },
			  function(){
				  $(this).removeClass('item_rollover');
			  });*/
	
	$('input.my_textinput, textarea.my_textarea, select.my_select').focus(
			function() {
					$(this).css('border','1px solid #004b91');
					});
	$('input.my_textinput, textarea.my_textarea, select.my_select').blur(
			function() {
					$(this).css('border','1px solid #CCCCCC');
					});
	
});

function preLoadImages(fileNames){
	for (var x = 0; x < fileNames.length; x++) {
		document.getElementById("ImageContainer").innerHTML += "<img src=\""+fileNames[x]+"\" />";
	}
}
