/*$(window).load(function(){*/ //FUNZIONA MA CARICAMENTO NON PERFETTO
/*$(document).ready(function(){*/ //FUNZIONA ma fa scattino su onresize
/*$(document).load(function(){*/ //NON FUNZIONA
/*$(window).ready(function(){*/ //FUNZIONA con leggero scatto
$(document).ready(function(){		
		/* LAYOUT */		
		//$("#preloader").show();
		
		var wPage = document.documentElement.clientWidth;
		var hPage = document.documentElement.clientHeight;
		var wContainer = document.documentElement.clientWidth - 960;
		var wOverlay = document.documentElement.clientWidth - 200;
		var hOverlay = document.documentElement.clientHeight - 200;
		var hIndexContent = document.documentElement.clientHeight - 450;
		
		if (wPage < 1024) {
				$("#page_container").css("margin-left", "0");
				$("#footer").css("margin-left", "0");
			} else {
				$("#page_container").css("margin-left", wContainer*0.3);
				$("#footer").css("margin-left", wContainer*0.3);
			}
		
		//$("#preloader").fadeOut(300);
		
		$("#page_container").css("min-height", hPage);
		$("#page_container").css("height", hPage);
		$("#index_container").css("min-height", hPage);
		$("#index_container").css("height", hPage);
		//$("#page_container").css("min-width", 960);
		$(".header_extra_left").css("width", wContainer*0.3);
		$(".apple_overlay").css("width", wOverlay);
		$("div.contentWrap").css("height", hOverlay);
		$(".apple_overlay").css("height", hOverlay);
		$(".index_content").css("top", hIndexContent*0.5);
		$(".css-panes").css("min-height", 0);
		
		
		window.onresize = function () {
			var wPage = document.documentElement.clientWidth;
			var hPage = document.documentElement.clientHeight;
			var wContainer = document.documentElement.clientWidth - 960;
			var wOverlay = document.documentElement.clientWidth - 200;
			var hOverlay = document.documentElement.clientHeight - 200;
			var hIndexContent = document.documentElement.clientHeight - 450;
			
			if (wPage < 1024) {
					$("#page_container").css("margin-left", "0");
					$("#footer").css("margin-left", "0");
				} else {
					$("#page_container").css("margin-left", wContainer*0.3);
					$("#footer").css("margin-left", wContainer*0.3);
				}
				
			$("#page_container").css("min-height", hPage);
			$("#page_container").css("height", hPage);
			$("#index_container").css("min-height", hPage);
			$("#index_container").css("height", hPage);
			//$("#page_container").css("min-width", 960);
			$(".header_extra_left").css("width", wContainer*0.3);
			$(".apple_overlay").css("width", wOverlay);
			$("div.contentWrap").css("height", hOverlay);
			$(".apple_overlay").css("height", hOverlay);
			$(".index_content").css("top", hIndexContent*0.5);
			
			$(".css-panes").css("min-height", 0);	
			}


			/* MENU */
			
			 //Remove outline from links
			$("a").click(function(){
				$(this).blur();
			});
			// ROLLOVER SLIDE
			
			$(function(){
			$('#navlist a')
				.css( {'background-position': "right -38px"} )
				.mouseover(function(){
					$(this).stop().animate({'background-position':"(right 0)"}, {duration:200, complete:function(){
					//$(this).stop().animate({backgroundPosition:"(right 0)"}, {duration:200, complete:function(){
					//$(this).stop().animate({'background-position':"(right 0)"}, {duration:200, complete:function(){
					$(this).css("color", '#fbcf45')}
					})
				})
				.mouseout(function(){
					$(this).stop().animate({'background-position':"(right -38px)"}, {duration:200, complete:function(){
					$(this).css("color", '#17244b')}
					})
			})
			});
			
			/* ROLLOVER SLIDE SUBMENU */
			
			$(function(){
			$('.submenu li a')
				.css( {'background-position': "-10px 6px"} )
				.mouseover(function(){
					$(this).stop().animate({'background-position':"(10px 6px)"}, {duration:200})
				})
				.mouseout(function(){
					$(this).stop().animate({'background-position':"(-10px 6px)"}, {duration:200})
				})
			});
	
			
			/* TABS NAVIGATION */
			
			$(function() {
			$("ol.css-tabs").tabs("div.css-panes > div", {effect: 'ajax', history: true});
			<!--document.title = div.document.title;-->
				$("ol.css-tabs li a").click(function(){
					//$("ol.css-tabs li a.current").removeClass(".current");
					//$("ol.css-tabs li a").stop().animate({'background-position':"(-10px 4px)"}, {duration:400})
					$(this, "a").addClass("a.current");
				});
			});
			
			
			/* OVERLAY INFORMAZIONI LEGALI */
			
			$(function() {
			$("a[rel]").overlay({
				mask: '#272727',
				effect: 'apple',
				onBeforeLoad: function() {
					// grab wrapper element inside content
					var wrap = this.getOverlay().find(".contentWrap");
					// load the page specified in the trigger
					wrap.load(this.getTrigger().attr("href"));
				}
				});
			});
			
			/* CREDITS */
			
			$(function(){
				$('.credits').mouseover(function(){
					//$(".credits p").toggle(100);
					$(".credits_btn").hide();
					$(".xsign").show();
					});
				$('.credits').mouseout(function(){
					$(".xsign").hide();
					$(".credits_btn").show();
					});
			});
			
			/* SITEMAP LOADING */
			
       		$(".sitemap_toggle").load("/it/sitemap.html");
						
			/* SITEMAP TOGGLE */
			
			$('#sitemap_btn').click(function() {
				$(".sitemap_toggle").css("margin-top", "-373px");
				$(".sitemap_toggle").slideToggle(400);		
			});
			
			/* SITEMAP LOADING */
			
       		$(".sitemap_toggle_en").load("/en/sitemap.html");
						
			/* SITEMAP TOGGLE */
			
			$('#sitemap_btn_en').click(function() {
				$(".sitemap_toggle_en").css("margin-top", "-373px");
				$(".sitemap_toggle_en").slideToggle(400);		
			});
			
});
