/* - - - - - - - - - - - - - - - - - - - - 
E R N E S T O M E D A
2009
http://www.ernestomeda.it/
website by websolute
http://www.websolute.it/
- - - - - - - - - - - - - - - - - - - - */


/* Browser Detect
- - - - - - - - - - - - - - - - - - - - */
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};



/* WIDGET
- - - - - - - - - - - - - - - - - - - - */
$.fn.widgetize = function(options) {
	var opt = jQuery.extend({
		classe: "widgetize"
	},options);

	return this.each(function() {
		var $this = $(this);
		var pre = '<div class="wig_a"></div><div class="wig_b"></div><div class="wig_c"></div>';
		var post = '<div class="wig_e"></div><div class="wig_f"></div><div class="wig_g"></div>';
		$this.removeClass($this.attr("class")).addClass(opt.classe + " clearfix").wrapInner('<div class="wig_d clearfix"></div>');
		$(pre).prependTo($(this));
		$(post).appendTo($(this));
	});
}


/* MENU
- - - - - - - - - - - - - - - - - - - - */
var wrap_height;
var lev_2_height;

function menu() {
	if (BrowserDetect.OS == "Mac" && BrowserDetect.browser == "Firefox") {
		$("#menu .wig_b, #menu .wig_f").css({"width":"141px"});
	}
	
	wrap_height = $("#menu .wrap").height();
	lev_2_height = $("#menu .lev_1").height();
	$("#openclose").click(function(){
		if ($(this).is(".open")) {
			$(this).removeClass("open").addClass("close");
			$("#menu .wrap").slideUp(300);
			$(".menu .wig_d").animate({"height": "38px"},300,function(){
				$(".menu .wig_e, .menu .wig_g").css({"bottom": "1px"}).css({"bottom": "0px"});
			});
		} else {
			$(this).removeClass("close").addClass("open");
			$("#menu .wrap").slideDown(300);
			if ($(".slide .wrap").css("left") == "0px") {
				lev_2_height = wrap_height - 11;
			}
			$(".menu .wig_d").animate({"height":lev_2_height + 49 + "px"},300,function(){
				$(".menu .wig_e, .menu .wig_g").css({"bottom": "1px"}).css({"bottom": "0px"});
			});
		}
	});
	$("#menu ul.lev_1 a").click(function(){
		if ($(this).next("ul").size()) {
			var lev_2 = $(this).next().html();
			var backClick = $(this).text();
			
			$("#menu ul.lev_2 li.backlink a").text(backClick).parent().nextAll().remove();
			$("#menu ul.lev_2").append(lev_2);
			
			// lavora con noi
			$("#menu ul a[href*='workwithus/lavora_con_noi.asp']").attr("href","cv/index_iframe.asp?ref=189b98514e3e0885f5ac2453a053bea1&cp=&css=_2&iframe").fancybox({
				'zoomOpacity': true,
				'overlayShow': true,
				'zoomSpeedIn': 500,
				'zoomSpeedOut': 500,
				'overlayOpacity': 0.7,
				'frameWidth':960,
				'frameHeight':500,
				'padding':0
			});

			lev_2_height = $("#menu ul.lev_2").height();
			$("#menu .wrap").animate({"left":"-140px", "height":lev_2_height + 15 + "px"},300,function(){
				
			});
			$(".menu .wig_d").animate({"height":lev_2_height + 40 + "px"},300,function(){
				$(".menu .wig_e, .menu .wig_g").css({"bottom": "1px"}).css({"bottom": "0px"});
			});
			return false;
		}
	});
	
	$(".backlink a").click(function(){
		$("#menu .wrap").animate({"left":"0px", "height": wrap_height + "px"},300);
		$(".menu .wig_d").animate({"height": wrap_height + 35 + "px"},300,function(){
			$(".menu .wig_e, .menu .wig_g").css({"bottom": "1px"}).css({"bottom": "0px"});
		});
		return false;														
	});
	
	
	// link esterno per ernestomedapress
	$("#menu li a[href*='ernestomedapress']").attr("target","_blank");
		
	$("#menu a.on").parents("ul").prev().click();
}


/* CARATTERISTICHE
- - - - - - - - - - - - - - - - - - - - */
$.fn.caratteristiche = function() {
	return this.each(function() {
		var $this = $(this);
		var opn = $this.find(".carat_open a");
		var carat = [];
		$this.find(".carat_int").children().each(function(){
			carat.push($(this).height());
		});
		$this.find(".carat_int").css({"height":"56px"});
		var maxHeight = Math.max(carat[0],carat[1],carat[2],carat[3]);
		$(this).find("em.chiudi").hide();
		$(this).find("em.apri").show();
		opn.css({"margin":"0px 0px 0px " + (580 - (opn.width() + 18))/2 + "px"});
		opn.click(function(){
			if ($(this).is(".open")) {
				$this.find(".carat_int").animate({"height":maxHeight + 60 + "px"},800,"easeInOutQuart");
				$(this).removeClass("open").addClass("close");
				$(this).find("em.chiudi").show();
				$(this).find("em.apri").hide();
			} else {
				$this.find(".carat_int").animate({"height":"56px"},800,"easeOutQuart");
				$(this).removeClass("close").addClass("open");
				$(this).find("em.chiudi").hide();
				$(this).find("em.apri").show();
			}
			$(this).css({"margin":"0px 0px 0px " + (580 - ($(this).width() + 18))/2 + "px"});
			return false;
		});
		
		// hover sui link
		var li = $this.find("li a");
		li.hover(function(){
			var corpoTop = $("#corpo").offset().top;
			var corpoLeft = $("#corpo").offset().left;
			var thisTop = $(this).offset().top;
			var thisLeft = $(this).offset().left;			
			$(this).next().css({"top": (thisTop - corpoTop) + 47 + "px","left":(thisLeft - corpoLeft) + "px"}).show();
		},function(){
			$(this).next().hide();
		}).click(function(){
			return false;
		});
	});
}

/* ACCESSORI*/

$.fn.accessori = function() {
		var $this = $(this);
		var opn = $this.find(".access_open a");
		var maxHeight = $this.find(".access_content").height();
		$(this).find("em.chiudi").hide();
		$(this).find("em.apri").show();
		opn.css({"margin":"0px 0px 0px " + (580 - (opn.width() + 18))/2 + "px"});
		$this.find(".access_int").hide();
		opn.click(function(){
			if ($(this).is(".open")) {
				
				
				//$this.find('.access_int').animate({"height":"1px"},600,"easeOutQuart"); // chiude gli altri
				$this.find('.access_int').slideUp(600,"easeOutQuart"); // chiude gli altri
				//$(this).parents(".access_open").prev().animate({"height":maxHeight + 60 + "px"},600,"easeOutQuart"); //apre il suo
				$(this).parents(".access_open").prev().slideDown(600,"easeOutQuart"); //apre il suo
				
				// cambia etichette e classi agli altri
				opn.find("em.chiudi").hide();
				opn.find("em.apri").show();
				$(opn).removeClass("close").addClass("open");
				
				$(this).removeClass("open").addClass("close");
				$(this).find("em.chiudi").show();
				$(this).find("em.apri").hide();
			} else {
				//$(this).parents(".access_open").prev().animate({"height":"1px"},600,"easeOutQuart");
				$(this).parents(".access_open").prev().slideUp(600,"easeOutQuart");
				$(this).removeClass("close").addClass("open");
				$(this).find("em.chiudi").hide();
				$(this).find("em.apri").show();
			}
			$(this).css({"margin":"0px 0px 0px " + (580 - ($(this).width() + 18))/2 + "px"});
			return false;
		});
}


/* SHOWREEL
- - - - - - - - - - - - - - - - - - - - */
$.fn.showreel = function() {
	return this.each(function() {
		var $this = $(this);
		var li = $this.find("li a");
		var interval;
		var i = 0;
		li.eq(0).addClass("on");
		li.mouseover(function(){
			var indx = li.index($(this));
			clearTimeout(interval);
			li.filter(".on").removeClass("on");
			$(this).addClass("on");
			$this.find(".label").stop().animate({"top": (11+ (indx * 20)) + "px"},800,"easeOutExpo");
			$this.find(".flower").stop().animate({"top": "-" + ((indx * 245)) + "px"},800,"easeOutExpo");
		});
		li.mouseout(function(){
			i = li.index($(this));
			looppa();
		});
		function looppa(){
			if (i > li.size() - 1) {
				i = 0;
			}
			li.eq(i++).mouseover();
			interval = setTimeout(looppa,3000);
		}
		looppa();
	});
}


/* CLEAR INPUT
- - - - - - - - - - - - - - - - - - - - */
$.fn.clearInput = function() {
	return this.each(function() {
		var $this = $(this);
		$this.focus(function(){
			if ($this.val() == $this.attr("title")) {
				$this.val("");
			}
		}).blur(function(){
			if ($this.val() == "") {
				$this.val($this.attr("title"));
			}
		});
	});
}


/* HOME VIDEO
- - - - - - - - - - - - - - - - - - - - */
function homeVideo() {
	winWidth = $(window).width();
	if (winWidth > 1024) {
		flashWidth = winWidth;
		flashHeight = parseInt((680 * flashWidth) / 1280);
	} else {
		flashWidth = 1024;
		flashHeight = parseInt((680 * flashWidth) / 1280);
	}
	
	
	$(".video_home").css({"width":flashWidth + "px", "height": flashHeight + "px"});
	marginCorpo = parseInt(flashHeight * 150 / 768);
	$("#corpo").css({"marginTop":"-" + marginCorpo + "px"});
	marginMenu = $("#corpo").offset().top - 42;
	$("#menu").css({"top":"-" + marginMenu + "px"});
}


/* WIDGET FORM
- - - - - - - - - - - - - - - - - - - - */
$.fn.widgetForm = function() {
	return this.each(function() {
		var $this = $(this);
		var url;
		$this.find("input:button").click(function(){
			var attr_1 = $this.find("input:text:eq(0)").val();
			var attr_2 = $this.find("input:text:eq(1)").size() ? $this.find("input:text:eq(1)").val() : $this.find("select").val();
			var suff;
			var lang = $this.find("input.button").attr("rel");
			if (lang != 1) {
				suff = "_e";
			} else {
				suff = "";
			}
			
			//alert(suff);
					
			switch ($this.attr("name")) {
				
				case "form_catalogo":
					url = "CatalogRequest/richiesta_catalogo" + suff + ".asp?nome_cognome=" + attr_1 + "&email="  + attr_2  ;
					break;
					
				case "form_store":
					url = "StoreLocator/cerca_rivenditore.asp?citta=" + attr_1 + "&cap="  + attr_2 ;
					break;
					
				case "form_cerca_cucina":
					url = "StoreLocator/cerca_rivenditore.asp?sType=1&citta=" + attr_1 + "&prodotto="  + attr_2 ;			
					break;
			}
					
			$this.append('<a href="' + url + '&iframe" class="fancyframe" style="display:none;">apri</a>');
			$this.find("a.fancyframe:last").fancybox({
				'zoomOpacity': true,
				'overlayShow': true,
				'zoomSpeedIn': 500,
				'zoomSpeedOut': 500,
				'overlayOpacity': 0.7,
				'padding': 0,
				'frameWidth':960,
				'frameHeight':$(window).height() - 80
			}).click();
			return false;
		});
	});
}


/* header img
- - - - - - - - - - - - - - - - - - - - */
altre = new Array();
function headerImg() {
	winWidth = $(window).width();
	$("#altre span").each(function(){
		altre.push($(this).text());
	});
	var headerHeight;
	
	if (winWidth > 1024 && winWidth <= 1280) {
		headerHeight = 650;
		$("#header").css({"height":"650px", "background": "url(" + altre[1] + ") no-repeat center top"});
	} else if (winWidth > 1280 && winWidth <= 1440){
		headerHeight = 735;
		$("#header").css({"height":"735px", "background": "url(" + altre[2] + ") no-repeat center top"});
	} else if (winWidth > 1440){
		headerHeight = 862;
		$("#header").css({"height":"862px", "background": "url(" + altre[3] + ") no-repeat center top"});
	} else {
		headerHeight = 514;
		$("#header").css({"height":"514px", "background": "url(" + altre[0] + ") no-repeat center top"});
	}
	$("#header img").hide();
	
	marginCorpo = parseInt(headerHeight * 150 / 768);
	$("#corpo").css({"marginTop":"-" + marginCorpo + "px"});
	marginMenu = $("#corpo").offset().top - 42;
	$("#menu").css({"top":"-" + marginMenu + "px"});
}



/* mappa
- - - - - - - - - - - - - - - - - - - - */
function mappa() {
	if ($("#footer_map").size()) {
		$(".footer_3").after('<div class="footer_3_2"><ul><li><ul></ul></li></ul></div>');
		$(".footer_3 ul li ul li:gt(5)").appendTo($(".footer_3_2 ul li ul"));
		// lavora con noi
		$("#footer_map a[href*='co_id=509']").attr("href","cv/index_iframe.asp?ref=189b98514e3e0885f5ac2453a053bea1&cp=&css=_2&iframe").fancybox({
			'zoomOpacity': true,
			'overlayShow': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'overlayOpacity': 0.7,
			'frameWidth':960,
			'frameHeight':500,
			'padding':0
		});
	}
}


/* no flash
- - - - - - - - - - - - - - - - - - - - */
function noFlash() {
	if ($("#header").hasClass("flash-update")) {
		$("#header").html("");
		$.ajax({
	    type: "GET",
			url: "Write_Image_After_Flash.asp",
			dataType: "xml",
			success: function(xml) {
		 		size = $(xml).find('item').size();
				num = Math.round(size*Math.random());
				image1 = $(xml).find('item:eq(' + num + ')').find("image1").text();
				image2 = $(xml).find('item:eq(' + num + ')').find("image2").text();
				image3 = $(xml).find('item:eq(' + num + ')').find("image3").text();
				image4 = $(xml).find('item:eq(' + num + ')').find("image4").text();
				$("#header").html('<img src="' + image1 + '" alt="cucine Elektravetro"/><div id="altre"><span>' + image1 + '</span><span>' + image2 + '</span><span>' + image3 + '</span><span>' + image4 + '</span></div>');
					headerImg();
			}
		});
		
	}
	if ($("#tag_clouds").hasClass("flash-update")) {
		$("#tag_clouds").parent().parent().remove();
	}
}


/* screenshot
- - - - - - - - - - - - - - - - - - - - */
function screenshot() {
	if ($("a.screenshot").size()){
		$("a.screenshot").hover(function(e){
			$("body").append('<img class="screenshot_img" style="position:absolute; z-index:10; top:' + (e.pageY - 140) + 'px; left:' + e.pageX + 'px;" src="' + $(this).attr("rel") + '" />');
			$(".screenshot_img").hide().fadeIn(300);
			$("body").mousemove(function(e){
				$(".screenshot_img").css({"top":(e.pageY - 135) + "px", "left":e.pageX + "px"});
			});
		},function(){
			$(".screenshot_img").remove();
		});
	}
}


/* querystring
- - - - - - - - - - - - - - - - - - - - */
function querystring(name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec(window.location.href);
  if(results == null){
    return "";
	} else {
    return results[1];
	}
}


/* fancyboxme
- - - - - - - - - - - - - - - - - - - - */
function fancyboxme() {
	if (querystring("fancyboxme").length > 0) {
		sufx = (querystring("fancyboxme").indexOf("?") != -1) ? "&iframe" : "?iframe";
		$fancyboxme = $('<a href="' + querystring("fancyboxme") + sufx + '" class="mostra_tutti fancyboxme" style="display:none;">' + querystring("fancyboxme") + '</a>');
		$fancyboxme.appendTo($("body"));
		$fancyboxme.fancybox({
			'zoomOpacity': true,
			'overlayShow': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'overlayOpacity': 0.7,
			'padding': 0,
			'frameWidth':960,
			'frameHeight':$(window).height() - 80
		}).click();
	}
}


/* INIT
- - - - - - - - - - - - - - - - - - - - */
$(function(){
	BrowserDetect.init();
	
	$("#menu").widgetize({classe:"menu"});
	$(".widget").widgetize();
	$("input.text").clearInput();
	menu();

	// altre cucine
	if ($("#altre_cucine").size()) {
		var api = $("#altre_cucine .scrollable").scrollable({
			'size': 1,
			//'interval': 5000,
			api: true
		});
		api.onSeek(function(){
			$("#altre_cucine").find(".active").removeClass("active");
			$("#altre_cucine").find(".items").find("div:eq(" + this.getIndex() + ")").addClass("active");
			$("#altre_cucine .name").text($("#altre_cucine").find(".active img").attr("alt"));
		});
		$("#altre_cucine .scrollable .items div").click(function(){
			$("#altre_cucine .name").text($(this).find("img").attr("alt"));									
		});
		$("#altre_cucine").find(".items div:eq(0)").click();
	}
	

	// showreel
	if ($("#showreel_home").size()) {
		$("#showreel_home").showreel();
	}

	// caratteristiche
	if ($(".caratteristiche").size()){
		$(".caratteristiche").caratteristiche();
	}
	
	// accessori
	if ($(".accessori").size()){
		$(".accessori").accessori();
	}
	
	// video home
	if ($(".video_home").size()) {
		/* checko cookie */
		if ($.cookie('skip') == "vero") {
			skipVar = true;
		} else if ($(".open_language").size()) {
			$.cookie('skip', 'falso', {expires:1});
			skipVar = false;
			// $("#openclose").click();
		} else {
			$.cookie('skip', 'vero', {expires:1});
			skipVar = false;
			// $("#openclose").click();
		}
		homeVideo();
		$(".video_home").flash({ src: 'swf/playerErnesto.swf', width:"100%", height:"100%", wmode:"transparent", flashvars: { skip: skipVar}, update:false});
	}
	if ($(".header_img").size()) {
		headerImg();
	}
	
	// tag cloud
	if ($("#tag_clouds").size()) {
		$("#tag_clouds").flash({ src: 'tagClouds.swf', width:"240px", height:"120px", wmode:"transparent", update:false});
	}
	
	// emvironment
	if ($("#emvironment_flash").size()) {
		$("#emvironment_flash").flash({ src: 'finale_cloud_02.swf?lang=' + $(".language_choice a.on").text().toUpperCase() , width:"768", height:"682", wmode:"transparent", update:false});
		if ($("#emvironment_flash").hasClass("flash-update")) {
			$("#emvironment_flash").html('<img src="img/emvironment.png" alt="emvironment" />');
		}
	}
	
	// YachtShowReel
	if ($("#yacht_flash").size()) {
		if ($("#header").attr("style").indexOf("1680") != -1) {
			flashWidth = 700;
			flashHeight = 621;
		} else if ($("#header").attr("style").indexOf("1440") != -1) {
			flashWidth = 600;
			flashHeight = 532;
		} else if ($("#header").attr("style").indexOf("1280") != -1) {
			flashWidth = 500;
			flashHeight = 444;
		} else {
			flashWidth = 400;
			flashHeight = 355;
		}
		$("#yacht_flash").flash({ src:"swf/YachtShowReel.swf" , width:flashWidth, height:flashHeight, wmode:"transparent", update:false}).css({"margin": (flashWidth/100) + "px 0px 0px -" + (flashWidth/2) + "px"});
		if ($("#yacht_flash").hasClass("flash-update")) {
			$("#yacht_flash").html('<img src="img/yacht_noflash.png" width="' + (flashWidth-20) + '" alt="Ernestomeda Yacht Division" />');
		}
	}
	
	// widget form
	$(".widgetize form").widgetForm();
	
	
	// twitter
	var twitter;
	if ($("#twitter").size()) {
		if ($("div#twitter .wig_d").size() != 1) {
			$("div#twitter .wig_c").after('<div class="wig_d">&nbsp;</div>');
		}
		$("div#twitter .wig_d").load("/Twitter/BuildTwitterWidget.asp");
	}


	// fancy
	$("a.fancy").fancybox({
		'zoomOpacity': true,
		'overlayShow': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'overlayOpacity': 0.7,
		'padding': 0
	});
	
	
	// choose language
	$("a.lavora_con_noi").fancybox({
		'zoomOpacity': true,
		'overlayShow': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'overlayOpacity': 0.7,
		'frameWidth':960,
		'frameHeight':$(window).height() - 100
	});
	
	if ($("a.open_language").size()) {
		$("a.choose_language").click();
	}
	
	// natale2009
	$("a.fancy_natale").click(function(){
		if ((location.href.indexOf("natale") == -1)) {
			location.href = location.href + "?natale=true";
			return false;
		} else {
			$(this).clone().prependTo($(this)).fancybox({
				'zoomOpacity': true,
				'overlayShow': true,
				'zoomSpeedIn': 500,
				'zoomSpeedOut': 500,
				'overlayOpacity': 0.7,
				'frameWidth':940,
				'frameHeight':576,
				'padding': 0
			}).hide().click();
			return false;
		}
	});
	
	// Kitchen care box
	$("a.kcarebox").fancybox({
		'zoomOpacity': true,
		'overlayShow': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'overlayOpacity': 0.7,
		'frameWidth':450,
		'frameHeight':450,
		'padding': 0
	});

	
	if (location.href.indexOf("natale") != -1) {
		$("#fancy_close, #fancy_overlay").click(function(){
			location.href = location.href.split("?")[0];
		});
		
		$("a.fancy_natale").clone().prependTo($(this)).fancybox({
			'zoomOpacity': true,
			'overlayShow': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'overlayOpacity': 0.7,
			'frameWidth':940,
			'frameHeight':576,
			'padding': 0
		}).hide().click();
	}
	
	
	// mostra tutto
	$("a.mostra_tutti").fancybox({
		'zoomOpacity': true,
		'overlayShow': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'overlayOpacity': 0.7,
		'frameWidth':960,
		'frameHeight':$(window).height() - 100,
		'padding': 0
	})
	
		// pageflip
	$("a.pageflip").click(function(){
		$("body").scrollTop(0);
		$("body").addClass("noscroll");
		$(this).clone().prependTo($(this)).fancybox({
			'zoomOpacity': true,
			'overlayShow': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'overlayOpacity': 0.7,
			'frameWidth':960,
			'frameHeight':$(window).height() - 100,
			'padding': 0
		}).hide().click();
		return false;
	});
	
	// mappa
	mappa();
	
	
	// no flash
	noFlash();
	
	
	// screenshot
	screenshot();


	// fancyboxme
	fancyboxme();
});

$(window).resize(function() {
	if ($(".video_home").size()) {
		homeVideo();
	}
	if ($(".header_img").size()) {
		headerImg();
	}
});

