
var myZanichelliLocale={};myZanichelliLocale.Riprova="Riprova";myZanichelliLocale.Hai_dimenticato_la_password="Hai dimenticato la password";myZanichelliLocale.Chiudi="Chiudi";myZanichelliLocale.password_troppo_breve="Password troppo breve";myZanichelliLocale.password_inviata="La password &egrave; stata inviata alla tua casella di posta.";myZanichelliLocale.check_Italia="Italia";myZanichelliLocale.nessun_istituto_trovato="Nessun istituto trovato, se non trovi la tua scuola inseriscila manualmente.";myZanichelliLocale.inserisci_la_scuola="Inserisci la scuola manualmente";myZanichelliLocale.nuova_ricerca="Nuova ricerca";myZanichelliLocale.inserire_una_scuola="Inserire una scuola";myZanichelliLocale.scegli_istituto="Scegli tra questi istituti:";myZanichelliLocale.conferma="Conferma";myZanichelliLocale.carrello_conferma_eliminazione="Sei sicuro di voler eliminare l'elemento dal carrello?";var myZanichelli={};myZanichelli.createModal=function(id){return $(id).modal({overlayClose:true,closeHTML:'',onOpen:function(d){d.data.show();d.overlay.fadeIn('fast');d.container.fadeIn('fast');},onClose:function(d){var self=this;d.overlay.fadeOut('fast');d.container.fadeOut('fast',function(){self.close()});}});}
myZanichelli.showModalAlert=function(msg,buttons,type)
{$("#modalDialog #popupContent div").html(msg);$("#modalDialog #popupContent").removeClass();$("#modalDialog #popupContent").addClass(type);$("#modalDialog #popupContent div").removeClass();$("#modalDialog #popupContent div").addClass(type);$("#modalDialog .buttons").empty();$(buttons).each(function(i,el){var css=i==0?"buttonDialogConfirm":"buttonDialog";if(el.label.length>18)css+=" multiline"
$("#modalDialog .buttons").append($('<li><a href="javascript:;" class="'+css+'">'+el.label+'</a></li>').click(function(){$("#simplemodal-overlay").trigger('click.simplemodal');if(el.callback)el.callback();}));});myZanichelli.createModal("#modalDialog");}
myZanichelli.closeModalAlert=function()
{$("#simplemodal-overlay").trigger('click.simplemodal');}
myZanichelli.showSuccessModalAlert=function(message)
{$("#simplemodal-overlay").trigger('click.simplemodal');setTimeout(function(){var buttons=[];buttons.push({label:myZanichelliLocale.Chiudi,callback:null});myZanichelli.showModalAlert(message,buttons,"success");},500);}
myZanichelli.showModalLinkList=function(linkList,callbackInsertSchool,callbackInsertSchoolManual)
{var buttons=[];var msg;if(linkList.length==0)
{buttons.push({label:myZanichelliLocale.inserisci_la_scuola,callback:callbackInsertSchoolManual});buttons.push({label:myZanichelliLocale.nuova_ricerca,callback:null});myZanichelli.showModalAlert(myZanichelliLocale.nessun_istituto_trovato,buttons,"warning");}
else
{var selectSchool=function(){var radio=$("input[name='school']:checked");callbackInsertSchool(radio.parent().attr("id"),radio.val());$('#simplemodal-overlay').trigger('click.simplemodal');}
buttons.push({label:myZanichelliLocale.conferma,callback:selectSchool});buttons.push({label:myZanichelliLocale.inserisci_la_scuola,callback:callbackInsertSchoolManual});buttons.push({label:myZanichelliLocale.nuova_ricerca,callback:null});var msg="<p>"+myZanichelliLocale.scegli_istituto+"</p>";msg+="<ul id=\"modalLinkList\">";target="";for(var i in linkList)
{if(!linkList[i])continue;msg+="<li id='"+i+"'>";names=linkList[i].split(",");msg+="<input id='school"+i+"' name='school' type='radio' value='"+names[0]+"' />";msg+="<label for='school"+i+"'>"+names[1]+"</label></li>";}
msg+="</ul>";myZanichelli.showModalAlert(msg,buttons,"list");}}
var passwordSender;myZanichelli.initCheckPassword=function()
{$("#user_password").keyup(function(){var value=$(this).val();if(value.length>5)
{if(typeof(passwordSender)=='object')
{passwordSender.abort();}
passwordSender=$.ajax({type:'POST',url:Glizy.ajaxUrl+"CheckPasswordStrength",dataType:"json",data:{loginpsw:$(this).val()},success:function(data){if(data&&data.result)
{$("#pwdCheckResult").text(data.result.result);var cssClass="checkPswBase checkPsw_"+data.result.score;$("#pwdCheckResult").removeClass();$("#pwdCheckResult").addClass(cssClass);}}});}
else
{$("#pwdCheckResult").text(myZanichelliLocale.password_troppo_breve);var cssClass="checkPswBase checkPsw_1";$("#pwdCheckResult").removeClass();$("#pwdCheckResult").addClass(cssClass);}});}
myZanichelli.initRegistrationForm=function(formName,controller)
{$("#"+formName).validationEngine("attach",{validationEventTrigger:"none",scroll:false,showAllErrors:false,onValidationComplete:function(form,r){if(r)
{myZanichelli.ajax({type:'POST',url:Glizy.ajaxUrl+"registration."+controller,dataType:"json",data:$("#"+formName).serialize(),success:function(data){if(data&&data.result)
{if(data.result.success)
{location.assign(data.result.result);}
else
{var buttons=[];buttons.push({label:myZanichelliLocale.Chiudi,callback:null});myZanichelli.showModalAlert(data.result.result,buttons,"warning");}}}});}
return false;}});}
myZanichelli.ajax=function(options)
{var removeOverlayOnSuccess=options.removeOverlayOnSuccess!=null?options.removeOverlayOnSuccess:true;$('#loading').show();var successCallback=options.success?options.success:function(){};options.success=function(data)
{if(removeOverlayOnSuccess)$('#loading').hide();successCallback(data);}
$.ajax(options);}
myZanichelli.showModalIframe=function(src)
{src+=src.indexOf("?")==-1?"?":"";$.modal('<iframe src="'+src+'&modal=true" height="448" width="828">',{closeHTML:'<a class="modalCloseImg" title="Chiudi">Chiudi</a>',close:true,containerCss:{backgroundColor:"#fff",borderColor:"#fff",height:450,padding:0,width:830,overflow:"visible","box-shadow":"0 0 5px #606060","-moz-box-shadow":"0 0 5px #606060","-webkit-box-shadow":"0 0 5px #606060"},overlayClose:true});}
myZanichelli.showLinkMenu=function($menu,top,left)
{$menu.css("top",top+"px");$menu.css("left",left+"px");$menu.show();var proxyHandleClickOutside=jQuery.proxy(function(){jQuery(document).unbind("click",proxyHandleClickOutside);proxyHandleClickOutside=null;$menu.hide();},null);jQuery(document).bind("click",proxyHandleClickOutside);}
$(document).ready(function(){$('span.link a').click(function(e){e.preventDefault();myZanichelli.showModalIframe(e.target.href);});$('div.boxCollapsible h3').each(function(index,el){var $el=$(el);$el.click(function(e){e.preventDefault();if($el.hasClass("expand"))
{$el.removeClass("expand");}
else
{$el.addClass("expand");}
if($el.next().hasClass("inner"))
{$el.next().slideToggle();}
else
{$el.next().next().slideToggle();}});$el.addClass("expand");if($el.next().hasClass("inner"))
{$el.next().hide();}
else
{$el.next().next().hide();}});$("div.favorite").each(function(index,el){var $el=$(el);$el.click(function(e){e.preventDefault();var cssClass="starFavorite";var options={opera_idOpera:$el.data("opera_idOpera"),setFavorite:!$el.hasClass(cssClass)};myZanichelli.ajax({type:"POST",url:Glizy.ajaxUrl+"userPages.SetFavorite",dataType:"json",data:options,success:function(data){if(options.setFavorite)
{$el.addClass(cssClass);}
else
{$el.removeClass(cssClass);}}});});});var handleMultilink=function(e){e.preventDefault();e.stopPropagation();var $target=$(e.currentTarget);var $menu=$target.parent().parent().find("div.link");var top,left;if(e.currentTarget.tagName=="IMG")
{top=10;left=-67;}
else
{top=25;left=0;}
top+=(e.pageY-$target.offset().top);myZanichelli.showLinkMenu($menu,top,left);};$("h5.multilink").click(handleMultilink);$("img.multilink").click(handleMultilink);});
