var ZLei_Museum={widgetEventPrefix:"museum",options:{settingsUrl:"settings.json"},_backgroundMusic:null,_create:function(){this._on(this._elementEvents);this._on(this.window,this._windowEvents);this._backgroundMusic=$('
');$(this.document[0].body).append(this._backgroundMusic)},_init:function(){var a=this.likeScreen(window.screen.width,window.screen.height,this.options.screens);this.options=this.walkReplaceString(this.options,"{screen}",a.screenId);this.options=this.walkAddScreenScale(this.options,a.screenWidth,a.screenHeight);this.options=this.walkResetCoords(this.options,a.screenWidth,a.screenHeight);this.element.Museum_Rooms(this.options);this._backgroundMusic.attr("src",this.options.backgroundMusicUrl);$(this._backgroundMusic).jPlayer({ready:function(b){$(this).jPlayer("setMedia",{mp3:$(this).attr("src")}).jPlayer("play")},play:function(b){$(this).attr("paused",0)},pause:function(b){$(this).attr("paused",1)},wmode:"window",loop:true,volume:0.1,smoothPlayBar:false,keyEnabled:false})},_elementEvents:{museumroomenter:function(c,b,a){var d=$('');this.element.after(d);d.Museum_Items(a)}},_windowEvents:{museumbackgroundmusicchange:function(b){var a=$(this).attr("paused");if(a=="1"){$(this._backgroundMusic).jPlayer("play");$(this).attr("paused","0")}else{$(this._backgroundMusic).jPlayer("pause");$(this).attr("paused","1")}}},likeScreen:function(d,g,a){var f=Math.sqrt(Math.pow(d,2)+Math.pow(g,2));var e=d/g;var b=null;f=Math.round(f*10000)/10000;e=Math.round(e*10000)/10000;for(var c in a){if(b==null){b=a[c]}if(Math.abs(a[c].screenAspectRatio-e)>0.2){continue}if(a[c].screenDiagonalLength>f){continue}b=a[c]}return b},walkReplaceString:function(a,c,d){switch(typeof(a)){case"string":a=a.replace(c,d);break;case"object":case"array":for(var b in a){a[b]=this.walkReplaceString(a[b],c,d)}break}return a},walkAddScreenScale:function(g,b,k){for(var f in g.rooms){for(var i in g.rooms[f].roomItems){var h=g.rooms[f].roomItems[i].itemDisplayConfig.itemWidth;var e=g.rooms[f].roomItems[i].itemDisplayConfig.itemHeight;var a=g.rooms[f].roomItems[i].itemDisplayConfig.itemThumbnailRemoveX;var l=g.rooms[f].roomItems[i].itemDisplayConfig.itemThumbnailRemoveY;var d=(b-a)/h;var c=(k-l)/e;var j=Math.round(Math.min(d,c)*10000)/10000;g.rooms[f].roomItems[i].itemDisplayConfig.itemThumbnailScale=j}}return g},walkResetCoords:function(e,a,j){var c=(a-e.coverRemoveX)/e.coverWidth;var b=(j-e.coverRemoveY)/e.coverHeight;var h=Math.round(Math.min(c,b)*10000)/10000;for(var d in e.rooms){var g=e.rooms[d].roomShapeCoords.split(",");for(var f in g){g[f]=Math.round(parseInt(g[f])*h)}e.rooms[d].roomShapeCoords=g.join(",")}return e}};$.widget("ZLei.Museum",ZLei_Museum);