$(init);function init(){$("#main-wrapper").css({height:"auto"});$("#top-menu, .info-section").css("min-height",$(window).height());$(".flexslider img").css({"max-height":($(window).height()-40)+"px"});$("#top-menu").animate({left:"0"},700,"easeOutCubic",showById);$("#top-menu ul a, #logo, .scroll").bind("click",showHands);$(".video").bind("click",showVideo);$("#show-reperire-cd").fancybox();$("#show-reperire-cd-from-home").fancybox();$("#show-reperire-cd-from-nav").fancybox();$("#top-menu ul a").hover(showMyLabel,hideMyLabel);$("#news-wrapper ul").jcarousel();$(".flexslider").flexslider({slideDirection:"vertical",pauseOnHover:true,controlNav:false});$(".ext, #myspace, #facebook, #youtube").bind("click",openNewTab);$("input#contacter").click(reset);$("input#contacter").focusout(reset);$("form#prenota-online input.text").click(reset);$("form#prenota-online input.text").focusout(reset);$("textarea").focusin(reset);$("textarea").focusout(reset);$("#contact-form form").submit(sendMail);$("form#prenota-online").submit(bookCd);$(window).resize(resizeObj);$(window).scroll(dealWithScroll);$("html, body").scroll(dealWithScroll);dealWithScroll()}function showVideo(){$.fancybox({padding:0,autoScale:true,transitionIn:"none",transitionOut:"none",title:false,width:$(window).width()-100,height:$(window).height()-100,href:this.href.replace(new RegExp("watch\\?v=","i"),"v/"),type:"swf",swf:{wmode:"transparent",allowfullscreen:"true"}});return false}function resizeObj(){$("#top-menu, .info-section").css("min-height",$(window).height())}function dealWithScroll(b){var a=window.pageYOffset;if(a>$(window).height()/2){$("#back-to-top").parent().removeClass("hide").fadeIn()}else{$("a#back-to-top").parent().fadeOut();$(".active").removeClass("active");if($("#desc-homepage").css("right")!="0px"){showById("homepage")}}scrollP=a+80;if(scrollP>=$("#history").offset().top&&scrollP<$("#pr").offset().top){if(!$("#storia").hasClass("active")){$(".active").removeClass("active");$("#storia").addClass("active");showById("storia")}}if(scrollP>=$("#pr").offset().top&&scrollP<$("#foto-section").offset().top){if(!$("#news").hasClass("active")){$(".active").removeClass("active");$("#news").addClass("active");showById("news")}}if(scrollP>$("#foto-section").offset().top&&scrollP<=$("#merchandise").offset().top){if(!$("#foto").hasClass("active")){$(".active").removeClass("active");$("#foto").addClass("active");showById("foto")}}if(scrollP>$("#merchandise").offset().top&&scrollP<=$("#contatti-section").offset().top){if(!$("#t-shirt").hasClass("active")){$(".active").removeClass("active");$("#t-shirt").addClass("active");showById("t-shirt")}}if(scrollP>$("#contatti-section").offset().top){if(!$("#contatti").hasClass("active")){$(".active").removeClass("active");$("#contatti").addClass("active");showById("contatti")}}}function showHands(){var d=window.pageYOffset;if($(this).hasClass("active")||($(this).attr("id")=="logo"&&(d>=0&&d<$(window).height()))){return false}var a=$($(this).attr("href"));var b=$(this);var c=topBottom(b);if($(this).attr("id")=="back-to-top"){c="top"}if(c=="top"){$("#mani-bottom").animate({bottom:0},700,"linear",function(){$(this).animate({bottom:"-300px"},500,"linear");$("html, body").animate({scrollTop:a.offset().top-20},1000,"easeOutCubic");$("a.active").removeClass("active");var e=b.attr("id");if(e!="back-to-top"&&e!="logo"){b.addClass("active")}})}else{$("#mani-top").animate({top:0},700,"linear",function(){$(this).animate({top:"-300px"},500,"linear");$("html, body, #main-wrapper").animate({scrollTop:a.offset().top-20},1000,"easeOutCubic");$("a.active").removeClass("active");var e=b.attr("id");if(e!="back-to-top"&&e!="logo"){b.addClass("active")}})}return false}function topBottom(c){var b=$($("#top-menu a.active").attr("href")).index();var a=$(c.attr("href")).index();if(b<a){return"bottom"}else{return"top"}}function showContactForm(){$("#top-menu").animate({top:($("#contact-form").height()-$("#top-menu").height())},500,"easeOutCubic");$("#contact-form").animate({top:0},500,"easeOutCubic");return false}function hideContactForm(){$("#top-menu").animate({top:0},500,"easeOutCubic");$("#contact-form").animate({top:"-500px"},500,"easeOutCubic");return false}function showMyLabel(){if(!$(this).hasClass("active")){var a=$(this).attr("id");showById(a)}}function showById(a){if(a==null){return}$("#section-description p").stop(true,true).animate({right:"-185px"},100,"linear",function(){$("#desc-"+a).animate({right:"-0"},200,"linear")})}function hideMyLabel(){if(!$(this).hasClass("active")){var a=$(".active").attr("id");if(a==undefined){a="homepage"}showById(a)}}function openNewTab(){$(this).attr("target","_blank")}function reset(){if(!$(this).val()){$(this).val($(this).attr("title"))}else{if($(this).val()==$(this).attr("title")){$(this).val("")}}if($(this).hasClass("textarea")){if(!$(this).val()){$(this).val("scrivi qui il tuo messaggio")}else{if($(this).val()=="scrivi qui il tuo messaggio"){$(this).val("")}}}}function sendMail(){if($("input#contacter").val()==""||$("input#contacter").val()==$("input#contacter").attr("title")||!is_mail($("input#contacter").val())){$("input#contacter").addClass("error-input");return false}$("#contact-form").height($("#contact-form").height());$(this).fadeOut("fast",function(){$("#loader").fadeIn("fast")});$.ajax({url:$(this).attr("action"),data:$(this).serialize(),type:"POST",success:function(b){var a="";if(b=="done"){a='<p style="display:none;">Abbiamo ricevuto la tua mail. Grazie Mille!</p>'}else{a='<p style="display:none;">Ops!!Ci sono stati dei problemi...l\'amministratore &egrave; stato avvisato</p>'}$("#contact-form").append(a);$("#loader").fadeOut("fast",function(){$(this).addClass("hide");$("#contact-form p").fadeIn()})}});return false}function is_mail(b){var a=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;return b.match(a)}function bookCd(){if($("input#book-mail").val()==""||$("input#book-mail").val()==$("input#book-mail").attr("title")||!is_mail($("input#book-mail").val())){$("input#book-mail").addClass("error-input");return false}if($("input#book-name").val()==""||$("input#book-name").val()==$("input#book-name").attr("title")){$("input#book-name").addClass("error-input");return false}$(this).fadeOut();var a=$(this);$.ajax({url:$(this).attr("action"),data:$(this).serialize(),type:"POST",success:function(c){var b="";if(c=="done"){b='<p style="display:none;" id="response">La tua richiesta &egrave; stata ricevuta. Grazie Mille!</p>'}else{b='<p style="display:none;" id="response">Ops!!Ci sono stati dei problemi...l\'amministratore &egrave; stato avvisato</p>'}a.parent().append(b);$("#response").fadeIn()}});return false};
