function MM_openBrWindow(theURL,winName,features){  
 	window.open(theURL,winName,features);
}

function scrollto(anc){  
     target = $(anc);  
     $('html, body').animate({  
         scrollTop: target.offset().top  
     }, 1000);  
};

(function(){var special=$.event.special,uid1='D'+(+new Date()),uid2='D'+(+new Date()+1);special.scrollstart={setup:function(){var timer,handler=function(evt){var _self=this,_args=arguments;if(timer){clearTimeout(timer)}else{evt.type='scrollstart';$.event.handle.apply(_self,_args)}timer=setTimeout(function(){timer=null},special.scrollstop.latency)};$(this).bind('scroll',handler).data(uid1, handler)},teardown:function(){$(this).unbind('scroll',$(this).data(uid1))}};special.scrollstop={latency:300,setup:function(){var timer,handler=function(evt){var _self=this,_args=arguments;if(timer){clearTimeout(timer)}timer=setTimeout(function(){timer=null;evt.type='scrollstop';$.event.handle.apply(_self, _args)},special.scrollstop.latency)};$(this).bind('scroll',handler).data(uid2,handler)},teardown:function(){$(this).unbind('scroll',jQuery(this).data(uid2))}}})()
$(function(){
   $('div.top>a').click(function(e){$('html,body').animate({scrollTop:'0px'},800);return false})
   $(window).scroll(function(){if($(this).scrollTop()>100){$('div.top').fadeIn()}else{$('div.top').fadeOut()}})
   init_events();
});


function init_events(){
	$('a.scrolltop').click(function(e){$('html,body').animate({scrollTop:'0px'},800);return false});
}

function AlertConfirm(url,msg) {
	doConfirm = confirm(msg);
	if (doConfirm == true) { 
		window.location = url;  
	} else {
		return;
	}
}

jQuery("document").ready(function($){
	var nav = $('header');
	width = $(window).width();
	$(window).scroll(function () {
		if(width > 720){
			if ($(this).scrollTop() > 106) {
			nav.addClass("smaller");
			} else {
			nav.removeClass("smaller");
			}
		}
	});
	
	$(window).scroll(function () {
		if ($(this).scrollTop() > 106) {
			$('#cart_mini').addClass("smaller");
		} else {
			$('#cart_mini').removeClass("smaller");
		}
	});
	
	
	$("#provincia").prop('disabled', true);
	if($("#stato").val() == 'IT'){ $("#provincia").prop('disabled', false); }
	$('#stato').on('change',function(){
	    if( $(this).val()==="IT"){ 
			$("#provincia").prop('disabled', false); 
		}else{
	        $("#provincia").prop('disabled', true);
	        }
	});
	
	
	//$(document).bind("contextmenu",function(e){
	//return false;
	
	//Volendo potete specificare anche un alert informativo:
	//es. alert("Non puoi usare il tasto destro su questo sito ci dispiace!");
	//});
	
});