$(document).ready(function(){
	
	$(function() {
		$("a[rel='_blank']").attr("target","_blank");				
	});
	
	jQuery.fn.fadeToggle = function(speed, easing, callback) {
   		return this.animate({opacity: 'toggle'}, speed, easing, callback);
	}; 
		
	$.urlParam = function(name){
		var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
		if(results) {
			return results[1] || 0;
		}
	};
	
	// INIZIO FUNZIONE MENU BOXES
	$(function() {
		function addBox(){
  			$(this).find('.menu-box').fadeIn();
			$(this).find('a:first').addClass('_hover');
		}
		function removeBox(){
  			$(this).find('.menu-box').fadeOut();
			$(this).find('a:first').removeClass('_hover');
		}
		var menuBox = {    
     		interval: 100,
     		sensitivity: 2,
			over: addBox,
			timeout: 100,
     		out: removeBox
     	};
		$('li.toggler').hoverIntent(menuBox);
		$('a#get-profilo, a#get-puntivendita, a#get-prodotti, a#get-inprimopiano, a#get-contatti').click(function(){
			return false
		});
	});
	// FINE FUNZIONE FUNZIONE MENU BOXES
	
	// INIZIO FUNZIONE CONTENT SUBMENU CLICK
	$(function() {
		$('.content-menu ul li a').click(function(){
			$('.content-menu ul li a').removeClass('current');
			$(this).addClass('current');
		});
	});
	// FINE FUNZIONE CONTENT SUBMENU CLICK
    
    function changeChk(obj){
    	if ($(obj).attr("checked")){
    		$(obj).parent().removeClass("unchecked");
    		$(obj).parent().addClass("checked");
    	}else{
    		$(obj).parent().removeClass("checked");
    		$(obj).parent().addClass("unchecked");					
    	}	
    }
});

/* nuova versione: si adatta alle dimensioni delle thumbs */
function slider(){
    $("ul.thumb li").each(function(){
        var w = 0;
        var h = 0;
        //var w = $(this).find('img').width();
        //var h = $(this).find('img').height();
        if (!w) w = 120;
        if (!h) h = 90;
        $(this).hover(function() {
            var nw = w+50;
            var nh = h+50;
            $(this).css({'z-index' : '9999'}); 
            $(this).find("a, img").css({'z-index' : '9999'});
            $(this).find('img').stop()           /* Add class of "hover", then stop animation queue buildup*/
        		.animate({
        			marginTop: '-30px',                           /* The next 4 lines will vertically align this image */ 
        			marginLeft: '-25px',
        			top: '50%',
        			left: '50%',
        			width: nw+'px',                                /* Set new width */
        			height: nh+'px',                               /* Set new height */
        			padding: '10px'
        		}, 200);                                           /* this value of "200" is the speed of how fast/slow this hover animates */
        } , function() {
            $(this).css({'z-index' : '0'});
        	$(this).find('img').stop()        /* Remove the "hover" class , then stop animation queue buildup*/
        		.animate({
        			marginTop: '0',                                /* Set alignment back to default */
        			marginLeft: '0',
        			top: '0',
        			left: '0',
        			width: w+'px',                                /* Set width back to default */
        			height: h+'px',                               /* Set height back to default */
        			padding: '5px'
        		}, 400);
             
        });
    });
}

