function brand(){$("#brand_home div").show().css({opacity:0});$("#brand_home ul li a").mouseover(function(){$(this).parent().find("div").stop().animate({opacity:1},"slow");$("#brand_home ul li a").not($(this)).stop().animate({opacity:.1},"slow")}).mouseout(function(){$(this).parent().find("div").stop().animate({opacity:0},"slow");$("#brand_home ul li a").not($(this)).stop().animate({opacity:1},"slow")})}function cover_brand(){$("#desc_brand").css("opacity",0);$("#desc_brand").css("filter","alpha(opacity=0)");$(".desc_brand").animate({opacity:.7,filter:"alpha(opacity=70)"});$(".desc_content").animate({opacity:1,filter:"alpha(opacity=100)"});var a=false,b;$(".cover_brand").mouseover(function(){a=true;$(".desc_brand").animate({right:"0"},"slow")});$(".cover_brand").mouseover(function(){a=true;clearTimeout(b)}).mouseout(function(){a=false;b=setTimeout(function(){!a&&$(".desc_brand").stop().animate({right:"-220px"},"slow")},1e3)})}var X=0,Y=0;function tooltip(){$("body").append('<div id="tooltip"></div>');function a(){maxX=$(window).width()-$("#tooltip").outerWidth()-40;maxY=$(window).height()+$(window).scrollTop()-$("#tooltip").outerHeight()-40;if(X>maxX)X=maxX;if(Y>maxY)Y=maxY;$("#tooltip").css({top:Y+"px",left:X+"px"}).show()}$(".navigbar_prodotti a").each(function(){var b=$(this).attr("title");$(this).removeAttr("title");if(b!=null){$(this).mouseover(function(c){X=c.pageX+10;Y=c.pageY+10;$("#tooltip").html(b);a()}).mouseout(function(){$("#tooltip").hide()}).mousemove(function(b){X=b.pageX+10;Y=b.pageY+10;a()});$("#tooltip").mouseover(function(){$(this).show()}).mouseout(function(){$(this).hide()})}})}function pulisciinput(a){$(a).each(function(){if($(this).length)$(this)[0].tmp_input_val=$(this).val();$(this).focus(function(){if(this.value==this.tmp_input_val)this.value=""});$(this).blur(function(){if(this.value=="")this.value=this.tmp_input_val})})}function mymenu(){if($("#hfSelectCoId").size()){var a=$("#hfSelectCoId").val();$("#coId_"+a).addClass("on")}$("#menu a.active").parent().parent().addClass("on");$("#menu ul li ul").not(".on").hide();$("#menu ul li a").click(function(){if($(this).attr("href")=="#"){if($(this).next().attr("class")=="on")$(this).parent().children().not("a").removeClass("on").slideUp("fast");else{$(this).parent().parent().find("ul.on").removeClass("on").slideUp("fast");$(this).parent().children().not("a").addClass("on").slideDown("normal")}return false}});apriMenu();$("img[src='']").src="/img/trasp.gif"}function apriMenu(){$("#menu a.on").each(function(){var a=this,b=0;while(a!==null&&b<30){a=$(a).parent();if(a[0].tagName=="UL"){$(a).parent().children().not("a").show();$(a).parent().children().addClass("on")}else if(a[0].tagName=="LI")b++;else if(a[0].tagName=="DIV")a=null;else b++}})}function photogallery(){$(".items a").click(function(){var e=$(".items div a").length;if(e<=1){$("body.classic .dettaglio").hide();$("body.outdoor .dettaglio").hide();$(".fotogallery").hide();var d=$("#zoomGallery a").attr("href");$(".cover_img img").wrap('<a href="'+d+'" class="new" />')}if($(this).hasClass("active"))return;var c=$(this).attr("rel"),a=$("#image_wrap").fadeTo("medium",.5),b=new Image;b.onload=function(){a.fadeTo("fast",1);a.find("img").attr("src",c)};b.src=c;$(".items a").removeClass("active");$(this).addClass("active")}).filter(":first").click()}function navigbar_showhide(){var a=false,b;$("#menu_top").mouseover(function(){var a=true;$("#show_menu_top").animate({opacity:"show",top:"0"},"slow")});$("#show_menu_top").mouseover(function(){a=true;clearTimeout(b)}).mouseout(function(){a=false;b=setTimeout(function(){!a&&$("#show_menu_top").stop().animate({opacity:"hide",top:"-10px"},"fast")},1e3)})}function bottombar_showhide(){var a=false,b;$("#show_menu_bottom").mouseover(function(){a=true;$("#brand").animate({bottom:"30px"},"slow")});$("#menu_bottom").mouseover(function(){a=true;clearTimeout(b)}).mouseout(function(){a=false;b=setTimeout(function(){!a&&$("#brand").stop().animate({bottom:"-200px"},"slow")},1e3)})}function manageLogin(){$("#Login").hide();$("#RetrievePassword").hide();$("#Logout").hide();if($("#hfUserState").size()){var a=$("#hfUserState").val();if(a<0){$("#Login").show();$("#btnLogin").click(function(){RegisterForm(this)});$("#btnRetrievePwd").click(function(){retrievePwd(this)});$("#showRetrievePwd").click(showRetrievePwd);$("#showLogin").click(showLogin)}else if(a>0){$("#Logout").show();$("#btnLogout").click(doLogout)}}}function showRetrievePwd(){$("#Login").fadeOut(800,function(){$("#RetrievePassword").fadeIn(500)});return false}function showLogin(){$("#RetrievePassword").fadeOut(800,function(){$("#Login").fadeIn(500)});return false}function retrievePwd(a){$("#EmailForRetrievePwdReq").hide();var b=$.trim($("#EmailForRetrievePwd").val());if(b==null||b.length<=0)$("#EmailForRetrievePwdReq").show();else{$("#divNotify2").html('<div id="loadingContainer"> <img src=\'/imgs/loading.gif\' /> <span class="red"> Verifica in Corso ... </span> </div>');$("#divNotify2").show();$(a).fadeOut(500);$.ajax({type:"POST",url:"/WS/wsForms.asmx/RetrievePassword",cache:false,contentType:"application/json; charset=utf-8",data:JSON2.stringify({email:b}),dataType:"json",success:function(b){$("#divNotify2").html('<span class="red"> '+b.d.HTML+"</span>");$("#divNotify2").fadeIn(800);removeLoading(a)},error:function(){alert("Web-Service Error!!");removeLoading(a)}})}}function retrievePwd2(){var a=$.trim($("#txtEmail").val());$.ajax({type:"POST",url:"/WS/wsForms.asmx/RetrievePassword",cache:false,contentType:"application/json; charset=utf-8",data:JSON2.stringify({email:a}),dataType:"json",success:function(a){$("#divNotify").html('<span class="red"> '+a.d.HTML+"</span>")},error:function(){alert("Web-Service Error!!")}})}function doLogout(){$.ajax({type:"POST",url:"/WS/wsForms.asmx/Logout",cache:false,contentType:"application/json; charset=utf-8",dataType:"json",success:function(){location.reload()},error:function(){alert("Web-Service Error!!");removeLoading(sender)}})}function SiteSearch(){var b=$("#txtSearchText").attr("defaultValue"),a=$.trim($("#txtSearchText").val());return a.length>0&&a!=b}function storeLocator(){$("#divIndirizzoNonTrovato").hide();$("#confermaIndirizzo").hide();$("#elencoRivenditori").hide();$("#pTitle2").hide();$("#pTitle3").hide();$("#btnIndirizzoOK").click(function(){slCercaRivenditori()});$("#btnIndirizzoKO").click(function(){$("#confermaIndirizzo").fadeOut(500,function(){removeMappa();$("#formIndirizzo").fadeIn(400);$("#pTitle2").hide();$("#pTitle3").hide();$("#pTitle1").show()})});$("#btnIndietro").click(function(){$("#elencoRivenditori").fadeOut(500,function(){$("#mappaIndirizzo").fadeOut(400,function(){removeMappa()});$("#formIndirizzo").fadeIn(400);slPublisci();$("#pTitle2").hide();$("#pTitle3").hide();$("#pTitle1").show()})});$("#mappaIndirizzo").hide();LogToConsole("Store Locator - init(): OK")}function slPublisci(){$("#divIndirizzoNonTrovato").hide();$("#formIndirizzo input[type='text']").val("")}function slCercaIndirizzo(){LogToConsole("Store Locator - Cerca Indirizzo");$("#divIndirizzoNonTrovato").hide();if(FormValidation()){var a=$("#Indirizzo").val()+", "+$("#NrCivico").val()+" - "+$("#CAP").val()+" "+$("#Citta").val()+" ("+$("#Provincia").val()+")";$("#hfAddress").val(a);$(".currAddress").html(a);LogToConsole("Store Locator - Indirizzo: "+$("#hfAddress").val());LoadGMap(a)}}function slCercaRivenditori(){LogToConsole("Store Locator - Cerca Rivenditori");$("#confermaIndirizzo").fadeOut(500,function(){$("#elencoRivenditori").fadeIn(400)});$("#pTitle1").hide();$("#pTitle2").hide();$("#pTitle3").show();$.ajax({type:"POST",url:"/WS/wsGetContent.asmx/StoreLocator",cache:false,contentType:"application/json; charset=utf-8",data:JSON2.stringify({idBrand:$("#hfBrand").val(),LAT:$("#hfAddressLAT").val(),LNG:$("#hfAddressLNG").val()}),dataType:"json",success:function(a){$("#lista_rivenditori").html(a.d.HTML);setMarkers()},error:function(){alert("Web-Service Error!!");$("#lista_rivenditori").html("")}})}function LoadGMap(d){var a,b,c=new google.maps.Geocoder;c.geocode({address:d},function(d,c){if(c==google.maps.GeocoderStatus.OK){a=d[0].geometry.location.lat();b=d[0].geometry.location.lng();$("#hfAddressLAT").val(a);$("#hfAddressLNG").val(b);LogToConsole("Store Locator - GEOCODING:  LAT = "+a+", LNG = "+b);$("#formIndirizzo").fadeOut(500,function(){$("#confermaIndirizzo").fadeIn(400);$("#pTitle1").hide();$("#pTitle2").show();$("#pTitle3").hide();$("#mappaIndirizzo").show();showGMap()})}else{LogToConsole("Store Locator - GEOCODING: "+c);$("#addressNotFoundErrType").html(c);$("#divIndirizzoNonTrovato").show()}})}function showGMap(){lat=$("#hfAddressLAT").val();lng=$("#hfAddressLNG").val();var a=new google.maps.LatLng(lat,lng),b={zoom:13,mapTypeId:google.maps.MapTypeId.ROADMAP};map=new google.maps.Map(document.getElementById("mappaIndirizzo"),b);var c=new google.maps.Marker({position:a,map:map,icon:"http://ciacci.websolute.it/imgs/home.gif",title:$("#hfAddress").val()});map.setCenter(a)}function setMarkers(){var b,d,e,a,c=new google.maps.LatLngBounds;$(".rivenditoreCoord").each(function(){b=$(this).val();d=b.split("|")[0];e=b.split("|")[1];a=new google.maps.LatLng(d,e);c.extend(a);var f=new google.maps.Marker({position:a,icon:"http://ciacci.websolute.it/imgs/api_google_maps.png",map:map}),g=new google.maps.InfoWindow({content:$(this).parent().html()});google.maps.event.addListener(f,"click",function(){g.open(map,f)})});map.fitBounds(c)}function removeMappa(){map=null;$("#mappaIndirizzo").fadeOut(400,function(){$("#mappaIndirizzo").remove();$("#formIndirizzo").after('<div id="mappaIndirizzo" style="width:650px; height:330px;"></div>')})}function openStoreLocator(){hrefId!=""&&setTimeout("$(hrefId).click(); hrefId = '';",100)}function loadDataUser(){$.ajax({type:"POST",url:"/WS/wsGetContent.asmx/GetUser",cache:false,contentType:"application/json; charset=utf-8",dataType:"json",success:function(a){if(a.d!=null){$("#txtNome").val(a.d.UT_Nome);$("#txtCognome").val(a.d.UT_Cognome);$("#txtEmail").val(a.d.UT_Email);$("#txtindirizzo").val(a.d.UT_Indirizzo);$("#txtCap").val(a.d.UT_Cap);$("#txtCitta").val(a.d.UT_Citta);$("#ddlProvincia").val(a.d.UT_Provincia);$("#ddlNazione").val(a.d.UT_Nazione)}},error:function(){alert("Web-Service Error!!")}})}function promoKreaty(){$("#colore_fly").hide();$("#chkLampada1").click(function(){$("#colore_fly").hide()});$("#chkLampada2").click(function(){$("#colore_fly").show()})}var map,hrefId="";function Testomod(){$("body.kreaty .link_store_locator a").html("Trova il rivenditore 'Illumina la tua tavola'")}$(function(){mymenu();brand();cover_brand();tooltip();navigbar_showhide();bottombar_showhide();photogallery();pulisciinput(".pulisci_input");storeLocator();promoKreaty();Testomod();$("body.gold .scrollable").scrollable({vertical:true,mousewheel:true});$("body.kreaty .scrollable").scrollable({vertical:true,mousewheel:true});$("body.classic .scrollable").scrollable({mousewheel:true});$("body.outdoor .scrollable").scrollable({mousewheel:true});$("#showreel").scrollable().navigator();var a=$("#hfCoId").val();$("#menu_co_"+a).size()&&$("#menu_co_"+a+" a").addClass("on");$(".fancyImgZoom").fancybox();$("#zoomGallery a").fancybox();$(".news_gallery a").fancybox();$(".cover_img a").fancybox();$(".fancyZoom").click(function(){src=$(this).find("img").attr("src");ind=$(".items a").index($(".items a[rel*='"+src+"']"));$("#zoomGallery a:eq("+ind+")").click();return false});$(".iFrameDesigner").fancybox({type:"iframe",titleShow:false,autoDimensions:false,width:725,height:620});$(".fancyLogin").fancybox({type:"iframe",titleShow:false,autoDimensions:false,width:370,height:350});$(".privacyFancy").fancybox({type:"iframe",titleShow:false,autoDimensions:false,width:725,height:620});$(".link_store_locator a").fancybox({type:"iframe",titleShow:false,autoDimensions:false,width:700,height:650});$(".link_news").fancybox({type:"iframe",titleShow:false,autoDimensions:true,onClosed:openStoreLocator});$(".link_store_locator_news a").click(function(){var b=$(this).attr("href"),a="#storeLoc"+b;parent.hrefId=a;parent.$.fancybox.close()});manageLogin();$("#btnRegistra").click(function(){RegisterForm(this)});if($("#openPDF").size()){var b=window.open("about:blank");if(b){b.document.location.href=$("#openPDF").attr("href");$.ajax({type:"POST",url:"/WS/wsForms.asmx/SetPDFOpened",cache:false,contentType:"application/json; charset=utf-8",dataType:"json"})}}});$(window).load(function(){$("#mcs3_container").size()&&$("#mcs3_container").mCustomScrollbar("vertical",900,"easeOutCirc",1.05,"auto","yes","no",0)});$.fx.prototype.cur=function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(jQuery.css(this.elem,this.prop));return typeof a=="undefined"?0:a};function ValidateEmail(a){try{var b=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;return b.test(a)}catch(c){return false}}$(function(){$(".field_required,.red").hide();$("#divNotify").hide();$("#divValidationSummary").hide()});function LogToConsole(a){try{console.info(a)}catch(b){}}function RegisterForm(a){var b=0;$("#divNotify").hide();FormValidation()&&Register(a)}function Register(a){var d=0;showLoading(a);var c=$("#hfWsMethod").val();LogToConsole("WS Method: '"+c+"'");var b=GetJsonData();for(o in b)d++;LogToConsole("jsonData Length: "+d);var e={data:b};$.ajax({type:"POST",url:"/WS/wsForms.asmx/"+c,cache:false,contentType:"application/json; charset=utf-8",data:JSON2.stringify(e),dataType:"json",success:function(b){if(b!=null){try{gaTrackFormResult(b.d.Status)}catch(c){alert(c)}LogToConsole("AJAX Result: "+b.d.Status);$("#divNotify").html('<span class="red"> '+b.d.HTML+"</span>");$("#divNotify").fadeIn(700)}else LogToConsole("AJAX Result: null");removeLoading(a)},error:function(){alert("Web-Service Error!!");removeLoading(a)}})}function gaTrackFormResult(b){if(b){var a=$("#hfTrackPage").val();a!=null&&a!=""&&gaTrackPage(a)}}function GetJsonData(){var a={};$("#form1 input[type=text], input[type=password], #form1 input[type=checkbox], #form1 input[type=radio], #form1 input[type=hidden]").each(function(){var d=$(this).attr("type");if(d!="submit"){var b=$(this).attr("id"),c=GetValueFromInput(this);if(b!="")a[b]=c}});$("#form1 select").each(function(){var b=$(this).attr("id"),c=$(this).val();if(b!="")a[b]=c});$("#form1 textarea").each(function(){var b=$(this).attr("id"),c=$(this).val();if(b!="")a[b]=c});if($("#hfBrand").size()>0)a.BrandId=$("#hfBrand").val();return a}function GetValueFromInput(a){var b=null,d=$(a).attr("id"),c=$(a).attr("type");switch(c){case"text":case"password":case"hidden":b=$.trim($(a).val());break;case"checkbox":case"radio":b=$("#"+d+":checked").size()>0}return b}function showLoading(){$("#divNotify").html('<div id="loadingContainer"> <img class="loading_reg" style="width:16px; height:16px" src=\'/imgs/loading.gif\' /> <span class="red"> Registrazione in Corso ... </span> </div>');$("#divNotify").show()}function showLoadingText(b,a){$("#divNotify").html('<div id="loadingContainer"> <img class="loading_reg" style="width:16px; height:16px" src=\'/imgs/loading.gif\' /> <span class="red"> '+a+" </span> </div>");$("#divNotify").show()}function removeLoading(){$("#loadingContainer").remove()}function FormValidation(){$("#divValidationSummary").hide();var b,a=true;$(".required").each(function(){try{b=ValidateSingleField(this)}catch(c){LogToConsole("Validation '"+$(this).attr("id")+"' Exception: "+c);b=false}a=a&&b});!a&&$("#divValidationSummary").fadeIn(800);LogToConsole("Validation Result: "+a);return a}function ValidateSingleField(a){var b=false,c=$(a).attr("type");if(c!=null&&c.length>0)switch(c){case"text":case"password":case"file":var d=$(a).attr("id");if(d=="txtEmail"||d=="Email")b=ValidateTextEmail(a);else b=ValidateText(a);break;case"checkbox":b=ValidateCheckbox(a)}else if($(a).is("select"))b=ValidateSelect(a);LogToConsole("FIELD: '"+$(a).attr("id")+"' VALID: "+b);return b}function ValidateText(c){var b=true,d=$(c).attr("id"),a=d+"Req",e=$.trim($(c).val());$("#"+a).hide();if(e.length<=0){b=false;$("#"+a).show()}return b}function ValidateTextEmail(b){$(b).removeAttr("title");var a=true;a=ValidateText(b);if(a){var e=$(b).attr("id"),c=e+"Req",d=$(b).val();a=ValidateEmail(d);$("#"+c).hide();if(!a){$("#"+c).show();$(b).attr("title","Indirizzo non Valido! - Wrong Address Format!")}}return a}function ValidateCheckbox(d){var b=true,c=$(d).attr("id"),a=c+"Req",e=$("#"+c+":checked").size();$("#"+a).hide();if(e<=0){b=false;$("#"+a).show()}return b}function ValidateSelect(f){var c=true,d=$(f).attr("id"),b=d+"Req";$("#"+b).hide();var e=$("#"+d+" option:selected").val(),a=parseInt(e);if(!isNaN(a)){if(a<0){c=false;$("#"+b).show()}}else if(a==null||a==""){c=false;$("#"+b).show()}return c}
