
var supersleight=false;function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p){d.MM_p=new Array();}
var i;var j=d.MM_p.length;var a=MM_preloadImages.arguments;for(i=0;i<a.length;i++){if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}}}
function preloadImages(imagesLink){if(document.images){var images=[]
var i=0
while(i<imagesLink.length){images[i]=new Image();images[i].src=imagesLink[i]
i++}}}
sfondo=1;function cambia_sfondo(){if(sfondo==3){sfondo=1;}else{sfondo++;}
obj=document.getElementById("contenuto");obj.style.backgroundImage="url(img/sfondo"+sfondo+".gif)";}
function rollOver(obj,img){return function(){if(obj.hasClassName('img_rollover')){obj.src=img;if(supersleight&&img.match(/\.png/i)!==null){supersleight.aggiorna(obj);}}}}
function attiva_rollover(obj){try{filtro=obj.style.filter;if(supersleight&&filtro){inizio="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='";src=filtro.substr(inizio.length);src=src.substr(0,src.indexOf("'"));}else{src=obj.getAttribute('src');}
if(src.match(/\_on./i)===null){nome_img=src.replace(/(.+)\.(\w+)\??[0-9]*$/,"$1");estensione_img=src.replace(/.*\/?[a-zA-Z0-9_-]+\.(\w+)\??[0-9]*$/,"$1");img_on=nome_img+"_on."+estensione_img;img_off=nome_img+"."+estensione_img;MM_preloadImages(img_on);Event.observe(obj,'mouseover',rollOver(obj,img_on));Event.observe(obj,'mouseout',rollOver(obj,img_off));}}catch(e){alert("An exception occurred in attiva_rollover(). Error name: "+e.name
+". Error message: "+e.message)}}
function cerca_rollover(){if($$('.img_rollover')){classi=$$('.img_rollover');$$('.img_rollover').each(function(obj){attiva_rollover(obj);});}}
function cerca_rollover_on_specific_kidget(kidId){if($$('#'+kidId+' .img_rollover ')){classi=$$('#'+kidId+' .img_rollover');$$('#'+kidId+' .img_rollover').each(function(obj){attiva_rollover(obj);});}}
function cerca_rollover_outside_kidget(kidClass){imgRolloverOnPage=$$('.img_rollover');var kidgets=$$(' .'+kidClass);imgRolloverInKidgetS=new Array();kidgets.each(function(kidget){imgRolloverInKidget=kidget.getElementsByClassName('img_rollover')
for(i=0;i<imgRolloverInKidget.length;i++){imgRolloverInKidgetS.push(imgRolloverInKidget[i]);}})
imgRolloverInKidgetS.each(function(elToRemove){imgRolloverOnPage=imgRolloverOnPage.without(elToRemove)})
imgRolloverOnPage.each(function(obj){attiva_rollover(obj);})}
function scroll_func(e){if(document.compatMode&&document.compatMode!="BackCompat"&&BrowserDetect.browser!='Safari'){var body=document.documentElement;}else{var body=document.body;}
if((body.scrollTop+$('tabFlaps').offsetHeight)<=$('mypage').offsetHeight){$('tabFlaps').style.top=body.scrollTop+"px";}else{$('tabFlaps').style.top=($('mypage').offsetHeight)-$('tabFlaps').offsetHeight+"px";}}
function blocca_contextmenu(e){Event.stop(e);}
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));},isIPad:function(){return(this.browser=="Safari"&&this.OS=="iPad");},isIPhone:function(){return(this.browser=="Safari"&&this.OS=="iPhone");},isIPod:function(){return(this.browser=="Safari"&&this.OS=="iPod");},supportHTML5:function(){return(this.isIPad()||this.isIPhone()||this.isIPod());},dataBrowser:[{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"Paparazzi",identity:"Paparazzi"},{string:navigator.userAgent,subString:"AdobeAIR",identity:"AdobeAIR"},{string:navigator.vendor,subString:"Apple",versionSearch:"Version",identity:"Safari"},{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"},{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"},{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.platform,subString:"MacPPC",identity:"Mac"},{string:navigator.platform,subString:"MacIntel",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"},{string:navigator.platform,subString:"iPod",identity:"iPod"},{string:navigator.platform,subString:"iPhone",identity:"iPhone"},{string:navigator.platform,subString:"iPad",identity:"iPad"}]};BrowserDetect.init();function validateEmail(email)
{if(email.length<=0)
{return false;}
var splitted=email.match("^(.+)@(.+)$");if(splitted==null)return false;if(splitted[1]!=null)
{var regexp_user=/^\"?[\w-_\.]*\"?$/;if(splitted[1].match(regexp_user)==null)return false;}
if(splitted[2]!=null)
{var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;if(splitted[2].match(regexp_domain)==null)
{var regexp_ip=/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;if(splitted[2].match(regexp_ip)==null)return false;}
return true;}
return false;}
function detectBrowser(args)
{var errore_browser=true;allowedBrowsersDefault=[{name:'Safari',minVer:3},{name:'Firefox',minVer:2},{name:'Explorer',minVer:7},{name:'Chrome'},{name:'Paparazzi'},{name:'AdobeAIR'}]
if((typeof args!='undefined')&&(typeof args.skipBrowser!='undefined')&&(args.skipBrowser==true)){errore_browser=false;}else{allowedBrowsers=((typeof args=='undefined')||(typeof args.allowedBrowsers=='undefined'))?allowedBrowsersDefault:args.allowedBrowsers
allowedBrowsers.each(function(b){if((BrowserDetect.browser==b.name)&&((typeof b.minVer=='undefined')||(BrowserDetect.version>=b.minVer))){errore_browser=false;throw $break;}})}
var errore_flash=false;var errore_cookie=true;var cookieEnabled=(navigator.cookieEnabled)?true:false
if(cookieEnabled){var tmpcookie=new Date();chkcookie=(tmpcookie.getTime()+'');document.cookie="chkcookie="+chkcookie+"; path=/";if(document.cookie.indexOf(chkcookie,0)<0){errore_cookie=true;}else{errore_cookie=false;}}else{errore_cookie=true;}
array_errori=Array();array_errori['errore_browser']=errore_browser;array_errori['errore_flash']=errore_flash;array_errori['errore_cookie']=errore_cookie;return array_errori;}
function validateBrowser(args)
{array_errori=detectBrowser(args);if(array_errori['errore_browser']){return false;}
if(array_errori['errore_flash']){return false;}
if(array_errori['errore_cookie']){return false;}
return true;}
MPCookies={create:function(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";},read:function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;},erase:function(name){createCookie(name,"",-1);}};function getTimeZone(){var rightNow=new Date();var jan1=new Date(rightNow.getFullYear(),0,1,0,0,0,0);var temp=jan1.toGMTString();var jan2=new Date(temp.substring(0,temp.lastIndexOf(" ")-1));var std_time_offset=(jan1-jan2)/(1000*60*60);return std_time_offset
var june1=new Date(rightNow.getFullYear(),6,1,0,0,0,0);temp=june1.toGMTString();var june2=new Date(temp.substring(0,temp.lastIndexOf(" ")-1));var daylight_time_offset=(june1-june2)/(1000*60*60);if(std_time_offset==daylight_time_offset){return std_time_offset;}else{return std_time_offset-1;}}
function checkEmailPattern(args){if(args.email==null||args.email.strip()==""||args.email.indexOf('@')==-1){return false;}
var account=args.email.split('@')[0];if(account==null||account.strip()==""||account.strip().indexOf(" ")!=-1){return false;}
var domain=args.email.split('@')[1];if(domain==null||domain.strip()==""||domain.strip().indexOf(" ")!=-1||domain.indexOf('.')==-1){return false;}else{domain='@'+domain;}
var rejectedDomains=['gmail.it','g-mail','@otmail','hotmaill','yaoo','yaooh','yhoo','yaho.','fastewebnet','@ibero.it','yhaoo','libero.net','libero.com','@lice.it'];var rejectedAccounts=['www'];var isOk=true;rejectedDomains.each(function(rejDom){if(domain.indexOf(rejDom)!=-1){isOk=false;throw $break;}})
rejectedAccounts.each(function(rejAcc){if(account.indexOf(rejAcc)!=-1){isOk=false;throw $break;}})
return isOk;}
var UpperBar=Class.create({initialize:function(){this.mainDiv=$('upper_bar');this.browserAlerts=$('browser_alerts');this.browserNotSupportedAdvise=$('browser_not_supported_adv');this.javascriptNotEnabledAdvise=$('javascript_not_enabled_adv');this.cookiesNotEnabledAdvise=$('cookies_not_enabled_adv');this.iPadBetaAdvise=$("ipad_beta_adv");this.components=new Hash();},showAlert:function(args){var showBar=true
if(args.component){if((args.component=='browser_alert')&&(args.alert)){if((typeof this.browserAlerts!='undefined')&&(typeof this.browserNotSupportedAdvise!='undefined')&&(typeof this.javascriptNotEnabledAdvise!='undefined')&&(typeof this.cookiesNotEnabledAdvise!='undefined')){this.browserNotSupportedAdvise.hide();this.javascriptNotEnabledAdvise.hide();this.cookiesNotEnabledAdvise.hide();switch(args.alert){case'browser_not_supported':this.browserNotSupportedAdvise.show();break;case'javascript_not_enabled':this.javascriptNotEnabledAdvise.show();break;case'cookies_not_enabled':this.cookiesNotEnabledAdvise.show();break;case'iPad_beta':this.iPadBetaAdvise.show();break;default:showBar=false;null;}
showBar?this.browserAlerts.show():this.browserAlerts.hide();}}else{showBar=false;}}
showBar?this.mainDiv.show():this.mainDiv.hide();},hideBar:function(){Effect.BlindUp(this.mainDiv,{duration:0.7});}})
function generalReloadPage(){window.location.reload(true);}
function getNextHighestZindex(obj){var highestIndex=0;var currentIndex=0;var elArray=Array();if(obj){elArray=obj.getElementsByTagName('*');}else{elArray=document.getElementsByTagName('*');}
for(var i=0;i<elArray.length;i++){if(elArray[i].currentStyle){currentIndex=parseFloat(elArray[i].currentStyle['zIndex']);}else if(window.getComputedStyle){currentIndex=parseFloat(document.defaultView.getComputedStyle(elArray[i],null).getPropertyValue('z-index'));}
if(!isNaN(currentIndex)&&currentIndex>highestIndex){highestIndex=currentIndex;}}
return(highestIndex+1);}
var Overlayer=Class.create({initialize:function(userManager){this.container=$('overlayer');this.userManager=userManager;this.banner_now=null;this.banner_last=null;this.pe=null;this.periodicalUpdateInterval=8;},show:function(){if(this.container==null){this.container=$('overlayer');}
this.container.show();},hide:function(options){if((typeof options!='undefined')&&(options.stop==true)){this.stopBanner();}
new Effect.Opacity($('overlayer'),{duration:0.3,from:1,to:0,afterFinish:function(effect){$('overlayer').hide()}});},startBanner:function(options){if(options!=null&&options.flashBanner==true){}else{if($$('#overlayer_int .banner').length){this.banner_now=1;var objs=$$('#overlayer_int .banner');this.banner_last=objs.last().getAttribute('id').replace('banner_','');this.pe=new PeriodicalExecuter(this.update.bindAsEventListener(this),this.periodicalUpdateInterval);}}},stopBanner:function(){if(this.pe!=null){this.pe.stop()}
var flashContainer=$$("#overlayer_int .flash")[0]
if(flashContainer!=null){flashContainer.innerHTML="";}},update:function(){this.scrollBanner({direction:'next'});},scrollBanner:function(options){var direction=(options!=null&&['next','prev'].indexOf(options.direction)!=-1)?options.direction:'next';var next=(direction=='next')?(this.banner_now+1<=this.banner_last?this.banner_now+1:1):(this.banner_now-1<1?this.banner_last:this.banner_now-1)
Effect.Fade('banner_'+this.banner_now);Effect.Appear('banner_'+next);this.banner_now=next;},skipNextBtnClicked:function(options){this.pe.stop();this.scrollBanner({direction:'next'});this.pe=new PeriodicalExecuter(this.update.bindAsEventListener(this),this.periodicalUpdateInterval);},skipPrevBtnClicked:function(){this.pe.stop();this.scrollBanner({direction:'prev'});this.pe=new PeriodicalExecuter(this.update.bindAsEventListener(this),this.periodicalUpdateInterval);},goBtnClicked:function(){switch(this.banner_now){case 1:this.userManager.goToPage({page:'friends',allowLogin:true});this.hide({stop:true});break;case 2:this.userManager.goToPage({page:'profile',tab:'magic_spell',allowLogin:true});this.hide({stop:true});break;case 3:this.userManager.goToPage({page:'profile',tab:'avatar',allowLogin:true});this.hide({stop:true});}}})
function getStringDimension(args){var string=args.string;var maxDim=args.maxDim;var dimension=0;if(string.strip().length>0){var stringToArray=string.toArray();var character=null;for(var i=0;i<stringToArray.length;i++){switch(stringToArray[i].toUpperCase()){case"M":dimension+=maxDim;break;case"W":dimension+=maxDim;break;case"I":dimension+=parseInt(maxDim*0.5);break;case"J":dimension+=parseInt(maxDim*0.5);break;case"L":dimension+=parseInt(maxDim*0.5);break;default:dimension+=parseInt(maxDim*0.8);}}}
return(dimension);}
var MPDownloadButton=Class.create({initialize:function(params){this.button=new Hash;this.download=new Hash;this.kidget=new Hash;this.user=new Hash;this.button.classes=params.button.classes?params.button.classes:'';this.button.html=params.button.html?params.button.html:'';this.button.positions=params.button.positions?params.button.positions.split(','):alert('Devi definire almeno una posizione per il pulsante!');this.download.file=params.download.file?params.download.file:alert('Andiamo in produzione senza un file da scaricare? Ne sei sicuro?');this.download.locale=params.download.locale?params.download.locale:false;this.download.path=params.download.path?params.download.path:alert('Non c\'è un file da scaricare!');this.download.throughPopup=params.download.throughPopup?params.download.throughPopup:false;this.download.tracking=params.download.tracking?params.download.tracking:true;this.kidget.id=params.kidget.id?params.kidget.id:alert('Devi dirmi di che kidget si tratta! L\'ID!!!');this.kidget.istance=params.kidget.istance?params.kidget.istance:alert('Devi dirmi l\'ID d\'istanza del Kidget!');this.user.lang=pageTabs.getUserLang()?pageTabs.getUserLang():'it';this.user.canDownload=pageTabs.userCanDownloadMedia();this.build(this.button.positions);this.bind(params.specificBind);},build:function(positions){for(var i=0;i<Number(positions.length);i++){if(this.button.html==''){this.button.html+='<a ';this.button.html+='href="'+(this.user.canDownload?(!this.download.throughPopup?this.download.path:'javascript:void(0)'):'javascript:void(0)')+'" ';this.button.html+=this.user.canDownload?'target="_blank" ':'';this.button.html+='class="MPDownloadButton scarica-'+this.user.lang+' '+(!this.user.canDownload?'cant-download':'')+' '+this.button.classes+'"';this.button.html+='>';this.button.html+=i18n.stringLocale('download_and_play','dialog');this.button.html+=this.user.canDownload?'':'<span>'+i18n.stringLocale('cant_download','dialog')+'</span>';this.button.html+='</a>';}
$$('#'+this.kidget.istance+' '+positions[i])[0].insert(this.button.html);}},bind:function(specificBind){Event.observe($$('#'+this.kidget.istance+' .scarica-'+this.user.lang)[0],'click',this.clicked.bindAsEventListener(this));if(typeof(specificBind)=='function'){specificBind();}},clicked:function(){if(this.user.canDownload){if(this.download.tracking){eventTracking.trackingDownloadPDF(this.kidget.id,this.download.file);}
if(this.download.throughPopup){window.open(this.download.path,"Download_completo","menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");}}else{}}});var MPEventTracking=Class.create({initialize:function(){this.categoriesHash={video:{profile:"VIDEO | PROFILE",stop:"VIDEO"},game:{profile:"GAME | PROFILE",stop:"GAME"},pdf:{profile:"PDF | PROFILE",kidget:"PDF | KIDGET",fan_award:"PDF | FAN-AWARD",stop:"PDF"},wallpaper:{award:{award:"WALLPAPER | AWARD ",teaser:"WALLPAPER | AWARD | TEASER "},stop:"WALLPAPER"},theme:{award:{teaser:"FF_THEME | AWARD | TEASER "},stop:"THEME"},emoticons:{award:{teaser:"MSN_EMOTICONS | AWARD | TEASER "},stop:"EMOTICONS"},msn_background:{award:{teaser:"MSN_BACKGROUNDS | AWARD | TEASER "},stop:"BACKGROUNDS"}}
this.actionsHash={download:"DOWNLOAD",play:"PLAY"}},track:function(params){var category=params.category;if(params.kidgetId){category+=" | KIDGET | "+params.kidgetId;}
this.doTracking(category,params.action,params.urlToFIle,params.optionalValue)
if(params.throughPopup&&params.downloadable){window.open(params.urlToFIle,"Download_completo","menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");}},doTracking:function(category,action,optional_label,optional_value){optional_label=typeof(optional_label)!='undefined'?optional_label:'nolabel';optional_value=typeof(optional_value)!='undefined'?optional_value:'novalue';if(typeof(pageTracker)!='undefined'){pageTracker._trackEvent(category,action,optional_label);}else{_gaq.push(['_trackEvent',category,action,optional_label])}},trackingDownloadPDF:function(params){this.doTracking(params.string,this.action.get(params.action),params.urlToFile);}});var eventTracking=new MPEventTracking();var CountDown=Class.create({initialize:function(options){this.pe=null
this.dateNow=null
this.expireYear=options.expireYears||0
this.expireMounth=options.expireMounth||0
this.expireDay=options.expireDay||0
this.expireHour=options.expireHour||0
this.expireMinute=options.expireMinute||0
this.expireSecond=options.expireSecond||0
this.intervalTimesPossible=["days","hours","minutes","seconds"]
this.dateForExpire=new Date(this.expireYear,this.expireMounth,this.expireDay,this.expireHour,this.expireMinute,this.expireSecond)
this.elements=new Hash
this.format=options.formatOfTime
this.numbersWithImage=options.numberShowedByImages||null
this.generalPath=options.generalPathForImage||""
this.elements.set("years",options.divElementForYears||"")
this.elements.set("mounth",options.divElementForMonths||"")
this.elements.set("days",options.divElementForDays||"")
this.elements.set("hours",options.divElementForHours||"")
this.elements.set("minutes",options.divElementForMinutes||"")
this.elements.set("seconds",options.divElementForSeconds||"")
this.callBack=options.callback||null
this.intervalTime=1
this.peForCountDown=null
this.peForCallback=null},start:function(){this.peForCountDown=new PeriodicalExecuter(this.countDown.bind(this),this.intervalTime);if(this.callBack){this.peForCallback=new PeriodicalExecuter(this.callBack.callback.bind(this),(this.callBack.interval/1000));}},countDown:function(){this.dateNow=new Date()
var timeRemainingInSeconds=(this.dateForExpire.getTime()-this.dateNow.getTime())/1000
var elementForCalculate=null
for(var i=0;i<this.intervalTimesPossible.size();i++){elementForCalculate=this.elements.get(this.intervalTimesPossible[i])
if(elementForCalculate!=""&&elementForCalculate!=undefined&&elementForCalculate!=null){this.insertStringFromattedIntoElement(elementForCalculate,this.buildStringFormattedForElement(elementForCalculate,this.buildStringArrayFromTimeToCalculate(timeRemainingInSeconds,this.intervalTimesPossible[i])))}}},buildStringArrayFromTimeToCalculate:function(timeRemainingInSeconds,kindOfInterval){var intervalCalculated=0
switch(kindOfInterval){case"days":intervalCalculated=60*60*24
break;case"hours":intervalCalculated=60*60
break;case"minutes":intervalCalculated=60
break;case"seconds":intervalCalculated=1
break;}
var timeFormatted=[]
var timeEffective=((Math.floor(timeRemainingInSeconds/intervalCalculated))).toString();var j=0
timeEffective=timeEffective.toArray()
while(j<timeEffective.size()){timeFormatted[j]=timeEffective[j]
j++}
return timeFormatted},insertStringFromattedIntoElement:function(element,formattedString){var i=0
if(element.size()==1){var string=""
while(i<formattedString.size()){string+=formattedString[i]
i++}
element[0].innerHTML=string}else{for(i=element.size()-1;i>=0;i--){element[i].innerHTML=(formattedString[i]!=undefined)?formattedString[i]:"0"}}},buildStringFormattedForElement:function(elementToInsert,arrayStringFromTime){var intervalTimeFromatted=[]
if(elementToInsert.size()!=1){var difference=elementToInsert.size()-arrayStringFromTime.length
var i=0
for(i;i<difference;i++){intervalTimeFromatted[i]="0"}
var j=0
for(i;i<arrayStringFromTime.length+difference;i++){intervalTimeFromatted[i]=arrayStringFromTime[j]
j++}}else{intervalTimeFromatted=arrayStringFromTime}
return intervalTimeFromatted}});var SlidingBuilder=Class.create({initialize:function(options){this.slidingContainer=new SlidingContainer({imageContainer:options.imageContainer,allTheImages:options.allTheImages,imageSet:options.imageSet,effectForSliding:options.effectForSliding,imagesHasPreview:options.imagesHasPreview,choiceContainer:options.choiceContainer,divImageInformation:options.divImageInformation,image_preview:options.image_preview})
this.slidingContainer.build()
this.effectSliding=new EffectSliding({objectSlidingContainer:this.slidingContainer,imageContainer:options.imageContainer,effectMovement:options.effectMovement,effectFading:options.effectFading,directionOfEffect:options.directionOfEffect,scrollForSlice:$$('.imageTeaser')[0].scrollWidth,imageSet:options.imageSet})
this.chrono=new Chrono({effectObject:this.effectSliding,image_has_preview:options.image_preview,imageSet:options.imageSet,slidingContainer:this.slidingContainer,nrOfSlice:options.imageContainer.children.length,durationOfEffect:options.durationOfEffect,divImageInformation:options.divImageInformation?true:false,intervalTime:options.intervalTime})},build:function(){this.chrono.checkLoadedImages()
this.chrono.start()}})
var SlidingContainer=Class.create({initialize:function(options){this.allTheImages=options.allTheImages
this.imageContainer=options.imageContainer
this.originalLenght=this.allTheImages.size()
this.imageSet=options.imageSet||"sliding"
this.imageDimensions=options.imageDimension||null
this.imagePreview=options.image_preview
this.effectForSliding=options.effectForSliding||"scroll"
options.imagesHasPreview?this.imagesHasPreview=true:this.imagesHasPreview=false
options.choiceContainer?this.choiceContainer=options.choiceContainer:this.choiceContainer=null
options.divImageInformation?this.divImageInformation=options.divImageInformation:this.divImageInformation=null},emptyFunction:function(){},build:function(options){this.buildSlidingImage()
this.choiceContainer?this.buildDirectChoiceElement():null
this.divImageInformation?this.buildDivImageInformation():null},buildSlidingImage:function(){this.imageContainer.insert({bottom:this.htmlForImages()})},insertSlidingImage:function(){this.buildSlidingImage()},removeOldsSlice:function(){var i=0
while(i<this.originalLength){delete this.imageContainer.children[i]
i++}},buildDirectChoiceElement:function(){this.choiceContainer.insert({bottom:this.htmlForDirectChoiceElement()})},buildDivImageInformation:function(){this.divImageInformation.insert({bottom:'<span class="title"></span><span class="subTitle"></span>'})},getStyleForImage:function(show){if(this.imageSet=="fading"){if(show){return"position:absolute;  -moz-opacity: 0; -khtml-opacity: 0; opacity:1; filter:alpha(opacity=1);"}
return"position:absolute; -moz-opacity: 0 -khtml-opacity: 0; opacity:0; filter:alpha(opacity=0);display:none;"}else if(this.imageSet=="sliding"){return"position:relative; float:left; margin:0px;"}
return null},htmlForImages:function(){var htmlForAllImages=''
var htmlForSingleImage=''
for(var i=0;i<this.allTheImages.size();i++){htmlForAllImages+='<a id=\"image_'+this.allTheImages[i].id+'\" class=\"imageTeaser\" style=\"'+this.getStyleForImage((i==0)?true:false)+'\" '
this.allTheImages[i].in_new_window?htmlForSingleImage+=' target=\"_blank\"':htmlForSingleImage+=''
this.allTheImages[i].link?htmlForSingleImage+=' href=\"'+this.allTheImages[i].link+'\">':htmlForSingleImage+='>'
this.allTheImages[i].url?htmlForSingleImage+='<img class=\"imageTeaser\" src=\"'+this.allTheImages[i].url+'\" ':htmlForSingleImage+=''
this.allTheImages[i].title?htmlForSingleImage+=' alt=\"'+this.allTheImages[i].title+'\"/>':htmlForSingleImage+='>'
htmlForAllImages=htmlForAllImages+htmlForSingleImage+'</a>'
htmlForSingleImage=""}
if(this.imageSet=="sliding"){htmlForAllImages+='<a id=\"image_'+this.allTheImages[0].id+' clone\" class=\"\" style=\"'+this.getStyleForImage((i==0)?true:false)+'\" '
this.allTheImages[0].in_new_window?htmlForSingleImage+=' target=\"_blank\"':htmlForSingleImage+=''
this.allTheImages[0].link?htmlForSingleImage+=' href=\"'+this.allTheImages[0].link+'\">':htmlForSingleImage+='>'
this.allTheImages[0].url?htmlForSingleImage+='<img class=\"imageTeaser\" src=\"'+this.allTheImages[0].url+'\" ':htmlForSingleImage+=''
this.allTheImages[0].title?htmlForSingleImage+=' alt=\"'+this.allTheImages[0].title+'\"/>':htmlForSingleImage+='>'
htmlForAllImages=htmlForAllImages+htmlForSingleImage+'</a>'
htmlForSingleImage=""}
return htmlForAllImages},htmlForDirectChoiceElement:function(){var htmlForAllDirectChoice=''
var htmlForSingleElement=''
for(var i=0;i<this.allTheImages.size();i++){if(this.imagePreview){htmlForSingleElement='<div class=\"singleDirectChoice direct_choice_'+this.allTheImages[i].id+'\">'
this.allTheImages[i].url_to_preview?htmlForSingleElement+='<img src=\"'+this.allTheImages[i].url_to_preview+'\" style=\"width:100%;height:100%\" alt=\"'+this.allTheImages[i].title+'\" />':htmlForSingleElement+='<img src=\"'+this.allTheImages[i].url+'\" style=\"width:100%;height:100%\" alt=\"'+this.allTheImages[i].title+'\" />'
htmlForAllDirectChoice=htmlForAllDirectChoice+htmlForSingleElement+'</div>'}else{htmlForSingleElement='<button class=\"singleDirectChoice direct_choice_'+this.allTheImages[i].id+'\">'
htmlForAllDirectChoice=htmlForAllDirectChoice+htmlForSingleElement+'</button>'}}
return htmlForAllDirectChoice},insertImageInformation:function(nrSlice){this.divImageInformation.children[0].innerHTML=this.allTheImages[nrSlice].title
this.divImageInformation.children[1].innerHTML=this.allTheImages[nrSlice].subtitle},insertImage:function(){this.imageContainer.style.right="0px"
this.imageContainer.update(this.htmlForImages())},setOpacityForElement:function(sliceElement){sliceElement.show()
sliceElement.style.opacity="opacity:0.0"
sliceElement.style.filter="alpha(opacity=0.0)"
sliceElement.style.MozOpacity=0;sliceElement.style.KhtmlOpacity=0;}});var Chrono=Class.create({initialize:function(options){this.effectObject=options.effectObject
this.intervalTime=options.intervalTime||1
this.durationOfEffect=options.durationOfEffect,this.slidingContainerObject=options.slidingContainer;this.nrOfSlice=options.nrOfSlice
this.directChoose=this.slidingContainerObject.choiceContainer
this.imageHasPreview=options.image_has_preview
this.divImageInformation=options.divImageInformation?true:false
this.prevSlice=0
this.imageSet=options.imageSet
this.currentSlice=0
this.nextSlice=1
this.linearSliding=options.linearSliding||true
this.sliceChoosebyUser=false
this.currentPeriodicalExecuter=0
this.periodicalExecuter=[]
this.periodicalExecuterForClick=null
this.i=0},deleteLoadSpinner:function(){if($$('.imagesList')[0]!=null){$$('.teaser_preload_spinner')[0].hide()
this.periodicalExecuterForClick.stop()}},checkLoadedImages:function(){this.periodicalExecuterForClick=new PeriodicalExecuter(this.deleteLoadSpinner.bind(this),0.1);},start:function(){this.effectObject.update(this)
this.showSlideInformation()
this.setImageStausForDirectChoose()
this.directChoose?this.bindDirectChoose({all:true}):null
this.periodicalExecuter[this.currentPeriodicalExecuter]=new PeriodicalExecuter(this.callSlidingObject.bind(this),this.intervalTime);},imgOver:function(window,element,isImg){if(isImg){element.style.borderWidth='2px'
element.style.borderStyle='solid'
element.style.borderColor='#f2e400'}else{element.style.backgroundColor='#aaaaaa'}},imgOut:function(window,element,isImg){if(isImg){element.style.borderWidth='2px'
element.style.borderStyle='solid'
element.style.borderColor='#FFFFFF'}else{element.style.backgroundColor='#2cbfde'}},bindDirectChoose:function(options){if(options.all){var i=0
var singleElement=null
while(i<this.directChoose.children.length){singleElement=this.directChoose.children[i]
Event.observe(singleElement,'mouseover',this.imgOver.bindAsEventListener(this,singleElement,this.imageHasPreview))
Event.observe(singleElement,'mouseout',this.imgOut.bindAsEventListener(this,singleElement,this.imageHasPreview))
Event.observe(singleElement,'click',this.sliceChoose.bindAsEventListener(this,i))
i++}}else{var singleElement=this.directChoose.children[options.idElement]
singleElement.style.cursor="pointer"
Event.observe(singleElement,'mouseover',this.imgOver.bindAsEventListener(this,singleElement,this.imageHasPreview))
Event.observe(singleElement,'mouseout',this.imgOut.bindAsEventListener(this,singleElement,this.imageHasPreview))
Event.observe(singleElement,'click',this.sliceChoose.bindAsEventListener(this,options.idElement))}},stopObserve:function(){var singleElement=this.directChoose.children[(this.currentSlice==this.nrOfSlice-1)?0:this.currentSlice]
singleElement.style.cursor=""
Event.stopObserving(singleElement,'mouseover')
Event.stopObserving(singleElement,'mouseout')
Event.stopObserving(singleElement,'click')},sliceChoose:function(window,elementChoose){if(elementChoose!=this.currentSlice){this.nextSlice=elementChoose
this.sliceChoosebyUser=true
this.callEffectAfterClick()}},callEffectAfterClick:function(){if(this.effectIsFinished){this.periodicalExecuter[this.currentPeriodicalExecuter].stop()
this.callSlidingObject()
this.currentPeriodicalExecuter++
this.periodicalExecuter[this.currentPeriodicalExecuter]=new PeriodicalExecuter(this.callSlidingObject.bind(this),this.intervalTime);}},effectFinished:function(){this.effectIsFinished=true
this.showSlideInformation()
this.setImageStausForDirectChoose()},setImageStausForDirectChoose:function(){if(this.directChoose){this.stopObserve()
this.imgOut(null,this.slidingContainerObject.choiceContainer.children[this.checkForSlideToPass(this.prevSlice)],this.imageHasPreview)
this.imgOver(null,this.slidingContainerObject.choiceContainer.children[this.checkForSlideToPass(this.currentSlice)],this.imageHasPreview)
this.bindDirectChoose({idElement:this.checkForSlideToPass(this.prevSlice)})}},showSlideInformation:function(){if(this.divImageInformation)
this.slidingContainerObject.insertImageInformation(this.checkForSlideToPass(this.currentSlice))},stop:function(){this.periodicalExecuter.stop()},checkForSlideToPass:function(slide){if(this.imageSet=="fading")
return slide
else
return(slide==this.nrOfSlice-1)?0:slide},callSlidingObject:function(){this.effectIsFinished=false
this.effectObject.effect(this.currentSlice,this.nextSlice,this.durationOfEffect,0.2)
this.setSliceToShow()
this.checkForResetStatus()},setSliceToShow:function(){this.prevSlice=this.currentSlice
this.currentSlice=this.nextSlice;if(this.linearSliding){if(this.sliceChoosebyUser){this.sliceChoosebyUser=false
this.effectObject.setOpacityForElement($(this.slidingContainerObject.imageContainer.children[this.currentSlice].id))}
this.nextSlice++;}else{this.nextSlice=this.getRandomNumber();}},getRandomNumber:function(){var random=this.nrOfSlice;while(random==this.currentSlice){random=Math.floor(Math.random()%(this.nrOfSlice-1))}
return random},checkForResetStatus:function(){if(this.nextSlice==this.nrOfSlice){if(this.imageSet=="fading")this.nextSlice=0
else this.nextSlice=1
this.effectObject.setOpacityForElement($(this.slidingContainerObject.imageContainer.children[this.currentSlice].id))}}})
var EffectSliding=Class.create({initialize:function(options){this.sliceContainer=options.objectSlidingContainer.imageContainer
this.numberOfSlice=this.sliceContainer.children.length
this.effectMovement=options.effectMovement||false
this.effectFading=options.effectFading||false
this.directionOfEffect=options.directionOfEffect||'right'
this.imageSet=options.imageSet
this.objectSlidingContainer=options.objectSlidingContainer
this.currentPosition=0
this.chrono=null
this.effectFinished=0
this.scrollForSlice=options.scrollForSlice
this.currentPage=this.currentPosition/this.scrollForSlice},update:function(object){this.chrono=object},effect:function(sliceToShow,nextSliceToShow,duration,delay){if(this.imageSet=="sliding"){this.morph(sliceToShow,nextSliceToShow,duration,delay)}else{this.fading(sliceToShow,nextSliceToShow,duration)}},fading:function(currentSlice,nextSlice,duration){var that=this
var idCurrentSlice=this.sliceContainer.children[currentSlice].id
var elementNextSlice=$(this.sliceContainer.children[nextSlice].id)
this.setOpacityForElement(elementNextSlice)
var currentImage=$(idCurrentSlice)
var nextImage=$(elementNextSlice)
currentImage.fade({duration:duration,from:1,to:0.0,afterFinish:function(){}})
nextImage.fade({duration:duration,from:0,to:1.0,afterFinish:that.effectFinish.bind(that,currentSlice)})},effectFinish:function(){this.chrono.effectFinished()},setOpacityForElement:function(sliceElement){if(this.imageSet=="fading")
this.objectSlidingContainer.setOpacityForElement(sliceElement)},morph:function(currentSlice,nextSlice,duration,delay){this.currentPosition=this.scrollForSlice*nextSlice
var that=this;this.objectSlidingContainer.imageContainer.morph(that.directionOfEffect+": "+this.currentPosition+"px",{duration:duration,delay:0,afterFinish:function(){that.checkPositionSlice(that.currentPosition,nextSlice);that.effectFinish(that);}});},checkPositionSlice:function(currentPosition,nextSlice){if(currentPosition>0&&($(this.sliceContainer.children[nextSlice].id).id).split('clone')[1]!=null){this.objectSlidingContainer.insertImage()
this.currentPosition=0}},changeSliceAssets:function(){var i=0
var length=this.sliceContainer.children.length
var sliceCloned=Object.clone(this.sliceContainer.children)
while(i<this.sliceContainer.children.length-1){this.sliceContainer.children[i]=sliceCloned[length-1]
length--;i++;}
this.currentSlice=1
this.objectSlidingContainer.insertSlidingImage()
this.objectSlidingContainer.removeOldsSlice()}})


var TabDialogForm=Class.create({initialize:function(dialog){this.form=null;this.dialog=dialog;this.callbacks=new Hash();},bind:function(){this.controlEnterKey();},controlEnterKey:function(){this.form.onkeypress=this.checkEnterKey.bindAsEventListener(this);},checkEnterKey:function(event){if(event.keyCode==13){this.OkBtnClicked();Event.stop(event);return false;}else{return true;}},hide:function(){this.form.hide();},show:function(){this.form.show();},setCallbacks:function(callbacks){var hash=this.callbacks;Object.keys(callbacks).each(function(key){hash.set(key,callbacks[key])})}});var LoginForm=Class.create(TabDialogForm,{initialize:function($super,dialog){$super(dialog);this.nicknameInput=null;this.passwordInput=null;this.nicknameFieldBg=null;this.passwordFieldBg=null;this.forgotPasswordBtn=null;},loaded:function(isLoaded){if(isLoaded){this.form=$('tabDialog_loginForm');this.nicknameInput=$('tabDialog_loginForm_nickname');this.passwordInput=$('tabDialog_loginForm_password');this.nicknameFieldBg=$$('#tabDialog_loginForm_campoNickname .tabDialog_campoSfondo')[0];this.passwordFieldBg=$$('#tabDialog_loginForm_campoPassword .tabDialog_campoSfondo')[0];this.OKBtn=$('tabDialog_LoginForm_OkBtn');this.cancelBtn=$('tabDialog_LoginForm_cancelBtn');this.forgotPasswordBtn=$$('#tabDialog_loginForm_passwordDimenticata a')[0];}},bind:function($super){$super();this.OKBtn.onclick=this.OkBtnClicked.bindAsEventListener(this);this.cancelBtn.onclick=this.cancelBtnClicked.bindAsEventListener(this);this.forgotPasswordBtn.onclick=this.forgotPasswordBtnClicked.bindAsEventListener(this);if((arguments.length>0)&&(arguments[1].callbacks!=null)){this.setCallbacks(arguments[1].callbacks);}},OkBtnClicked:function(){if(this.callbacks.get('loginConfirmed')!=null){this.callbacks.get('loginConfirmed')({parameters:this.form.serialize()});}else{new Ajax.Request('/user/login',{asynchronous:true,evalScripts:true,parameters:this.form.serialize(),requestHeaders:{Accept:'text/x-json'},onComplete:this.checkLoginResponse.bindAsEventListener(this)})}},cancelBtnClicked:function(){if(this.callbacks.get('loginCancelled')!=null){this.callbacks.get('loginCancelled')();}else{pageTabs.cancelLoginForm();}},hide:function($super){$super();this.nicknameFieldBg.setStyle({position:'absolute'});this.passwordFieldBg.setStyle({position:'absolute'});},show:function($super){this.cleanFields();this.nicknameFieldBg.setStyle({position:'relative'});this.passwordFieldBg.setStyle({position:'relative'});if((arguments.length>1)&&(arguments[1].callbacks!=null)){this.setCallbacks(arguments[1].callbacks);}
$super();},cleanFields:function(){this.nicknameInput.value="";this.passwordInput.value="";},forgotPasswordBtnClicked:function(){this.callbacks.get('passwordForgotten')();},checkLoginResponse:function(request){if(this.callbacks.get('checkLoginResponse')!=null){this.callbacks.get('checkLoginResponse')(request);}else{pageTabs.checkLoginResponse();}}});var PasswordForgottenForm=Class.create(TabDialogForm,{initialize:function($super,dialog,loginForm){$super(dialog);this.loginForm=loginForm;this.nicknameInput=null;this.parentEmailInput=null;this.nicknameFieldBg=null;this.parentEmailFieldBg=null;this.OKBtn=null;this.cancelBtn=null;},loaded:function(isLoaded){if(isLoaded){this.form=$('tabDialog_passwordForgottenForm');this.nicknameInput=$('tabDialog_passwordForgottenForm_nickname');this.parentEmailInput=$('tabDialog_passwordForgottenForm_parentEmail');this.nicknameFieldBg=$$('#tabDialog_passwordForgottenForm_campoNickname .tabDialog_campoSfondo')[0];this.parentEmailFieldBg=$$('#tabDialog_passwordForgottenForm_campoParentEmail .tabDialog_campoSfondo')[0];this.OKBtn=$('passwordForgottenForm_OKBtn');this.cancelBtn=$('passwordForgottenForm_cancelBtn');}},bind:function($super){$super();this.OKBtn.onclick=this.OkBtnClicked.bindAsEventListener(this);this.cancelBtn.onclick=this.cancelBtnClicked.bindAsEventListener(this);},hide:function($super){if(this.nicknameFieldBg){this.nicknameFieldBg.setStyle({position:'absolute'})};if(this.parentEmailFieldBg){this.parentEmailFieldBg.setStyle({position:'absolute'})};$super();},show:function($super){this.cleanFields();if(this.nicknameFieldBg){this.nicknameFieldBg.setStyle({position:'relative'})};if(this.parentEmailFieldBg){this.parentEmailFieldBg.setStyle({position:'relative'})};$super();},cleanFields:function(){this.nicknameInput.value="";this.parentEmailInput.value="";},OkBtnClicked:function(){var nickname=this.nicknameInput.getValue();var parent_email=this.parentEmailInput.getValue();if((nickname!='')&&(parent_email!='')){this.dialog.startSpinner(i18n.stringLocale('invio_richiesta_in_corso','dialog'));var objectToPost={'nickname':nickname,'parent_email':parent_email}
var options={JSON:true,evalJS:true,onComplete:this.checkForgotPasswordRequest.bindAsEventListener(this)};this.dialog.sendRequest('/user/forgot_password/',objectToPost,options);}else{this.dialog.displayMessage({title:'warning',description:i18n.stringLocale('inserisci_nick_e_p_mail','dialog'),actions:'1button',actionOK:this.dialog.showPasswordForgottenForm.bindAsEventListener(this.dialog)})}},checkForgotPasswordRequest:function(request){if(request.status=='200'){response=request.responseJSON;if(response.status.action_result=='OK'){this.dialog.displayMessage({title:'good',description:i18n.stringLocale('mail_inviata_a_genitori_reset_p','dialog')+"<br><br>"+i18n.stringLocale('corri_da_mama_e_papa','dialog'),actionOK:this.dialog.hideDialog.bindAsEventListener(this.dialog),size:'small'})}else{this.dialog.displayMessage({title:'warning',description:response.status.message,actions:'1button',actionOK:this.dialog.showPasswordForgottenForm.bindAsEventListener(this.dialog)})}}else{this.dialog.displayMessage({title:'warning',description:i18n.stringLocale('problema_server_prova_1_minuto','dialog'),actionOK:window.location.reload(true),size:'small'})}
this.dialog.stopSpinner();},cancelBtnClicked:function(){this.loginForm.cancelBtnClicked();if(typeof(pageTabs.cancelLoginForm)!='undefined'){pageTabs.cancelLoginForm();}}});var AddFriendForm=Class.create(TabDialogForm,{initialize:function($super,dialog){$super(dialog);this.magicSpellInput=null;this.OKBtn=null;this.cancelBtn=null;this.onComplete=null;this.targetNickname=null;},loaded:function(isLoaded){if(isLoaded){this.form=$('tabDialog_addFriendForm');this.magicSpellInput=$('tabDialog_addFriendForm_magicSpell');this.magicSpellFieldBg=$('#tabDialog_addFriendForm_magicSpellField .tabDialog_campoSfondo');this.OKBtn=$('addFriend_OKBtn');this.cancelBtn=$('addFriend_CancelBtn');}},bind:function($super){$super();this.OKBtn.onclick=this.OkBtnClicked.bindAsEventListener(this);this.cancelBtn.onclick=this.cancelBtnClicked.bindAsEventListener(this);},hide:function($super){if(this.magicSpellFieldBg){this.magicSpellFieldBg.setStyle({position:'absolute'})};$super();},show:function($super,options,additionalOptions){if((typeof additionalOptions!='undefined')&&(additionalOptions!=null)){if((typeof additionalOptions.friendNickname!='undefined')&&(additionalOptions.friendNickname!=null)){this.targetNickname=additionalOptions.friendNickname;}
if((typeof additionalOptions.callbackToContinue!='undefined')&&(additionalOptions.callbackToContinue!=null)){this.onComplete=additionalOptions.callbackToContinue;}}
this.dialog.displayTitle('warning');this.dialog.setDescription(i18n.stringLocale('enter_magic_spell_1','dialog')+this.targetNickname+i18n.stringLocale('enter_magic_spell_2','dialog')+this.targetNickname);this.cleanFields();if(this.magicSpellFieldBg){this.magicSpellFieldBg.setStyle({position:'relative'})};$super();},cleanFields:function(){this.magicSpellInput.value="";},OkBtnClicked:function(){var magicSpell=this.magicSpellInput.value;if(magicSpell!=''){this.dialog.startSpinner(i18n.stringLocale('invio_richiesta_in_corso','dialog'));var objectToPost={'nickname':this.targetNickname,'magic_spell':magicSpell}
var options={JSON:true,evalJS:true,onComplete:this.checkAddFriendResponse.bindAsEventListener(this)};this.dialog.sendRequest('/friendship/add_friend/',objectToPost,options);}else{this.dialog.displayMessage({title:'warning',description:i18n.stringLocale('magic_spell_not_entered','dialog'),actions:'1button',actionOK:this.dialog.showAddFriendForm.bindAsEventListener(this.dialog)})}},cancelBtnClicked:function(){this.dialog.hideDialog();if(this.onComplete!=null){this.onComplete()}},checkAddFriendResponse:function(request){if(request.status=='200'){response=request.responseJSON;if(response.status.action_result=='OK'){this.dialog.displayMessage({title:'good',description:response.status.message,actions:'1button',size:'small',actionOK:this.checkForActionsToPerform.bindAsEventListener(this)})}else{actions=null;actionOK=null;actionCancel=null;switch(response.status.action_to_perform){case'logout!':actions='1button';actionOK=this.forceRefresh.bindAsEventListener(this);break;case'tryAgain':actions='2buttons';actionOK=this.dialog.showAddFriendForm.bindAsEventListener(this.dialog);actionCancel=this.checkForActionsToPerform.bind(this);break;default:actions='1button';actionOK=this.dialog.hideDialog.bindAsEventListener(this.dialog);}
this.dialog.displayMessage({title:'warning',description:response.status.message,actions:actions,actionOK:actionOK,actionCancel:actionCancel})}}else{this.dialog.displayMessage({title:'warning',description:i18n.stringLocale('problema_server_prova_1_minuto','dialog'),actions:'1button',actionOK:window.location.reload(true)})}
this.dialog.stopSpinner();},checkForActionsToPerform:function(){this.dialog.hideDialog();if(this.onComplete!=null){this.onComplete()}},forceRefresh:function(){if(window.pageTabs!=undefined){pageTabs.forceRefresh();}else{window.location.reload(true);}}});var TabDialog=Class.create({initialize:function(){this.dialog=null;this.title=null;this.titleImg=null;this.description=null;this.loginForm=new LoginForm(this);this.passwordForgottenForm=new PasswordForgottenForm(this,this.loginForm);this.addFriendForm=new AddFriendForm(this);this.actionsTab=null;this.actionsImgOK=null;this.actionsImcCancel=null;this.actionsImgOKMiddle=null;this.actionsType='1button';this.closeBtn=null;this.spinner=null;this.spinnerText=null;this.spinnerUp=null;this.size='big';this.actions=new Hash();this.communicator=new Communicator();},loaded:function(isLoaded){if(isLoaded){this.dialog=$('tabDialog');this.titleStamp=$('tabDialog_stamp').select('img')[0];this.title=$$('.tabDialog_titolo')[0];this.titleImg=this.title.select('img')[0];this.description=$('tabDialog_descrizione');this.loginForm.loaded(isLoaded);this.passwordForgottenForm.loaded(isLoaded);this.addFriendForm.loaded(isLoaded);this.actionsTab=$('tabDialog_azioni');this.actionsImgOK=$('tabDialog_azioni_imgOK');this.actionsImcCancel=$('tabDialog_azioni_imgCancel');this.actionsImgOKMiddle=$('tabDialog_azioni_imgOK_middle');this.closeBtn=$('tabDialog_closeBnt').down('img');this.spinner=$('tabDialog_spinner');this.spinnerText=$('tabDialog_spinner_innertext');this.spinnerUp=$('tabDialog_spinner_up')
this.setSize({size:'big'});this.hideInputForms();this.bindTabDialog();}},bindTabDialog:function(){this.loginForm.bind({callbacks:{passwordForgotten:this.passwordForgotten.bindAsEventListener(this)}});this.passwordForgottenForm.bind();this.addFriendForm.bind();this.bindActions();},isVisible:function(){return(this.dialog!=null&&this.dialog.visible()&&this.dialog.getStyle('opacity')==1)},setSize:function(options){if(options.size=="small"){this.size='small';this.dialog.hasClassName('tabDialog_big')?this.dialog.removeClassName('tabDialog_big'):null;this.dialog.hasClassName('tabDialog_small')?null:this.dialog.addClassName('tabDialog_small');this.closeBtn.show();}else{this.size='big';this.dialog.hasClassName('tabDialog_small')?this.dialog.removeClassName('tabDialog_small'):null;this.dialog.hasClassName('tabDialog_big')?null:this.dialog.addClassName('tabDialog_big');this.closeBtn.hide();}},showLoginForm:function(options){options=options||{};this.setSize({size:'big'});this.hideInputForms();this.displayTitle('enter');this.setDescription(options.message!=null?options.message:i18n.stringLocale('inserisci_usr_e_pwd_per_accedere_tua_pagina','dialog'));this.loginForm.show(options);this.hideActions();this.showDialog(options);},displayTitle:function(titleToDisplay){var titleStampSrc=null;var titleStampAlt=null;var titleClassName=null;var titleImgSrc=null;var titleImgAlt=null;switch(titleToDisplay){case'enter':titleStampSrc=this.size=='small'?"/images/mypage/dialog/stamp/entra_esci_bollo_s.png":"/images/mypage/dialog/stamp/entra_esci_bollo_b.png";titleStampAlt=i18n.stringLocale('entra','dialog');titleClassName='title_enter';titleImgSrc=this.size=='small'?"/images/mypage/dialog/title/entra_s.png":"/images/mypage/dialog/title/entra_b.png"
titleImgAlt=titleStampAlt;break;case'exit':titleStampSrc=this.size=='small'?"/images/mypage/dialog/stamp/entra_esci_bollo_s.png":"/images/mypage/dialog/stamp/entra_esci_bollo_b.png";titleStampAlt=i18n.stringLocale('esci','dialog');titleClassName='title_exit';titleImgSrc=this.size=='small'?"/images/mypage/dialog/title/esci_s.png":"/images/mypage/dialog/title/esci_b.png"
titleImgAlt=titleStampAlt;break;case'warning':titleStampSrc=this.size=='small'?"/images/mypage/dialog/stamp/attenzione_bollo_s.png":"/images/mypage/dialog/stamp/attenzione_bollo_b.png";titleStampAlt=i18n.stringLocale('attenzione','dialog');titleClassName='title_warning';titleImgSrc=this.size=='small'?"/images/mypage/dialog/title/attenzione_s.png":"/images/mypage/dialog/title/attenzione_b.png"
titleImgAlt=titleStampAlt;break;case'good':titleStampSrc=this.size=='small'?"/images/mypage/dialog/stamp/bravo_bollo_s.png":"/images/mypage/dialog/stamp/bravo_bollo_b.png";titleStampAlt=i18n.stringLocale('bravo','dialog');titleClassName='title_good';titleImgSrc=this.size=='small'?"/images/mypage/dialog/title/bravo_s.png":"/images/mypage/dialog/title/bravo_b.png"
titleImgAlt=titleStampAlt;break;case'halt':titleStampSrc=this.size=='small'?"/images/mypage/dialog/stamp/divieto_bollo_s.png":"/images/mypage/dialog/stamp/divieto_bollo_b.png";titleStampAlt='Ops';titleClassName='title_ooops';titleImgSrc=this.size=='small'?"/images/mypage/dialog/title/ops_s.png":"/images/mypage/dialog/title/ops_b.png"
titleImgAlt='Ops';break;case'benvenuto':this.titleImg.writeAttribute('src',i18n.imageLocale("/images/mypage/dialog/benvenuto_it.png"));this.titleImg.writeAttribute('alt','Benvenuto');break;}
this.titleStamp.writeAttribute('src',titleStampSrc);this.titleStamp.writeAttribute('alt',titleStampAlt);titleClassName=='title_enter'?(this.title.hasClassName('title_enter')?null:this.title.addClassName('title_enter')):(this.title.hasClassName('title_enter')?this.title.removeClassName('title_enter'):null);titleClassName=='title_exit'?(this.title.hasClassName('title_exit')?null:this.title.addClassName('title_exit')):(this.title.hasClassName('title_exit')?this.title.removeClassName('title_exit'):null);titleClassName=='title_warning'?(this.title.hasClassName('title_warning')?null:this.title.addClassName('title_warning')):(this.title.hasClassName('title_warning')?this.title.removeClassName('title_warning'):null);titleClassName=='title_good'?(this.title.hasClassName('title_good')?null:this.title.addClassName('title_good')):(this.title.hasClassName('title_good')?this.title.removeClassName('title_good'):null);titleClassName=='title_ooops'?(this.title.hasClassName('title_ooops')?null:this.title.addClassName('title_ooops')):(this.title.hasClassName('title_ooops')?this.title.removeClassName('title_ooops'):null);this.titleImg.writeAttribute('src',i18n.imageLocale(titleImgSrc));this.titleImg.writeAttribute('alt',titleImgAlt);},setDescription:function(description){this.description.update('<p>'+description.toUpperCase()+'</p>');},getZIndex:function(){return parseInt(Element.getStyle(this.dialog,'z-index')||0);},setZIndex:function(currentZIndex){if(currentZIndex>this.getZIndex()){this.dialog.setStyle({zIndex:currentZIndex});}},showActions:function(type){typeof(type)=='undefined'?this.actionsType='1button':this.actionsType=type
switch(this.actionsType){case'1button':this.actionsImgOK.hide();this.actionsImcCancel.hide();this.actionsImgOKMiddle.show();break;case'2buttons':this.actionsImgOK.show();this.actionsImcCancel.show();this.actionsImgOKMiddle.hide();break;default:this.actionsImgOK.hide();this.actionsImcCancel.hide();this.actionsImgOKMiddle.hide();}
this.hideInputForms();this.actionsTab.show();},hideActions:function(){this.actionsTab.hide();},bindActions:function(){this.actionsImgOK.onclick=this.actionOKClicked.bindAsEventListener(this);this.actionsImcCancel.onclick=this.actionCancelClicked.bindAsEventListener(this);this.actionsImgOKMiddle.onclick=this.actionOKMiddleClicked.bindAsEventListener(this);if(this.closeBtn!=null){this.closeBtn.onclick=this.closeBtnClicked.bindAsEventListener(this);}},setActionOK:function(action){if(this.actionsType=='1button'){this.actions.set('OKMiddle',action);}else{this.actions.set('OK',action);}},setActionCancel:function(action){this.actions.set('Cancel',action);},setActionClose:function(action){this.actions.set('Close',action);},showDialog:function(options){if(!this.isVisible()){var zIndex=options!=null&&options.zIndex!=null?options.zIndex:(typeof(pageTabs.getCurrentZIndex)!='undefined'?pageTabs.getCurrentZIndex(true):null);if(zIndex!=null){this.setZIndex(zIndex)}
var dialogMaskHeight=options!=null&&options.dialogMaskHeight!=null?options.dialogMaskHeight:(typeof(pageTabs.getDialogMaskHeight)!='undefined'?pageTabs.getDialogMaskHeight():null);if(dialogMaskHeight!=null){this.dialog.style.heigtht=dialogMaskHeight+'px'}
this.dialog.setOpacity(0);this.dialog.show();new Effect.Opacity(this.dialog,{duration:0.3,from:0,to:1});}
this.stopSpinner();},setDefaultDialog:function(){this.hideInputForms();this.loginForm.show();},hideDialog:function(){if(this.isVisible()){new Effect.Opacity('tabDialog',{duration:0.3,from:1,to:0,afterFinish:function(effect){$('tabDialog').hide()}});}},actionOKClicked:function(){this.actions.get('OK')!=null?this.actions.get('OK')():this.hideDialog();},actionOKMiddleClicked:function(){this.actions.get('OKMiddle')!=null?this.actions.get('OKMiddle')():this.hideDialog();},actionCancelClicked:function(){this.actions.get('Cancel')!=null?this.actions.get('Cancel')():this.hideDialog();},closeBtnClicked:function(){this.actions.get('Close')!=null?this.actions.get('Close')():this.hideDialog();},showPasswordForgottenForm:function(){this.hideInputForms();this.hideActions();this.displayTitle('enter');this.setDescription(i18n.stringLocale('messaggio_pwd_dimenticata','dialog'))
this.passwordForgottenForm.show();},passwordForgotten:function(){this.showPasswordForgottenForm();},hideInputForms:function(){this.loginForm.hide();this.passwordForgottenForm.hide();this.addFriendForm.hide();},showAddFriendForm:function(options,additionalOptions){options=options||{}
this.hideInputForms()
this.hideActions();this.setSize({size:'big'});this.addFriendForm.show(options,additionalOptions)
this.showDialog(options)},startSpinner:function(message){if(message){this.spinnerText.innerHTML=message}
this.spinner.show();},stopSpinner:function(){this.spinner.hide();},sendRequest:function(url,objectToPost,options){this.communicator.sendRequest(url,objectToPost,options);},displayMessage:function(){if(arguments.length>0&&arguments[0].size!=null){this.setSize({size:arguments[0].size})}else{this.setSize({size:'big'})}
if(arguments.length>0){if(arguments[0].title!=null){this.displayTitle(arguments[0].title)}
if(arguments[0].description!=null){this.setDescription(arguments[0].description)}
if(arguments[0].size&&arguments[0].size=='small'){this.showActions('closeBtn');if(arguments[0].actionOK!=null){this.setActionClose(arguments[0].actionOK)}}else{if(arguments[0].actions!=null){this.showActions(arguments[0].actions)}
if(arguments[0].actionOK!=null){this.setActionOK(arguments[0].actionOK)}
if(arguments[0].actionCancel!=null){this.setActionCancel(arguments[0].actionCancel)}}}
this.hideInputForms();},waitAndRedirect:function(options){this.spinnerUp.show();this.setDescription(options.message);this.hideInputForms();this.hideActions();this.showDialog();setTimeout(this.redirectAfterWait.bindAsEventListener(this,{url:options.url,showDialogAvvisiAtStartup:options.showDialogAvvisiAtStartup}),options.timeout);},redirectAfterWait:function(){var url="/page/back_to_homepage";if(arguments[1].url!=null){url=arguments[1].url;}else{url=arguments[1].showDialogAvvisiAtStartup==true?"/page/back_to_homepage?show_dialog_avvisi=true":"/page/back_to_homepage"}
location.href=url;}});var Action=Class.create({initialize:function(action,parameters){this.action=action;this.parameters=parameters;}});var ActionCfg=Class.create({initialize:function(action,parameters,executeOnce,asynchronous){this.action=action;this.parameters=parameters;this.executeOnce=executeOnce!=null?executeOnce:false;this.asynchronous=asynchronous!=null?asynchronous:false;},perform:function(callbackToContinue){this.action({parameters:this.parameters,callbackToContinue:callbackToContinue});},isSingleExecution:function(){return this.executeOnce;},isAsynchronous:function(){return this.asynchronous;}})
var ActionsToPerform=Class.create({initialize:function(){this.actions=new Hash();},addAction:function(){if((arguments.length>0)&&(arguments[0].event!=null)&&(arguments[0].when!=null)&&(arguments[0].action!=null)){if(this.actions.get(arguments[0].event)==null){this.actions.set(arguments[0].event,new Hash());}
var eventHash=this.actions.get(arguments[0].event);eventHash.set(arguments[0].when,arguments[0].action);}},removeAction:function(){if((arguments.length>0)&&(arguments[0].event!=null)&&(arguments[0].when!=null)){if(this.actions.get(arguments[0].event)!=null){var eventHash=this.actions.get(arguments[0].event);eventHash.set(arguments[0].when,null);}}},getAction:function(){if((arguments.length>0)&&(arguments[0].event!=null)&&(arguments[0].when!=null)){var eventHash=this.actions.get(arguments[0].event)
if(eventHash!=null){return eventHash.get(arguments[0].when);}else{return null;}}},eventHappen:function(){if((arguments.length>0)&&(arguments[0].event!=null)&&(arguments[0].when!=null)){var event=arguments[0].event;var when=arguments[0].when;var actionToPerform=this.getAction({event:event,when:when})
if(actionToPerform!=null){if(actionToPerform.isAsynchronous()){actionToPerform.perform(arguments[0].callbackToContinue);}else{actionToPerform.perform();arguments[0].callbackToContinue();}
if(actionToPerform.isSingleExecution()){this.removeAction({event:event,when:when});}}else{arguments[0].callbackToContinue();}}},eventCancelled:function(){if((arguments.length>0)&&(arguments[0].event!=null)){var event=arguments[0].event;var actionToPerform=this.getAction({event:event,when:'after'})
if(actionToPerform!=null&&actionToPerform.isSingleExecution()){this.removeAction({event:event,when:'after'});}}}})
var EventCallback=Class.create({initialize:function(options){this.callback=options.callback;this.callbackParams=options.callbackParams;this.executeOnce=options.executeOnce!=null?options.executeOnce:true;this.asynchronous=options.asynchronous!=null?options.asynchronous:false;this.blocksQueue=options.blocksQueue!=null?options.blocksQueue:false;},perform:function(options){this.callback({parameters:this.callbackParams,callbackToContinue:options.callbackToContinue});},isSingleExecution:function(){return this.executeOnce;},isAsynchronous:function(){return this.asynchronous;},isBlockingQueue:function(){return this.blocksQueue;}})
var EventInCourse=Class.create({initialize:function(options){this.event=options.event;this.when=options.when;this.callbackToContinueEvent=options.callbackToContinueEvent;this.pendingCallbacks=0;},addPendingCallback:function(){this.pendingCallbacks++;},removePendingCallback:function(){this.pendingCallbacks--;},canEventContinue:function(){return this.pendingCallbacks==0;}})
var EventQueueDispatcher=Class.create({initialize:function(){this.callbacks=new Hash();this.eventsInCourse=new Hash();},addCallback:function(options){if(this.callbacks.get(options.event)==null){this.callbacks.set(options.event,new Hash())}
var eventHash=this.callbacks.get(options.event);if(eventHash.get(options.when)==null){eventHash.set(options.when,new Hash({queue:new Array(),callbackToExecuteIndex:0}));}
var callbacksQueue=eventHash.get(options.when).get('queue');if(options.placeFirst!=null&&options.placeFirst==true){callbacksQueue.unshift(options.callback)}else{callbacksQueue.push(options.callback)}},eventHappen:function(options){this.eventsInCourse.set(options.event,new EventInCourse({event:options.event,when:options.when,callbackToContinueEvent:options.callbackToContinueEvent}))
var eventHash=this.callbacks.get(options.event);if(eventHash!=null){var callbacksQueue=eventHash.get(options.when);if(callbacksQueue!=null){callbacksQueue.set('callbackToExecuteIndex',0);}}
this.checkQueue({event:options.event,when:options.when});},eventCancelled:function(options){var eventHash=this.callbacks.get(options.event);if(eventHash!=null){var callbacksQueue=eventHash.get('before');if(callbacksQueue!=null){this.clearQueueFromSingleExecutionCallbacks({event:options.event,when:'before'})}
callbacksQueue=eventHash.get('after');if(callbacksQueue!=null){this.clearQueueFromSingleExecutionCallbacks({event:options.event,when:'after'})}}
this.eventsInCourse.unset(options.event);},clearQueueFromSingleExecutionCallbacks:function(options){var callbacksQueue=this.callbacks.get(options.event).get(options.when);var queue=callbacksQueue.get('queue');for(var i=0;i<queue.size();i++){var callback=queue[i];if(callback.isSingleExecution()){queue[i]=null;callbacksQueue.set('queue',queue.compact());}}
callbacksQueue.set('callbackToExecuteIndex',0);},checkQueue:function(options){var eventInCourse=this.eventsInCourse.get(options.event);var eventHash=this.callbacks.get(options.event);if(eventHash!=null){var callbacksQueue=eventHash.get(options.when);if(callbacksQueue!=null&&callbacksQueue.get('queue').size()>0){var queue=callbacksQueue.get('queue');var callbackToExecute=queue[callbacksQueue.get('callbackToExecuteIndex')];if(callbackToExecute!=null){if(callbackToExecute.isSingleExecution()){queue[callbacksQueue.get('callbackToExecuteIndex')]=null;callbacksQueue.set('queue',queue.compact());}else{callbacksQueue.set('callbackToExecuteIndex',callbacksQueue.get('callbackToExecuteIndex')+1);}
if(callbackToExecute.isBlockingQueue()){if(callbackToExecute.isAsynchronous()){eventInCourse.addPendingCallback();callbackToExecute.perform({callbackToContinue:this.callbackExecuted.bind(this,{event:options.event,when:options.when,wasAsynch:true})});}else{callbackToExecute.perform({callbackToContinue:this.callbackExecuted.bind(this,{event:options.event,when:options.when,wasAsynch:false})});}}else{if(callbackToExecute.isAsynchronous()){eventInCourse.addPendingCallback();callbackToExecute.perform({callbackToContinue:this.callbackExecuted.bind(this,{event:options.event,when:options.when,wasAsynch:true})});}else{callbackToExecute.perform({callBackToContinue:null});}
this.checkQueue({event:options.event,when:options.when});}}else{this.continueEvent({event:options.event,when:options.when});}}else{this.continueEvent({event:options.event,when:options.when});}}else{this.continueEvent({event:options.event,when:options.when});}},callbackExecuted:function(options){var eventInCourse=this.eventsInCourse.get(options.event)
if(eventInCourse!=null&&options.wasAsynch==true){eventInCourse.removePendingCallback();}
this.checkQueue({event:options.event,when:options.when});this.continueEvent({event:options.event,when:options.when});},continueEvent:function(options){var eventToContinue=this.eventsInCourse.get(options.event);if(eventToContinue!=null&&eventToContinue.canEventContinue()){this.eventsInCourse.unset(options.event);if(eventToContinue.callbackToContinueEvent1=!null){eventToContinue.callbackToContinueEvent();}}},stopDispatching:function(options){var eventHash=this.callbacks.get(options.event);if(eventHash!=null){var callbacksQueue=eventHash.get(options.when);if(callbacksQueue!=null){callbacksQueue.set('callbackToExecuteIndex',callbacksQueue.get('queue').size());}}
this.eventsInCourse.unset(options.event);}})
var User=Class.create({initialize:function(){this.id=0;this.nickname="";this.enabled=false;this.registered=false;this.logged_in=false;this.gender=null;this.birthday=function(){this.day=null;this.month=null;this.year=null;}
this.new_notifications_count=0;this.media_download=false;this.write_text=false;this.friendship_p_auth=false;this.can_have_friends=false;this.friends=new Array();this.lang=null;this.keep_contents_on_notification=false;this.keep_contents_on_paste=false;this.page=function(){this.id=0;this.tabs=new Array();}
this.newFriendsCount=0;this.avatarUrl="";this.hasDialogAvvisi=false;},setUserInfoFromServerData:function(responseFromServer,new_notifications_count){this.id=responseFromServer.id;this.nickname=responseFromServer.nickname;this.enabled=responseFromServer.enabled;this.registered=responseFromServer.registered;this.logged_in=responseFromServer.logged_in;this.gender=responseFromServer.gender;if(responseFromServer.birthday!=null){this.birthday.day=responseFromServer.birthday.day;this.birthday.month=responseFromServer.birthday.month;this.birthday.year=responseFromServer.birthday.year;}
this.new_notifications_count=new_notifications_count!=null?new_notifications_count:responseFromServer.new_notifications_count;this.media_download=responseFromServer.media_download
this.write_text=responseFromServer.write_text;this.friendship_p_auth=responseFromServer.friendship_p_auth;this.can_have_friends=responseFromServer.can_have_friends;this.friends=responseFromServer.friends;this.is_famous_friend=responseFromServer.is_famous_friend;this.can_require_friendship=responseFromServer.can_require_friendship;this.lang=responseFromServer.lang
this.keep_contents_on_notification=responseFromServer.keep_contents_on_notification;this.keep_contents_on_paste=responseFromServer.keep_contents_on_paste;if(typeof responseFromServer.page!='undefined'){this.page.id=responseFromServer.page.id;this.page.tabs=responseFromServer.page.tabs;}
this.newFriendsCount=typeof responseFromServer.new_friends_count!='undefined'?responseFromServer.new_friends_count:null;this.avatarUrl=responseFromServer.avatar_url;this.hasDialogAvvisi=responseFromServer.has_dialog_avvisi==true?true:false},equalsTo:function(otherUser){return typeof(otherUser.id)!='undefined'&&this.id==otherUser.id?true:false;},getId:function(){return this.id;},isLoggedIn:function(){return this.logged_in;},isRegistered:function(){return this.registered;},canDownloadMedia:function(){return this.media_download;},canWriteText:function(){return this.write_text;},getYourPageId:function(){return this.page.id;},setNewNotificationsCount:function(notifications_count){this.new_notifications_count=notifications_count;},getNewNotificationsCount:function(){return this.new_notifications_count;},canHaveFriends:function(){return this.can_have_friends;},canRequireFriendship:function(){return this.can_require_friendship;},getLang:function(){return this.lang;},getLanguage:function(){return this.getLang();},getGender:function(){return this.gender;},keepContentsOnNotification:function(){return this.keep_contents_on_notification;},keepContentsOnPaste:function(){return this.keep_contents_on_paste;},isFamousFriend:function(){return this.is_famous_friend;},isFriendWith:function(friend){return this.isFriendWithById(friend.id)},isFriendWithById:function(friendId){var areFriends=false;this.friends.each(function(user_friend){if(user_friend.id==friendId){if(user_friend.has_blocked==true){areFriends="friend_has_blocked"}else if(user_friend.is_blocked==true){areFriends="friend_is_blocked"}else{areFriends=true}
throw $break;}})
return areFriends;},getNewFriendsCount:function(){return this.newFriendsCount;}});MPSound={play:function(sound_url){Sound.play(sound_url);},enable:function(sound_url){Sound.enable(sound_url);},disable:function(sound_url){Sound.disable(sound_url);},stop:function(sound_url){Sound.enable();Sound.play('',{replace:true});}};var MPConfiguration=Class.create({initialize:function(){this.flashMediaPath=null;},setFlashMediaPath:function(path){this.flashMediaPath=path;},getFlashMediaPath:function(){return this.flashMediaPath!=null?this.flashMediaPath:'';},setVideoMediaPath:function(path){this.videoMediaPath=path;},getVideoMediaPath:function(){return this.videoMediaPath!=null?this.videoMediaPath:'';},setDownloadMediaPath:function(path){this.downloadMediaPath=path;},getDownloadMediaPath:function(){return this.downloadMediaPath!=null?this.downloadMediaPath:'';}})
var I18N=Class.create({initialize:function(){this.confs=null;},setConfiguration:function(confs){this.confs=confs;},stringLocale:function(stringName,contest,params)
{var lang=typeof(pageTabs)!='undefined'?pageTabs.getUserLang():'it';var string="";if(contest!=null&&this.confs[contest]!=null){string=this.confs[contest][stringName][lang]!=null?this.confs[contest][stringName][lang]:this.confs[contest][stringName]['it'];}else{string=this.confs[stringName][lang]!=null?this.confs[stringName][lang]:this.confs[stringName]['it'];}
if((typeof arguments[2]!='undefined')&&(string.split("%s").length>1)){params=typeof params!='object'?[params]:params;var tokens=string.split("%s");string="";for(var i=0;i<tokens.length;i++){string+=tokens[i];if(params[i]!=null&&i!=tokens.length-1){string+=params[i];}}}
return string},imageLocale:function(source,lang){language=typeof(lang)!='undefined'?lang:(pageTabs.getUserLang()||'it');filename=source.split('/').last()
ext=filename.split('.').last()
name_s=filename.split('.').first()
basePath=source.split(filename).first()
name_e=name_s.indexOf('_it')>0?name_s.sub('_it','_'+language):(name_s+'_'+language)
basePath=basePath.indexOf('/it/')>0?basePath.sub('/it/','/'+language+'/'):basePath+language+'/'
return basePath+name_e+(ext!=name_s?('.'+ext):"");},mediaLocale:function(source,lang){return this.imageLocale(source,lang);}})
var DialogAvvisi=Class.create({initialize:function(options){this.userManager=options.userManager;this.user=options.user
this.mainDiv=null;this.statusInfoContent=null;this.statusInfoEmailParentsBtn=null;this.statusInfoEmailFeedback=null;this.notificationsEmailParentsBtn=null;this.parentEmailField=null;this.parentEmailFieldInitialValue=null;this.parentEmailBtn=null;this.parentEmailNokFeedback=null;this.closeDialogBtn=null;this.goToYourPageLink=null;this.userId=(options!=null&&options.userId!=null)?options.userId:null;this.dialogLanguage=null;this.load({showAfterLoad:options.show,callbackToContinue:options.callbackToContinue,userId:options.userId})},load:function(options){var userId=(this.userId!=null)?this.userId:this.user.getId();new Ajax.Request('/user/load_dialog_avvisi/'+userId,{asynchronous:true,evalScripts:true,onComplete:this.hasLoaded.bindAsEventListener(this,{showAfterLoad:options.showAfterLoad,callbackToContinue:options.callbackToContinue})});},reload:function(options){var userId=(this.userId!=null)?this.userId:this.user.getId();this.dialogLanguage=options.language;new Ajax.Request("/user/load_dialog_avvisi?id="+userId+"&lang="+options.language+"&display=true",{asynchronous:true,evalScripts:true,onComplete:this.hasLoaded.bindAsEventListener(this,{showAfterLoad:options.showAfterLoad,callbackToContinue:options.callbackToContinue})});},hasLoaded:function(){this.bind();var showAfterLoad=arguments[1].showAfterLoad;if(showAfterLoad){this.show();}
if(arguments[1].callbackToContinue!=null&&arguments[1].callbackToContinue){arguments[1].callbackToContinue()};},bind:function(){this.mainDiv=$("dialogAvvisi");this.statusInfoContent=$("dialogAvvisi_statusInfo_content");this.statusInfoEmailParentsBtn=$("dialogAvvisi_statusInfo_emailParentsBtn");this.statusInfoEmailFeedback=$("dialogAvvisi_statusInfo_emailFeedback");this.notificationsEmailParentsBtn=$('dialogAvvisi_notifications_emailParentsBtn');this.parentEmailField=$('dialogAvvisi_parentEmailForm_Field');this.parentEmailBtn=$('dialogAvvisi_parentEmailForm_Link');this.parentEmailNokFeedback=$('dialogAvvisi_parentEmailForm_NokFeedback');this.closeDialogBtn=$("dialogAvvisi_closeBtn");this.goToYourPageLink=$('dialogAvvisi_profileSummary_goToYourPage_link');if(this.statusInfoEmailParentsBtn){this.statusInfoEmailParentsBtn.onclick=this.statusInfoEmailParentsBtnClicked.bindAsEventListener(this);}
if(this.notificationsEmailParentsBtn){this.notificationsEmailParentsBtn.onclick=this.notificationsEmailParentsBtnClicked.bindAsEventListener(this);}
if(this.parentEmailField){this.parentEmailFieldInitialValue=this.parentEmailField.value.strip();this.parentEmailField.onfocus=this.parentEmailFieldFocusedOn.bindAsEventListener(this);this.parentEmailBtn.onclick=this.parentEmailBtnClicked.bindAsEventListener(this);}
if(this.closeDialogBtn){this.closeDialogBtn.onclick=this.closeDialogBtnClicked.bindAsEventListener(this);}
if(this.goToYourPageLink){this.goToYourPageLink.onclick=this.goToYourPageLinkClicked.bindAsEventListener(this);}},hide:function(){this.mainDiv.hide();},show:function(){this.mainDiv.show();},statusInfoEmailParentsBtnClicked:function(){this.emailParents();},notificationsEmailParentsBtnClicked:function(){this.emailParents();},emailParents:function(){var userId=(this.userId!=null)?this.userId:this.user.getId();var objectToPost={'user_id':userId};if(this.dialogLanguage!=null){objectToPost.language=this.dialogLanguage;}
var options={JSON:true,evalJS:true,onComplete:this.checkEmailParentsResponse.bindAsEventListener(this)};this.userManager.communicator.sendRequest('/user/email_parents/',objectToPost,options);},checkEmailParentsResponse:function(request){if(this.userManager.communicator.checkResponseFromServer({request:request,refreshOnLogout:true,tabDialog:this.userManager.tabDialog})){this.statusInfoContent.hide();this.statusInfoEmailFeedback.show();}},parentEmailFieldFocusedOn:function(){if(this.parentEmailField.value.strip()==this.parentEmailFieldInitialValue){this.parentEmailField.value="";}
this.parentEmailNokFeedback.hide();},parentEmailBtnClicked:function(){this.changeParentEmail();},changeParentEmail:function(){var email=this.parentEmailField.value;if(email.strip().length>0){if(checkEmailPattern({email:email})){var userId=(this.userId!=null)?this.userId:this.user.getId();var objectToPost={parent_email:email,user_id:userId};var options={JSON:true,evalJS:true,onComplete:this.checkChangeParentEmailResponse.bindAsEventListener(this)};this.userManager.communicator.sendRequest('/user/change_parent_email/',objectToPost,options);}else{this.parentEmailNokFeedback.show();}}},checkChangeParentEmailResponse:function(request){if(this.userManager.communicator.checkResponseFromServer({request:request,refreshOnLogout:true,tabDialog:this.userManager.tabDialog,callbackOnApplicationError:this.showChangePMailServerNokFeedback.bind(this)})){this.statusInfoContent.hide();this.statusInfoEmailFeedback.show();}else{this.showChangePMailServerNokFeedback();}},showChangePMailServerNokFeedback:function(){this.userManager.tabDialog.hideDialog();this.parentEmailNokFeedback.show();},closeDialogBtnClicked:function(){this.hide();},goToYourPageLinkClicked:function(){location.href="/page/back_to_homepage";}})
var MyPageHeaderConf=Class.create({initialize:function(myPageHeaderBehaviour,myPageHeaderBehaviourAvoidFamous){this.myPageHeaderBehaviour=myPageHeaderBehaviour;this.myPageHeaderBehaviourAvoidFamous=myPageHeaderBehaviourAvoidFamous;},isElementVisible:function(){var element=arguments[0].element;var page=arguments[0].page;var user=arguments[0].user;var pageOwner=arguments[0].pageOwner;if(user.isFamousFriend()&&this.myPageHeaderBehaviourAvoidFamous.indexOf(element)!=-1){return false}
var elementObj=this.myPageHeaderBehaviour[element];if(typeof elementObj[page]=='undefined'){return false}
if(elementObj[page]==true){return true}
var pageObj=elementObj[page];if(user.isRegistered()){if(typeof(pageObj['user_registered'])!='undefined'){if(pageObj['user_registered']==true){return true}
var userObj=pageObj['user_registered'];if((typeof userObj['user_page']!='undefined')||(typeof userObj['not_user_page']!='undefined')){if(typeof userObj['user_page']!='undefined'){return(user.id==pageOwner.id)?true:false;}else{return(user.id!=pageOwner.id)?true:false;}}else{if(user.isLoggedIn()){if(typeof userObj['user_logged']!='undefined'){if(userObj['user_logged']==true){return true}
var userPageObj=userObj['user_logged'];if((typeof userPageObj['user_page']!='undefined')||(typeof userPageObj['not_user_page']!='undefined')){if(typeof userPageObj['user_page']!='undefined'){return(user.id==pageOwner.id)?true:false;}else{return(user.id!=pageOwner.id)?true:false;}}else{return false}}else{return false;}}else{if(typeof userObj['user_not_logged']!='undefined'){if(userObj['user_not_logged']==true){return true}
var userPageObj=userObj['user_not_logged'];if((typeof userPageObj['user_page']!='undefined')||(typeof userPageObj['not_user_page']!='undefined')){if(typeof userPageObj['user_page']!='undefined'){return(user.id==pageOwner.id)?true:false;}else{return(user.id!=pageOwner.id)?true:false;}}else{return false}}else{return false;}}}}else{return false;}}else{if(typeof pageObj['user_not_registered']!='undefined'){if(pageObj['user_not_registered']==true){return true}
var userObj=pageObj['user_not_registered'];if((typeof userObj['user_page']!='undefined')||(typeof userObj['not_user_page']!='undefined')){if(typeof userObj['user_page']!='undefined'){return(user.id==pageOwner.id)?true:false;}else{return(user.id!=pageOwner.id)?true:false;}}else{return false}}else{return false;}}}})
var Header=Class.create({initialize:function(header,pageName){this.header=header;this.pageName=pageName;this.myPageHeaderConf=null;},update:function(){if((typeof(arguments[0].myPageHeaderConf)!='undefined')&&(arguments[0].myPageHeaderConf!=null)){this.myPageHeaderConf=arguments[0].myPageHeaderConf;}}})
var UpperHeader=Class.create(Header,{initialize:function($super,header,pageName){$super(header,pageName);this.container=$('upper_header');this.staticHPLink=$('homeStLink');this.starPagesLink=$('starPagesLink');this.loginLink=$('loginLink');this.logoutLink=$('logoutLink');this.registerLink=$('registerLink');this.writeToMyPageLink=$('writeToMyPageLink');this.languageBox=$$('#upper_header #language_box')[0];this.bind();},bind:function(){this.staticHPLink.onclick=this.staticHPLinkClicked.bindAsEventListener(this);if(this.startPagesLink)this.starPagesLink.onclick=this.starPagesLinkClicked.bindAsEventListener(this);this.loginLink.onclick=this.loginLinkClicked.bindAsEventListener(this);this.logoutLink.onclick=this.logoutLinkClicked.bindAsEventListener(this);this.registerLink.onclick=this.registerLinkClicked.bindAsEventListener(this);this.writeToMyPageLink.onclick=this.writeToMyPageLinkClicked.bindAsEventListener(this);},staticHPLinkClicked:function(){this.header.staticHPLinkClicked();},starPagesLinkClicked:function(){this.header.starPagesLinkClicked();},loginLinkClicked:function(){this.header.loginLinkClicked();},logoutLinkClicked:function(){this.header.logoutLinkClicked();},registerLinkClicked:function(){this.header.registerLinkClicked();},writeToMyPageLinkClicked:function(){this.header.writeToMyPageLinkClicked();},update:function($super){$super(arguments[1]);var user=arguments[1].user;var pageOwner=arguments[1].pageOwner;if(this.myPageHeaderConf.isElementVisible({element:'language_box',page:this.pageName,user:user,pageOwner:pageOwner})){this.languageBox.style.display='block';}else{this.languageBox.style.display='none';}
if(user.isLoggedIn()){this.loginLink.style.display='none';this.logoutLink.style.display='inline';this.registerLink.style.display='none';}else{this.loginLink.style.display='inline';this.logoutLink.style.display='none';this.registerLink.style.display='inline';}}})
var LowerHeader=Class.create(Header,{initialize:function($super,header,pageName){$super(header,pageName);this.container=$('header_mypage');this.profileLink=$('profiloLink');this.passaparolaLink=$('passaparolaLink');this.friendsLink=$('amiciLink');this.awardsSupporterLink=$('awardsSupporterLink');this.passaparolaNotifications=$('passaparolaNotifiche');this.friendsNotifications=$('amiciNotifiche');this.accountLink=$('accountLink');this.pageOfMarker=$('pageOfMarker');this.headerAvatar=$('header_avatar');this.becomeFriendLink=$('becomeFriendLink');this.youAreFriendAd=$('youAreFriendAd');this.addFanLink=$('addFanLink');this.youAreFanAd=$('youAreFanAd');this.homePageLink=$('homePageLink');this.closePageLink=$('closePageLink');this.bind();},bind:function(){this.profileLink.onclick=this.profileLinkClicked.bindAsEventListener(this);this.accountLink.onclick=this.accountLinkClicked.bindAsEventListener(this);if(this.passaparolaLink!=null)
this.passaparolaLink.onclick=this.passaparolaLinkClicked.bindAsEventListener(this);if(this.friendsLink!=null)
this.friendsLink.onclick=this.friendsLinkClicked.bindAsEventListener(this);if(this.awardsSupporterLink!=null)
this.awardsSupporterLink.onclick=this.awardsSupporterLinkClicked.bindAsEventListener(this);this.homePageLink.onclick=this.homePageLinkClicked.bindAsEventListener(this);if(this.closePageLink!=null)
this.closePageLink.onclick=this.closePageLinkClicked.bindAsEventListener(this);this.becomeFriendLink.onclick=this.becomeFriendLinkClicked.bindAsEventListener(this);this.addFanLink.onclick=this.addFanLinkClicked.bindAsEventListener(this);},profileLinkClicked:function(){this.header.profileLinkClicked();},accountLinkClicked:function(){this.header.accountLinkClicked();},passaparolaLinkClicked:function(){this.header.passaparolaLinkClicked();},friendsLinkClicked:function(){this.header.friendsLinkClicked();},awardsSupporterLinkClicked:function(){this.header.awardsSupporterLinkClicked();},homePageLinkClicked:function(){this.header.homePageLinkClicked();},closePageLinkClicked:function(){this.header.closePageLinkClicked();},becomeFriendLinkClicked:function(){this.header.becomeFriendLinkClicked();},addFanLinkClicked:function(){this.header.addFanLinkClicked();},update:function($super){$super(arguments[1]);var user=arguments[1].user;var pageOwner=arguments[1].pageOwner;var profileLinkVisible=this.myPageHeaderConf.isElementVisible({element:'profile_page_link',page:this.pageName,user:user,pageOwner:pageOwner});var passaparolaLinkVisible=this.myPageHeaderConf.isElementVisible({element:'word_of_mouth_link',page:this.pageName,user:user,pageOwner:pageOwner});var friendsLinkVisible=this.myPageHeaderConf.isElementVisible({element:'friendship_page_link',page:this.pageName,user:user,pageOwner:pageOwner});var awardsSupporterLinkVisible=this.myPageHeaderConf.isElementVisible({element:'awards_supporter_link',page:this.pageName,user:user,pageOwner:pageOwner})
var homePageLinkVisible=this.myPageHeaderConf.isElementVisible({element:'go_to_my_page_link',page:this.pageName,user:user,pageOwner:pageOwner});if(profileLinkVisible){this.profileLink.style.display=user.isFamousFriend()?'none':'block';this.accountLink.style.display=user.isFamousFriend()?'block':'none';}else{this.profileLink.style.display='none';this.accountLink.style.display='none';}
if(this.passaparolaLink!=null)
this.passaparolaLink.style.display=passaparolaLinkVisible?'block':'none';if(this.passaparolaNotifications!=null){if(passaparolaLinkVisible){var newNotificationsCount=user.getNewNotificationsCount()
if(newNotificationsCount>0){this.passaparolaNotifications.innerHTML=newNotificationsCount;this.passaparolaNotifications.style.display='block';}else{this.passaparolaNotifications.style.display='none';}}else{this.passaparolaNotifications.style.display='none';}}
if(this.friendsLink!=null)
this.friendsLink.style.display=friendsLinkVisible?'block':'none';if(this.friendsNotifications!=null){if(friendsLinkVisible){var newFriendsCount=user.getNewFriendsCount();if(newFriendsCount>0){this.friendsNotifications.innerHTML=newFriendsCount;this.friendsNotifications.style.display='block';}else{this.friendsNotifications.style.display='none';}}else{this.friendsNotifications.style.display='none';}}
if(this.awardsSupporterLink!=null)
this.awardsSupporterLink.style.display=awardsSupporterLinkVisible?'block':'none';if(homePageLinkVisible){this.homePageLink.style.display='inline';}else{this.homePageLink.hide();}
var pageOfMarkerVisible=this.myPageHeaderConf.isElementVisible({element:'page_of_marker',page:this.pageName,user:pageOwner,pageOwner:pageOwner});var avatarVisible=this.myPageHeaderConf.isElementVisible({element:'avatar',page:this.pageName,user:pageOwner,pageOwner:pageOwner});var becomeFriendLinkVisible=this.myPageHeaderConf.isElementVisible({element:'become_friend',page:this.pageName,user:user,pageOwner:pageOwner});var nicknameDimension=getStringDimension({string:pageOwner.nickname,maxDim:11});this.showPageOfMarker(pageOwner,pageOfMarkerVisible);if(becomeFriendLinkVisible){if(user.isFriendWith(pageOwner)!=false){if(user.isFamousFriend()){this.youAreFriendAd.style.display='none';this.youAreFanAd.style.display='none';}else{if(!pageOwner.isFamousFriend()){this.youAreFriendAd.style.display='block';this.youAreFriendAd.setStyle('left:'+(nicknameDimension+174)+'px');this.youAreFanAd.style.display='none';}else{this.youAreFriendAd.style.display='none';this.youAreFanAd.style.display='block';this.youAreFanAd.setStyle('left:'+(nicknameDimension+174)+'px');}}
this.becomeFriendLink.style.display='none';this.addFanLink.style.display='none';}else{if((user.id!=pageOwner.id)){if(!pageOwner.isFamousFriend()){this.becomeFriendLink.style.display='block';this.addFanLink.style.display='none';this.becomeFriendLink.setStyle('left:'+(nicknameDimension+174)+'px');}else{this.becomeFriendLink.style.display='none';this.addFanLink.style.display='block';this.addFanLink.setStyle('left:'+(nicknameDimension+174)+'px');}}else{this.becomeFriendLink.style.display='none';this.addFanLink.style.display='none';}
this.youAreFriendAd.style.display='none';this.youAreFanAd.style.display='none';}}else{this.becomeFriendLink.style.display='none';this.addFanLink.style.display='none';this.youAreFriendAd.style.display='none';this.youAreFanAd.style.display='none';}
if(avatarVisible){if(pageOwner.avatarUrl!=null&&pageOwner.avatarUrl.strip().length>0){this.headerAvatar.select('img')[0].writeAttribute('src',pageOwner.avatarUrl);}
this.headerAvatar.setStyle('left:'+(nicknameDimension+96)+'px');}else{this.headerAvatar.hide();}},showPageOfMarker:function(pageOwner,show){if(show){var hasReqestedVersion=DetectFlashVer(requiredMajorVersion,requiredMinorVersion,requiredRevision);if(hasReqestedVersion){if(!pageOwner.isFamousFriend()){stringa=AC_FL_RunContent("src","/flash/mypage/pageOfMarker","width","256","height","19","align","middle","quality","high","wmode","transparent","menu","false","flashvars","nomeutente="+pageOwner.nickname,"allowScriptAccess","sameDomain","type","application/x-shockwave-flash",'codebase','http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',"pluginspage","http://www.adobe.com/go/getflashplayer");}else{stringa=AC_FL_RunContent("src","/flash/mypage/pageOfMarker_superuser","width","435","height","19","align","middle","quality","high","wmode","transparent","menu","false","flashvars","nomeutente="+pageOwner.nickname,"allowScriptAccess","sameDomain","type","application/x-shockwave-flash",'codebase','http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',"pluginspage","http://www.adobe.com/go/getflashplayer");}}else{var stringa='<img src="/images/mypage/page_of_marker.gif" alt="mypage.it/" /><span>'+pageOwner.nickname+'</span>';}
this.pageOfMarker.update(stringa);this.pageOfMarker.show();}else{this.pageOfMarker.hide();}},updateNewFriendshipItemsCounter:function(newValue){if(this.friendsNotifications){this.friendsNotifications.style.display=newValue>0?'block':'none'
this.friendsNotifications.innerHTML=newValue;}}})
var HeaderMyPage=Class.create({initialize:function(userManager,pageName){this.userManager=userManager;this.pageNmae=pageName;this.upperHeader=new UpperHeader(this,pageName);this.lowerHeader=new LowerHeader(this,pageName);this.actionToPerform=null;},staticHPLinkClicked:function(){this.userManager.staticHPLinkClicked();},starPagesLinkClicked:function(){this.userManager.starPagesLinkClicked();},loginLinkClicked:function(){this.userManager.loginLinkClicked();},logoutLinkClicked:function(){this.userManager.logoutLinkClicked();},registerLinkClicked:function(){this.userManager.registerLinkClicked();},writeToMyPageLinkClicked:function(){this.userManager.writeToMyPageLinkClicked();},profileLinkClicked:function(){this.userManager.profileLinkClicked();},accountLinkClicked:function(){this.userManager.accountLinkClicked();},passaparolaLinkClicked:function(){this.userManager.passaparolaLinkClicked();},friendsLinkClicked:function(){this.userManager.friendsLinkClicked();},awardsSupporterLinkClicked:function(){this.userManager.awardsSupporterLinkClicked();},homePageLinkClicked:function(){this.userManager.homePageLinkClicked();},closePageLinkClicked:function(){this.userManager.closePageLinkClicked();},becomeFriendLinkClicked:function(){this.userManager.becomeFriendLinkClicked();},addFanLinkClicked:function(){this.userManager.addFanLinkClicked();},update:function(){var headerConf=(typeof(arguments[0].myPageHeaderBehaviour)!='undefined'&&(arguments[0].myPageHeaderBehaviour!=null))?new MyPageHeaderConf(arguments[0].myPageHeaderBehaviour,arguments[0].myPageHeaderBehaviourAvoidFamous):null;this.upperHeader.update({user:arguments[0].user,pageOwner:arguments[0].pageOwner,myPageHeaderConf:headerConf})
this.lowerHeader.update({user:arguments[0].user,pageOwner:arguments[0].pageOwner,myPageHeaderConf:headerConf})},updateNewFriendshipItemsCounter:function(newValue){this.lowerHeader.updateNewFriendshipItemsCounter(newValue);}})
var UserManager=Class.create({initialize:function(options){this.pageTabs=options!=null&&options.pageTabs?options.pageTabs:arguments[0];this.user=options!=null&&options.user?options.user:arguments[1];this.pageOwner=options!=null&&options.pageOwner?options.pageOwner:arguments[2];this.tabDialog=options!=null&&options.tabDialog?options.tabDialog:arguments[3];this.pageName=options!=null&&options.pageName?options.pageName:arguments[4];this.communicator=options!=null&&options.communicator?options.communicator:arguments[5];var hasHeader=options!=null&&options.has_header?options.has_header:arguments[6];this.pageIsPrivate=options!=null&&options.pageIsPrivate?options.pageIsPrivate:null;this.pageAvailableToFamousUser=options!=null&&options.pageAvailableToFamousUser?options.pageAvailableToFamousUser:null
this.headerMyPage=hasHeader?new HeaderMyPage(this,this.pageName):null;this.pageToRefreshAtLogin=options!=null&&options.pageToRefreshAtLogin?options.pageToRefreshAtLogin:false;this.pageToRefreshAtLogout=options!=null&&options.pageToRefreshAtLogout?options.pageToRefreshAtLogout:this.pageToRefreshAtLogin;this.dialogAvvisi=null;this.actionsToPerform=new ActionsToPerform();this.eventQueueDispatcher=new EventQueueDispatcher();this.refreshPageAfterLogin=false;this.loginParameters=null;this.skipShowDialogAvvisi=false;this.start();},start:function(){this.checkUserInPage();this.subscribeAction({event:'login',when:'after',callback:new EventCallback({callback:this.showDialogAvvisi.bindAsEventListener(this),callbackParams:null,executeOnce:false,asynchronous:false,blocksQueue:false})})},showDialogAvvisi:function(options){var forceShow=options!=null&&options.force?options.force:false;var userId=options!=null&&options.userId?options.userId:null;if(this.user.hasDialogAvvisi&&(forceShow||(this.user.isLoggedIn()&&!this.skipShowDialogAvvisi))){var callbackToContinue=options!=null&&typeof options.callbackToContinue!='undefined'?options.callbackToContinue:null;this.dialogAvvisi=new DialogAvvisi({userManager:this,user:this.user,show:true,callbackToContinue:callbackToContinue,userId:userId});this.tabDialog.hideDialog();}},reloadDialogAvvisi:function(options){if(options!=null&&options.language!=null){this.dialogAvvisi.reload({language:options.language})}},subscribeAction:function(){this.eventQueueDispatcher.addCallback(arguments[0]);},checkSubscribeArguments:function(){if((arguments.length==0)||(arguments[0].event==null)||(['login','logout'].indexOf(arguments[0].event)==-1)||(arguments[0].when==null)||(['before','after'].indexOf(arguments[0].when)==-1)||(arguments[0].action==null)){return false;}else{return true;}},userCanAccessPage:function(){var pageIsPrivate=this.pageIsPrivate!=null?this.pageIsPrivate:["pass_the_word","pass_the_word_index","user_profile","friendship_page"].indexOf(this.pageName)!=-1
if(pageIsPrivate){if(this.user.isLoggedIn()){if(this.user.isFamousFriend()){var pageAvailableToFamousUser=this.pageAvailableToFamousUser!=null?this.pageAvailableToFamousUser:["pass_the_word","pass_the_word_index","friendship_page"].indexOf(this.pageName)!=-1
if(pageAvailableToFamousUser){return false;}else{return true;}}else{return true;}}else{return false;}}else{return true;}},checkUserInPage:function(){if(!this.userCanAccessPage()){location.href="/page/back_to_homepage";}},checkAlertForUser:function(){if(this.userCanAccessPage()){if(this.user.getId()!=this.pageOwner.getId()){if(!this.pageOwner.isFamousFriend()){if(this.user.isFamousFriend()){this.displayAlertForNotFriendUser({userIsFamous:true});}else{if(!this.user.isFriendWith(this.pageOwner)){this.displayAlertForNotFriendUser({userIsFamous:false});}}}}}},displayAlertForNotFriendUser:function(){var userIsFamous=typeof arguments[0]!='undefined'&&typeof arguments[0].userIsFamous!='undefined'?arguments[0].userIsFamous:false;var description=userIsFamous?message=i18n.stringLocale('not_friend_content_hidden','dialog',[this.pageOwner.nickname]):message=i18n.stringLocale('not_friend_content_hidden','dialog',[this.pageOwner.nickname])
this.tabDialog.displayMessage({title:'halt',description:description,actionOK:this.tabDialog.hideDialog.bind(this.tabDialog),size:'small'})
this.tabDialog.showDialog();},staticHPLinkClicked:function(){location.href='/';},starPagesLinkClicked:function(){null;},loginLinkClicked:function(){var redirectToHomepage=((this.pageName=='static_homepage'||this.pageName=='static_page')?false:true)
this.startLogin({redirectToHomepage:redirectToHomepage});},startLogin:function(options){if(options!=null&&options.skipShowDialogAvvisi==true){this.skipShowDialogAvvisi=true}
var redirectToHomepage=((typeof(arguments[0])!='undefined')&&(typeof(arguments[0].redirectToHomepage)!='undefined')&&(arguments[0].redirectToHomepage!=null))?arguments[0].redirectToHomepage:true;this.tabDialog.showLoginForm({callbacks:{loginConfirmed:this.loginConfirmed.bind(this,{redirectToHomepage:redirectToHomepage}),loginCancelled:this.loginCancelled.bindAsEventListener(this)},message:typeof arguments[0]!='undefined'?arguments[0].message:null});},loginConfirmed:function(){this.loginParameters=arguments[1].parameters;var redirectToHomepage=((typeof(arguments[0])!='undefined')&&(typeof(arguments[0].redirectToHomepage)!='undefined')&&(arguments[0].redirectToHomepage!=null))?arguments[0].redirectToHomepage:true;this.eventQueueDispatcher.eventHappen({event:'login',when:'before',callbackToContinueEvent:this.sendLoginRequest.bind(this,{redirectToHomepage:redirectToHomepage})});},loginCancelled:function(){this.eventQueueDispatcher.eventCancelled({event:'login'});this.tabDialog.hideDialog();},sendLoginRequest:function(){var redirectToHomepage=((typeof(arguments[0])!='undefined')&&(typeof(arguments[0].redirectToHomepage)!='undefined')&&(arguments[0].redirectToHomepage!=null))?arguments[0].redirectToHomepage:true;new Ajax.Request('/user/login',{asynchronous:true,evalScripts:true,parameters:this.loginParameters,requestHeaders:{Accept:'text/x-json'},onComplete:this.checkLoginResponse.bindAsEventListener(this,{redirectToHomepage:redirectToHomepage})})},checkLoginResponse:function(request){var redirectToHomepage=((typeof(arguments[1])!='undefined')&&(typeof(arguments[1].redirectToHomepage)!='undefined')&&(arguments[1].redirectToHomepage!=null))?arguments[1].redirectToHomepage:true;if(this.communicator.checkResponseFromServer({request:request,refreshOnLogout:true,tabDialog:this.tabDialog,redirectToHomepageOnLogin:redirectToHomepage})){var currentUserLang=this.user.getLang();this.user.setUserInfoFromServerData(request.responseJSON.content);this.refreshPageAfterLogin=(this.user.getLang()!=currentUserLang)||(this.pageToRefreshAtLogin);if((redirectToHomepage&&(this.user.id!=this.pageOwner.id))||this.refreshPageAfterLogin){this.skipShowDialogAvvisi=true}
this.eventQueueDispatcher.eventHappen({event:'login',when:'after',callbackToContinueEvent:this.completeLogin.bind(this,{redirectToHomepage:redirectToHomepage})});}},completeLogin:function(){var redirectToHomepage=((typeof(arguments[0])!='undefined')&&(typeof(arguments[0].redirectToHomepage)!='undefined')&&(arguments[0].redirectToHomepage!=null))?arguments[0].redirectToHomepage:true;if((redirectToHomepage)&&(this.user.id!=this.pageOwner.id)){this.tabDialog.waitAndRedirect({message:i18n.stringLocale('stai_andando_tua_pagina','dialog'),url:null,timeout:2000,showDialogAvvisiAtStartup:true});}else{if(this.refreshPageAfterLogin){this.pageTabs.forceRefresh({showDialogAvvisiAtStartup:true});}else{this.updateHeader();this.pageTabs.applyLoginToPage();}}
this.refreshPageAfterLogin=false;},logoutLinkClicked:function(){this.tabDialog.displayMessage({title:'exit',description:i18n.stringLocale('msg_uscita_1','dialog')+"</p><p>"+i18n.stringLocale('msg_uscita_2','dialog')+"</p><p>"+i18n.stringLocale('msg_uscita_3','dialog'),actions:'2buttons',actionOK:this.logoutConfirmed.bindAsEventListener(this),actionCancel:this.cancelLogout.bindAsEventListener(this)})
this.tabDialog.showDialog();},logoutConfirmed:function(){this.eventQueueDispatcher.eventHappen({event:'logout',when:'before',callbackToContinueEvent:this.startLogout.bind(this)});},cancelLogout:function(){this.eventQueueDispatcher.eventCancelled({event:'logout'});this.tabDialog.hideDialog();},startLogout:function(){new Ajax.Request('/user/logout',{asynchronous:true,evalScripts:true,onComplete:this.checkLogoutResponse.bindAsEventListener(this)});},checkLogoutResponse:function(request){var responseCheck=this.communicator.checkResponseFromServer({request:request,refreshOnLogout:true,tabDialog:this.tabDialog,forceRefreshCallback:this.forceRefresh.bind(this),forceLogoutCallback:this.forceLogout.bind(this),startLoginCallback:this.startLogin.bind(this)});if(responseCheck){if(request.responseJSON!=null&&typeof request.responseJSON.content!='undefined'&&request.responseJSON.content!=null){this.pageTabs.user.setUserInfoFromServerData(request.responseJSON.content);this.eventQueueDispatcher.eventHappen({event:'logout',when:'after',callbackToContinueEvent:this.completeLogout.bind(this)});}else{window.location.reload(true);}}},completeLogout:function(){this.tabDialog.hideDialog();if(!this.userCanAccessPage()){location.href="/page/back_to_homepage";}else{if(this.pageToRefreshAtLogout){this.pageTabs.forceRefresh()}else if(typeof(this.pageTabs.applyLogoutToPage)!='undefined'){this.pageTabs.applyLogoutToPage();}};this.updateHeader();},registerLinkClicked:function(){this.registerUser();},registerUser:function(){var url="/user/register/";switch(this.pageName){case'static_homepage':url="/user/register?from=static"
break;case'page':url="/user/register"
break;}
location.href=url;},writeToMyPageLinkClicked:function(){this.writeToMyPage();},writeToMyPage:function(){var userLang=this.user.getLang()||'it'
window.open('http://parental.mypage.it/'+userLang+'/support.php','support','height=600, width=550, left=20, top=20, resizable=yes, scrollbars=yes, menubar=yes, toolbar=yes, directories=yes, location=no, status=yes');},forceLogout:function(){this.user.logged_in=false;this.completeLogout();},forceRefresh:function(){if(typeof pageTabs.forceRefresh!='undefined'){pageTabs.forceRefresh();}else{window.location.reload(true);}},checkUserStatusAtStartUp:function(myPageHeaderBehaviour,myPageHeaderBehaviourAvoidFamous){this.updateHeader(myPageHeaderBehaviour,myPageHeaderBehaviourAvoidFamous);if(this.user.isLoggedIn()){if(typeof(this.pageTabs.applyLoginToPage)!='undefined'){this.pageTabs.applyLoginToPage({atStartup:true});}}},profileLinkClicked:function(){if(this.pageName!='user_profile'){location.href='/user/profile/'+this.user.id;}},accountLinkClicked:function(){if(this.pageName!='user_profile'){location.href='/user/profile/'+this.user.id;}},passaparolaLinkClicked:function(){if((this.pageName!='pass_the_word_index')&&(this.pageName!='pass_the_word')){location.href="/word_of_mouth/index/?page=1";}},friendsLinkClicked:function(){if(this.pageName!='friendship_page'){location.href="/friends";}},awardsSupporterLinkClicked:function(){if(this.pageName!='awards_supporter_personal_page'){location.href="/supporter"}},homePageLinkClicked:function(){location.href='/'+this.user.nickname;},closePageLinkClicked:function(){this.homePageLinkClicked();},becomeFriendLinkClicked:function(){this.becomeFriendSecond();},addFanLinkClicked:function(){this.becomeFriendSecond();},becomeFriendSecond:function(){var callbackToContinue=typeof arguments[0]!='undefined'&&typeof arguments[0].callbackToContinue!='undefined'?arguments[0].callbackToContinue:null;if(this.user.isRegistered()){if(this.user.isLoggedIn()){if(this.user.canRequireFriendship()!=false){if(this.user.canRequireFriendship()==true||(this.user.canRequireFriendship()=='only_famous_friends'&&this.pageOwner.isFamousFriend())){if((this.pageOwner.isRegistered())&&(this.pageOwner.nickname!=this.user.nickname)&&(!this.pageOwner.canHaveFriends())){this.sendMailToParent({caller:this.user,receiver:this.pageOwner,callerIsBlocked:false});message=i18n.stringLocale('amico_controllato_1','dialog')+this.pageOwner.nickname+i18n.stringLocale('amico_controllato_2','dialog');this.tabDialog.displayMessage({title:'halt',description:message,actionOK:this.addFriendRequestFailed.bind(this,{callbackToContinue:callbackToContinue}),size:'small'})
this.tabDialog.showDialog();}else{var addingFriendNickname=this.pageOwner.nickname;this.startFriendshipRequest({friendNickname:addingFriendNickname,callbackToContinue:callbackToContinue})}}else{this.sendMailToParent({caller:this.user,receiver:this.pageOwner,callerIsBlocked:true});message=i18n.stringLocale('user_controllato','dialog')
this.tabDialog.displayMessage({title:'halt',description:message,actionOK:this.addFriendRequestFailed.bind(this,{callbackToContinue:callbackToContinue}),size:'small'})
this.tabDialog.showDialog();}}else{this.sendMailToParent({caller:this.user,receiver:this.pageOwner,callerIsBlocked:true});message=i18n.stringLocale('cannot_ask_friendship','dialog')
this.tabDialog.displayMessage({title:'halt',description:message,actionOK:this.addFriendRequestFailed.bind(this,{callbackToContinue:callbackToContinue}),size:'small'})
this.tabDialog.showDialog();}}else{this.subscribeAction({event:'login',when:'after',placeFirst:true,callback:new EventCallback({callback:this.becomeFriendSecond.bindAsEventListener(this),callbackParams:null,executeOnce:true,asynchronous:false,blocksQueue:true})})
message=i18n.stringLocale('friendship_checker_login','dialog');this.tabDialog.displayMessage({title:'halt',description:message,actions:'2buttons',actionOK:this.startLogin.bind(this,{redirectToHomepage:false}),actionCancel:this.tabDialog.hideDialog.bindAsEventListener(this.tabDialog)})
this.tabDialog.showDialog();}}else{message=i18n.stringLocale('friendship_checker_register','dialog');this.tabDialog.displayMessage({title:'halt',description:message,actions:'1button',actionOK:this.registerUser.bindAsEventListener(this),actionCancel:this.tabDialog.hideDialog.bindAsEventListener(this.tabDialog)})
this.tabDialog.showDialog();}},startFriendshipRequest:function(){var callbackToContinue=typeof arguments[0]!='undefined'&&typeof arguments[0].callbackToContinue!='undefined'?arguments[0].callbackToContinue:null;this.addingFriendNickname=arguments[0].friendNickname;var objectToPost={'nickname':this.addingFriendNickname};var options={JSON:true,evalJS:true,onComplete:this.checkAddFriendResponse.bindAsEventListener(this,{callbackToContinue:callbackToContinue})};this.communicator.sendRequest('/friendship/add_friend/',objectToPost,options);},checkAddFriendResponse:function(request){var callbackToContinue=arguments[1].callbackToContinue;var title='warning';var size='big';if(this.communicator.checkResponseFromServer({request:request,refreshOnLogout:true,tabDialog:this.tabDialog,callbackOnApplicationError:this.addFriendRequestFailed.bind(this,{callbackToContinue:callbackToContinue})})){var response=request.responseJSON;if(response.status.action_to_perform=='insertMagicSpell'){this.tabDialog.showAddFriendForm({},{friendNickname:this.addingFriendNickname,callbackToContinue:callbackToContinue});}else{if(response.status.action_result=='OK'){title='good';size='small';actionOK=this.addFriendRequestCompleted.bind(this,{response:response,callbackToContinue:callbackToContinue});}else{actionOK=this.addFriendRequestFailed.bind(this,{callbackToContinue:callbackToContinue});}
this.tabDialog.displayMessage({title:title,description:response.status.message,actions:'1button',actionOK:actionOK,size:size})
this.tabDialog.showDialog();}}},addFriendRequestCompleted:function(){this.tabDialog.hideDialog();if(typeof arguments[0]!='undefined'&&typeof arguments[0].response!='undefined'&&typeof arguments[0].response.content!='undefined'&&arguments[0].response.content!=null){this.user.setUserInfoFromServerData(arguments[0].response.content);}
this.updateHeader();if(typeof arguments[0]!='undefined'&&typeof arguments[0].callbackToContinue!='undefined'&&arguments[0].callbackToContinue!=null){arguments[0].callbackToContinue();}},addFriendRequestFailed:function(){this.tabDialog.hideDialog();if(typeof arguments[0]!='undefined'&&typeof arguments[0].callbackToContinue!='undefined'&&arguments[0].callbackToContinue!=null){arguments[0].callbackToContinue();}},reloadUserInfo:function(){var includePageOwner=typeof arguments[0]!='undefined'&&arguments[0].includePageOwner!=null?arguments[0].includePageOwner:false
var objectToPost=includePageOwner?this.pageOwner.getId():null;var options={JSON:false,evalJS:false,requestHeaders:{Accept:'text/x-json'},onComplete:this.checkReloadUserInfoResponse.bindAsEventListener(this)};this.communicator.sendRequest('/user/reload_user_info/',objectToPost,options);},checkReloadUserInfoResponse:function(request){if(this.communicator.checkResponseFromServer({request:request,refreshOnLogout:true,tabDialog:this.tabDialog})){var content=request.responseJSON.content;this.user.setUserInfoFromServerData(content.user);this.pageOwner.setUserInfoFromServerData(content.page_owner);this.updateHeader();}},updateHeader:function(myPageHeaderBehaviour,myPageHeaderBehaviourAvoidFamous){if(this.headerMyPage!=null){this.headerMyPage.update({user:this.user,pageOwner:this.pageOwner,myPageHeaderBehaviour:myPageHeaderBehaviour,myPageHeaderBehaviourAvoidFamous:myPageHeaderBehaviourAvoidFamous});}},updateNewFriendshipItemsCounter:function(newValue){this.headerMyPage.updateNewFriendshipItemsCounter(newValue);},sendMailToParent:function(){var caller=arguments[0].caller;var receiver=arguments[0].receiver;var callerIsBlocked=arguments[0].callerIsBlocked;var objectToPost={caller_id:caller.getId(),receiver_id:receiver.getId(),caller_is_blocked:callerIsBlocked}
var options={JSON:true,evalJS:false};this.communicator.sendRequest('/friendship/send_mail_to_parent_for_friendship/',objectToPost,options);},pageOwnerIsFriendWithUser:function(){var friendship=this.pageOwner.isFriendWith(this.user);if(friendship!=false){if(this.user.isFamousFriend()){return'userIsFamous';}else{return friendship;}}else{return friendship;}},userIsFriendWithOtherById:function(otherId){var friendship=this.user.isFriendWithById(otherId);if(friendship!=false){if(this.user.isFamousFriend()){return'userIsFamous';}else{return friendship;}}else{return friendship;}},goToPage:function(options){var options=options.parameters!=null?options.parameters:options
if(this.user.isLoggedIn()){if(options.page=='friends'){location.href="/friends";}else if(options.page=='profile'){switch(options.tab){case('avatar'):location.href="/user/profile?tab=avatar";break;case('magic_spell'):location.href="/user/profile?tab=magic_spell";break;default:location.href="/user/profile?tab=account";}}}else{this.subscribeAction({event:'login',when:'after',callback:new EventCallback({callback:this.goToPage.bindAsEventListener(this),callbackParams:options,executeOnce:true,asynchronous:false,blocksQueue:true})})
this.startLogin({redirectToHomepage:false})}}})
var FlashPreloader=Class.create({initialize:function(options){this.idDivContainer=options.idDivContainer;this.browser=options.browser!=null?options.browser:BrowserDetect.browser;this.movieFlash=null;this.objectFlash=null;this.intervalId=null;this.divContainer=null;this.spinnerBuilded=0;this.topForPreloaderImage=options.topForPreloaderImage
this.leftForPreloaderImage=options.leftForPreloaderImage
this.imageForSpinner=options.imageForSpinner},getContainerFlashObject:function(){this.divContainer=$(''+this.idDivContainer+'')},buildContainerSpinner:function(){if(!this.spinnerBuilded){this.divContainer.parentNode.insert({bottom:'<div id=\"spinner_for_preload\" style=\"display:block; position:absolute; top:'+this.topForPreloaderImage+'px; left:'+this.leftForPreloaderImage+'px;width:100px;height:40px;\" >'+'<img src=\"/images/'+this.imageForSpinner+'.gif\"/ style=\"float:left;\">'+'<span id=\"percent_loaded\" style=\"position: relative; text-align: center; width: 250px; height: 30px;left:10px;top:5px;\"></span></div>'})
this.spinnerBuilded=1}else{$('spinner_for_preload').style.display=""
$('spinner_for_preload').update('<img src=\"/images/'+this.imageForSpinner+'.gif\"/ style=\"float:left;\">'+'<span id=\"percent_loaded\" style=\"position: relative; text-align: center; width: 250px; height: 30px;left:10px;top:5px;\"></span>')}},getFlashName:function(){this.movieFlash=this.divContainer.down().src},getMovieFlashIstance:function(){if(this.browser=="Firefox"||this.browser=="Safari"){i=0
while(window.document.plugins[i]!=null){if(this.movieFlash==window.document.plugins[i].src){this.objectFlash=window.document.plugins[i]
break;}else
i++;}}else{if(this.divContainer)
this.objectFlash=this.divContainer.down('OBJECT').object}
return this.objectFlash;},hideObjectFlash:function(){this.divContainer.style.visibility="hidden"},stopPreloader:function(){if(this.intervalId){this.intervalId.stop();this.intervalId=null}},getFlash:function(){this.getContainerFlashObject()
this.getFlashName();return this.getMovieFlashIstance();},initPreloader:function(){this.getContainerFlashObject()
this.getFlashName();this.hideObjectFlash();return this.getMovieFlashIstance();},startPreloader:function(){this.intervalId=new PeriodicalExecuter(this.checkFlashLoading.bindAsEventListener(this),1);},checkFlashLoading:function(){if(this.objectFlash.PercentLoaded()==100){$('spinner_for_preload').style.display="none"
this.divContainer.style.visibility=""
if(this.intervalId)
this.stopPreloader()}else{$('percent_loaded').innerHTML=this.objectFlash.PercentLoaded()+" %"}}})
var mpConfig=new MPConfiguration();var i18n=new I18N();


Ajax.JSON=Class.create(Ajax.Request,{initialize:function($super,url,options){options=options||{};options.method='post';options.contentType='application/json';options.postBody=Object.toJSON(options.object);$super(url,options);}});var Request=Class.create({initialize:function(communicator,url,requestObj,options){this.communicator=communicator;var defaults={JSON:false,asynchronous:true,evalScripts:true,requestHeaders:{Accept:'text/x-json'},evalJS:false,sanitizeJSON:true,onComplete:null}
this.url=url;this.requestObj=requestObj;this.options=Object.extend(defaults,options||{});this.completed=false;},perform:function(){if(!this.options.JSON){new Ajax.Request(this.url+this.requestObj,{asynchronous:this.options.asynchronous,evalScripts:this.options.evalScripts,requestHeaders:this.options.requestHeaders,evalJS:this.options.evalJS,onComplete:this.callback.bindAsEventListener(this)});}else{new Ajax.JSON(this.url,{object:this.requestObj,asynchronous:this.options.asynchronous,evalScripts:this.options.evalScripts,requestHeaders:this.options.requestHeaders,evalJS:this.options.evalJS,sanitizeJSON:this.options.sanitizeJSON,onComplete:this.callback.bindAsEventListener(this)});}},callback:function(request){if(this.options.onComplete!=null){this.options.onComplete((this.communicator.checkResponse(request)?request:false));}
this.completed=true;}})
var Communicator=Class.create({initialize:function(){this.requests=new Array();this.unloading_page=false;},sendRequest:function(url,requestObj,options){if((BrowserDetect.browser=="Safari")&&(this.unloading_page)){options.asynchronous=false;}
var req=new Request(this,url,requestObj,options);this.requests.push(req)
req.perform();},checkResponse:function(request){return true;},set_unloading_page:function(unloading_page){this.unloading_page=unloading_page;},checkResponseFromServer:function(){var request=arguments[0].request;var refreshOnLogout=typeof arguments[0].refreshOnLogout!='undefined'?arguments[0].refreshOnLogout:false;var redirectToHomepageOnLogin=typeof arguments[0].redirectToHomepageOnLogin!='undefined'?arguments[0].redirectToHomepageOnLogin:true;var tabDialog=typeof arguments[0].tabDialog!='undefined'?arguments[0].tabDialog:pageTabs.tabDialog;var callbackOnApplicationError=typeof arguments[0].callbackOnApplicationError!='undefined'?arguments[0].callbackOnApplicationError:tabDialog.hideDialog.bind(tabDialog);var callbackOnSystemError=typeof arguments[0].callbackOnSystemError!='undefined'?arguments[0].callbackOnSystemError:generalReloadPage.bind();var forceRefreshCallback=typeof arguments[0].forceRefreshCallback!='undefined'?arguments[0].forceRefreshCallback:(typeof pageTabs.forceRefresh!='undefined'?pageTabs.forceRefresh.bind(pageTabs):generalReloadPage.bind());var forceLogoutCallback=typeof arguments[0].forceLogoutCallback!='undefined'?arguments[0].forceLogoutCallback:(typeof pageTabs.forceLogout!='undefined'?pageTabs.forceLogout.bind(pageTabs):tabDialog.hideDialog.bind(tabDialog));var startLoginCallback=typeof arguments[0].startLoginCallback!='undefined'?arguments[0].startLoginCallback:(typeof pageTabs.startLogin!='undefined'?pageTabs.startLogin.bind(pageTabs,{redirectToHomepage:redirectToHomepageOnLogin}):tabDialog.hideDialog.bind(tabDialog));var error=false
var title=null;var actions=null;var description=null;var actionOK=null;var size='big';if(request.status=='200'){if(typeof(request.responseJSON)!='undefined'&&request.responseJSON!=null){response=request.responseJSON;if(response.status.action_result=='OK'){error=false;}else{error=true;title='warning';description=response.status.message;actions='1button';actionOK=generalReloadPage.bindAsEventListener();if(typeof response.status.action_to_perform!='undefined'&&response.status.action_to_perform!=null){switch(response.status.action_to_perform){case'logout!':title='halt';size='small';if(refreshOnLogout){actionOK=forceRefreshCallback;}else{actionOK=forceLogoutCallback;}
break;case'login!':actionOK=startLoginCallback;break;case'reload':title='halt';size='small';actionOK=forceRefreshCallback;break;case'show_dialog_avvisi':title='halt';size='small';actionOK=pageTabs.showDialogAvvisi({force:true,userId:response.content.id})
break;default:title='halt';size='small';actionOK=callbackOnApplicationError;}}else{actionOK=callbackOnApplicationError;}}}else{if(request.statusText=='OK'){error=false;}else{error=true;title='warning';description="ERROR OCCURRED";actions='1button';actionOK=callbackOnApplicationError;}}}else{error=true;title='halt';description=i18n.stringLocale('problema_server_prova_1_minuto','dialog');actions='1button';actionOK=callbackOnSystemError;size='small'}
if(!error){return true;}else{tabDialog.displayMessage({title:title,description:description||i18n.stringLocale('problema_server_prova_1_minuto','dialog'),actions:actions,actionOK:actionOK,size:size})
tabDialog.showDialog();return false;}}});


function dragObserver(){dragObserver.prototype.onEnd=function(eventName,draggable,event){manageEndDrag(draggable.element);}}
function manageEndDrag(draggableElement){if(!pageTabs.isDroppingKidget()){if(pageTabs.userCanModifyPage()){if(pageTabs.getMovingKidget()!=null){if(!pageTabs.checkKidgetPositionIntoPage(draggableElement)){pageTabs.onTabFlapDrop(draggableElement,null);}else{pageTabs.dropKidgetOnCurrentTab($(pageTabs.getMovingKidget().id));}
pageTabs.setMovingKidget(null);}
var moved;draggObjects=pageTabs.getCurrentTab().getDraggObjects();var dragged=null;for(p=0;(p<draggObjects.length)&&(dragged==null);p++){if(draggObjects[p].obj==draggableElement){dragged=draggObjects[p];currentDragged=dragged;}}
if(dragged==null){}
if(pageTabs.checkKidgetPositionIntoPage(dragged.obj)){dragged.setPosition();moved=lookWhoSUnderAndMove(dragged,draggObjects);if(moved!=true){dragged.y=dragged.y+(moved[3]-dragged.y)+20;dragged.ye=dragged.y+dragged.h
new Effect.Move(dragged.obj,{x:dragged.x,y:dragged.y+(moved[3]-dragged.y)+20,mode:'absolute',duration:(0.5)*(dragged.area/150000)+0.3});moved=lookWhoSUnderAndMove(dragged,draggObjects);}}else{new Effect.Move(dragged.obj,{x:dragged.x,y:dragged.y,mode:'absolute',duration:(0.5)*(dragged.area/150000)+0.3});}}}
pageTabs.checkPageBottom();}
function lookWhoSUnderAndMove(dragged,draggObjects){var moved=true;var underPosition=[0,0,0,0];for(q=0;q<draggObjects.length;q++){if(draggObjects[q].obj!=dragged.obj){draggObjects[q].setPosition();}}
for(q=0;q<draggObjects.length;q++){if(draggObjects[q]!=dragged){if(draggObjects[q].isUnder(dragged)){for(r=0;r<draggObjects.length;r++){if(draggObjects[r]!=dragged){draggObjects[r].setNeighboursFirst(dragged,draggObjects);}}
for(r=0;r<draggObjects.length;r++){if(draggObjects[r]!=dragged){draggObjects[r].setNeighboursSecond();}}
moved=draggObjects[q].firstToMove(dragged,draggObjects);if(!moved){underPosition=[draggObjects[q].x,draggObjects[q].y,draggObjects[q].xe,draggObjects[q].ye];return underPosition;}}}}
return moved;}
function draggableObject(object,draggObjects){this.obj=document.getElementById(object);this.above=new Array();this.right=new Array();this.under=new Array();this.left=new Array();this.moved=false;this.x=0;this.y=0;this.w=0;this.h=0;this.xe=0;this.ye=0;this.area=0;this.setPosition=function(){if((this.x!=0)&&(this.y!=0)){if((this.x!=parseInt(Element.getStyle(this.obj,'left')))||(this.y!=parseInt(Element.getStyle(this.obj,'top')))){this.moved=true;}}
this.x=this.obj.offsetLeft;this.y=this.obj.offsetTop;this.w=parseInt(Element.getStyle(this.obj,'width'))+
parseInt(Element.getStyle(this.obj,'padding-right'))+
parseInt(Element.getStyle(this.obj,'padding-left'));this.h=parseInt(Element.getStyle(this.obj,'height'))+
parseInt(Element.getStyle(this.obj,'padding-top'))+
parseInt(Element.getStyle(this.obj,'padding-bottom'));this.xe=this.x+this.w;this.ye=this.y+this.h;this.area=this.w*this.h;}
this.isUnder=function(object){var d1=this.x-object.x;var d2=(object.x+object.w)-this.x;var d3=object.x-this.x;var d4=(this.x+this.w)-object.x;var d5=this.y-object.y;var d6=(object.y+object.h)-this.y;var d7=object.y-this.y;var d8=(this.y+this.h)-object.y;var IMUnder=(((d1>=0)&&(d2>=0))||((d3>=0)&&(d4>=0)))&&(((d5>=0)&&(d6>=0))||((d7>=0)&&(d8>=0)));return IMUnder;}
this.setNeighboursFirst=function(exceptObj,draggObjects){this.above=this.above.clear();this.right=this.right.clear();this.under=this.under.clear();this.left=this.left.clear();for(i=0;i<draggObjects.length;i++){var nbour=draggObjects[i];if((nbour.obj!=this.obj)&&(nbour.obj!=exceptObj.obj)){if(nbour.ye<this.y)
{if(((this.x<=nbour.x)&&(nbour.x<=this.xe))||((this.x<=nbour.xe)&&(nbour.xe<=this.xe))||((nbour.x<=this.x)&&(this.xe<=nbour.xe)))
{this.above.push(nbour);}}
else if(this.xe<nbour.x)
{if(((this.y<=nbour.y)&&(nbour.y<=this.ye))||((this.y<=nbour.ye)&&(nbour.ye<=this.ye))||((nbour.y<=this.y)&&(this.ye<=nbour.ye)))
{this.right.push(nbour);}}
else if(this.ye<nbour.y)
{if(((this.x<=nbour.x)&&(nbour.x<=this.xe))||((this.x<=nbour.xe)&&(nbour.xe<=this.xe))||((nbour.x<=this.x)&&(this.xe<=nbour.xe)))
{this.under.push(nbour);}}
else
{if(((this.y<=nbour.y)&&(nbour.y<=this.ye))||((this.y<=nbour.ye)&&(nbour.ye<=this.ye))||((nbour.y<=this.y)&&(this.ye<=nbour.ye)))
{this.left.push(nbour);}}}}}
this.setNeighboursSecond=function(){for(i=0;i<this.above.length;i++)
{for(j=0;j<this.above.length;j++)
{if(this.above[i].isUnderYou(this.above[j].obj))
{this.above[i]=null;this.above=this.above.compact();break;}}}
for(i=0;i<this.right.length;i++)
{for(j=0;j<this.right.length;j++)
{if(this.right[i].isLeftYou(this.right[j].obj))
{this.right[i]=null;this.right=this.right.compact();break;}}}
for(i=0;i<this.under.length;i++)
{for(j=0;j<this.under.length;j++)
{if(this.under[i].isAboveYou(this.under[j].obj))
{this.under[i]=null;this.under=this.under.compact();break;}}}
for(i=0;i<this.left.length;i++)
{for(j=0;j<this.left.length;j++)
{if(this.left[i].isRightYou(this.left[j].obj))
{this.left[i]=null;this.left=this.left.compact();break;}}}}
this.isAboveYou=function(object){if((object==null)||(object==this.obj))
{return false;}
else
{var retValue=false;for(m=0;m<this.above.length;m++)
{if(this.above[m].obj==object){retValue=true}}
return retValue}}
this.isRightYou=function(object){if((object==null)||(object==this.obj))
{return false;}
else
{var retValue=false;for(m=0;m<this.right.length;m++)
{if(this.right[m].obj==object){retValue=true}}
return retValue}}
this.isUnderYou=function(object){if((object==null)||(object==this.obj))
{return false;}
else
{var retValue=false;for(m=0;m<this.under.length;m++)
{if(this.under[m].obj==object){retValue=true}}
return retValue}}
this.isLeftYou=function(object){if((object==null)||(object==this.obj))
{return false;}
else
{var retValue=false;for(m=0;m<this.left.length;m++)
{if(this.left[m].obj==object){retValue=true}}
return retValue;}}
this.firstToMove=function(object,draggObjects){var movX=0;var movY=0;var xci=0;var xco=0;var yci=0;var yco=0;var d1=this.x-object.x;var d2=(object.x+object.w)-this.x;var d3=object.x-this.x;var d4=(this.x+this.w)-object.x;var d5=this.y-object.y;var d6=(object.y+object.h)-this.y;var d7=object.y-this.y;var d8=(this.y+this.h)-object.y;var d9=(object.x+object.w)-(this.x+this.w);var d10=(object.y+object.h)-(this.y+this.h);if(d1>0)
{if(d5>0)
{if(d10>0)
{movX=d2+20;}
else if(d9>0)
{movY=d6+20;}
else
{movX=d2+20;movY=d6+20;}}
else
{if(d9>0)
{movY=-d8-20;}
else if(d10>0)
{movX=d2+20;movY=-d8-20;}
else
{movX=d2+20;}}}
else if(d10>0)
{if(d9>0)
{if(d5>0)
{movX=-d4-20;}
else
{movX=-d4-20;movY=-d8-20;}}
else
{movY=-d8-20;}}
else
{if(d5>0)
{if(d9>0)
{movX=-d4-20;movY=d6+20;}
else
{movY=d6+20;}}
else
{if(d9>0)
{movX=-d4-20;}
else
{xci=object.x+(object.w)/2;xco=this.x+(this.w)/2;yci=object.y+(object.h)/2;yco=this.y+(this.h)/2
if((xco-xci)>=0)
{if((yco-yci)>=0)
{movX=(object.xe+20)-this.x;movY=(object.ye+20)-this.y;}
else
{movX=(object.xe+20)-this.x;movY=(object.y-this.h-20)-this.y;}}
else
{if((yco-yci)>=0)
{movX=(object.x-this.w-20)-this.x;movY=(object.ye+20)-this.y;}
else
{movX=(object.x-this.w-20)-this.x;movY=(object.y-this.h-20)-this.y;}}}}}
var moved=this.move(movX,movY,object.x,object.y,object.w,object.h,draggObjects);if(!moved){movY=object.y+object.h+20-this.y
var moved=this.move(0,movY,object.x,object.y,object.w,object.h,draggObjects)}
return moved;}
this.move=function(movX,movY,hisFinalX,hisFinalY,hisW,hisH,draggObjects){var myMovX=0;var MyMovY=0;var nextX=0;var nextY=0;var hisBottomRightX=0;var hisBottomRighty=0;var tmpObjects=new Array();var result=true;var id1=0;var id2=0;var id3=0;var id4=0;var id5=0;var id6=0;var id7=0;var id8=0;var id9=0;var id10=0;if((this.y+movY)<0)
{return false;}
if(movX>0)
{for(id5=0;id5<this.right.length;id5++)
{if(((this.right[id5].x-this.xe)-movX)<20)
{result=this.right[id5].move(movX,0,this.x+movX,this.y+movY,this.w,this.h);}}
if(movY>0)
{for(i=0;i<draggObjects.length;i++)
{if((this.xe<draggObjects[i].x)&&(this.ye<draggObjects[i].y)&&(draggObjects[i]!=currentDragged))
{tmpObjects.push(draggObjects[i]);}}
nextX=this.xe+movX;nextY=this.ye+movY;for(id1=0;id1<tmpObjects.length;id1++)
{if((tmpObjects[id1].x<=nextX)&&(tmpObjects[id1].y<=nextY))
{result=tmpObjects[id1].move(movX,movY,this.x+movX,this.y+movY,this.w,this.h);}}}
else if(movY<0)
{for(i=0;i<draggObjects.length;i++)
{if((this.xe<draggObjects[i].x)&&(draggObjects[i].ye<this.y)&&(draggObjects[i]!=currentDragged))
{tmpObjects.push(draggObjects[i]);}}
nextX=this.xe+movX;nextY=this.y+movY;for(id2=0;id2<tmpObjects.length;id2++)
{if((tmpObjects[id2].x<=nextX)&&(nextY<=tmpObjects[id2].ye))
{result=tmpObjects[id2].move(movX,movY,this.x+movX,this.y+movY,this.w,this.h);}}}}
else if(movX<0)
{for(id6=0;id6<this.left.length;id6++)
{if(((this.x-this.left[id6].xe)-(-movX))<20)
{result=this.left[id6].move(movX,0,this.x+movX,this.y+movY,this.w,this.h);}}
if(movY>0)
{for(i=0;i<draggObjects.length;i++)
{if((draggObjects[i].xe<this.x)&&(this.ye<draggObjects[i].y)&&(draggObjects[i]!=currentDragged))
{tmpObjects.push(draggObjects[i])}}
nextX=this.x+movX;nextY=this.ye+movY;for(id3=0;id3<tmpObjects.length;id3++)
{if((nextX<tmpObjects[id3].xe)&&(tmpObjects[id3].y<=nextY))
{result=tmpObjects[id3].move(movX,movY,this.x+movX,this.y+movY,this.w,this.h);}}}
else if(movY<0)
{for(i=0;i<draggObjects.length;i++)
{if((draggObjects[i].xe<this.x)&&(draggObjects[i].ye<this.y)&&(draggObjects[i]!=currentDragged))
{tmpObjects.push(draggObjects[i])}}
nextX=this.x+movX;nextY=this.y+movY;for(id4=0;id4<tmpObjects.length;id4++)
{if((nextX<tmpObjects[id4].xe)&&(nextY<=tmpObjects[id4].ye))
{result=tmpObjects[id4].move(movX,movY,this.x+movX,this.y+movY,this.w,this.h);}}}}
if(movY>0)
{for(id7=0;id7<this.under.length;id7++)
{if(((this.under[id7].y-this.ye)-movY)<20)
{result=this.under[id7].move(0,movY,this.x+movX,this.y+movY,this.w,this.h);}}}
else if(movY<0)
{for(id8=0;id8<this.above.length;id8++)
{if(((this.y-this.above[id8].ye)-(-movY))<20)
{result=this.above[id8].move(0,movY,this.x+movX,this.y+movY,this.w,this.h);}}}
if(movX>0)
{if((this.xe+movX)>maxW)
{hisBottomRightX=hisFinalX+hisW;hisBottomRightY=hisFinalY+hisH;movY=hisBottomRightY-this.y+20;movX=0;for(id9=0;id9<this.under.length;id9++)
{if(((this.under[id9].y-this.ye)-movY)<20)
{result=this.under[id9].move(0,movY,this.x+movX,this.y+movY,this.w,this.h);}}}}
else if(movX<0)
{if((this.x+movX)<0)
{hisBottomLeftX=hisFinalX;hisBottomLeftY=hisFinalY+hisH;movY=hisBottomLeftY-this.y+20;movX=0;for(id10=0;id10<this.under.length;id10++)
{if((this.under[id10].y-this.ye)-movY<20)
{result=this.under[id10].move(0,movY,this.x+movX,this.y+movY,this.w,this.h);}}}}
else if(movY<0)
{if((this.y+movY)<0)
{return false;}}
if(result)
{new Effect.Move(this.obj,{x:(this.x+movX),y:(this.y+movY),mode:'absolute',duration:(0.5)*(this.area/150000)+0.3});this.x=this.x+movX;this.y=this.y+movY;this.xe=this.xe+movX;this.ye=this.ye+movY;this.moved=true;}
return result;}}


var KXXXGeneric=Class.create({initialize:function(kidget_id,sConf,kLang){this.kidgetId=kidget_id;this.kidget=null;this.sConf=sConf;this.kidgetLanguage=kLang;this.overFlap=null;},setKidget:function(kidget){kidget.setSpecificKidget(this)
this.kidget=kidget;},bindKidget:function(){this.bindStdButtons();this.bindBackFlaps();this.kidget.manageZIndexes();},bindStdButtons:function(){this.kidget.addBeforeStdButton("turn_back",this.beforeTurnBack);this.kidget.addBeforeStdButton("delete",this.beforeDelete);this.kidget.addBeforeStdButton("back_OK",this.beforeBackOK);this.kidget.addBeforeStdButton("back_cancel",this.beforeBackCancel);this.kidget.addAfterAction("turn_back",this.afterTurnBack);this.kidget.addAfterAction("restore",this.afterRestore);this.kidget.bindStandardBtns(this);this.kidget.bindStandardComponents(this);this.kidget.bindStandardFields(this);},bindBackFlaps:function(){if(this.automaticBindBackFlaps){var counterForFlap=1
var nameOfFlap=null;var containerFlap=null;while($$('#'+this.kidget.id+' .kdflaps_idle .kdflap_'+counterForFlap)[0]!=null){containerFlap=$$('#'+this.kidget.id+' .kdflaps_idle .kdflap_'+counterForFlap)[0]
if(BrowserDetect.browser=="Firefox"){nameOfFlap=$$('#'+this.kidget.id+' .kdflaps_idle .kdflap_'+counterForFlap)[0].textContent}else{nameOfFlap=$$('#'+this.kidget.id+' .kdflaps_idle .kdflap_'+counterForFlap)[0].innerText}
if(nameOfFlap.toLowerCase()=="invia"||nameOfFlap.toLowerCase()=="send"||nameOfFlap.toLowerCase()=="envoie"){nameOfFlap="notifica"}else if(nameOfFlap.toLowerCase()=="incolla"||nameOfFlap.toLowerCase()=="paste"||nameOfFlap.toLowerCase()=="colle"){nameOfFlap="importa"}else if(nameOfFlap.toLowerCase()=="scarica"||nameOfFlap.toLowerCase()=="download"||nameOfFlap.toLowerCase()=="télécharge"){nameOfFlap="scarica"}
this.kidget.addBackTab(nameOfFlap,containerFlap);if(counterForFlap==1){this.kidget.setDefaultTab(nameOfFlap);}
counterForFlap++}}},displayKidget:function(){$$('#'+this.kidget.id+' .kdfront')[0].setOpacity(0);$$('#'+this.kidget.id+' .kdfront')[0].show();new Effect.Opacity($$('#'+this.kidget.id+' .kdwait')[0],{duration:0.6,from:1,to:0,afterFinish:this.hideSpinner.bindAsEventListener(this)})
new Effect.Opacity($$('#'+this.kidget.id+' .kdfront')[0],{duration:0.6,from:0,to:1})},hideSpinner:function(){$$('#'+this.kidget.id+' .kdwait')[0].hide();},setLanguage:function(lang){this.kidgetLanguage=lang;},getLanguage:function(){return this.kidgetLanguage;},stringLocale:function(stringName,kidgetSpecific){if(arguments[0].stringName){string_name=arguments[0].stringName;lang=(arguments[0].kidgetSpecific&&arguments[0].kidgetSpecific==true)?(this.kidgetLanguage||pageTabs.getUserLang()):pageTabs.getUserLang();}else{string_name=stringName
lang=(typeof(kidgetSpecific)!='undefined'&&kidgetSpecific==true)?(this.kidgetLanguage||pageTabs.getUserLang()):pageTabs.getUserLang();}
return this.sConf[string_name][lang];},imageLocale:function(imagePath,kidgetSpecific){if(arguments[0].imagePath){image_path=arguments[0].imagePath;lang=(arguments[0].kidgetSpecific&&arguments[0].kidgetSpecific==true)?(this.kidgetLanguage||pageTabs.getUserLang()):pageTabs.getUserLang();}else{image_path=imagePath
lang=(typeof(kidgetSpecific)!='undefined'&&kidgetSpecific==true)?(this.kidgetLanguage||pageTabs.getUserLang()):pageTabs.getUserLang();}
return i18n.imageLocale(image_path,lang);},mediaLocale:function(mediaPath,kidgetSpecific){if(arguments[0].mediaPath){media_path=arguments[0].mediaPath;lang=(arguments[0].kidgetSpecific&&arguments[0].kidgetSpecific==true)?(this.kidgetLanguage||pageTabs.getUserLang()):pageTabs.getUserLang();}else{media_path=mediaPath
lang=(typeof(kidgetSpecific)!='undefined'&&kidgetSpecific==true)?(this.kidgetLanguage||pageTabs.getUserLang()):pageTabs.getUserLang();}
return i18n.mediaLocale(media_path,lang);},getConfigurationVar:function(varName){return this.sConf[varName];},createFlashObject:function(options){var kidgetType=options.kidgetType
var kidgetSwItemName=options.kidgetSwItemName
var flashFilename=options.flashFilename;var flashWidth=options.flashWidth;var flashHeight=options.flashHeight;var wmode=options.wmode?options.wmode:'transparent';var noFlashImgFileName=options.noFlashImgFilename;var flashIsUrl=options.flashIsUrl?options.flashIsUrl:false;var flashVars=options.flashVars?options.flashVars:false;var addIdToFlashObject=options.addIdToFlashObject?options.addIdToFlashObject:false;var stringa="";var hasReqestedVersion=DetectFlashVer(requiredMajorVersion,requiredMinorVersion,requiredRevision);if(hasReqestedVersion){var flashSrc="";if(mpConfig){flashSrc=mpConfig.getFlashMediaPath()+"/kidgets/"+kidgetType+"/"+kidgetSwItemName+"/"+flashFilename}else{flashSrc="/flash/kidgets/"+kidgetType+"/"+kidgetSwItemName+"/"+flashFilename;}
if(addIdToFlashObject==true){stringa=AC_FL_RunContent("id",this.kidget.id+"_flash_object","src",flashIsUrl?flashIsUrl:flashSrc,"width",flashWidth,"height",flashHeight,"align","middle","quality","high","wmode",wmode,"menu","false","flashvars",flashVars,"allowScriptAccess","sameDomain","type","application/x-shockwave-flash",'codebase','http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',"pluginspage","http://www.adobe.com/go/getflashplayer");}else{stringa=AC_FL_RunContent("src",flashIsUrl?flashIsUrl:flashSrc,"width",flashWidth,"height",flashHeight,"align","middle","quality","high","wmode",wmode,"menu","false","flashvars",flashVars,"allowScriptAccess","sameDomain","type","application/x-shockwave-flash",'codebase','http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',"pluginspage","http://www.adobe.com/go/getflashplayer");}
$$('#'+this.kidget.id+'.'+kidgetSwItemName+' .flash')[0].update(stringa);}else{var message=BrowserDetect.isIPad()||BrowserDetect.isIPhone()||BrowserDetect.isIPod()?i18n.stringLocale('no_flash_ipad'):i18n.stringLocale('no_flash');stringa="<div style ='position:relative'>"+"<img src = '/images/kidgets/"+kidgetType+"/"+kidgetSwItemName+"/"+noFlashImgFileName+"'/>"+"<img src ='/images/mypage/img_no_flash.png' class='nuvola_noflash'/>"+"<div class='text_noflash'>"+message+"</div>"+"</div>"
$$('#'+this.kidget.id+'.'+kidgetSwItemName+' .no_flash')[0].update(stringa);$$('#'+this.kidget.id+' .no_flash')[0].style.display="";}},hasHTML5Version:function(){return this.getConfigurationVar('has_html5_version');},createMediaObject:function(options){var useFlash=false
if(this.hasHTML5Version()){if(BrowserDetect.supportHTML5()){useFlash=false;}else{useFlash=true}}else{useFlash=true}
if(useFlash){this.createFlashObject(options)}else{this.createHTML5Version();}},createHTML5Version:function(){if(typeof(this.html5Loaded)!='undefined'){var objectToPost={'kidget_id':this.kidgetId,'tab_item_id':this.kidget.getShortId()};var options={JSON:true,evalJS:true,requestHeaders:{Accept:'text/javascript, application/json'},onComplete:this.checkLoadHtml5ContentResponse.bind(this)};pageTabs.communicator.sendRequest('/kidget/load_htlm5_content/',objectToPost,options);}else{$(this.kidget.id+"_html5").show();}},checkLoadHtml5ContentResponse:function(request){if(pageTabs.communicator.checkResponseFromServer({request:request})){this.html5Loaded();}}});var Kidget=Class.create({initialize:function(kidId){this.id=kidId;this.backTabs=new Hash();this.authorTabs=new Hash();this.actions=new Hash();this.stdBtnActions=new Hash();this.afterActions=new Hash();this.beforeActions=new Hash();this.specificKidget=new KXXXGeneric(this);this.defaultTabClassName=null;this.notifyFlap=null;this.pasteFlap=null;this.langFlap=null;this.draggListener=null;this.waitOnStartUp=0;this.notifyNicknameField=null;this.specificKidgetCallback=null;this.peInviaKidget=null;this.deletingKidget=false;this.displayDefaultTabWhenTurningBack=false;this.kidgetWriter=null;this.balloon=null;this.initialBalloonPaddingTop=null;this.initialBalloonHeight=null;this.upperElement=null;},getId:function(){return this.id;},getExtId:function(){return this.id;},getShortId:function(){return this.id.gsub('kd_','')},setSpecificKidget:function(specificKd){specificKd.kidget=this;this.specificKidget=specificKd;this.checkIfWritingKidget();this.startPreload();this.checkTrackDownloadOption();},checkTrackDownloadOption:function(){this.specificKidget;},bindDownloadButton:function(){},checkIfWritingKidget:function(){if($('writing_actions_'+this.getShortId())!=null){this.kidgetWriter=new KidgetWriter({kidget:this})}},getSpecificKidget:function(){return this.specificKidget;},isBackShown:function(){return $$('#'+this.id+' .kdback')[0].visible();},startPreload:function(){$$('#'+this.id+' .kdfront')[0].setOpacity(0);$$('#'+this.id+' .kdwait')[0].show();new Effect.Opacity($$('#'+this.id+' .kdwait')[0],{duration:0.8,from:0,to:1})
if((this.specificKidget.preloadTime!=null)&&(this.specificKidget.preloadTime>0)){setTimeout(this.startKidget.bindAsEventListener(this),this.specificKidget.preloadTime)}else{this.startKidget();}},enableDragging:function(){if(this.draggListener==null){if(BrowserDetect.isIPad()||BrowserDetect.isIPhone()||BrowserDetect.isIPod()){var obj=$(this.id);var handlerObj=$(this.id+"_h");var startX,startY,objTransX,objTransY,loadX,loadY;obj.addEventListener("touchmove",function(e){e.preventDefault();},false);handlerObj.addEventListener("touchstart",function(e){loadX=obj.offsetLeft;loadY=obj.offsetTop;startX=e.touches[0].clientX;startY=e.touches[0].clientY;},false);handlerObj.addEventListener("touchmove",function(e){var posX=e.touches[0].clientX;var posY=e.touches[0].clientY;var offX=posX-startX;var offY=posY-startY;obj.style.left=(loadX+offX)+'px';obj.style.top=(loadY+offY)+'px';},false);handlerObj.addEventListener("touchend",function(e){var handlerId=e.changedTouches[0].target.up('div').id;var draggedId=handlerId.split('_h')[0];manageEndDrag($(draggedId));},false);}else{this.draggListener=new Draggable(this.id,{handle:this.id+'_h',onStart:this.startDragging.bindAsEventListener(this),onEnd:this.endDragging.bindAsEventListener(this)});}}},disableDragging:function(){if(this.draggListener!=null){this.draggListener.destroy();this.draggListener=null;}},startKidget:function(){if(typeof this.specificKidget.startKidget!='undefined'){this.specificKidget.startKidget();}else{this.specificKidget.bindKidget();if(this.specificKidget.loadDataFromServer){this.getDataFromServer({specificKidgetCallback:false,onComplete:this.dataReceivedAtStartup.bind(this)});}else{this.completeStartOfKidget();}}
this.displayTabsAndFlaps(pageTabs.userCanModifyPage(),this.userCanModifyKidget());pageTabs.checkPageBottomAtStartUp();},getDataFromServer:function(options){var callback=options.onComplete!=null?(options.specificKidgetCallback==false?options.onComplete:options.onComplete.bindAsEventListener(this.specificKidget)):null;pageTabs.sendKidgetRequest(this.getShortId(),'/kidget/show/',this.getShortId(),{JSON:options.JSON||false,onComplete:this.checkDataFromServer.bindAsEventListener(this,callback)})},checkDataFromServer:function(request){var response=request.responseJSON;var data=[response[0]!=null?response[0].evalJSON(true):null,response[1]!=null?response[1].evalJSON(true):null];var callback=arguments[1];if(callback!=null){callback(data);}},dataReceivedAtStartup:function(request){if(this.kidgetWriter){this.kidgetWriter.initializeWritingContents(instanceData=request[0].writingContents)}
this.specificKidget.setSpecificContent(request);this.completeStartOfKidget();},completeStartOfKidget:function(){this.specificKidget.displayKidget();this.specificKidget.displayContent({writingContents:this.kidgetWriter?this.kidgetWriter.getWritingContentsToDisplay({checkAlerts:true}):null});this.specificKidget.displayDefaultTab();},refreshContent:function(){this.getDataFromServer({specificKidgetCallback:false,onComplete:this.dataReceivedAtRefresh.bind(this)});},dataReceivedAtRefresh:function(request){if(this.kidgetWriter){this.kidgetWriter.initializeWritingContents(instanceData=request[0].writingContents)}
this.specificKidget.setSpecificContent(request);this.specificKidget.displayContent({writingContents:this.kidgetWriter?this.kidgetWriter.getWritingContentsToDisplay({checkAlerts:true}):null});},bindStandardBtns:function(kidgetSpecific){$$('#'+this.id+' .opzioni')[0].onclick=this.turnKidgetBack.bindAsEventListener(this);$$('#'+this.id+' .chiudi')[0].onclick=this.deleteKidget.bindAsEventListener(this);$$('#'+this.id+' .opzioni')[0].onmouseover=this.flapToFront.bindAsEventListener(this);$$('#'+this.id+' .opzioni')[0].onmouseout=this.flapToBack.bindAsEventListener(this);$$('#'+this.id+' .chiudi')[0].onmouseover=this.flapToFront.bindAsEventListener(this);$$('#'+this.id+' .chiudi')[0].onmouseout=this.flapToBack.bindAsEventListener(this);$$('#'+this.id+' .sposta')[0].onmouseover=this.flapToFront.bindAsEventListener(this);$$('#'+this.id+' .sposta')[0].onmouseout=this.flapToBack.bindAsEventListener(this);$$('#'+this.id+' .conf_btns .ok')[0].onclick=this.backOK.bindAsEventListener(this);$$('#'+this.id+' .conf_btns .cancel')[0].onclick=this.backCancel.bindAsEventListener(this);$$('#'+this.id+' .importa')[0].select('img')[0].onclick=this.pasteThis.bindAsEventListener(this);$$('#'+this.id+' .notifica_invia')[0].onclick=this.sendThis.bindAsEventListener(this);},bindStandardComponents:function(){this.upperElement=$(this.id);this.balloon=$$('#'+this.id+" .balloonNew")[0];if(this.balloon!=null){this.initialBalloonPaddingTop=parseInt(Element.getStyle(this.balloon.down('p'),'padding-top'));this.initialBalloonHeight=parseInt(Element.getStyle(this.balloon.down('p'),'height'));this.alertBalloonListener=Event.observe(this.balloon,'click',this.hideAlertBalloon.bindAsEventListener(this))}
if(this.kidgetWriter){this.kidgetWriter.bind()}},bindStandardFields:function(kidgetSpecific){this.notifyNicknameField=$$('#'+this.id+' .sfondo_input_nickname')[0].select('input')[0];},manageZIndexes:function(){var kidgetZIndex=getNextHighestZindex(this.upperElement);if(this.kidgetWriter){this.kidgetWriter.setZIndex(kidgetZIndex+1)}
if(this.balloon){this.balloon.setStyle({zIndex:(kidgetZIndex+2)})}},addBeforeStdButton:function(event,action){this.stdBtnActions.set(event,action.bind(this.specificKidget));},addAfterAction:function(event,action){this.afterActions.set(event,action.bind(this.specificKidget));},addBeforeAction:function(event,action){this.beforeActions.set(event,action.bind(this.specificKidget));},addBackTab:function(){tabClass=arguments[0];if((tabClass!='lingua')||((tabClass=='lingua')&&(!pageTabs.isCard)&&(!pageTabs.isNotification))){flapObj=arguments[1];flapObj.onclick=this.flapClicked.bindAsEventListener(this);this.backTabs.set(flapObj.className,tabClass);if(arguments.length>2){if(arguments[2]=='author'){this.authorTabs.set(flapObj.className,[tabClass,$$('#'+this.id+' .'+flapObj.className)[0]]);}else{if(typeof(arguments[2])=='function'){action=arguments[2];this.actions.set(flapObj.className,action);}
if(arguments[3]=='author'){this.authorTabs.set(flapObj.className,[tabClass,$$('#'+this.id+' .'+flapObj.className)[0]]);}}}
if(arguments[0]=='importa'){this.pasteFlap=arguments[1];}
if(arguments[0]=='notifica'){this.notifyFlap=arguments[1];}
if(arguments[0]=='lingua'){this.languageFlap=arguments[1];}}},turnKidgetBack:function(event){if(this.stdBtnActions.get("turn_back")){this.stdBtnActions.get("turn_back")($(this.id));}
if(!this.deletingKidget){this.notifyNicknameField.value="";$$('#'+this.id+' .notifica_inviato')[0].style.display="none";pageTabs.turnKidgetBack(this);}
if(this.displayDefaultTabWhenTurningBack){this.displayDefaultTab();this.displayDefaultTabWhenTurningBack=false;}},deleteKidget:function(event){this.beforeDeleteKidget();if((!this.deletingKidget)&&(pageTabs.userCanModifyPage())){shortId=this.getShortId();this.deletingKidget=true;$$('#'+this.id+' .chiudi')[0].style.cursor='default';if($$('#'+this.id+' .chiudi')[0].select('img')[0].hasClassName('img_rollover')){$$('#'+this.id+' .chiudi')[0].select('img')[0].removeClassName('img_rollover');$$('#'+this.id+' .chiudi')[0].select('img')[0].src=$$('#'+this.id+' .chiudi')[0].select('img')[0].readAttribute('src').replace('_on.','.');}
new Ajax.Request('/tab/delete_kidget/'+shortId,{asynchronous:false,evalScripts:true,onComplete:function(request){pageTabs.checkDeleteKidgetResponse(request,shortId)}});}else{}},beforeDeleteKidget:function(){if(this.stdBtnActions.get("delete")){this.stdBtnActions.get("delete")($(this.id));}},reloadKidget:function(reloadParameters){if((!this.deletingKidget)&&(pageTabs.userCanModifyPage())){reloadParameters=reloadParameters||{}
reloadParameters.kidget_lang=reloadParameters.kidget_lang||this.getSpecificKidget().getLanguage();pageTabs.reloadKidget(this.getShortId(),reloadParameters)}},undoDelete:function(){this.deletingKidget=false;$$('#'+this.id+' .chiudi')[0].style.cursor='pointer';if(!$$('#'+this.id+' .chiudi')[0].select('img')[0].hasClassName('img_rollover')){$$('#'+this.id+' .chiudi')[0].select('img')[0].src=$$('#'+this.id+' .chiudi')[0].select('img')[0].readAttribute('src').replace('_on.','.');attiva_rollover($$('#'+this.id+' .chiudi')[0].select('img')[0]);}},backOK:function(event){if(this.stdBtnActions.get("back_OK"))
this.stdBtnActions.get("back_OK")($(this.id));if(this.kidgetWriter){if(!pageTabs.isCard&&!pageTabs.isNotification){saving=this.kidgetWriter.saveContent({onComplete:this.completeBackOK.bind(this)});if(!saving){this.completeBackOK()}}else{this.completeBackOK({keepEditingContents:true})}}else{this.completeBackOK();}},completeBackOK:function(options){if(options!=null&&options.keepEditingContents!=true){this.specificKidget.displayContent({writingContents:this.kidgetWriter&&(!pageTabs.isCard&&!pageTabs.isNotification)?this.kidgetWriter.getWritingContentsToDisplay({checkAlerts:true}):null});}else{if(this.specificKidget.displayContent){this.specificKidget.displayContent({keepEditingContents:true});}}
pageTabs.restoreKidget(this);},backCancel:function(event){if(this.stdBtnActions.get("back_cancel")){this.stdBtnActions.get("back_cancel")($(this.id));}
pageTabs.restoreKidget(this);},afterTurnBack:function(event){this.displayTabsAndFlaps(pageTabs.userCanModifyPage());if(this.afterActions.get("turn_back")){this.afterActions.get("turn_back")($(this.id));}},afterRestore:function(event){if(this.afterActions.get("restore")){this.afterActions.get("restore")($(this.id));}},flapClicked:function(event){flapClick=Event.findElement(event,'div')
this.changeBackTab(flapClick.className);},changeBackTab:function(flapClassName){var flapOn=null;if($$('#'+this.id+' .kdflaps_on .'+flapClassName).length>0){flapOn=$$('#'+this.id+' .kdflaps_on .'+flapClassName)[0];}
if($$('#'+this.id+' .kdflaps_top_on .'+flapClassName).length>0){flapOn=$$('#'+this.id+' .kdflaps_top_on .'+flapClassName)[0];}
tab=$$('#'+this.id+' .'+this.backTabs.get(flapClassName))[0]
tab.show();flapOn.show();kidId=this.id;this.backTabs.each(function(pair){if(pair.key!=flapClassName){$$('#'+kidId+' .'+pair.value)[0].hide();if($$('#'+kidId+' .kdflaps_on .'+pair.key).length>0){$$('#'+kidId+' .kdflaps_on .'+pair.key)[0].hide();}
if($$('#'+kidId+' .kdflaps_top_on .'+pair.key).length>0){$$('#'+kidId+' .kdflaps_top_on .'+pair.key)[0].hide();}}})
if(this.actions.get(flapClassName)){tab=$$('#'+this.id+' .'+this.backTabs.get(flapClassName))[0]
this.actions.get(flapClassName)(tab);}},displayDefaultTab:function(){var defTab=this.defaultTabClassName;var defFlap=null;if((!this.isAuthorTab(defTab))||((this.isAuthorTab(defTab))&&(this.userCanModifyKidget()))){this.backTabs.each(function(backTab){if(backTab.value==defTab){defFlap=backTab.key;}})}else{var authorTabsKeys=this.authorTabs.keys();var backTabsKeys=this.backTabs.keys();var index=0;for(index=0;(index<backTabsKeys.length)&&(defFlap==null);index++){if(authorTabsKeys.indexOf(backTabsKeys[index])==-1){defFlap=backTabsKeys[index];}}}
if(defFlap!=null){this.changeBackTab(defFlap);}},isAuthorTab:function(tabClassName){var isAuthor=false
this.authorTabs.each(function(authorTab){if(tabClassName==authorTab.value[0]){isAuthor=true;throw $break;}})
return isAuthor;},setDefaultTab:function(tabClassName){this.defaultTabClassName=tabClassName;},getTabItemId:function(){return(this.id.substring(3,this.id.length)*1);},displayTabsAndFlaps:function(userCanModifyPage){if(!userCanModifyPage){$$('#'+this.id+' .sposta')[0].hide();$$('#'+this.id+' .chiudi')[0].hide();}else{$$('#'+this.id+' .sposta')[0].show();$$('#'+this.id+' .chiudi')[0].show();}
if(!this.userCanModifyKidget()){this.notifyFlap!=null?this.notifyFlap.show():null;this.pasteFlap!=null?this.pasteFlap.show():null;this.authorTabs.each(function(authorTab){authorTab.value[1].hide();});if((pageTabs.isIE7)&&(!this.isBackShown())){this.displayDefaultTabWhenTurningBack=true;}else{this.displayDefaultTab();}}else{this.notifyFlap!=null?this.notifyFlap.show():null;this.pasteFlap!=null?this.pasteFlap.show():null;this.authorTabs.each(function(authorTab){authorTab.value[1].show();});}},userCanModifyKidget:function(){return(pageTabs.isCard)||(pageTabs.isNotification)?true:pageTabs.userCanModifyPage();},sendThis:function(){var nickname=this.notifyNicknameField.value;if(nickname.length>0){this.notifyNicknameField.value="";var comment=$$('#'+this.id+' .select_commento')[0].value;$$('#'+this.id+' .sfondo_input_nickname input')[0].value="";var keepContents=pageTabs.pageOwner.keepContentsOnNotification();var kidgetConfiguration=this.getConfiguration({getEditingContents:true,clearContents:!keepContents})
pageTabs.sendKidget('',nickname,comment,{'kidget_id':this.specificKidget.kidgetId,'kidget_data':kidgetConfiguration,'kidget_language':this.specificKidget.getLanguage()});if(pageTabs.user.isRegistered()&&pageTabs.user.isLoggedIn()){$$('#'+this.id+' .notifica_inviato')[0].style.display="";this.peInviaKidget=new PeriodicalExecuter(this.feedbackSendThis.bind(this),3);}}},feedbackSendThis:function(){this.peInviaKidget.stop();this.peInviaKidget=null;$$('#'+this.id+' .notifica_inviato')[0].style.display="none";},pasteThis:function(){var keepContents=pageTabs.pageOwner.keepContentsOnPaste()||pageTabs.isCard||pageTabs.isNotification;var kidgetConfiguration=this.getConfiguration({getEditingContents:true,clearContents:!keepContents})
pageTabs.pasteKidget({'kidget_id':this.specificKidget.kidgetId,'kidget_data':kidgetConfiguration,'kidget_language':this.specificKidget.getLanguage()});},postDataToServer:function(dataToPost,options){options=options||{};pageTabs.sendKidgetRequest(this.getShortId(),options.URL||'/kidget/update/',dataToPost,{asynchronous:options.asynchronous||true,JSON:options.JSON||false,onComplete:(options.onComplete!=null)?options.onComplete.bindAsEventListener(this.specificKidget):null})},performKidgetAction:function(actionData,options){options=options||{};pageTabs.sendKidgetRequest(this.getShortId(),options.URL||'/kidget/kidget_action',actionData,{asynchronous:options.asynchronous||true,JSON:options.JSON||false,onComplete:(options.onComplete!=null)?options.onComplete.bindAsEventListener(this.specificKidget):null})},getConfiguration:function(args){var getEditingContents=args.getEditingContents!=null?args.getEditingContents:false;var clearContents=args.clearContents!=null?args.clearContents:false
var kidgetConfiguration=this.specificKidget.getConfiguration();if(this.kidgetWriter){var writingContents=this.kidgetWriter.getWritingContents({clearTexts:clearContents,getEditingContents:getEditingContents});kidgetConfiguration.set('writingContents',writingContents);}
return kidgetConfiguration;},performEmailCheck:function(element){value=element.value;if(value.length==0){this.notifyEmailField.setStyle({backgroundColor:'#F4E500'});}else if(validateEmail(value)){this.notifyEmailField.setStyle({backgroundColor:'green'});}else{this.notifyEmailField.setStyle({backgroundColor:'red'});}},startDragging:function(){if(this.specificKidget.startDragging){this.specificKidget.startDragging();}},endDragging:function(){if(this.specificKidget.endDragging){this.specificKidget.endDragging();}
pageTabs.checkPageBottom();},tabSetCurrent:function(){if(this.afterActions.get("after_tab_set_current")){this.afterActions.get("after_tab_set_current")($(this.id));}},beforeTabSetNotCurrent:function(){if(this.beforeActions.get("before_tab_set_not_current")){this.beforeActions.get("before_tab_set_not_current")($(this.id));}},sendCustomDataToServer:function(){if(this.beforeActions.get("before_tab_set_not_current")){this.beforeActions.get("before_tab_set_not_current")($(this.id));}},loginPerformed:function(){if(this.kidgetWriter){this.kidgetWriter.checkUserStatus({action:'login'})}
if(this.afterActions.get("after_login_performed")){this.afterActions.get("after_login_performed")($(this.id))}},logoutPerformed:function(){if(this.kidgetWriter){this.kidgetWriter.checkUserStatus({action:'logout'})}
if(this.afterActions.get("after_logout_performed")){this.afterActions.get("after_logout_performed")($(this.id))}},flapToFront:function(e){flap=Event.element(e).up('div');this.overFlap=flap.getAttribute('class');if(BrowserDetect.browser!='Explorer'||BrowserDetect.version>=8){new PeriodicalExecuter(function(pe){if(this.overFlap==flap.getAttribute('class')){flap.setStyle('z-index:1');}
pe.stop();}.bind(this),0.5);}else{flap.setStyle('z-index:1');}},flapToBack:function(e){this.overFlap=null;flap=Event.element(e).up('div');flap.setStyle('z-index:0');},displayAlertBalloon:function(){if(arguments[0].show){if(arguments[0].message.length<50){this.balloon.down('p').setStyle({paddingTop:(this.initialBalloonPaddingTop+15)+'px'})
this.balloon.down('p').setStyle({height:(this.initialBalloonHeight-15)+'px'})}else{this.balloon.down('p').setStyle({paddingTop:(this.initialBalloonPaddingTop)+'px'})
this.balloon.down('p').setStyle({height:(this.initialBalloonHeight)+'px'})}
this.balloon.down('p').innerHTML=arguments[0].message;this.balloon.setStyle({display:'block'});if(arguments[0].sound!=null){var sound_url="/sounds/kidgets/alerts/error.mp3";switch(arguments[0].sound){default:sound_url="/sounds/kidgets/alerts/error.mp3";}
this.sound=MPSound.play(sound_url);}}else{if(this.alertBalloonListener!=null){Event.stopObserving(this.balloon,'click',this.alertBalloonListener);}
this.balloon.setStyle({display:'none'});}},hideAlertBalloon:function(){this.displayAlertBalloon({show:false})},setWritingActionsPosition:function(options){if(this.kidgetWriter){this.kidgetWriter.setActionsPosition(options)}}});var KidgetWriter=Class.create({initialize:function(){this.kidget=arguments[0].kidget;this.actionsBox=$('writing_actions_'+this.kidget.getShortId());this.saveBtn=$$('#writing_actions_'+this.kidget.getShortId()+' .save')[0];this.publishBtn=$$('#writing_actions_'+this.kidget.getShortId()+' .publish')[0];this.clearBtn=$$('#writing_actions_'+this.kidget.getShortId()+' .clear')[0];this.saveBtnSpinner=$$('#writing_actions_'+this.kidget.getShortId()+' .savingSpinner')[0];this.publishBtnSpinner=$$('#writing_actions_'+this.kidget.getShortId()+' .publishingSpinner')[0];this.clearBtnSpinner=$$('#writing_actions_'+this.kidget.getShortId()+' .clearingSpinner')[0];this.writingContents=null;this.writingContentsDisapproved=false;this.requestInProgress=false;this.peSave=null;this.checkUserStatus();},bind:function(){if(this.saveBtn){this.saveBtn.onclick=this.saveBtnClicked.bindAsEventListener(this);}
if(this.publishBtn){this.publishBtn.onclick=this.publishBtnClicked.bindAsEventListener(this);}
if(this.clearBtn){this.clearBtn.onclick=this.clearBtnClicked.bindAsEventListener(this);}},initializeWritingContents:function(writingContents){this.writingContents=writingContents;var textDisapproved=false;sectionNames=Object.keys(writingContents);sectionNames.each(function(sectionName){section=writingContents[sectionName]
textNames=Object.keys(section)
textNames.each(function(textName){text=section[textName]
if(text.disapproved){textDisapproved=true;}})})
this.writingContentsDisapproved=textDisapproved},getWritingContents:function(options){var getEditingContents=options.getEditingContents!=null?options.getEditingContents:false;var clearTexts=options.clearTexts!=null?options.clearTexts:false
var contentsToReturn=getEditingContents?this.kidget.getSpecificKidget().getContents().writingContents:Object.clone(this.writingContents);if(clearTexts){sectionNames=Object.keys(contentsToReturn);sectionNames.each(function(sectionName){section=contentsToReturn[sectionName]
textNames=Object.keys(section)
textNames.each(function(textName){text=section[textName]
contentsToReturn[sectionName][textName].title="";contentsToReturn[sectionName][textName].content="";})})}
return contentsToReturn;},getWritingContentsToDisplay:function(options){var checkAlerts=options.checkAlerts!=null?options.checkAlerts:true
var writingContentsToDisplay=null;var userCanWriteText=false
if(this.kidget.userCanModifyKidget()){if(pageTabs.userCanWriteText()){writingContentsToDisplay=Object.clone(this.writingContents);userCanWriteText=true;}else{userCanWriteText=false;writingContentsToDisplay="";}}else{writingContentsToDisplay=Object.clone(this.writingContents);}
if(checkAlerts){if(pageTabs.user.isRegistered()){if(this.kidget.userCanModifyKidget()){if(pageTabs.userCanWriteText()){if(this.writingContentsDisapproved){this.kidget.displayAlertBalloon({message:i18n.stringLocale('text_disapproved'),show:true,sound:'error'})}else{this.kidget.displayAlertBalloon({show:false});}}else{this.kidget.displayAlertBalloon({show:false});}}else{if(!pageTabs.userIsPageOwner()){if(!pageTabs.pageOwnerIsFamous()){var friendship=pageTabs.pageOwnerIsFriendWithUser();if(friendship!=true){if(friendship=='userIsFamous'){this.kidget.displayAlertBalloon({message:i18n.stringLocale('cannot_access_content'),show:true});}else if(friendship=='friend_has_blocked'){var message=i18n.stringLocale('cannot_access_content_friend_is_blocked')+pageTabs.pageOwner.nickname+"!";this.kidget.displayAlertBalloon({message:message,show:true});}else if(friendship=='friend_is_blocked'){var message=i18n.stringLocale('cannot_access_content_friend_has_blocked_1')+pageTabs.pageOwner.nickname+i18n.stringLocale('cannot_access_content_friend_has_blocked_2');this.kidget.displayAlertBalloon({message:message,show:true});}else{this.kidget.displayAlertBalloon({message:i18n.stringLocale('cannot_read_content_1')+pageTabs.getPageOwnerNickname()+i18n.stringLocale('cannot_read_content_2'),show:true});}}else{this.kidget.displayAlertBalloon({show:false});}}else{this.kidget.displayAlertBalloon({show:false});}}else{this.kidget.displayAlertBalloon({show:false});}}}else{this.kidget.displayAlertBalloon({message:i18n.stringLocale('register_for_this_kidget','dialog'),show:true,sound:'error'});}}
return{contents:writingContentsToDisplay,userCanWriteText:userCanWriteText};},checkUserStatus:function(){var actionPerformed=typeof arguments[0]!='undefined'?arguments[0].action:null;switch(actionPerformed){case'login':this.kidget.getSpecificKidget().refreshContent();break;case'logout':if(pageTabs.userIsPageOwner()){this.saveContent()};this.kidget.getSpecificKidget().refreshContent();break;}
if(pageTabs.user.isRegistered()&&this.kidget.userCanModifyKidget()&&!pageTabs.isCard&&!pageTabs.isNotification){this.actionsBox.show();if(this.peSave==null){this.peSave=new PeriodicalExecuter(this.saveContent.bind(this),120)}}else{this.actionsBox.hide();if(this.peSave!=null){this.peSave.stop();}
this.peSave=null;}},saveBtnClicked:function(){this.saveContent({force:true});},publishBtnClicked:function(){this.publishContent();},clearBtnClicked:function(){this.clearContent();},saveContent:function(options){var infoToSave=this.kidget.getSpecificKidget().getContents();var textContentsToSave=infoToSave.writingContents;var callbackAfterSave=(options!=null&&options.onComplete!=null)?options.onComplete:infoToSave.onComplete;if(textContentsToSave!=null&&((options!=null&&options.force==true)||this.contentsHaveChanged(textContentsToSave))&&!this.requestInProgress){var objectToPost={'tab_item_id':this.kidget.getTabItemId(),'action':'save','type':'texts','writingContents':textContentsToSave}
var options={JSON:true,onComplete:this.saveCompleted.bindAsEventListener(this,callbackAfterSave,textContentsToSave)}
if(this.saveBtnSpinner)this.saveBtnSpinner.show();this.requestInProgress=true;this.kidget.postDataToServer(objectToPost,options);return true;}else{return false;}},contentsHaveChanged:function(newWritingContents){var changed=false;var oldWritingContents=this.writingContents;sectionNames=Object.keys(oldWritingContents);sectionNames.each(function(sectionName){section=oldWritingContents[sectionName]
textNames=Object.keys(section)
textNames.each(function(textName){text=section[textName]
if(text.title!=newWritingContents[sectionName][textName].title||text.content!=newWritingContents[sectionName][textName].content){changed=true;throw $break;}})})
return changed;},saveCompleted:function(request,customCallback,textContentsSaved){if(pageTabs.communicator.checkResponseFromServer({request:request})){this.writingContents=textContentsSaved;this.writingContentsDisapproved=false
if(this.saveBtnSpinner)this.saveBtnSpinner.hide();this.requestInProgress=false;if(customCallback!=null){customCallback()}}},publishContent:function(options){var displayFeedback=options!=null&&!options.displayFeedback?false:true;var infoToPublish=this.kidget.getSpecificKidget().getContents();if(infoToPublish!=null&&!this.requestInProgress){var textContentsToPublish=infoToPublish.writingContents;var callbackAfterPublish=infoToPublish.onComplete;var objectToPost={'tab_item_id':this.kidget.getTabItemId(),'action':'publish','type':'texts','writingContents':textContentsToPublish}
var options={JSON:true,onComplete:this.publishCompleted.bind(this,callbackAfterPublish,displayFeedback)}
if(this.publishBtnSpinner)this.publishBtnSpinner.show();this.requestInProgress=true;this.kidget.postDataToServer(objectToPost,options);}},publishCompleted:function(){var request=arguments[2];var customCallback=arguments[0];var displayFeedback=arguments[1];if(pageTabs.communicator.checkResponseFromServer({request:request})){if(this.publishBtnSpinner)this.publishBtnSpinner.hide();this.requestInProgress=false;if(customCallback!=null){customCallback();}else{this.kidget.refreshContent();}
if(displayFeedback){pageTabs.tabDialog.displayMessage({title:"warning",description:i18n.stringLocale('published_text_feedback'),actions:'1button',actionOK:pageTabs.tabDialog.hideDialog.bind(pageTabs.tabDialog),size:'small'})
pageTabs.tabDialog.showDialog();}}},clearContent:function(){var infoToClear=this.kidget.getSpecificKidget().getContents();if(infoToClear!=null&&!this.requestInProgress){var textContentsToClear=infoToClear.writingContents;var callbackAfterClear=infoToClear.onComplete;var objectToPost={'tab_item_id':this.kidget.getTabItemId(),'action':'clear','type':'texts','writingContents':textContentsToClear}
var options={JSON:true,onComplete:this.clearCompleted.bind(this,callbackAfterClear)}
if(this.clearBtnSpinner)this.clearBtnSpinner.show();this.requestInProgress=true;this.kidget.postDataToServer(objectToPost,options);}},clearCompleted:function(){var request=arguments[1];var customCallback=arguments[2];if(pageTabs.communicator.checkResponseFromServer({request:request})){if(this.clearBtnSpinner)this.clearBtnSpinner.hide();this.requestInProgress=false;if(customCallback!=null){customCallback();}else{this.kidget.refreshContent();}}},setZIndex:function(zIndex){this.actionsBox.setStyle({zIndex:(zIndex)})},setActionsPosition:function(options){this.actionsBox.setStyle({right:options.right+'px'});this.actionsBox.setStyle({top:options.top+'px'});}})
function flash_to_javascript(datesAfterGame){kidget=pageTabs.getKidgetByTabItemId(datesAfterGame[0]).specificKidget;var cards=[]
cards[0]=datesAfterGame[1]
cards[1]=datesAfterGame[2]
cards[2]=datesAfterGame[3]
var points=datesAfterGame[4]
kidget.cardsFromFlash(cards,points)
return 1;}


function loadTabKidgets(tabId,tabElement){new Ajax.Request('/page/load_tab_kidgets/'+tabId,{asynchronous:false,evalScripts:false});}
function addKidgetToCurrentTab(){location.href="/kidgetbox";}
var KidgetPosition=Class.create({initialize:function(kidId,kidX,kidY){this.id=kidId;this.x=kidX;this.y=kidY;}});var TabKidgetsPosition=Class.create({initialize:function(tabId,kidsArray,bottomOfKidgets){this.id=tabId;this.kidgets=kidsArray;this.bottomOfKidgets=bottomOfKidgets;}});var PageKidgetsPosition=Class.create({initialize:function(pageId,tabsArray){this.id=pageId;this.tabs=tabsArray;},addTabKidgetsPosition:function(tabInfo){this.tabs.push(tabInfo);},areKidgetPositionToUpdate:function(){return(this.tabs.length>0)}});var DraggObjectsCollection=Class.create({initialize:function(myPageContainer){this.kidgets=new Array();this.draggObjects=new Array();this.moved=false;this.container=myPageContainer;},getDraggObjects:function(){return this.draggObjects;},getKidgets:function(){return this.kidgets;},addDraggableByTabItemId:function(tabItemId,enable){newKidget=new Kidget('kd_'+tabItemId)
this.kidgets.push(newKidget)
newDraggObject=new draggableObject('kd_'+tabItemId,this.draggObjects);this.draggObjects.push(newDraggObject);newDraggObject.setPosition();if(enable){newKidget.enableDragging()}
return newKidget},addDraggableByKidgetObj:function(kidget,enable){this.kidgets.push(kidget)
newDraggObject=new draggableObject(kidget.id,this.draggObjects);newDraggObject.moved=true;this.draggObjects.push(newDraggObject);newDraggObject.setPosition();if(enable){kidget.enableDragging()}},enableDragging:function(enable){if(enable){for(var d=0;d<this.kidgets.length;d++){this.kidgets[d].enableDragging();}}else{this.disableDragging();}
for(var e=0;e<this.kidgets.length;e++){this.kidgets[e].displayTabsAndFlaps(enable);}},disableDragging:function(){for(var f=0;f<this.kidgets.length;f++){this.kidgets[f].disableDragging();}},applyLoginToKidgets:function(){for(var e=0;e<this.kidgets.length;e++){this.kidgets[e].loginPerformed();}},applyLogoutToKidgets:function(){for(var e=0;e<this.kidgets.length;e++){this.kidgets[e].logoutPerformed();}},getDraggObjects:function(){return this.draggObjects;},hasMoved:function(){if(!this.moved){for(d=0;(d<this.draggObjects.length)&&(!this.moved);d++){this.moved=this.draggObjects[d].moved;}}
return this.moved;},findDraggableByObjId:function(objId){var found=false;var obj=null;for(r=0;(r<this.draggObjects.length)&&(!found);r++){if(this.draggObjects[r].obj.id==objId){obj=this.draggObjects[r];found=true;}}
return obj;},findAndDeleteDraggableByObjId:function(objId){var deleted=false;var listenerDeleted=false;var kidgetDeleted=false;for(r=0;(r<this.draggObjects.length)&&(!deleted);r++){if(this.draggObjects[r].obj.id==objId){new Effect.Puff(objId,{duration:1,afterFinish:function(effect){document.getElementById(objId).remove();}})
delete this.draggObjects[r];this.draggObjects=this.draggObjects.compact();for(s=0;(s<this.kidgets.length)&&(!kidgetDeleted);s++){if(this.kidgets[s].id==objId){this.kidgets[s].disableDragging();delete this.kidgets[s];this.kidgets=this.kidgets.compact();kidgetDeleted=true;}}
deleted=true;}}
return deleted;},findAndReloadKidgetByObjId:function(objId,reloadParams){var found=false;var kidgetDeleted=false;var kidX=null;var kidY=null;for(var r=0;(r<this.draggObjects.length)&&(!found);r++){if(this.draggObjects[r].obj.id==objId){kidX=this.draggObjects[r].x;kidY=this.draggObjects[r].y;delete this.draggObjects[r];this.draggObjects=this.draggObjects.compact();for(var s=0;(s<this.kidgets.length)&&(!kidgetDeleted);s++){if(this.kidgets[s].id==objId){this.kidgets[s].disableDragging();specKidget=this.kidgets[s].getSpecificKidget();delete specKidget;delete this.kidgets[s];this.kidgets=this.kidgets.compact();kidgetDeleted=true;}}
found=true;shortId=objId.gsub('kd_','');reloadParams.pos_x=kidX;reloadParams.pos_y=kidY;new Ajax.JSON('/page/load_tab_kidget/',{object:{'tab_item_id':shortId,'loadParameters':reloadParams},asynchronous:true,evalScripts:true});}}
return found;},undoDeleteKidget:function(objId){var undo=false;for(r=0;(r<this.kidgets.length)&&(!undo);r++){if(this.kidgets[r].id==objId){this.kidgets[r].undoDelete();undo=true;}}},removeAllKidgets:function(){var kidgetsDeleted=false;if(this.draggObjects.length>0){for(var j=0;j<this.draggObjects.length;j++){document.getElementById(this.draggObjects[j].obj.id).remove();delete this.draggObjects[j];}
this.draggObjects=this.draggObjects.compact();for(var i=0;i<this.kidgets.length;i++){this.kidgets[i].beforeDeleteKidget();this.kidgets[i].disableDragging();delete this.kidgets[i];}
this.kidgets=this.kidgets.compact();kidgetsDeleted=true;return kidgetsDeleted;}else{return true;}},getKidgetsPosition:function(){var array=new Array();for(p=0;p<this.draggObjects.length;p++){if(this.draggObjects[p].moved){array.push(new KidgetPosition(this.draggObjects[p].obj.id,this.draggObjects[p].x,this.draggObjects[p].y));}}
return array;},setMoved:function(movedIn){for(pp=0;pp<this.draggObjects.length;pp++){this.draggObjects[pp].moved=movedIn;}
this.moved=movedIn},getBottomOfKidgets:function(){var bottom=0;for(p=0;p<this.draggObjects.length;p++)
{if(!isNaN(this.draggObjects[p].ye)){if(this.draggObjects[p].ye>bottom)
{bottom=this.draggObjects[p].ye;}}else{bottom=null;break;}}
return bottom;},getBottomOfKidgetsNotNull:function(){var bottom=0;for(p=0;p<this.draggObjects.length;p++)
{if(this.draggObjects[p].ye>bottom)
{bottom=this.draggObjects[p].ye;}}
return bottom;},extractKidget:function(kidget){var kidExtracted=null;for(r=0;r<this.draggObjects.length;r++){if(this.draggObjects[r].obj.id==kidget.id){delete this.draggObjects[r];this.draggObjects=this.draggObjects.compact();break;}}
for(t=0;t<this.kidgets.length;t++){if(this.kidgets[t].id==kidget.id){kidExtracted=this.kidgets.splice(t,1)[0];this.kidgets.compact();break;}}
return kidExtracted;},refreshKidgetsPosition:function(){for(j=0;j<this.draggObjects.length;j++){this.draggObjects[j].setPosition();}},getKidgetByTabItemId:function(tabItemId){for(d=0;d<this.kidgets.length;d++){if(this.kidgets[d].getExtId()==tabItemId){return this.kidgets[d];}}
return null;},beforeTabSetNotCurrent:function(){for(var f=0;f<this.kidgets.length;f++){this.kidgets[f].beforeTabSetNotCurrent();}},tabSetCurrent:function(){for(var f=0;f<this.kidgets.length;f++){this.kidgets[f].tabSetCurrent();}},sendCustomKidgetDataToServer:function(){for(var n=0;n<this.kidgets.length;n++){this.kidgets[n].sendCustomDataToServer();}},recallKidgetsPosition:function(){for(var q=0;q<this.draggObjects.length;q++){this.draggObjects[q].setPosition();}}});var TabPropsPage=Class.create({initialize:function(){this.logoPath=null;this.backgroundsPath=null;this.iconsPath=null;this.soundsPath=null;this.sponsoredMediaPath=null;this.addingTab=false;this.isShown=false;this.trumptMenuShown=false;this.lockerMenuShown=false;this.trashMenuShown=false;this.backgroudsMenuShown=false;this.iconsMenuShown=false;this.soundsMenuShown=false;this.wallPaperShow=false;},setPageElements:function(){this.trumpetAperturaON=$('tabProps_apertura_suoni_on')
this.trumpetAperturaOFF=$('tabProps_apertura_suoni_off')
this.trumpetSegnapaginaON=$('tabProps_segnapagina_suoni_on')
this.trumpetSegnapaginaOFF=$('tabProps_segnapagina_suoni_off')
this.locker=$('tabProps_lucchetto')
this.lockerMenu=$('tabProps_opzione_segreta')
this.trash=$('tabProps_cestino')
this.trashMenu=$('tabProps_opzione_elimina');this.trashOptOk=$('tabProps_opzione_elimina_ok')
this.trashOptCancel=$('tabProps_opzione_elimina_annulla')
this.logoMenuSets=$$('#tabProps_mylogo_box .tabProps_mylogo_set')
this.logoMenuNavSx=$('tabProps_mylogo_nav_sx').select('img')[0]
this.logoMenuNavDx=$('tabProps_mylogo_nav_dx').select('img')[0]
this.iconsMenu=$('tabProps_pagina_faidate_segnapagina_box')
this.iconsMenuSets=$$('#tabProps_pagina_faidate_segnapagina_box .tabProps_pagina_faidate_segnapagina_set')
this.iconsMenuNavSx=$('tabProps_pagina_faidate_segnapagina_nav_sx').select('img')[0]
this.iconsMenuNavDx=$('tabProps_pagina_faidate_segnapagina_nav_dx').select('img')[0]
this.soundsMenu=$('tabProps_pagina_faidate_suoni_box')
this.backgroundsMenuTitle=$('tabProps_pagina_faidate_sfondi_tit')
this.backgroundsMenu=$('tabProps_pagina_faidate_sfondi_box')
this.iconsMenuTitle=$('tabProps_pagina_faidate_segnapagina_tit')
this.soundsMenuTitle=$('tabProps_pagina_faidate_suoni_tit')
this.soundsTrumpetFlap=$('tromba_segnapagina')
this.soundsTrumpetOpen=$('tromba_apertura')
this.OK=$('tabProps_azioni_OK')
this.Cancel=$('tabProps_azioni_Cancel')
this.logoThumbnails=$$("#tabProps_mylogo_box .logo_thumb")
this.sponsoredThumbnails=$$("#tabProps_pagina_firmata_box .sponsored_thumb")
this.iconsThumbnails=$$("#tabProps_pagina_faidate_segnapagina_box .ico_thumb")
this.cloudTags=$('tabProps_pagina_faidate_cloud').select('a')
this.menuNavSxSponsoredTab=$('tabProps_pagina_firmata_freccia_su')
this.menuNavDxSponsoredTab=$('tabProps_pagina_firmata_freccia_giu')
this.containerSponsoredTab=$$('#tabProps_pagina_firmata_box .tabProps_pagina_firmata_set')},hideAllMenus:function(){this.lockerMenu.hide();this.trashMenu.hide();if(this.wallPaperShow)
this.backgroundsMenu.hide();this.iconsMenu.hide();this.soundsMenu.hide();},bindPage:function(){this.trumpetAperturaON.onclick=this.trumpetAperturaONClicked.bindAsEventListener(this);this.trumpetAperturaOFF.onclick=this.trumpetAperturaOFFClicked.bindAsEventListener(this);this.trumpetSegnapaginaON.onclick=this.trumpetSegnapaginaONClicked.bindAsEventListener(this);this.trumpetSegnapaginaOFF.onclick=this.trumpetSegnapaginaOFFClicked.bindAsEventListener(this);this.locker.onclick=this.lockerClicked.bindAsEventListener(this);this.trash.onclick=this.trashClicked.bindAsEventListener(this);this.trashOptOk.onclick=this.trashOptOkClicked.bindAsEventListener(this);this.trashOptCancel.onclick=this.trashOptCancelClicked.bindAsEventListener(this);this.logoMenuNavSx.onclick=this.logoMenuNavSxClicked.bindAsEventListener(this);this.logoMenuNavDx.onclick=this.logoMenuNavDxClicked.bindAsEventListener(this);this.backgroundsMenuTitle.onclick=this.backgroundsTitleClicked.bindAsEventListener(this);this.iconsMenuTitle.onclick=this.iconsTitleClicked.bindAsEventListener(this);this.iconsMenuNavSx.onclick=this.iconsMenuNavSxClicked.bindAsEventListener(this);this.iconsMenuNavDx.onclick=this.iconsMenuNavDxClicked.bindAsEventListener(this);this.soundsMenuTitle.onclick=this.soundsTitleClicked.bindAsEventListener(this);this.soundsTrumpetFlap.onclick=this.soundsTrumpetFlapClicked.bindAsEventListener(this);this.soundsTrumpetOpen.onclick=this.soundsTrumpetOpenClicked.bindAsEventListener(this);this.OK.onclick=this.OKClicked.bindAsEventListener(this);this.Cancel.onclick=this.CancelClicked.bindAsEventListener(this);this.menuNavSxSponsoredTab.onclick=this.menuNavSxSponsoredTabClicked.bindAsEventListener(this);this.menuNavDxSponsoredTab.onclick=this.menuNavDxSponsoredTabClicked.bindAsEventListener(this);for(j=0;j<this.logoThumbnails.length;j++){this.logoThumbnails[j].onclick=this.logoThumbnailsListner.bindAsEventListener(this);}
for(k=0;k<this.sponsoredThumbnails.length;k++){this.sponsoredThumbnails[k].onclick=this.sponsoredThumbnailsListner.bindAsEventListener(this);}
for(h=0;h<this.iconsThumbnails.length;h++){this.iconsThumbnails[h].onclick=this.iconsThumbnailsListner.bindAsEventListener(this);}},startPage:function(options){this.logoMenuSets[0].show()
this.logoMenuSets[1].hide()
$('tabProps_mylogo_nav').select('span')[0].update('1 di 2')
this.iconsMenuSets[0].show()
this.iconsMenuSets[1].hide()
this.iconsMenuSets[2].hide()
$('tabProps_pagina_faidate_segnapagina_nav').select('span')[0].update('1 di 3')
this.checkTrashStatus();this.hideAllMenus();if(options!=null&&options.openBackgroundsMenu==true){this.backgroundsTitleClicked();}},setAddingTab:function(){this.addingTab=true;},checkTrashStatus:function(){tagIMG=this.trash.select('img')[0];if(pageTabs.getNumberOfTabs()>1){tagIMG.writeAttribute('src','images/mypage/tabProps/top/cestino_open.gif');tagIMG.addClassName("cursor_pointer img_rollover");attiva_rollover(tagIMG);}else{tagIMG.writeAttribute('src','images/mypage/tabProps/top/cestino_disabled.gif');tagIMG.removeClassName("cursor_pointer img_rollover");}},displayCurrentPrefs:function(){this.displayCurrentSoundsOnOffPrefs();this.displayCurrentLogoPrefs();this.displayCurrentIcoPrefs();this.displayCurrentSoundPrefs();this.displayCurrentSponsorPrefs();},displayCurrentSoundsOnOffPrefs:function(){try{var tabProps=pageTabs.getCurrentTab().tabProps;if(tabProps.sound_apertura_on){$('tabProps_apertura_suoni_on').removeClassName('img_rollover');$('tabProps_apertura_suoni_on').writeAttribute('src','images/mypage/tabProps/top/top_on_it_on.gif');$('tabProps_apertura_suoni_off').writeAttribute('src','images/mypage/tabProps/top/top_off_it.gif')
$('tabProps_apertura_suoni_off').addClassName('img_rollover');}else{$('tabProps_apertura_suoni_on').writeAttribute('src','images/mypage/tabProps/top/top_on_it.gif')
$('tabProps_apertura_suoni_on').addClassName('img_rollover');$('tabProps_apertura_suoni_off').removeClassName('img_rollover');$('tabProps_apertura_suoni_off').writeAttribute('src','images/mypage/tabProps/top/top_off_it_on.gif')}
if(tabProps.sound_segnapagina_on){$('tabProps_segnapagina_suoni_on').removeClassName('img_rollover');$('tabProps_segnapagina_suoni_on').writeAttribute('src','images/mypage/tabProps/top/top_on_it_on.gif');$('tabProps_segnapagina_suoni_off').writeAttribute('src','images/mypage/tabProps/top/top_off_it.gif')
$('tabProps_segnapagina_suoni_off').addClassName('img_rollover');}else{$('tabProps_segnapagina_suoni_on').writeAttribute('src','images/mypage/tabProps/top/top_on_it.gif')
$('tabProps_segnapagina_suoni_on').addClassName('img_rollover');$('tabProps_segnapagina_suoni_off').removeClassName('img_rollover');$('tabProps_segnapagina_suoni_off').writeAttribute('src','images/mypage/tabProps/top/top_off_it_on.gif')}}catch(e){alert("An exception occurred in the TabPropsPage.displayCurrentSoundsOnOffPrefs(). Error name: "+e.name
+". Error message: "+e.message)}},displayCurrentLogoPrefs:function(){try{var tabProps=pageTabs.getCurrentTab().tabProps
var tagsA=null
if(this.logoMenuSets[0].getStyle('display')=='none'){tagsA=$$('.tabProps_mylogo_set')[1].select('a')}else{tagsA=$$('.tabProps_mylogo_set')[0].select('a')}
for(i=0;i<tagsA.length;i++){tagIMG=tagsA[i].select('img')[0]
src=tagIMG.readAttribute('src').split('/').last().gsub('tn_','').split('.').first()
if(src==tabProps.mypage_logo_url.split('.').first()){tagsA[i].hasClassName('in')?null:tagsA[i].addClassName('in')}else{tagsA[i].hasClassName('in')?tagsA[i].removeClassName('in'):null}}}catch(e){alert("An exception occurred in the TabPropsPage.displayCurrentLogoPrefs(). Error name: "+e.name
+". Error message: "+e.message)}},displayCurrentBgPrefs:function(){try{if($$('.tabProps_pagina_faidate_sfondi_set')[0]!=null)
{var tabProps=pageTabs.getCurrentTab().tabProps
var tagsA=null
this.backgroundsMenuSets.each(function(bk,index){if(bk.getStyle('display')!='none'){tagsA=$$('.tabProps_pagina_faidate_sfondi_set')[index].select('a');throw $break;}});for(i=0;i<tagsA.length;i++){tagIMG=tagsA[i].select('img')[0]
src=tagIMG.readAttribute('src').split('/').last().gsub('tn_','').split('.').first()
if((tabProps.background_url!=null)&&(src==tabProps.background_url.split('.').first())){tagsA[i].hasClassName('in')?null:tagsA[i].addClassName('in')}else{tagsA[i].hasClassName('in')?tagsA[i].removeClassName('in'):null}}}}catch(e){alert("An exception occurred in the TabPropsPage.displayCurrentBgPrefs(). Error name: "+e.name
+". Error message: "+e.message)}},displayCurrentIcoPrefs:function(){try{var tabProps=pageTabs.getCurrentTab().tabProps
var tagsA=null
if(this.iconsMenuSets[0].getStyle('display')=='none'){tagsA=$$('.tabProps_pagina_faidate_segnapagina_set')[1].select('a')}else{tagsA=$$('.tabProps_pagina_faidate_segnapagina_set')[0].select('a')}
for(i=0;i<tagsA.length;i++){tagIMG=tagsA[i].select('img')[0]
src=tagIMG.readAttribute('src').split('/').last().gsub('tn_','').split('.').first()
if(src==tabProps.flap_url.split('.').first()){tagsA[i].hasClassName('in')?null:tagsA[i].addClassName('in')}else{tagsA[i].hasClassName('in')?tagsA[i].removeClassName('in'):null}}}catch(e){alert("An exception occurred in the TabPropsPage.displayCurrentIcoPrefs(). Error name: "+e.name
+". Error message: "+e.message)}},displayCurrentSoundPrefs:function(){try{var tabProps=pageTabs.getCurrentTab().tabProps;tabsFlapOption=$$('#tabProps_pagina_faidate_suoni_box .suono_segnapagina')[0].select('option')
for(i=0;i<tabsFlapOption.length;i++){option=tabsFlapOption[i];if(option.value==tabProps.sound_flap_url.split('.')[0]){option.writeAttribute('selected','selected')}}
tabsOpenOption=$$('#tabProps_pagina_faidate_suoni_box .suono_apertura')[0].select('option')
for(i=0;i<tabsOpenOption.length;i++){option=tabsOpenOption[i];if(option.value==tabProps.sound_open_url.split('.')[0]){option.writeAttribute('selected','selected')}}}catch(e){alert("An exception occurred in the TabPropsPage.displayCurrentSoundPrefs(). Error name: "+e.name
+". Error message: "+e.message)}},displayCurrentSponsorPrefs:function(){try{tagsA=$('tabProps_pagina_firmata_box').select('a');for(i=0;i<tagsA.length;i++){tagIMG=tagsA[i].select('img')[0];tokens=tagIMG.readAttribute('src').split('/');halfPath=tokens[tokens.length-2];var tabProps=pageTabs.getCurrentTab().tabProps;if((tabProps.sponsored_tab.add_path!=null)&&(halfPath==tabProps.sponsored_tab.add_path.split('/').last())){tagsA[i].hasClassName('in')?null:tagsA[i].addClassName('in')}else{tagsA[i].hasClassName('in')?tagsA[i].removeClassName('in'):null}}}catch(e){alert("An exception occurred in the TabPropsPage.displayCurrentSponsorPrefs(). Error name: "+e.name
+". Error message: "+e.message)}},trumpetClicked:function(){this.openTrumpetMenu();this.closeTabPropsMenus('trumpet');},trumpetAperturaONClicked:function(){pageTabs.getCurrentTab().setAperturaSoundsON();this.displayCurrentSoundsOnOffPrefs();},trumpetAperturaOFFClicked:function(){pageTabs.getCurrentTab().setAperturaSoundsOFF();this.displayCurrentSoundsOnOffPrefs();},trumpetSegnapaginaONClicked:function(){pageTabs.getCurrentTab().setSegnapaginaSoundsON();this.displayCurrentSoundsOnOffPrefs();},trumpetSegnapaginaOFFClicked:function(){pageTabs.getCurrentTab().setSegnapaginaSoundsOFF();this.displayCurrentSoundsOnOffPrefs();},lockerClicked:function(){this.openLockerMenu();this.closeTabPropsMenus('locker');},trashClicked:function(){if(pageTabs.getNumberOfTabs()>1){this.openTrashMenu();this.closeTabPropsMenus('trash');}},trashOptOkClicked:function(){this.closeTabPropsMenus();this.addingTab=false;pageTabs.hideTabProperties(true);},trashOptCancelClicked:function(){this.closeTrashMenu();},openTrumpetMenu:function(){if(!this.trumpetMenuShown){this.trumpetMenu.slideDown({duration:0.3});this.trumpetMenuShown=true;}},closeTrumpetMenu:function(){if(this.trumpetMenuShown){this.trumpetMenu.slideUp({duration:0.3});this.trumpetMenuShown=false;}},openLockerMenu:function(){if(!this.lockerMenuShown){this.lockerMenu.slideDown({duration:0.3});this.lockerMenuShown=true;}},closeLockerMenu:function(){if(this.lockerMenuShown){this.lockerMenu.slideUp({duration:0.3});this.lockerMenuShown=false;}},openTrashMenu:function(){if(!this.trashMenuShown){this.trashMenu.slideDown({duration:0.3});this.trashMenuShown=true;}},closeTrashMenu:function(){if(this.trashMenuShown){this.trashMenu.slideUp({duration:0.3});this.trashMenuShown=false;}},closeUpRightMenus:function(except){if(except!='trumpet'){this.closeTrumpetMenu()};if(except!='locker'){this.closeLockerMenu()};if(except!='trash'){this.closeTrashMenu()};},logoMenuNavSxClicked:function(){if(this.logoMenuSets[0].getStyle('display')=='none'){this.logoMenuSets[1].hide();this.logoMenuSets[0].show();$('tabProps_mylogo_nav').select('span')[0].update('1 di 2')}else{this.logoMenuSets[0].hide();this.logoMenuSets[1].show();$('tabProps_mylogo_nav').select('span')[0].update('2 di 2')}
this.displayCurrentLogoPrefs();this.closeTabPropsMenus();},logoMenuNavDxClicked:function(){this.logoMenuNavSxClicked();this.closeTabPropsMenus();},bindPageForWallPapers:function(){this.backgroundsMenuSets=$$('#tabProps_pagina_faidate_sfondi_box .tabProps_pagina_faidate_sfondi_set')
this.backgroundsMenuNavSx=$('tabProps_pagina_faidate_sfondi_nav_sx').select('img')[0]
this.backgroundsMenuNavDx=$('tabProps_pagina_faidate_sfondi_nav_dx').select('img')[0]
this.bgThumbnails=$$("#tabProps_pagina_faidate_sfondi_box .bg_thumb")
this.backgroundsMenuNavSx.onclick=this.backgroundsMenuNavSxClicked.bindAsEventListener(this);this.backgroundsMenuNavDx.onclick=this.backgroundsMenuNavDxClicked.bindAsEventListener(this);for(i=0;i<this.bgThumbnails.length;i++){this.bgThumbnails[i].onclick=this.bgThumbnailsListner.bindAsEventListener(this);}
this.backgroundsMenuSets.invoke('hide');this.backgroundsMenuSets[0].show();$('tabProps_pagina_faidate_sfondi_nav').select('span')[0].update('1 di '+this.backgroundsMenuSets.length)},checkShowKidgetResponse:function(request){response=request.responseText.evalJSON(true);location.href=response.redirect_to;},backgroundsTitleClicked:function(){if($('tabProps_pagina_faidate_sfondi_box').down('div').next('div')==null)
{$('tabProps_pagina_faidate_sfondi_box').setStyle.display=""
this.openBackgroundsMenu(true),this.closeTabPropsMenus('backgrounds'),this.wallPaperShow=true;}
else
{this.openBackgroundsMenu(false)
this.closeTabPropsMenus('backgrounds')}},loadWallPaperBackGround:function()
{that=this
new Ajax.JSON('/tab/show_wallpapers/',{asynchronous:true,evalScripts:false,onComplete:function(){that.bindPageForWallPapers(),that.displayCurrentBgPrefs(),$('tabProps_pagina_faidate_sfondi_box').down('img').hide(),$('first_page_wallpaper').fade({duration:0.8,from:0,to:1});}})},backgroundsMenuNavSxClicked:function(){var totale=this.backgroundsMenuSets.length;this.backgroundsMenuSets.each(function(bk,index){if(bk.visible()){bk.hide();nuovo_set=index==0?totale-1:index-1;throw $break;}});this.backgroundsMenuSets[nuovo_set].show();$('tabProps_pagina_faidate_sfondi_nav').select('span')[0].update((nuovo_set+1)+' di '+totale);this.displayCurrentBgPrefs();},backgroundsMenuNavDxClicked:function(){var totale=this.backgroundsMenuSets.length;this.backgroundsMenuSets.each(function(bk,index){if(bk.visible()){bk.hide();nuovo_set=index==totale-1?0:index+1;throw $break;}});this.backgroundsMenuSets[nuovo_set].show();$('tabProps_pagina_faidate_sfondi_nav').select('span')[0].update((nuovo_set+1)+' di '+totale);this.displayCurrentBgPrefs();},menuNavSxSponsoredTabClicked:function(){totale=this.containerSponsoredTab.length;this.containerSponsoredTab.each(function(bk,index){if(bk.visible()){bk.hide();nuovo_set=index==0?totale-1:index-1;throw $break;}});this.containerSponsoredTab[nuovo_set].show();this.displayCurrentSponsorPrefs();},menuNavDxSponsoredTabClicked:function(){totale=this.containerSponsoredTab.length;this.containerSponsoredTab.each(function(bk,index){if(bk.visible()){bk.hide();nuovo_set=index==totale-1?0:index+1;throw $break;}});this.containerSponsoredTab[nuovo_set].show();this.displayCurrentSponsorPrefs();},iconsTitleClicked:function(){this.openIconsMenu();this.closeTabPropsMenus('icons');},iconsMenuNavSxClicked:function(){if(this.iconsMenuSets[0].getStyle('display')=='block'){this.iconsMenuSets[0].hide();this.iconsMenuSets[1].hide();this.iconsMenuSets[2].show();$('tabProps_pagina_faidate_segnapagina_nav').select('span')[0].update('3 di 3')}else{if(this.iconsMenuSets[1].getStyle('display')=='block'){this.iconsMenuSets[0].show();this.iconsMenuSets[1].hide();this.iconsMenuSets[2].hide();$('tabProps_pagina_faidate_segnapagina_nav').select('span')[0].update('1 di 3')}else{this.iconsMenuSets[0].hide();this.iconsMenuSets[1].show();this.iconsMenuSets[2].hide();$('tabProps_pagina_faidate_segnapagina_nav').select('span')[0].update('2 di 3')}}
this.displayCurrentIcoPrefs();},iconsMenuNavDxClicked:function(){if(this.iconsMenuSets[0].getStyle('display')=='block'){this.iconsMenuSets[0].hide();this.iconsMenuSets[1].show();this.iconsMenuSets[2].hide();$('tabProps_pagina_faidate_segnapagina_nav').select('span')[0].update('2 di 3')}else{if(this.iconsMenuSets[1].getStyle('display')=='block'){this.iconsMenuSets[0].hide();this.iconsMenuSets[1].hide();this.iconsMenuSets[2].show();$('tabProps_pagina_faidate_segnapagina_nav').select('span')[0].update('3 di 3')}else{this.iconsMenuSets[0].show();this.iconsMenuSets[1].hide();this.iconsMenuSets[2].hide();$('tabProps_pagina_faidate_segnapagina_nav').select('span')[0].update('1 di 3')}}},soundsTitleClicked:function(){this.openSoundsMenu();this.closeTabPropsMenus('sounds');},soundsTrumpetFlapClicked:function(event){soundName=$F($$('.suono_segnapagina')[0])
MPSound.play(TabPropsPage.soundsPath+soundName+".wav")},soundsTrumpetOpenClicked:function(event){soundName=$F($$('.suono_apertura')[0])
MPSound.play(TabPropsPage.soundsPath+soundName+".wav");},OKClicked:function(){if(this.addingTab){this.addingTab=false}
soundFlapName=$F($$('.suono_segnapagina')[0])
soundOpenName=$F($$('.suono_apertura')[0])
pageTabs.getCurrentTab().confirmChanges(soundFlapName,soundOpenName)
this.closeTabPropsPage();},CancelClicked:function(){pageTabs.getCurrentTab().cancelChanges()
this.closeTabPropsPage();},openBackgroundsMenu:function(load){if(!this.backgroudsMenuShown){that=this
this.backgroundsMenu.slideDown({duration:0.5,afterFinish:function(){if(load)
{that.loadWallPaperBackGround();}}});this.backgroudsMenuShown=true;}},closeBackgroundsMenu:function(){if(this.backgroudsMenuShown){this.backgroundsMenu.slideUp({duration:0.5});this.backgroudsMenuShown=false;}},openIconsMenu:function(){if(!this.iconsMenuShown){this.iconsMenu.slideDown({duration:0.5});this.iconsMenuShown=true;}},closeIconsMenu:function(){if(this.iconsMenuShown){this.iconsMenu.slideUp({duration:0.4});this.iconsMenuShown=false;}},openSoundsMenu:function(){if(!this.soundsMenuShown){this.soundsMenu.slideDown({duration:0.5});this.soundsMenuShown=true;}},closeSoundsMenu:function(){if(this.soundsMenuShown){this.soundsMenu.slideUp({duration:0.3});this.soundsMenuShown=false;}},closeFaiDaTeMenus:function(except){if(except!='backgrounds'){this.closeBackgroundsMenu()}
if(except!='icons'){this.closeIconsMenu()}
if(except!='sounds'){this.closeSoundsMenu()}},closeTabPropsMenus:function(except){this.closeUpRightMenus(except);this.closeFaiDaTeMenus(except);},closeTabPropsPage:function(){this.closeTabPropsMenus();if(this.addingTab){this.addingTab=false;pageTabs.hideTabProperties(true);}else{pageTabs.hideTabProperties(false);}},bgThumbnailsListner:function(event){shortName=Event.element(event).readAttribute('src').split('/').last().gsub('tn_','');pageTabs.getCurrentTab().changeBackground(shortName,false);this.displayCurrentBgPrefs();this.displayCurrentSponsorPrefs();},logoThumbnailsListner:function(event){shortName=Event.element(event).readAttribute('src').split('/').last().gsub('tn_','');pageTabs.getCurrentTab().changeLogo(shortName);this.displayCurrentLogoPrefs();this.closeTabPropsMenus();},sponsoredThumbnailsListner:function(event){tokens=Event.element(event).readAttribute('src').split('/')
filePath=tokens[tokens.length-3]+'/'+tokens[tokens.length-2]+'/'+tokens[tokens.length-1]
sponsoredFlapName=null;switch(tokens[tokens.length-2]){case'014_tobia':sponsoredFlapName='icon_tobia.png';break;case'011_andersen':sponsoredFlapName='icon_andersen.png';break;case'012_cactoons':sponsoredFlapName='icon_cactoons.png';break;case'013_macchiavello':sponsoredFlapName='icon_macchia.png';break;case'010_biciscuola_2008':sponsoredFlapName='icon_biciscuola.png';break;case'015_ferrero_cartoons':sponsoredFlapName='icon_ferrero.png';break;case'016_trebisonda':sponsoredFlapName='icon_trebisonda.png';break;case'017_nickelodeon':sponsoredFlapName='icon_nickelodeon.png';break;case'018_editoriale_scienza':sponsoredFlapName='icon_ed_scienza.png';break;case'019_straspeed':sponsoredFlapName='icon_straspeed.png';break;case'020_trebisonda':sponsoredFlapName='icon_trebisonda_2.png';break;case'021_kung_fu_panda':sponsoredFlapName='icon_panda.png';break;case'022_i_did_it_mum':sponsoredFlapName='icon_i_did_it_mum.png';break;case'023_high_school_musical_3':sponsoredFlapName="icon_hsm3.png";break;case'024_giornalino_pinky':sponsoredFlapName="icon_giornalino_pinky.png";break;case'025_madagascar_2':sponsoredFlapName="icon_madagascar_2.png";break;case'026_andersen':sponsoredFlapName="icon_andersen_2.png";break;case'027_tom_trueheart':sponsoredFlapName="icon_tom_trueheart.png";break;case'028_autosprint':sponsoredFlapName="icon_autosprint.png";break;case'029_amnesty_kids':sponsoredFlapName="icon_009.png";break;case'030_giffoni_ff_2009':sponsoredFlapName="icon_giffoni_ff_2009.png";break;case'031_spongebob':sponsoredFlapName="icon_spongebob.png";break;case'032_niko_renna':sponsoredFlapName="icon_niko_renna.png";break;case'033_lego_games':sponsoredFlapName="icon_lego.png";break;case'034_astro_boy':sponsoredFlapName="icon_astro_boy.png";break;case'035_eye_pet':sponsoredFlapName="icon_eye_pet.png";break;case'036_nicolas':sponsoredFlapName="icon_nicolas.png";break;case'037_telefono_azzurro':sponsoredFlapName="icon_telefono_azzurro.png";break;case'038_le_39_chiavi':sponsoredFlapName="icon_le_39_chiavi.png";break;case'039_citta_della_scienza':sponsoredFlapName="icon_citta_della_scienza.png";break;}
if(sponsoredFlapName!=null){pageTabs.getCurrentTab().changeIcon(sponsoredFlapName);this.displayCurrentIcoPrefs();}
pageTabs.getCurrentTab().changeBackground(filePath,true);this.displayCurrentBgPrefs();this.displayCurrentSponsorPrefs();this.closeTabPropsMenus();},iconsThumbnailsListner:function(event){shortName=Event.element(event).readAttribute('src').split('/').last().gsub('tn_','');pageTabs.getCurrentTab().changeIcon(shortName.gsub('gif','png'));this.displayCurrentIcoPrefs();},cloudTagsListener:function(event){this.cloudTags.each(function(tag){if(tag==Event.element(event)){tag.hasClassName('in')?tag.removeClassName('in'):tag.addClassName('in');}})}});var TabProps=Class.create({initialize:function(){this.id=null;this.background_url=null;this.flap_url=null;this.magic_spell=null;this.mypage_logo_url=null;this.sound_flap_url=null;this.sound_open_url=null;this.sound_apertura_on=false;this.sound_segnapagina_on=false;this.sponsored_tab=new function(){this.add_path=null;this.background_url=null;this.flap_url=null;this.id=0;this.sound_flap_url=null;this.sound_open_url=null;}},setPropsFromServerData:function(propsObjFromServer){this.id=propsObjFromServer.id;this.background_url=propsObjFromServer.background_url;this.flap_url=propsObjFromServer.flap_url;this.magic_spell=propsObjFromServer.magic_spell;this.mypage_logo_url=propsObjFromServer.mypage_logo_url;this.sound_flap_url=propsObjFromServer.sound_flap_url;this.sound_open_url=propsObjFromServer.sound_open_url;this.sound_apertura_on=propsObjFromServer.sound_apertura_on;this.sound_segnapagina_on=propsObjFromServer.sound_segnapagina_on;if((propsObjFromServer.sponsored_tab!=null)&&(propsObjFromServer.sponsored_tab!=0)){this.sponsored_tab.add_path=propsObjFromServer.sponsored_tab.add_path;this.sponsored_tab.background_url=propsObjFromServer.sponsored_tab.background_url;this.sponsored_tab.flap_url=propsObjFromServer.sponsored_tab.flap_url;this.sponsored_tab.id=propsObjFromServer.sponsored_tab.id;this.sponsored_tab.sound_flap_url=propsObjFromServer.sponsored_tab.sound_flap_url;this.sponsored_tab.sound_open_url=propsObjFromServer.sponsored_tab.sound_open_url;}}});var GlobalTab=Class.create({initialize:function(tabId,myPageContainer,noOfKidgetsAtStartUp){this.id=tabId
this.isLoaded=false
this.isCurrent=false
this.moved=false
this.draggablesCollection=new DraggObjectsCollection(this.container);this.kidgetsPosition=new TabKidgetsPosition(this.id,new Array(),0);this.container=myPageContainer
this.tabProps=new TabProps();this.tabPropsOLD=new TabProps();this.playingSound=false
this.tabNotifyShown=false
this.numberOfKidgetsAtStartUp=noOfKidgetsAtStartUp;},addDraggableByTabItemId:function(tabItemId,enable){return this.draggablesCollection.addDraggableByTabItemId(tabItemId,enable);},addDraggableByKidgetObj:function(kidget,enable){this.draggablesCollection.addDraggableByKidgetObj(kidget,enable);},enableDraggingInTab:function(enable){this.draggablesCollection.enableDragging(enable);},disableDraggingInTab:function(){this.draggablesCollection.disableDragging();},applyLoginToKidgets:function(){this.draggablesCollection.applyLoginToKidgets();},applyLogoutToKidgets:function(){this.draggablesCollection.applyLogoutToKidgets();},getDraggObjects:function(){return this.draggablesCollection.getDraggObjects();},getKidgets:function(){return this.draggablesCollection.getKidgets();},hasMoved:function(){if(!this.moved){this.moved=this.draggablesCollection.hasMoved();}
return this.moved;},findDraggableByObjId:function(objId){return this.draggablesCollection.findDraggableByObjId(objId);},findAndDeleteDraggableByObjId:function(objId){deleted=this.draggablesCollection.findAndDeleteDraggableByObjId(objId);if(deleted){this.sendBottomOfKidgetsToServer();}
return deleted;},findAndReloadKidgetByObjId:function(objId,reloadParams){var found=false;found=this.draggablesCollection.findAndReloadKidgetByObjId(objId,reloadParams);return found;},undoDeleteKidget:function(objId){this.draggablesCollection.undoDeleteKidget(objId);},removeAllKidgets:function(){return this.draggablesCollection.removeAllKidgets();},setMoved:function(moved){this.draggablesCollection.setMoved(moved);},setKidgetsPosition:function(){if(this.hasMoved()||this.isCurrent){this.kidgetsPosition=new TabKidgetsPosition(this.id,this.draggablesCollection.getKidgetsPosition(),this.getBottomOfYourKidgets());this.moved=false;this_tab_id=this.id;new Ajax.JSON('/tab/set_kidgets_position/',{object:this.kidgetsPosition,onComplete:function(request){pageTabs.getTabById(this_tab_id).checkSetKidgetsPositionResponse(request)}});}},recallKidgetsPosition:function(){this.draggablesCollection.recallKidgetsPosition();},checkSetKidgetsPositionResponse:function(request){if(pageTabs.checkResponseFromServer(request,true)){this.draggablesCollection.setMoved(false);}},getKidgetsPosition:function(){if(this.hasMoved()||this.isCurrent){this.kidgetsPosition=new TabKidgetsPosition(this.id,this.draggablesCollection.getKidgetsPosition(),this.getBottomOfYourKidgets());this.moved=false;return this.kidgetsPosition;}else{return false;}},getBottomOfYourKidgets:function(){return this.draggablesCollection.getBottomOfKidgets();},getBottomOfYourKidgetsNotNull:function(){return this.draggablesCollection.getBottomOfKidgetsNotNull();},beforeSetNotCurrent:function(){this.draggablesCollection.beforeTabSetNotCurrent();},setNotCurrent:function(sendToServer){if(pageTabs.userCanModifyPage()&&sendToServer){this.setKidgetsPosition();}
$("tabFlap"+this.id).childElements()[0].removeClassName("tabFlapIn");$("tabFlap"+this.id).childElements()[1].hide();$("tab"+this.id).hide();this.isCurrent=false},setCurrent:function(loadKidgets,onlyJS){if((!onlyJS)&&($('logo')!=null)){$('logo').select('img')[0].writeAttribute('src',TabPropsPage.logoPath+this.tabProps.mypage_logo_url);}
if(((!onlyJS))&&(this.tabProps.background_url!=null)&&(this.tabProps.background_url!='')){$('tab'+this.id).setStyle({border:'none'})
$('tab'+this.id).setStyle({backgroundImage:'url('+TabPropsPage.backgroundsPath+this.tabProps.background_url+')'});}
if(((!onlyJS))&&(this.tabProps.sound_apertura_on)){MPSound.play(TabPropsPage.soundsPath+this.tabProps.sound_open_url);}
if(!this.isLoaded){if(loadKidgets){loadTabKidgets(this.id,document.getElementById("tab"+this.id));}
this.isLoaded=true;}
$("tabFlap"+this.id).childElements()[0].addClassName("tabFlapIn");$("tabFlap"+this.id).childElements()[1].show();$("tab"+this.id).show();this.isCurrent=true;new Ajax.Request('/tab/set_current/'+this.id,{asynchronous:true,evalScripts:false});},afterSetCurrent:function(){this.draggablesCollection.tabSetCurrent();},getDraggObjects:function(){return this.draggablesCollection.getDraggObjects();},extractKidget:function(kidget){return this.draggablesCollection.extractKidget(kidget);},getXY:function(){return{x:$("tab"+this.id).offsetLeft,y:$("tab"+this.id).offsetTop};},refreshKidgetsPosition:function(){this.draggablesCollection.refreshKidgetsPosition();},setTabPropsOnCreate:function(props){this.tabProps.setPropsFromServerData(props);sponsorOLD=Object.clone(this.tabProps.sponsored_tab)
this.tabPropsOLD=Object.clone(this.tabProps);this.tabPropsOLD.sponsored_tab=sponsorOLD},setFlapColor:function(sponsored){if(sponsored){tabBgColor=this.tabProps.sponsored_tab.background_url.split('_').last().split('.').first()}else{if((this.tabProps.background_url!=null)&&(this.tabProps.background_url!='')){tabBgColor=this.tabProps.background_url.split('_').last().split('.').first()}else{tabBgColor="E6DFDF"}}
tabFlapClassName=$w($('tabFlap'+this.id).className).first()
cssRule='#tabFlaps li.'+tabFlapClassName+' a, #tabFlaps li.'+tabFlapClassName+' a:visited, #tabFlaps li.'+tabFlapClassName+' span.tabFlapIn a:hover'
el=$$(cssRule).first()
el.setStyle({backgroundColor:'#'+tabBgColor})},setFlapOverSound:function(){tabFlapLi=$('tabFlap'+this.id)
tabFlapIMG=tabFlapLi.select('img')[0]
tabFlapIMG.onmouseover=this.playSoundFlapOver.bindAsEventListener(this);tabFlapIMG.onmouseout=this.mouseOutFlap.bindAsEventListener(this);},playSoundFlapOver:function(event){if(this.tabProps.sound_segnapagina_on){if((!this.playingSound)){this.playingSound=true;MPSound.play(TabPropsPage.soundsPath+this.tabProps.sound_flap_url);}}},mouseOutFlap:function(event){this.playingSound=false;},changeBackground:function(bgName,sponsored){if((bgName!=null)&&(bgName!='')){$('tab'+this.id).setStyle({border:'none'})
if(sponsored){tokens=bgName.split('/')
this.tabProps.sponsored_tab.add_path=tokens[tokens.length-3]+'/'+tokens[tokens.length-2]
color=tokens[tokens.length-1].split('_').last().split('.').first();fileName='back_'+color+'.jpg'
this.tabProps.sponsored_tab.background_url=fileName
this.tabProps.background_url=null
$('tab'+this.id).setStyle({backgroundImage:'url('+TabPropsPage.sponsoredMediaPath+this.tabProps.sponsored_tab.add_path+'/'+fileName+')'});}else{if(bgName.include(".png")){bgName=bgName.replace(".png",".jpg");}
this.tabProps.background_url=bgName
this.tabProps.sponsored_tab.add_path=null
this.tabProps.sponsored_tab.background_url=null
$('tab'+this.id).setStyle({backgroundImage:'url('+TabPropsPage.backgroundsPath+this.tabProps.background_url+')'});}}else{$('tab'+this.id).setStyle({border:'solid 1px black'})}
this.setFlapColor(sponsored);},changeLogo:function(fileName){pngName=fileName.split('.').first()+'.png';this.tabProps.mypage_logo_url=pngName;$('logo').select('img')[0].writeAttribute('src',TabPropsPage.logoPath+this.tabProps.mypage_logo_url);},changeIcon:function(fileName){this.tabProps.flap_url=fileName;$('tabFlap'+this.id).select('img').first().writeAttribute('src',TabPropsPage.iconsPath+this.tabProps.flap_url);},setAperturaSoundsON:function(){this.tabProps.sound_apertura_on=true;},setAperturaSoundsOFF:function(){this.tabProps.sound_apertura_on=false;},setSegnapaginaSoundsON:function(){this.tabProps.sound_segnapagina_on=true;},setSegnapaginaSoundsOFF:function(){this.tabProps.sound_segnapagina_on=false;},confirmChanges:function(soundFlapName,soundOpenName){this.tabProps.sound_flap_url=soundFlapName+'.wav'
this.setFlapOverSound();this.tabProps.sound_open_url=soundOpenName+'.wav'
this_tab_id=this.id;new Ajax.JSON('/tab/update_tab_properties/',{object:this.tabProps,onComplete:function(request){pageTabs.getTabById(this_tab_id).checkUpdateTabPropertiesResponse(request)}})},checkUpdateTabPropertiesResponse:function(request){if(pageTabs.checkResponseFromServer(request,true)){sponsorOLD=Object.clone(this.tabProps.sponsored_tab);this.tabPropsOLD=Object.clone(this.tabProps);this.tabPropsOLD.sponsored_tab=sponsorOLD;}else{this.cancelChanges();}},cancelChanges:function(){sponsor=Object.clone(this.tabPropsOLD.sponsored_tab)
this.tabProps=Object.clone(this.tabPropsOLD)
this.tabProps.sponsored_tab=sponsor
if(this.tabProps.sponsored_tab.add_path!=null){$('tab'+this.id).setStyle({backgroundImage:'url('+TabPropsPage.sponsoredMediaPath+this.tabProps.sponsored_tab.add_path+'/'+this.tabProps.sponsored_tab.background_url+')'});this.setFlapColor(true);}else{$('tab'+this.id).setStyle({backgroundImage:'url('+TabPropsPage.backgroundsPath+this.tabProps.background_url+')'});this.setFlapColor(false);}
$('logo').select('img')[0].writeAttribute('src',TabPropsPage.logoPath+this.tabProps.mypage_logo_url);$('tabFlap'+this.id).select('img').first().writeAttribute('src',TabPropsPage.iconsPath+this.tabProps.flap_url)},sendBottomOfKidgetsToServer:function(){var bottomOfYourKidgets=this.getBottomOfYourKidgets();if(bottomOfYourKidgets!=null){new Ajax.Request('/tab/set_bottom_of_kidgets/'+bottomOfYourKidgets,{asynchronous:true,evalScripts:false});}},allKidgetsLoaded:function(){return(this.numberOfKidgetsAtStartUp==this.draggablesCollection.kidgets.length);},getKidgetByTabItemId:function(tabItemId){return this.draggablesCollection.getKidgetByTabItemId(tabItemId);},sendCustomKidgetDataToServer:function(){this.draggablesCollection.sendCustomKidgetDataToServer();}});var GlobalTabs=Class.create({initialize:function(myPageContainer,tabsContainer,pollTime){this.isCard=false;this.isBazaar=false;this.isCard=false;this.isNotification=false;this.container=myPageContainer;this.tabsContainer=tabsContainer;this.tabs=new Array();this.user=new User();this.pageOwner=new User();this.pageId=0;this.pageOwnerNickname=null;this.kidgetsPosition=new PageKidgetsPosition(this.pageId,new Array());this.newBottom=parseInt(Element.getStyle(this.container,'height'));this.oldBottom=this.newBottom
this.movingKidget=null;this.droppingKidget=false;this.forcingRefresh=false;this.tabPropsPage=new TabPropsPage()
this.tabNotifyShown=false;this.actionToPerform=null;this.communicator=new Communicator();this.windowLoaded=false;this.timeoutAtStartUpExpired=false;this.currentZIndex=100;this.isIE7=false;this.tabDialog=new TabDialog();MM_preloadImages('images/mypage/tabFlap1_on.png');MM_preloadImages('images/mypage/tabFlap2_on.png');MM_preloadImages('images/mypage/tabFlap3_on.png');MM_preloadImages('images/mypage/tabFlap4_on.png');MM_preloadImages('images/mypage/tabFlap5_on.png');MM_preloadImages('images/mypage/tabFlap6_on.png');MM_preloadImages('images/mypage/tabFlap7_on.png');MM_preloadImages('images/mypage/tabFlap8_on.png');setTimeout(this.timeoutAtStarUpExpires.bindAsEventListener(this),5000);this.newNotificationsTimeout=pollTime
this.newNotificationsTimeoutHandler=null;this.scroll=false;this.currentUserLang=null;this.addingFriendNickname=null;this.userManager=new UserManager(this,this.user,this.pageOwner,this.tabDialog,'page',this.communicator,true);this.checkBrowser();this.justLoggedUser=false;this.showContentProtectionAlertAtStartup=false;this.showTabPropsAtStartup=false;},checkBrowser:function(){if(BrowserDetect.browser=='Explorer'){this.isIE7=true;}
if(!validateBrowser()){var errori=detectBrowser();if(errori['errore_cookie']){upperBar.showAlert({component:'browser_alert',alert:'cookies_not_enabled'});return false;}
if((errori['errore_browser'])&&(MPCookies.read('check_ok')!='true')){upperBar.showAlert({component:'browser_alert',alert:'browser_not_supported'});return false;}}else{}},startPage:function(myPageHeaderBehaviour,myPageHeaderBehaviourAvoidFamous,showDialogAvvisiAtStartup,showContentProtectionAlertAtStartup,showTabPropsAtStartup){this.userManager.checkUserStatusAtStartUp(myPageHeaderBehaviour,myPageHeaderBehaviourAvoidFamous);this.managePageFlapsAndButtons();this.userManager.subscribeAction({event:'logout',when:'before',callback:new EventCallback({callback:this.actionBeforeLogout.bindAsEventListener(this),callbackParams:null,executeOnce:false,asynchronous:true,blocksQueue:false})})
this.showContentProtectionAlertAtStartup=showContentProtectionAlertAtStartup;if(showDialogAvvisiAtStartup){this.userManager.showDialogAvvisi()}
if(showTabPropsAtStartup){this.showTabPropsAtStartup=true;}},prepareTabPropsPage:function(){this.tabPropsPage.setPageElements();this.tabPropsPage.bindPage();},setUserInfoFromServerData:function(responseFromServer,new_notifications_count){this.user.setUserInfoFromServerData(responseFromServer,new_notifications_count);this.currentUserLang=this.user.getLang();},setPageOwnerInfoFromServerData:function(responseFromServer){this.pageOwner.setUserInfoFromServerData(responseFromServer,null);},userCanModifyPage:function(){if(this.user.getYourPageId()==this.pageId){if(this.user.isRegistered()){if(this.user.isLoggedIn()){return true;}else{return false;}}else{return true;}}else{return false;}},setUserCanModifyPage:function(canHe){this.user.setUserModifyPage(canHe);},userIsLogged:function(){return this.user.isLoggedIn();},userIsRegistered:function(){return this.user.isRegistered();},userCanDownloadMedia:function(){return this.user.canDownloadMedia();},userCanHaveFriends:function(){return this.user.canHaveFriends();},userCanWriteText:function(){return this.user.canWriteText();},setPageId:function(pageIdentifier,pageOwnerNick){this.pageId=pageIdentifier;this.pageOwnerNickname=pageOwnerNick;},addTabById:function(tabId,numberOfKidgetsAtStartUp){this.tabs.push(new GlobalTab(tabId,this.container,numberOfKidgetsAtStartUp));},getCurrentTabId:function(){for(var t=0;t<this.tabs.length;t++){if(this.tabs[t].isCurrent){return this.tabs[t].id}}},setCurrent:function(tabId){for(t=0;t<this.tabs.length;t++){if(this.tabs[t].id==tabId){this.tabs[t].isCurrent=true;}else{this.tabs[t].isCurrent=false;}}},getCurrentTab:function(){for(var t=0;t<this.tabs.length;t++){if(this.tabs[t].isCurrent){return this.tabs[t];}}},getTabDialog:function(){return this.tabDialog;},getCurrentZIndex:function(incrementZIndex){var zIndex=this.currentZIndex;if(incrementZIndex==true){this.currentZindex+=1}
return zIndex;},getDialogMaskHeight:function(){return this.newBottom;},setLoaded:function(tabId){for(t=0;t<this.tabs.length;t++){if(this.tabs[t].id==tabId){this.tabs[t].isLoaded=true;}}},isLoaded:function(tabId){for(t=0;t<this.tabs.length;t++){if(this.tabs[t].id==tabId){return this.tabs[t].isLoaded;}}},setMovingKidget:function(kidget){this.movingKidget=kidget;},getMovingKidget:function(){return this.movingKidget;},setDroppingKidget:function(value){this.droppingKidget=value;},isDroppingKidget:function(){return this.droppingKidget;},deleteKidgetById:function(kidId){var kidgetToDelete=this.findDraggableByObjId("kd_"+kidId);deleted=this.findAndDeleteDraggableByObjId("kd_"+kidId);this.checkPageBottom();},reloadKidget:function(kidId,reloadParameters){var found=false;for(var p=0;(p<this.tabs.length)&&(!found);p++){found=this.tabs[p].findAndReloadKidgetByObjId("kd_"+kidId,reloadParameters);}},getNumberOfTabs:function(){return this.tabs.length;},getTabById:function(tabId){for(var t=0;t<this.tabs.length;t++){if(this.tabs[t].id==tabId){return this.tabs[t];}}},disableDraggingInPage:function(){for(p=0;p<this.tabs.length;p++){this.tabs[p].disableDraggingInTab();}},enableDraggingInPage:function(enable){for(p=0;p<this.tabs.length;p++){this.tabs[p].enableDraggingInTab(enable);}},loadKidget:function(tabItemId,specificKd){this.addDraggableByTabItemIdOnTabId(tabItemId,this.getCurrentTabId()).setSpecificKidget(specificKd);},addDraggableByTabItemIdOnTabId:function(tabItemId,tabId){return this.getTabById(tabId).addDraggableByTabItemId(tabItemId,this.userCanModifyPage());},addDraggableByKidgetObjOnTabId:function(kidget,tabId){this.getTabById(tabId).addDraggableByKidgetObj(kidget,this.userCanModifyPage());},findDraggableByObjId:function(objId){var found=false;var obj=null;for(p=0;(p<this.tabs.length)&&(!found);p++){obj=this.tabs[p].findDraggableByObjId(objId);if(obj!=null){found=true;}}
return obj;},findAndDeleteDraggableByObjId:function(objId){var deleted=false;for(p=0;(p<this.tabs.length)&&(!deleted);p++){deleted=this.tabs[p].findAndDeleteDraggableByObjId(objId);}
return deleted;},undoDeleteKidget:function(kidId){var undo=false;for(p=0;(p<this.tabs.length)&&(!undo);p++){undo=this.tabs[p].undoDeleteKidget("kd_"+kidId);}},deleteTab:function(tabId){var tabFound=false;var kidgetsDeleted=false;for(var i=0;(i<this.tabs.length)&&(!tabFound);i++){if(this.tabs[i].id==tabId){tabFound=true;tabToDelete=this.tabs[i];kidgetsDeleted=tabToDelete.removeAllKidgets();if(kidgetsDeleted){$("tab"+tabToDelete.id).remove();$("tabFlap"+tabToDelete.id).remove();delete this.tabs[i]
this.tabs=this.tabs.compact();if(i==this.tabs.length){this.tabs[i-1].setCurrent(true,false);}else{this.tabs[i].setCurrent(true,false);}}else{alert("ERROR while deleting kidgets in tab "+tabId);}}}
this.managePageFlapsAndButtons();this.checkPageBottom();},setKidgetsPositionForAllTabs:function(actionOnSuccess){this.kidgetsPosition=new PageKidgetsPosition(this.pageId,new Array());for(t=0;t<this.tabs.length;t++){kidPos=this.tabs[t].getKidgetsPosition();if(kidPos){this.kidgetsPosition.addTabKidgetsPosition(kidPos);}}
if(this.kidgetsPosition.areKidgetPositionToUpdate()){new Ajax.JSON('/page/set_kidgets_position/',{object:this.kidgetsPosition,asynchronous:((BrowserDetect.browser=="Safari")&&(actionOnSuccess=='unload_page'))?false:true,onComplete:function(request){pageTabs.checkSetKidgetsPositionForAllTabsResponse(request,actionOnSuccess)}});}else{if(actionOnSuccess=='logout'){pageTabs.performLogout();}else if(actionOnSuccess=='addKidget'){this.getCurrentTab().sendBottomOfKidgetsToServer();location.href='/kidgetbox';}}},checkSetKidgetsPositionForAllTabsResponse:function(request,actionOnSuccess){if(pageTabs.checkResponseFromServer(request,true)){this.setMoved(false);if(actionOnSuccess=='logout'){pageTabs.performLogout();}else if(actionOnSuccess=='addKidget'){this.getCurrentTab().sendBottomOfKidgetsToServer();location.href='/kidgetbox/select_kidget';}else if(actionOnSuccess!=null){actionOnSuccess();}}},setMoved:function(moved){for(p=0;p<this.tabs.length;p++){this.tabs[p].setMoved(moved);}},startLogin:function(options){this.userManager.startLogin(options);},applyLoginToPage:function(args){if((typeof args=='undefined')||(typeof args.hideDialog=='undefined')||(args.hideDialog==true)){this.tabDialog.hideDialog();}
this.managePageFlapsAndButtons();var loginAtStartup=((typeof(args)!='undefined')&&(typeof(args.atStartup)!='undefined')&&(args.atStartup==true))?true:false;if(this.newNotificationsTimeoutHandler==null){if((!this.userCanModifyPage)&&(!loginAtStartup)){setTimeout(this.checkDialogForNewNotifications.bindAsEventListener(this),5000);}else{this.newNotificationsTimeoutHandler=setTimeout(this.periodicalNewNotificationsCheck.bindAsEventListener(this),this.newNotificationsTimeout);}}
if(!loginAtStartup){for(p=0;p<this.tabs.length;p++){this.tabs[p].applyLoginToKidgets();}}
this.enableDraggingInPage(this.userCanModifyPage());},infoToServerSent:function(){alert("Informazioni al server inviate prima del Logout");},sendGlobalPageInfoToServer:function(actionOnSuccess){$A(arguments).length>1?actionOnSuccess=$A(arguments)[1]:null;if(!this.forcingRefresh){if(actionOnSuccess=='unload_page'){this.communicator.set_unloading_page(true);}
this.sendCustomKidgetDataToServer();this.setKidgetsPositionForAllTabs(actionOnSuccess);}},sendCustomKidgetDataToServer:function(){this.getCurrentTab().sendCustomKidgetDataToServer();},registerUser:function(){location.href="/user/register/";},applyLogoutToPage:function(){this.hideTabProperties(false);this.tabDialog.hideDialog();this.managePageFlapsAndButtons();for(p=0;p<this.tabs.length;p++){this.tabs[p].applyLogoutToKidgets();}
this.enableDraggingInPage(this.userCanModifyPage());clearTimeout(this.newNotificationsTimeoutHandler);this.newNotificationsTimeoutHandler=null;},forceLogout:function(){this.user.logged_in=false;this.tabDialog.hideDialog();this.managePageFlapsAndButtons();this.enableDraggingInPage(this.userCanModifyPage());},actionBeforeLogout:function(){var callbackToContinueLogout=null;if((arguments.length>0)&&(arguments[0].callbackToContinue!=null)){callbackToContinueLogout=arguments[0].callbackToContinue;if(this.userCanModifyPage()){this.sendGlobalPageInfoToServer(callbackToContinueLogout);}else{callbackToContinueLogout();}}},forceRefresh:function(options){var url=options!=null&&options.showDialogAvvisiAtStartup==true?"/page/back_to_homepage?show_dialog_avvisi=true":"/page/back_to_homepage";location.href=url;},showDialogAvvisi:function(options){this.userManager.showDialogAvvisi(options);},managePageFlapsAndButtons:function(){$('addKidgetLink').style.display='block';if(this.userCanModifyPage()){if(pageTabs.getNumberOfTabs()<8){$('flapAddTab').show();}else{$('flapAddTab').hide();}
this.user.isRegistered()?this.displayNotifyFlap(true):this.displayNotifyFlap(false);$('propTabLink').show();}else{$('flapAddTab').hide();this.displayNotifyFlap(false);$('propTabLink').hide();}},displayNotifyFlap:function(display){if($('passaparolaNotifiche')!=null)
$('passaparolaNotifiche').update(this.user.getNewNotificationsCount());},checkDialogForNewNotifications:function(){if(!this.tabDialog.isVisible()){if((this.userIsLogged())&&(this.user.getNewNotificationsCount()>0)){this.playNewNotificationsSound();var message=this.user.getNewNotificationsCount()==1?i18n.stringLocale('nuovo_kidget_1')+"<br><br>"+i18n.stringLocale('nuovo_kidget_2'):i18n.stringLocale('nuovi_kidgets_1')+"<br><br>"+i18n.stringLocale('nuovi_kidgets_2');this.tabDialog.displayMessage({title:'warning',description:message,actionOK:this.hideTabDialog.bindAsEventListener(this),size:'small'})
this.tabDialog.showDialog({zIndex:this.currentZIndex,dialogMaskHeight:this.newBottom});this.currentZIndex+=1;}
if(this.userIsRegistered()){this.newNotificationsTimeoutHandler=setTimeout(this.periodicalNewNotificationsCheck.bindAsEventListener(this),this.newNotificationsTimeout);}}else{setTimeout(this.checkDialogForNewNotifications.bindAsEventListener(this),5000);}},periodicalNewNotificationsCheck:function(){options={JSON:true,evalJS:true,onComplete:this.checkNewNotificationsCheckResponse.bindAsEventListener(this,true)};this.communicator.sendRequest('/user/get_new_notifications_count',{'check_duplicate_login':this.userIsLogged()?'true':'false'},options);},checkNewNotificationsCheckResponse:function(request){if(pageTabs.checkResponseFromServer(request,true)){if(this.userCanModifyPage()){if(this.user.getNewNotificationsCount()<request.responseJSON.content){this.playNewNotificationsSound();}
this.user.setNewNotificationsCount(request.responseJSON.content);this.displayNotifyFlap();}
this.newNotificationsTimeoutHandler=setTimeout(this.periodicalNewNotificationsCheck.bindAsEventListener(this),this.newNotificationsTimeout);}},playNewNotificationsSound:function(){MPSound.play("/sounds/mypage/wordofmouth.wav");},checkKidgetPositionIntoPage:function(kidget){isOutLeft=parseInt(Element.getStyle(kidget,'left'))<0
isOutUp=parseInt(Element.getStyle(kidget,'top'))<0
isOutRight=(parseInt(Element.getStyle(kidget,'left'))+parseInt(Element.getStyle(kidget,'width')))>parseInt(Element.getStyle(this.container,'width'))
if(isOutLeft||isOutUp||isOutRight){return false;}else{return true;}},checkPageBottomAtStartUp:function(){if((this.getCurrentTab().allKidgetsLoaded())&&($('splashScreen')!=null)&&(!$('splashScreen').visible())&&(!this.tabPropsPage.isShown)){this.checkPageBottom();}},checkPageBottom:function(options){var currentTabNewBottom=this.getCurrentTab().getBottomOfYourKidgets();this.oldBottom=parseInt(Element.getStyle(this.container,'height'));if((currentTabNewBottom!=null)){var sendToServer=options!=null&&options.skipSendToServer==true?false:pageTabs.userCanModifyPage();if(currentTabNewBottom>this.oldBottom){this.newBottom=currentTabNewBottom+20
this.scaleToHeight(this.newBottom,2.0,sendToServer);this.oldBottom=this.newBottom;}else if(currentTabNewBottom<this.oldBottom){bottomOfAllTabs=this.getBottomOfAllTabs();if(((bottomOfAllTabs+20)<this.oldBottom)&&(this.oldBottom>600)){this.newBottom=bottomOfAllTabs+20
if(this.newBottom<600){this.newBottom=600}
this.scaleToHeight(this.newBottom,3.0,sendToServer);}
this.oldBottom=this.newBottom;}}
if(this.scroll==true){this.scroll=false;docH=document.getElementById('whole_page').offsetHeight;window.scrollTo(0,docH+50);}},scaleToHeight:function(toHeight,speed,sendToServer){var oldBottom=parseInt(Element.getStyle(this.container,'height'));scale=(((toHeight-oldBottom)/oldBottom)*100)+100;durationS=speed*((0.5)*(scale/400)+0.2);new Effect.Scale($('tab'+this.getCurrentTab().id),scale,{scaleX:false,scaleContent:false,duration:durationS,afterFinish:function(){pageTabs.newBottom=toHeight;pageTabs.setBottomForAllTabs(sendToServer);pageTabs.setPageHeightToCurrentTabHeight();if(pageTabs.isIE7){window.scroll(0,document.documentElement.scrollTop-1);scroll_func(null);}}});},setPageHeightToCurrentTabHeight:function(){var heightTo=parseInt(Element.getStyle($('tab'+this.getCurrentTabId()),'height'));this.container.setStyle({height:heightTo+'px'});},setBottomForAllTabs:function(sendToServer){for(p=0;p<this.tabs.length;p++){id_a='tab'+this.tabs[p].id
$(id_a).style.height=this.newBottom+'px';}
if(sendToServer){this.sendPageHeightToServer(this.newBottom);}},getBottomOfAllTabs:function(){var pageBottom=0
var i=0
var tmp=0
for(i=0;i<this.tabs.length;i++){tmp=this.tabs[i].getBottomOfYourKidgets();if((tmp!=null)&&(tmp>pageBottom)){pageBottom=tmp;}}
return pageBottom;},sendPageHeightToServer:function(){new Ajax.Request('/page/set_page_height/'+this.container.getHeight(),{asynchronous:true,evalScripts:true,onComplete:function(request){pageTabs.checkSendPageHeightResponse(request)}});},checkSendPageHeightResponse:function(request){if(pageTabs.checkResponseFromServer(request,true)){}},turnKidgetBack:function(kidget){kidId=kidget.getExtId();$(kidId).setStyle({zIndex:this.currentZIndex});this.currentZIndex+=1;new Effect.Opacity(document.getElementById(kidId).getElementsByClassName("kdfront")[0],{duration:0.5,from:1,to:0,afterFinish:function(effect){document.getElementById(kidId).getElementsByClassName("kdfront")[0].hide(),kidget.afterTurnBack();}});back=$(kidId).getElementsByClassName("kdback")[0]
back.setOpacity(0);back.show();new Effect.Opacity(document.getElementById(kidId).getElementsByClassName("kdback")[0],{duration:0.5,from:0,to:1});},restoreKidget:function(kidget){kidId=kidget.id;this.isIE7?$(kidId).setStyle('zIndex','auto'):$(kidId).setStyle({zIndex:'auto'});front=$(kidId).getElementsByClassName("kdfront")[0];front.setOpacity(0);front.show();new Effect.Opacity(document.getElementById(kidId).getElementsByClassName("kdfront")[0],{duration:0.5,from:0,to:1,afterFinish:function(effect){kidget.afterRestore();}});new Effect.Opacity(document.getElementById(kidId).getElementsByClassName("kdback")[0],{duration:0.5,from:1,to:0,afterFinish:function(effect){document.getElementById(kidId).getElementsByClassName("kdback")[0].hide()}});},restoreAllKidgets:function(){this.getCurrentTab().getKidgets().each(function(kidget){kidget.backCancel();})},changeTab:function(newTabId,sendToServer,loadKidgets,onlyJS){if(!this.tabNotifyShown){if(newTabId!=this.getCurrentTabId()){oldCurrentTab=this.getCurrentTab();if(oldCurrentTab!=null){oldCurrentTab.beforeSetNotCurrent()};this.getTabById(newTabId).setCurrent(loadKidgets,onlyJS);if(oldCurrentTab!=null){oldCurrentTab.setNotCurrent(sendToServer);}
this.getTabById(newTabId).afterSetCurrent();}}else{this.getTabById(newTabId).setCurrent(loadKidgets,onlyJS);$('tabNotifiche').hide();this.tabNotifyShown=false;this.checkPageBottom(true);}},getLastTabId:function(){return this.tabs.last().id;},getNumberOfTabs:function(){return this.tabs.size();},addTabFlapDroppables:function(){tabFlapsLis=$("tabFlapsUl").childElements();for(i=0;i<tabFlapsLis.length;i++){li=tabFlapsLis[i];if((!li.hasClassName("notifica"))&&(!li.hasClassName("addTab"))){Droppables.add(li.id,{accept:'kidget',onHover:function(element,droppableElement){pageTabs.onTabFlapHover(element,droppableElement)},onDrop:function(element,droppableElement){pageTabs.onTabFlapDrop(element,droppableElement)}})}}},onTabFlapHover:function(element,droppableElement){pageTabs.evaluateKidgetOnTabFlap(element,droppableElement)},evaluateKidgetOnTabFlap:function(element,droppableElement){if(!pageTabs.isDroppingKidget()){if(element.descendantOf("tab"+pageTabs.getCurrentTab().id)){pageTabs.grabKidgetOutOfTab(element);}
pageTabs.changeTab(droppableElement.id.gsub('tabFlap',''),false,true,false);}},grabKidgetOutOfTab:function(kidget){kidgetObj=pageTabs.getCurrentTab().extractKidget(kidget);pageTabs.setMovingKidget(kidgetObj);kidHTML=kidget.remove();Element.insert($('mypage'),{top:kidHTML});},onTabFlapDrop:function(element,droppableElement){tabXY=pageTabs.getCurrentTab().getXY();bottom=pageTabs.getCurrentTab().getBottomOfYourKidgetsNotNull();newX=(tabXY.x*1)+20;newY=(tabXY.y*1)+bottom+50;pageTabs.setDroppingKidget(true);pageTabs.dropKidgetOnCurrentTab(element);new Effect.Move(kidHTML,{x:newX,y:newY,mode:'absolute',duration:1.5,afterFinish:function(){pageTabs.setMovingKidget(null);pageTabs.setDroppingKidget(false);pageTabs.refreshKidgetsPosition();pageTabs.checkPageBottom();}});},dropKidgetOnCurrentTab:function(kidget){kidHTML=kidget.remove();Element.insert($('tab'+pageTabs.getCurrentTabId()),{bottom:kidHTML});kidgetMoved=pageTabs.getMovingKidget();pageTabs.addDraggableByKidgetObjOnTabId(kidgetMoved,pageTabs.getCurrentTabId());params='tab_item_id='+kidgetMoved.id.gsub('kd_','')+'&tab_id='+pageTabs.getCurrentTabId();new Ajax.Request('/page/change_tab_of_kidget/',{asynchronous:true,evalScripts:true,method:'post',parameters:params,requestHeaders:{Accept:'text/x-json'},onComplete:function(t){pageTabs.getCurrentTab().setKidgetsPosition();}});},refreshKidgetsPosition:function(){for(i=0;i<this.tabs.length;i++){this.tabs[i].refreshKidgetsPosition();}},addTab:function(){if(this.tabNotifyShown==false){new Ajax.Request('/page/add_tab/'+pageTabs.getCurrentTabId(),{asynchronous:false,evalScripts:true,requestHeaders:{Accept:'text/x-json'},onComplete:function(request){pageTabs.checkAddTabResponse(request);}});}},checkAddTabResponse:function(request){if(pageTabs.checkResponseFromServer(request,true)){this.tabHasBeenAdded(request.responseJSON.content);}},tabHasBeenAdded:function(tabInfo){altTab="no info";lastTabId=this.getLastTabId();background_url_complete=((tabInfo.background_url!=null)&&(tabInfo.background_url!=' '))?TabPropsPage.backgroundsPath+tabInfo.background_url:'';$('tab'+lastTabId).insert({after:'<div id=tab'+tabInfo.id+' style=\"height:'+this.newBottom+'px;position:relative;background-image:url('+background_url_complete+'); display:none \"> </div>'});tabNo=this.getNumberOfTabs()+1;flap_url_complete=((tabInfo.flap_url!=null)&&(tabInfo.flap_url!=' '))?TabPropsPage.iconsPath+tabInfo.flap_url:'';$('tabFlap'+lastTabId).insert({after:"<li id=tabFlap"+tabInfo.id+" class=\"TabFlap"+tabNo+"\"><span><a href=\"#\" onclick=\"pageTabs.changeTab("+tabInfo.id+",true,true,false); return false;\"><img src=\""+flap_url_complete+"\"/></a></span><span class=\"tabFlapRotella\" style=\"display:none\"><img src=\"/images/mypage/tabFlapCheck.png\" /></span></li>"});$('propTabLink').style.display='block';Droppables.add('tabFlap'+tabInfo.id,{accept:'kidget',onHover:function(element,droppableElement){pageTabs.onTabFlapHover(element,droppableElement)},onDrop:function(element,droppableElement){pageTabs.onTabFlapDrop(element,droppableElement)}})
this.addTabById(tabInfo.id);this.getTabById(tabInfo.id).setTabPropsOnCreate(tabInfo);this.getTabById(tabInfo.id).changeBackground(tabInfo.background_url,false)
this.getTabById(tabInfo.id).setFlapColor();this.tabPropsPage.setAddingTab();this.setLoaded(tabInfo.id);this.changeTab(tabInfo.id,true,false,false);this.managePageFlapsAndButtons();this.showTabProperties(tabInfo.id);},showTabProperties:function(options){if(pageTabs.userCanModifyPage()){this.tabPropsPage.isShown=true;this.tabPropsPage.startPage({openBackgroundsMenu:(options!=null&&options.openBackgroundsMenu==true?true:false)});heightPropsMax=1980;var tabPropsMaskHeight=55+heightPropsMax+30;var scale=((heightPropsMax+20)>(parseInt(Element.getStyle(this.tabsContainer,'height'))))||Element.getStyle(this.tabsContainer,'height')==null
if(scale){try{this.scaleToHeight(heightPropsMax+30,2,false);}catch(e){alert("1. An exception occurred in the script. Error name: "+e.name
+". Error message: "+e.message+". Line number. "+e.lineNumber);}}else{try{tabPropsMaskHeight=parseInt(Element.getStyle(this.tabsContainer,'height'))+55;}catch(e){alert("2. An exception occurred in the script. Error name: "+e.name
+". Error message: "+e.message+". Line number. "+e.lineNumber);}}
try{this.tabPropsPage.displayCurrentPrefs();$('tabPropsMask').setStyle({height:(tabPropsMaskHeight)+'px'})}catch(e){alert("3. An exception occurred in the script. Error name: "+e.name
+". Error message: "+e.message+". Line number. "+e.lineNumber);}
try{$('tabPropsMask').show();$('tabPropsMask').setStyle({zIndex:this.currentZIndex});$('tabPropsMaskHeader').show();$('tabPropsMaskUpperHeader').show();this.currentZIndex+=1;$('tabProps').setStyle({zIndex:this.currentZIndex});this.currentZIndex+=1;$('tabProps').setOpacity(0);$('tabProps').show();if(BrowserDetect.browser=='Explorer'&&BrowserDetect.version<8){$('logo').setStyle('z-index:1');}else{$('logo').setStyle('z-index:auto');}
new Effect.Opacity('tabProps',{duration:0.5,from:0,to:1});new Effect.Opacity('addKidgetLink',{duration:0.5,from:1,to:0,afterFinish:function(effect){$('addKidgetLink').hide()
$('propTabLink').hide();}})}catch(e){alert("0. An exception occurred in the script. Error name: "+e.name
+". Error message: "+e.message+". Line number. "+e.lineNumber);}}},hideTabProperties:function(delete_tab){if(this.tabPropsPage.isShown){$('addKidgetLink').show();$('propTabLink').show();$('tabPropsMaskHeader').hide();$('tabPropsMaskUpperHeader').hide();$('logo').setStyle('z-index:1001');new Effect.Opacity('addKidgetLink',{duration:0.5,from:0,to:1})
new Effect.Opacity('tabProps',{duration:0.5,from:1,to:0,afterFinish:function(effect){pageTabs.closeTabProperties(delete_tab);}});}},closeTabProperties:function(delete_tab){$('tabProps').hide();this.tabPropsPage.isShown=false;this.isIE7?$('tabProps').setStyle('zIndex','auto'):$('tabProps').setStyle({zIndex:'auto'});$('tabPropsMask').hide();this.isIE7?$('tabPropsMask').setStyle('zIndex','auto'):$('tabPropsMask').setStyle({zIndex:'auto'});if(delete_tab){pageTabs.deleteCurrentTab();}else{this.checkPageBottom({skipSendToServer:true})}},sendTimeZoneOffset:function(){var tmp=new Date();var tzo=getTimeZone();new Ajax.Request('/user/set_time_zone_offset/'+tzo,{asynchronous:true,evalScripts:false,onComplete:function(request){pageTabs.checkSendTimeZoneOffsetResponse(request);}});},checkSendTimeZoneOffsetResponse:function(request){if(pageTabs.checkResponseFromServer(request,false)){}},deleteCurrentTab:function(){if(pageTabs.getNumberOfTabs()>1){if(this.userCanModifyPage()){currentTabId=this.getCurrentTabId();new Ajax.Request('/page/delete_tab/'+currentTabId,{asynchronous:false,evalScripts:false,onComplete:function(request){pageTabs.checkDeleteCurrentTabResponse(request,currentTabId);}});}else{alert("ERRORE in deleteCurrentTab");}}},checkDeleteCurrentTabResponse:function(request,currentTabId){if(pageTabs.checkResponseFromServer(request,false)){pageTabs.deleteTab(currentTabId);}},checkDeleteKidgetResponse:function(request,kidId){if(pageTabs.checkResponseFromServer(request,true)){pageTabs.deleteKidgetById(kidId);}},checkResponseFromServer:function(request,refresh_on_logout){var error=false
var title=null;var actions=null;var description=null;var actionOK=null;var size='big';if(request.status!='0'){if(request.status=='200'){response=request.responseJSON;if(response.status.action_result=='OK'){error=false;}else{error=true;title='halt';size='small';description=response.status.message;switch(response.status.action_to_perform){case'logout!':if(refresh_on_logout){actionOK=this.forceRefresh.bindAsEventListener(this);}else{actionOK=this.forceLogout.bindAsEventListener(this);}
break;case'login!':actionOK=this.userManager.startLogin.bindAsEventListener(this.userManager);break;default:actionOK=this.hideTabDialog.bindAsEventListener(this);}}}else{error=true;title='halt';description=i18n.stringLocale('problema_server_prova_1_minuto');actionOK=this.afterInternalError.bindAsEventListener(this);size='small';}
if(!error){return true;}else{this.tabDialog.displayMessage({title:title,description:description,actions:actions,actionOK:actionOK,size:size})
this.tabDialog.showDialog({zIndex:this.currentZIndex,dialogMaskHeight:this.newBottom});this.currentZIndex+=1;return false;}}else{return true}},hideTabDialog:function(){this.tabDialog.hideDialog();},setTabFlapsColor:function(){for(i=0;i<this.tabs.length;i++){sponsored=(this.tabs[i].tabProps.sponsored_tab!=null)&&(this.tabs[i].tabProps.sponsored_tab.add_path!=null)
this.tabs[i].setFlapColor(sponsored);}},setFlapsOverSound:function(){for(i=0;i<this.tabs.length;i++){this.tabs[i].setFlapOverSound();}},afterInternalError:function(){this.tabDialog.hideDialog();if(this.user.getLang()!=this.currentUserLang){this.forceRefresh();}},setTabMediaPaths:function(logoP,bgP,icoP,soundP,sponsoredP){TabPropsPage.logoPath=logoP;TabPropsPage.backgroundsPath=bgP;TabPropsPage.iconsPath=icoP;TabPropsPage.soundsPath=soundP;TabPropsPage.sponsoredMediaPath=sponsoredP;},kidgetSponsorLogoClicked:function(kidId,sponsorId,valid_url){if((sponsorId!='null')&&(valid_url)){window.open('/sponsor/leave_to/'+sponsorId);}},timeoutAtStarUpExpires:function(){this.timeoutAtStartUpExpired=true;if((this.userIsRegistered())&&(this.userCanModifyPage())){this.newNotificationsTimeoutHandler=setTimeout(this.periodicalNewNotificationsCheck.bindAsEventListener(this),this.newNotificationsTimeout);}
this.hideSplash();},windowLoadedAtStartUp:function(){this.windowLoaded=true;this.hideSplash();this.tabDialog.loaded(true);if(!$('splashScreen').visible()){setTimeout(this.checkPageBottomAtStartUp.bindAsEventListener(this),500);}
if(this.showContentProtectionAlertAtStartup){this.userManager.checkAlertForUser();}
if(this.showTabPropsAtStartup){this.showTabProperties({openBackgroundsMenu:true});}},hideSplash:function(){if(this.windowLoaded&&this.timeoutAtStartUpExpired&&$('splashScreen').visible()){$('splashScreen').hide();$('whole_page').show();$('upper_header').show();this.newBottom=parseInt(Element.getStyle(this.container,'height'));this.oldBottom=this.newBottom;setTimeout(this.checkPageBottomAtStartUp.bindAsEventListener(this),500);this.getCurrentTab().recallKidgetsPosition();this.checkPageBottomAtStartUp();}},startOverlayer:function(){var cook=MPCookies.read('overlayer_lista_amici_shown');if(cook!='true'){if(this.user.isRegistered()){if(!this.overlayerShown){MPCookies.create('overlayer_lista_amici_shown','true',1);this.overlayerShown=true;this.displayOverlayer({flashBanner:false});MPSound.play("/sounds/mypage/wordofmouth.wav");}}else{MPCookies.create('overlayer_lista_amici_shown','true',1);this.overlayerShown=true;this.displayOverlayer({flashBanner:true});}}},displayOverlayer:function(options){this.overlayer.show();this.overlayer.startBanner(options);},closeOverlayer:function(){this.overlayer.hide({stop:true});},overlayerGoBtnClicked:function(){this.overlayer.goBtnClicked();},overLayerBackBtnClicked:function(){this.overlayer.skipPrevBtnClicked();},overLayerForwardBtntnClicked:function(){this.overlayer.skipNextBtnClicked();},overlayerCloseBtnClicked:function(){this.closeOverlayer();},pasteKidget:function(kidgetConfiguration){this.startPasteKidget(kidgetConfiguration);},startPasteKidget:function(kidgetConfiguration){if(this.user.isRegistered()){if(this.user.isLoggedIn()){this.completePasteKidget({parameters:kidgetConfiguration})}else{this.userManager.subscribeAction({event:'login',when:'after',placeFirst:true,callback:new EventCallback({callback:this.completePasteKidget.bind(this),callbackParams:kidgetConfiguration,executeOnce:true,asynchronous:false,blocksQueue:true})})
this.justLoggedUser=true;this.userManager.startLogin();}}else{this.completePasteKidget({parameters:kidgetConfiguration});}},completePasteKidget:function(){var kidgetConfiguration=arguments[0].parameters;options={JSON:true,evalJS:true,onComplete:this.checkPasteKidgetResponse.bindAsEventListener(this)};this.communicator.sendRequest('/kidget/paste_kidget/',kidgetConfiguration,options);},checkPasteKidgetResponse:function(request){var error=false
var title=null;var actions=null;var description=null;var actionOK=null;var actionCancel=null;var size='big';if(request.status=='200'){var response=request.responseJSON;if(response.status.action_result=='OK'){error=false;}else{error=true;title='halt';switch(response.status.action_to_perform){case'register_first':description=response.status.message;actions='1button';actionOK=this.redirectToRegister.bindAsEventListener(this);break;case'already_pasted':description=response.status.message;actions='2buttons';actionOK=this.redirectToTab.bindAsEventListener(this,response.content);actionCancel=null;break;default:description=i18n.stringLocale('problema_server_prova_1_minuto');actionOK=this.afterInternalError.bindAsEventListener(this);size='small';}}}else{error=true;title='halt';description=i18n.stringLocale('problema_server_prova_1_minuto');actions='1button';actionOK=this.afterInternalError.bindAsEventListener(this);}
if(!error){if(this.justLoggedUser){this.justLoggedUser=false;location.href="/page/back_to_homepage?after=add_kidget&show_dialog_avvisi=true";}else{location.href="/page/back_to_homepage?after=add_kidget";}}else{this.tabDialog.displayMessage({title:title,description:description,actions:actions,actionOK:actionOK,actionCancel:actionCancel,size:size})
this.tabDialog.showDialog({zIndex:this.currentZIndex,dialogMaskHeight:this.newBottom});this.currentZIndex+=1;return false;}},redirectToTab:function(){var tab=arguments[1];location.href="/tab/show/?tab="+tab+"&user="+this.user.nickname;},redirectToRegister:function(){location.href="/user/register";},sendKidget:function(email,nickname,comment,kidgetConfiguration){this.startSendKidget(email,nickname,comment,kidgetConfiguration);},startSendKidget:function(email,nickname,comment,kidgetConfiguration){if((email.length>0)||(nickname.length>0)){var notificationData={'email':email,'nickname':nickname,'comment':comment,'kidget_data':kidgetConfiguration};if(this.user.isRegistered()){if(this.user.isLoggedIn()){this.completeSendKidget({parameters:notificationData});}else{this.userManager.subscribeAction({event:'login',when:'after',callback:new EventCallback({callback:this.completeSendKidget.bind(this),callbackParams:notificationData,executeOnce:true,asynchronous:false,blocksQueue:true})})
this.justLoggedUser=true;this.userManager.startLogin({redirectToHomepage:false});}}else{this.completeSendKidget({parameters:notificationData})}
return true;}else{return false;}},completeSendKidget:function(){var notificationData=arguments[0].parameters;var callbackToContinueLogin=arguments[0].callbackToContinue;options={JSON:true,evalJS:true,onComplete:this.checkNotifyKidgetResponse.bindAsEventListener(this,callbackToContinueLogin)};this.communicator.sendRequest('/kidget/notify_kidget/',notificationData,options);},checkNotifyKidgetResponse:function(){var request=arguments[0];var callbackToContinueLogin=arguments[1];var error=false
if(request.status=='200'){response=request.responseJSON;if(response.status.action_result=='OK'){error=false;}else{error=true;}}else{error=true;}
if(error&&(request.status!='200')){this.tabDialog.displayMessage({title:'hatlt',description:i18n.stringLocale('problema_server_prova_1_minuto'),actionOK:this.afterInternalError.bindAsEventListener(this),size:'small'})
this.tabDialog.showDialog({zIndex:this.currentZIndex,dialogMaskHeight:this.newBottom});this.currentZIndex+=1;return false;}else{if(callbackToContinueLogin!=null){callbackToContinueLogin();}}},performAction:function(){switch(this.actionToPerform.action){case'paste_kidget':this.completePasteKidget(this.actionToPerform.parameters[0])
break;case'notify_kidget':this.tabDialog.isVisible()?this.applyLoginToPage():null;this.sendKidget(this.actionToPerform.parameters[0],this.actionToPerform.parameters[1],this.actionToPerform.parameters[2],this.actionToPerform.parameters[3])
break;case'start_add_friend':this.actionToPerform=null;if(this.tabDialog.isVisible()){this.applyLoginToPage({hideDialog:false});}
this.becomeFriendLinkClicked();break;}
this.actionToPerform=null;},getKidgetByTabItemId:function(tabItemId){for(t=0;t<this.tabs.length;t++){kidget=this.tabs[t].getKidgetByTabItemId(tabItemId);if(kidget){return kidget;}}
return null;},sendKidgetRequest:function(kidSenderId,url,requestObj,options){this.communicator.sendRequest(url,requestObj,options);},cancelAddFriendDialog:function(){this.tabDialog.hideDialog();},getUserLang:function(){return this.user.lang!=null?this.user.lang:'it';},showFlapAmiciCloud:function(){if(!$('flapAmiciCloud').visible()){$('flapAmiciCloud').show();new PeriodicalExecuter(function(pe){$('flapAmiciCloud').hide();pe.stop();}.bind(this),2);}},scrollAfterLoaded:function(){this.scroll=true;},userIsPageOwner:function(){return this.userManager.user.id==this.userManager.pageOwner.id},pageOwnerIsFriendWithUser:function(){return this.userManager.pageOwnerIsFriendWithUser();},userIsFriendWithOtherById:function(otherId){return this.userManager.userIsFriendWithOtherById(otherId);},getPageOwnerNickname:function(){return this.userManager.pageOwner.nickname;},pageOwnerIsFamous:function(){return this.userManager.pageOwner.isFamousFriend();},subscribeAction:function(options){this.userManager.subscribeAction(options)},showDialog:function(options){this.tabDialog.showDialog(options);},hideDialog:function(options){this.tabDialog.hideDialog(options);},displayDialogMessage:function(options){this.tabDialog.displayMessage(options)}});