var Global;$("document").ready(function(){Global=new GlobalHandler()});$.ajaxSetup({cache:true});var g_isLoading=false;$(document).ajaxStart(function(){$("body").addClass("loading");g_isLoading=true;showLoading()});$(document).ajaxStop(function(){$("body").removeClass("loading");g_isLoading=false;hideLoading()});var GLOBALS={ArchiveId:null,ArchiveType:"",Columns:4,Rows:1,ThumbnailSize:170,Sorting:"ModifiedTimeAsc",Search:"",Preview:false,PreviewAccess:false,PostBackUrl:"",KeywordMetaFieldId:0};var CONFIG={SelectionSyncDelay:1250,HoverPreviewSize:450};function showLoading(){$(".loadingIndicator .background").css("opacity",0.2);$(".loadingIndicator").fadeIn(300)}function hideLoading(){window.setTimeout(function(){if(g_isLoading){return}$(".loadingIndicator").fadeOut(300)},500)}function GlobalHandler(){var f={show:150,hide:150};var D={show:300,hide:300};var L={show:300,hide:300};var y={show:100,hide:100};var a=10;var q=5;var u=TRANSLATIONS.Search;var A=false;var p;var c=false;var g=false;var B=170;var e=0;var H=CONFIG.HoverPreviewSize;function o(){if($("body.page-default").length){return}console.log("using unminified version of global.js");j();E();t();J();NavigationPaneControl.call($("#NavigationPaneControl")[0]);h();w();d();x();G();z()}function j(){GLOBALS.ArchiveId=parseInt(GLOBALS.ArchiveId);GLOBALS.Rows=parseInt(GLOBALS.Rows);GLOBALS.Columns=parseInt(GLOBALS.Columns);GLOBALS.ImagesPerPage=GLOBALS.Rows*GLOBALS.Columns;GLOBALS.PreviewAccess=parseInt(GLOBALS.PreviewAccess)}function E(){if(!$(".SelectableImage").length){return}$(".SelectableImage").each(function(){Thumbnail.call(this)})}function K(M){var O=4;var N=M/O;var P=window.location.toString();if(window.location.search.length){P=P.replace(/#/,"");if(P.match(/columns=/)){P=P.replace(/columns=\d*/,"columns="+O+"")}else{P=P+"&columns="+O+""}if(P.match(/rows=/)){P=P.replace(/rows=\d*/,"rows="+N)}else{P=P+"&rows="+N}}else{P=P+"?columns="+O+"&rows="+N}window.location=P}function k(M){var N=window.location.toString();if(window.location.search.length){N=N.replace(/#/,"");if(N.match(/sorting=/)){N=N.replace(/sorting=\w*/,"sorting="+M)}else{N=N+"&sorting="+M}}else{N=N+"?sorting="+M}window.location=N}function m(){if($.cookie("directPreview")==1){$("#directPreview").attr("checked","checked")}else{if($.cookie("directPreview")==0){$("#directPreview").removeAttr("checked")}else{$("#directPreview").attr("checked","checked")}}if($.cookie("extendedInfo")==1){$("#extendedInfo").attr("checked","checked")}else{$("#extendedInfo").removeAttr("checked")}if($.cookie("showRating")==1){$("#showRating").attr("checked","checked")}else{$("#showRating").removeAttr("checked")}$("#ImagesPerPage option").each(function(){if($(this).val()==GLOBALS.ImagesPerPage){$(this).attr("selected","selected")}});$("#ImageQuickSorter option").each(function(){if($(this).val()==GLOBALS.Sorting){$(this).attr("selected","selected")}})}function C(N){if($("#directPreview").attr("checked")){$.cookie("directPreview",1,{expires:30});$(".SelectableImage .Thumb img").tooltip({delay:200,track:true,showURL:false,bodyHandler:function(){var O=this.src.replace(/sz=\d*/,"sz="+H);return $("<img/>").attr("src",O)}})}else{$.cookie("directPreview",0,{expires:30});$(".SelectableImage img").unbind("mouseover").unbind("mouseout")}if($("#showRating").attr("checked")){$.cookie("showRating",1,{expires:30});if(N){$(".ThumbContainer .Rating").fadeIn(L.show)}else{$(".ThumbContainer .Rating").show()}}else{$.cookie("showRating",0,{expires:30});if(N){$(".ThumbContainer .Rating").fadeOut(L.hide)}else{$(".ThumbContainer .Rating").hide()}}var M=false;if($("#extendedInfo").attr("checked")){$.cookie("extendedInfo",1,{expires:30});M=true}else{$.cookie("extendedInfo",0,{expires:30});M=false}if(M&&e>100){if(N){$(".ThumbContainer .Info").fadeIn(D.show)}else{$(".ThumbContainer .Info").show()}}else{if(N){$(".ThumbContainer .Info").fadeOut(D.hide)}else{$(".ThumbContainer .Info").hide()}}if(c){K($("#ImagesPerPage").val())}if(g){k($("#ImageQuickSorter").val())}}function G(){if(!$("#LayoutSwitch").length){return}m();C(false);$("#LayoutSwitch").click(function(){if($(this).hasClass("Active")){n("revert")}else{b()}});$("#LayoutSwitch").add("#LayoutDropdown").click(function(M){M.stopPropagation()});$("#btnLayoutSave").click(function(){C(true);n()});$("#btnLayoutCancel").click(function(){n("revert")});$("#ImagesPerPage").change(function(){if($(this).val()!=GLOBALS.ImagesPerPage){c=true}else{c=false}});$("#ImageQuickSorter").change(function(){if($(this).val()!=GLOBALS.Sorting){g=true}else{g=false}});$("html").click(function(){n("revert")})}function b(){$("#LayoutSwitch").addClass("Active");$("#LayoutDropdown").slideDown(f.hide)}function n(M){$("#LayoutDropdown").slideUp(f.show,function(){$("#LayoutSwitch").removeClass("Active");if(M=="revert"){m()}})}function t(){console.log("PreviewAccess "+GLOBALS.PreviewAccess);if(!GLOBALS.PreviewAccess){I();return}e=$.cookie("ImageScale")?$.cookie("ImageScale"):B;i(e);$("#ImageScaleSlider").slider({value:e,min:100,max:450,step:70,stop:function(M,N){e=N.value;i(N.value);C(true)}})}function i(M){console.log("rezising pics to",M);$(".SelectableImage").each(function(){this.resize(M)});$.cookie("ImageScale",M,{expires:30})}function I(){$(".SelectableImage").each(function(){var N=$(this).find("img")[0];var O=$(this).attr("id").replace(/\D/g,"");var M=this;e=GLOBALS.ThumbnailSize;N.onload=function(){$(this).fadeIn(300)};$(M).find(".ThumbContainer").width(e+"px");$(M).find(".Thumb").width(e+"px");$(M).find(".Thumb").height(e+"px");var P=$(N).attr("src");P="/fotoweb/cmdrequest/rest/preview.fwx?f="+GLOBALS.ImageInfos[O].thumbnailId;$(N).attr("src",P)})}function J(){$(".Panel").each(function(M){Panel.call(this,"Panel_"+M)})}function h(){if(!$("#ArchiveMenu").length){return}$.get("/fotoweb/cmdrequest/rest/ArchiveList.fwx",{rd:+new Date},function(M){var N=s(M);$(N).attr("id","ArchiveList");$("#ArchiveMenu").append(N);$("#ArchiveMenu").parent().addClass("multilvl-menu horizontal scrollable");MultiLvlMenu.call($("#ArchiveMenu").parent()[0]);$("#ArchiveMenu").find(".scroller").append('<div class="bottom"></div>');F()},"xml")}function s(O){var U=$(O).find("Archive");var Q=document.createElement("ul");var V=new Array();var N;var T;var R;var S;for(N=0;N<U.length;N++){R=$(U[N]).attr("Id");T=document.createElement("li");$(T).attr("id","Archive_"+R);S=document.createElement("a");$(S).attr("href","/fotoweb/Grid.fwx?archiveId="+R+"&position=1&search=");$(S).text($(U[N]).attr("Name"));try{if(GLOBALS.ArchiveId==R){$(S).addClass("isCurrent");GLOBALS.KeywordMetaFieldId=$(U[N]).attr("KeywordCloudField")}}catch(P){}$(T).append(S);$(Q).append(T);V.push(T)}var M;for(N=0;N<V.length;N++){M=$(U[N]).attr("ParentId");if(M==0){continue}ParentNode=$(Q).find("#Archive_"+M);CurrentNode=V[N];$(ParentNode).append(CurrentNode)}$(Q).find("li:has(li)").each(function(){$(this).children("li").wrapAll("<ul/>")});$(Q).find("a").wrap("<span/>");return Q}function w(){if(!$("#TopMenuToolsList").length){return}$.get("/fotoweb/cmdrequest/rest/ToolsMenu.fwx",{rd:+new Date},function(M){$("#TopMenuToolsList").empty();$(M).find("ToolsMenu > MenuItem > MenuItem").each(function(){var N=$(this).attr("JavaScript")?$(this).attr("JavaScript"):$(this).attr("Url");$("#TopMenuToolsList").append("<li><span><a href='"+N+"'>"+$(this).attr("DisplayName")+"</a></span></li>")})},"xml")}function x(){if(!$("#TopMenuAdministrationList").length){return}$("#TopMenuAdministration").hide();$.get("/fotoweb/cmdrequest/rest/AdministrationMenu.fwx",{rd:+new Date},function(M){$("#TopMenuAdministrationList").empty();$(M).find("AdministrationMenu > MenuItem > MenuItem").each(function(){var N=$(this).attr("JavaScript")?$(this).attr("JavaScript"):$(this).attr("Url");$("#TopMenuAdministrationList").append("<li><span><a href='"+N+"'>"+$(this).attr("DisplayName")+"</a></span></li>")});if($("#TopMenuAdministrationList li").length){$("#TopMenuAdministration").show()}},"xml")}function d(){if(!$("#TopMenuViewList").length){return}var M=new Object();M.ts=+new Date;if(typeof GLOBALS!="undefined"){if(typeof GLOBALS.Preview!="undefined"&&GLOBALS.Preview){M.pm=1}if(typeof GLOBALS.ArchiveType!="undefined"&&GLOBALS.ArchiveType!=""){M.at=GLOBALS.ArchiveType}}$("#TopMenuViewList").empty();$.get("/fotoweb/cmdrequest/rest/ViewMenu.fwx",M,function(N){$(N).find("ViewMenu > MenuItem > MenuItem").each(function(){var O=$(this).attr("JavaScript")?$(this).attr("JavaScript"):$(this).attr("Url");$("#TopMenuViewList").append("<li><span><a href='"+O+"'>"+$(this).attr("DisplayName")+"</a></span></li>")})},"xml")}function r(){var M=$("#searchInputField").val();if(M==u||M==""){$("#ClearSearchButton").css("display","none")}else{$("#ClearSearchButton").css("display","inline")}}function z(){if(!$("#searchInputField").length){return}$("#searchInputField").addClass("searchInputField_Inactive");if(GLOBALS.Search==""){$("#searchInputField").val(u)}else{$("#searchInputField").val(GLOBALS.Search)}r();$("#searchInputField").keyup(function(){r()});$("#MainFrameOpacityLayer").css("opacity",0);$("#searchInputField").focus(function(){$("#SearchPopUp").slideDown(y.show);if($(this).val()==u){$("#searchInputField").val("")}$("#searchInputField").addClass("searchInputField_Active");$("#searchInputField").removeClass("searchInputField_Inactive")});$("#SearchPopUp,#searchInputField,#SearchSubmit").click(function(){A=true});$("html").click(function(){if(A){A=false;return}if($("#searchInputField").val()==""){$("#searchInputField").val(u)}$("#searchInputField").addClass("searchInputField_Inactive");$("#searchInputField").removeClass("searchInputField_Active");$("#SearchPopUp").slideUp(y.hide)})}function F(){if(!$("#KeywordsPopUpTrigger")[0]){return}$("#KeywordsPopUpTrigger").hide();var M={ar:GLOBALS.ArchiveId,md:GLOBALS.KeywordMetaFieldId,cc:a,ic:q};$.get("/fotoweb/cmdrequest/rest/KeywordCloud.fwx",M,function(N){if($(N).find("KeywordCloud")){var O=v(N);l(O);$("#KeywordsPopUpTrigger").show()}},"xml");$("#KeywordsPopUpTrigger").click(function(){if(p){p.show()}return false})}function v(V){var Q=$(V).find("Category");var U;var R;var P;var M;var N="";var Y=new Array();var T=null;console.log(Q);for(U=0;U<a;U++){if(!Q[U]){continue}T=$(Q[U]).find("Value");for(R=0;R<q;R++){if(!T[R]){continue}M=T[R];P=(a-U);N="/fotoweb/Grid.fwx?archiveId="+GLOBALS.ArchiveId+"&position=1&search="+$(M).attr("Value");Y.push($('<a rel="'+P+'" href="'+N+'">'+$(M).attr("Value")+"</a>"))}}console.log("KeywordCloud TagNodes",Y);var S=Y.length;var X;var W;for(U=0;U<S;U++){X=Math.floor(Math.random()*Y.length)+1;W=Y[X];Y[X]=Y[U];Y[U]=W}var O=$("<div/>");$(Y).each(function(){O.append(this).append("\n")});$(O).find("a").tagcloud({size:{start:1,end:2,unit:"em"},color:{start:"#999",end:"#333"}});return O}function l(M){p=new PopDiv("KeywordCloudPopUp");p.setCaption($("#KeywordsPopUpTrigger").text());p.setContent(M);p.setOverlaySpeed(200,200);p.setPopDivSpeed(200,200)}o()}function DownloadPopup(){var a;this.show=function(k,h,g){if(!a){this.create()}var d;var c=document.createElement("div");var l=document.createElement("div");$(l).addClass("downloadpopup-images");if(k.length==1){$(l).addClass("single")}for(d=0;d<k.length;d++){l.appendChild(k[d])}$(l).find("img").wrap('<div class="downloadpopup-image-container"><div><div></div></div></div>').addClass("downloadpopup-image");var j=document.createElement("div");$(j).addClass("downloadpopup-profile-container");var e=$(h).find("DirectDownloads ProcessingProfile");for(d=0;d<e.length;d++){var f=document.createElement("a");$(f).attr("href",g+"&pp="+encodeURIComponent($(e[d]).attr("Name")));$(f).attr("title",$(e[d]).attr("Description"));var b=$(e[d]).attr("DisplayName");$(f).text(b);$(f).addClass("downloadpopup-profile");j.appendChild(f)}c.appendChild(l);c.appendChild(j);a.setContent(c);a.show()};this.create=function(){a=new PopDiv("DownloadPopUp");a.setCaption(TRANSLATIONS.Download);a.setOverlaySpeed(200,200);a.setPopDivSpeed(200,200)}}function TopRowDropDown(b){var d=b;var a;var h;var g={up:150,down:150};function i(){$(d).find(".TopRowDropDownSwitch").click(function(){if($(this).hasClass("Active")){c()}else{f()}});$(d).find(".TopRowDropDownSwitch, .TopRowDropDown").click(function(){a=true});$("html").click(function(){if(a){a=false;return}c()})}function f(){$(d).find(".TopRowDropDownSwitch").addClass("Active").next(".TopRowDropDown").slideDown(g.down)}function c(){$(d).find(".TopRowDropDown").slideUp(g.up,function(){$(d).find(".TopRowDropDownSwitch").removeClass("Active")});if(h){h()}}function e(j){h=j}this.hide=c;this.setHideEvent=e;i()}function Panel(d){var i={show:200,hide:200};var p=false;var l=true;var f=false;var j=false;var m=false;var c=false;var o=false;var h=false;var g=false;var k=false;var b=false;var e=false;var a="";var n=this;this.construct=function(q){this.id=q;a=q+"_status_on_"+window.location.pathname.replace(/\//g,"");console.log("Panel cookie id",a);console.log("Panel cookie value",$.cookie(a));if($.cookie(a)){if($.cookie(a)=="open"){p=true}}else{if($(this).hasClass("OpenedPanel")){p=true}}$(this).find(".PanelHeader").click(function(){n.toggle()});this.update()};this.toggle=function(){if(p){this.hide()}else{this.show()}};this.show=function(){if(typeof f=="function"){b=f}if(typeof j=="function"){e=j}p=true;this.update()};this.hide=function(){if(typeof m=="function"){b=m}if(typeof c=="function"){e=c}p=false;this.update()};this.disable=function(){l=false;this.update()};this.activate=function(){if(typeof o=="function"){b=o}if(typeof h=="function"){e=h}l=true;this.update()};this.update=function(){if(l){if(typeof b=="function"){b()}b=false;if(typeof g=="function"){g()}$(this).removeClass("DisabledPanel")}else{$(this).addClass("DisabledPanel")}if(p&&l){$(this).addClass("OpenedPanel");$.cookie(a,"open",{expires:30});$(this).find(".InnerContainer").slideDown(i.show,function(){if(typeof e=="function"){e()}if(typeof k=="function"){k()}})}else{$.cookie(a,"closed",{expires:30});$(this).find(".InnerContainer").slideUp(i.hide,function(){$(this).closest(".Panel").removeClass("OpenedPanel");if(typeof e=="function"){e()}if(typeof k=="function"){k()}e=false})}};this.setPreShowEvent=function(q){f=q};this.setPostShowEvent=function(q){j=q};this.setPreActivateEvent=function(q){o=q};this.setPostActivateEvent=function(q){h=q};this.setPreHideEvent=function(q){m=q};this.setPostHideEvent=function(q){c=q};this.setPreUpdateEvent=function(q){g=q};this.setPostUpdateEvent=function(q){k=q};this.construct(d)}function Thumbnail(){this.foxtoken="";this.thumbnailId="";this.position=0;this.fckCheckbox=false;this.isMarked=false;this.previewUrl="";this.downloadId="";this.filename="";var c=false;var a=this;this.init=function(){this.position=this.id.replace(/\D/g,"");this.foxtoken=GLOBALS.ImageInfos[this.position].foxtoken;this.thumbnailId=GLOBALS.ImageInfos[this.position].thumbnailId;this.previewUrl=GLOBALS.ImageInfos[this.position].PreviewUrl;this.downloadId=GLOBALS.ImageInfos[this.position].downloadId;this.filename=GLOBALS.ImageInfos[this.position].filename;this.fckCheckbox=$("#fck"+this.position)[0];this.isMarked=this.fckCheckbox.checked;$(this).click(this.processClick);$(this).hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")});this.initRatings()};this.initRatings=function(){$(this).find(".Rating .submitrating").rating({callback:function(f){if(!f){return}var e=parseInt(this.parentNode.id.replace(/\D/g,""));$.get("/fotoweb/cmdrequest/FileAction.fwx?fwSetRating=1&rating="+parseInt(f)+"&f="+GLOBALS.ImageInfos[e].foxtoken)}});$(this).find(".Rating").css("visibility","visible");$(this).find(".rating-cancel").click(function(h){h.stopImmediatePropagation();var g=0;var f=parseInt(this.parentNode.parentNode.id.replace(/Rating/,""));$(this).rating("select");$.get("/fotoweb/cmdrequest/FileAction.fwx?fwSetRating=1&rating="+parseInt(g)+"&f="+GLOBALS.ImageInfos[f].foxtoken)});$(this).find(".Rating .submitrating").click(function(f){f.stopImmediatePropagation()})};this.processClick=function(g){console.log("Processing click",this);console.log(g);var f=g.target;if($(f).hasClass("Download")){g.stopImmediatePropagation();$("#NavigationPaneControl")[0].processDownloadRequest.call(this)}else{if($(f).hasClass("Rating")){}else{if($(f).hasClass("Selection")){g.stopImmediatePropagation();this.toggle()}else{if($(f).hasClass("Zoom")){g.stopImmediatePropagation();this.goToPreview()}else{if($(f).hasClass("Thumbnail")&&GLOBALS.PreviewAccess){g.stopImmediatePropagation();this.goToPreview()}else{if($(f).hasClass("Priority")){g.stopImmediatePropagation();this.showPrioritySelector()}}}}}}};this.showPrioritySelector=function(){if(c){$(".PrioSelector:visible").not(c).trigger("hide");var f=$(c).find(":hidden").length?"show":"hide";$(c).trigger(f);return}$(".PrioSelector:visible").trigger("hide");$.ajax({url:"/fotoweb/cmdrequest/rest/ActionsMenu.fwx",data:{f:this.foxtoken,pm:1,at:GLOBALS.ArchiveType,ar:GLOBALS.ArchiveId,rd:+new Date()},success:function(e){c=b(e);if(!c){return}$(c).bind("show",function(){$(this).slideDown(300)});$(c).bind("hide",function(){$(this).slideUp(300)});$(document).click(function(){$(c).trigger("hide")});$(c).find("a").click(function(g){g.preventDefault();d(this)});$(c).hide();$(a).find(".ThumbContainer").append(c);$(c).trigger("show")},error:function(){}})};function d(e){$.ajax({url:$(e).attr("href"),success:function(){var f=$(e).attr("href").match(/priority=(\d)/);f=f&&f[1]?f[1]:"";console.log("desired level",f);var g=$(a).find(".Priority");$(g).removeClass();$(g).addClass("Priority Prio"+f);$(c).trigger("hide")}})}function b(f){var e=$(f).find("[Url*=fwSetPriority]");if(!$(e).length){return false}var i=$('<div class="PrioSelector"></div>');var g=$("<ul/>");var h=null;$(e).each(function(){h=$('<li><a href="'+$(this).attr("Url")+'"><span>'+$(this).attr("DisplayName")+"</span></a></li>");$(h).find("a").css("background-image","url("+$(this).attr("IconUrl")+")");$(h).click(function(j){j.stopImmediatePropagation()});$(g).append(h)});$(i).append(g);return i}this.goToPreview=function(){console.log("Going to preview",this);var e=GLOBALS.PreviewUrl+"?";e+="&position="+this.position;e+="&archiveType="+GLOBALS.ArchiveType;e+="&archiveId="+GLOBALS.ArchiveId;e+="&albumId="+GLOBALS.ArchiveId;e+="&sorting="+GLOBALS.Sorting;e+="&search="+GLOBALS.Search;e+="&fileId="+this.foxtoken;window.location=e};this.showZoom=function(){OpenCompingImageWindow("Zoom.fwx?position="+this.position+"&archiveId="+GLOBALS.ArchiveId+"&sorting="+GLOBALS.Sorting+"&columns="+GLOBALS.Columns+"&row="+GLOBALS.Rows+"&search="+GLOBALS.Search+"&fileId="+this.foxtoken+"&archiveType="+GLOBALS.ArchiveType,475,370)};this.toggle=function(){if(this.isMarked){this.unselect()}else{this.select()}};this.select=function(){if(!$("#NavigationPaneControl")[0].SelectionPanel){return}console.log("Select Thumbnail Container",this);$("#NavigationPaneControl")[0].addToSelection(this,function(){a.fckCheckbox.checked=true;a.update()},"xml")};this.unselect=function(){if(!$("#NavigationPaneControl")[0].SelectionPanel){return}console.log("Unselect Thumbnail Container",this);$("#NavigationPaneControl")[0].removeFromSelection(this,function(){a.fckCheckbox.checked=false;a.update()},"xml")};this.update=function(){console.log("Updating Thumbnail Container",this);if(this.fckCheckbox.checked){$(this).addClass("DocMtxSelectedCell");$(this).removeClass("DocMtxCell");this.isMarked=true}else{$(this).removeClass("DocMtxSelectedCell");$(this).addClass("DocMtxCell");this.isMarked=false}};this.resize=function(h){var e=$(this).find(".Thumb img")[0];var g=$(this).attr("id").replace(/\D/g,"");var f=this;var i="";if(window.location.search.match(/reload=1/)){i="&dp="+new Date().getTime()}e.onload=function(){$(this).fadeIn(300)};$(e).fadeOut(300,function(){$(f).find(".ThumbContainer").width(h+"px");$(f).find(".Thumb").width(h+"px");$(f).find(".Thumb").height(h+"px");var j=$(e).attr("src");j="/fotoweb/cmdrequest/rest/Preview.fwx?rt=1&f="+GLOBALS.ImageInfos[g].foxtoken+"&sz="+h+i;$(e).attr("src",j)})};this.init()}function NavigationPaneControl(){var g=this;var d=new DownloadPopup();var m=false;var i=false;var p=[];var h=[];this.updateSelectionRecallTimeoutIndicator=0;this.ActionPanel=$(g).find(".ActionsMenu")[0];this.SelectionPanel=$(g).find(".Selection")[0];this.StructurePanel=$(g).find(".Structure")[0];this.DataMiningPanel=$(g).find(".DataMining")[0];this.SizesPanel=$(g).find(".SizesMenu")[0];this.KeywordPanel=$(g).find(".KeywordMenu")[0];this.SearchtreePanel=$(g).find(".Searchtree")[0];this.construct=function(){e();$.asap(function(){if(!$(".Thumbnail").length){return true}var s=true;$(".Thumbnail").each(function(){if(!this.complete){s=false}});return s},function(){g.initSelection();b();l();q();o();j();r();g.initOutboxMenu()},{delay:500})};function j(){if(!g.SizesPanel){return}$(g.SizesPanel).hide();k();var t={ar:GLOBALS.ArchiveId};var s=function(v){showLoading();console.log("open preview viewer with size",v);$("body").addClass("loading");var u=new Image();u.onload=function(){m.show();$("body").removeClass("loading");hideLoading()};u.src="/fotoweb/cmdrequest/rest/preview.fwx/"+GLOBALS.filename+"?rt=1&f="+GLOBALS.foxtoken+"&sz="+v;m.setCaption(TRANSLATIONS.PreviewSize+" - "+v);m.setContent(u)};$.get("/fotoweb/cmdrequest/rest/PreviewSizeList.fwx",t,function(u){var v=$(g.SizesPanel).find("ul").empty();$(u).find("PreviewSize").each(function(){var w=$(this).attr("Name");var x=$(this).attr("Size");var y=$('<li><a href="javascript:">'+w+" - "+x+"</a></li>");$(y).find("a").click(function(){s(x)});$(v).append(y)});$(g.SizesPanel).fadeIn(300)})}function k(){m=new PopDiv("PreviewSizePopUp");m.setOverlaySpeed(200,200);m.setPopDivSpeed(200,200)}this.initOutboxMenu=function(){if($("#OutboxMenuList").length){this.updateOutboxMenu()}};this.updateOutboxMenu=function(s){this.updateMenu("/fotoweb/cmdrequest/rest/outboxMenu.fwx","",$("#OutboxMenuList")[0],s)};this.updateMenu=function(s,u,t,v){$.get(s,u,function(x){$(t).empty();var w="";if($(x).find("FotoWebRest > *:first-child > MenuItem").length>1){w="FotoWebRest > *:first-child > MenuItem"}else{w="FotoWebRest > *:first-child > MenuItem > MenuItem"}$(x).find(w).each(function(){g.integrateIntoMenu(this,$(t))});$(t).closest(".multilvl-menu")[0].update();if(v){v()}},"xml")};this.integrateIntoMenu=function(y,w){var u=$(y).attr("DisplayName");var t=$(y).attr("Url");var s=$(y).attr("IconUrl");var B="";if(u=="---"){w.append("<li><div class='MenuSeperator'></div></li>");return}t=typeof t=="undefined"?"":t;var z=document.createElement("a");if(t.match(/DeleteFiles/i)&&GLOBALS.deleteReturnUrl){t=GLOBALS.deleteReturnUrl}if(!t.match(/SetRating/i)){$(z).text(u)}if(t.match(/download/i)){$(z).click(g.processDownloadRequest)}$(z).attr("href",t);$(z).css("background-image","url("+s+")");var v=document.createElement("div");$(v).addClass("submenu-indicator");z.appendChild(v);B=document.createElement("li");var A=document.createElement("span");A.appendChild(z);$(A).hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")});B.appendChild(A);if(y.hasChildNodes()){$(v).addClass("active");var x=document.createElement("ul");$(y).children("MenuItem").each(function(){g.integrateIntoMenu(this,x)});$(B).append(x)}$(w).append(B)};this.initSelection=function(){if(!this.SelectionPanel){return}$(".Grid").add(".gridTable").explore(".SelectableImage","DocMtxSelectedCell");$(".SelectionItemRemove").live("click",function(){g.removeFromSelectionBySelectionItem(this)});$("#btnClearSelection").live("click",function(s){$("body").append('<form name="ClearSelectionForm" method="post" action="/fotoweb/cmdrequest/ClearSelection.fwx"></form>');document.ClearSelectionForm.submit()});$(this.SelectionPanel).find(".PanelHeader").append('<span id="btnClearSelection" title="'+TRANSLATIONS.ClearSelection+'"></span>');$("#btnClearSelection").hide();g.updateSelection()};function e(){if(g.ActionPanel){g.ActionPanel.setPreActivateEvent(function(){b()})}if(g.StructurePanel){g.StructurePanel.setPostShowEvent(function(){$(g).find(".StructureList li").filter(":has(>ul:hidden)").addClass($.fn.treeview.classes.expandable).replaceClass($.fn.treeview.classes.last,$.fn.treeview.classes.lastExpandable);$(g).find(".StructureList li").not(":has(>ul:hidden)").addClass($.fn.treeview.classes.collapsable).replaceClass($.fn.treeview.classes.last,$.fn.treeview.classes.lastCollapsable)})}if(g.DataMiningPanel){g.DataMiningPanel.setPostShowEvent(function(){$(g).find(".DataMining li").filter(":has(>ul:hidden)").addClass($.fn.treeview.classes.expandable).replaceClass($.fn.treeview.classes.last,$.fn.treeview.classes.lastExpandable);$(g).find(".DataMining li").not(":has(>ul:hidden)").addClass($.fn.treeview.classes.collapsable).replaceClass($.fn.treeview.classes.last,$.fn.treeview.classes.lastCollapsable)})}if(g.KeywordPanel){g.KeywordPanel.setPostShowEvent(function(){$(g).find(".KeywordList li").filter(":has(>ul:hidden)").addClass($.fn.treeview.classes.expandable).replaceClass($.fn.treeview.classes.last,$.fn.treeview.classes.lastExpandable);$(g).find(".KeywordList li").not(":has(>ul:hidden)").addClass($.fn.treeview.classes.collapsable).replaceClass($.fn.treeview.classes.last,$.fn.treeview.classes.lastCollapsable)})}if(g.SearchtreePanel){g.SearchtreePanel.setPostShowEvent(function(){$(g).find(".SearchtreeList li").filter(":has(>ul:hidden)").addClass($.fn.treeview.classes.expandable).replaceClass($.fn.treeview.classes.last,$.fn.treeview.classes.lastExpandable);$(g).find(".SearchtreeList li").not(":has(>ul:hidden)").addClass($.fn.treeview.classes.collapsable).replaceClass($.fn.treeview.classes.last,$.fn.treeview.classes.lastCollapsable)})}}function o(){if(!g.SearchtreePanel){return}var t=$(g.SearchtreePanel).find("ul")[0];var s=function(w){var x="";x=$(w).attr("Name");var v="";if($(w).attr("Search")){v="?search="+encodeURIComponent($(w).attr("Search"))}else{v="javascript:"}return{display:x,href:v}};var u=function(){console.log("called searchTreeProcess");var x=this;var y=$(this).data("Name");var w="?ar="+GLOBALS.ArchiveId+"&nm="+$(this).data("Name")+"&r=1&rt="+$(this).data("Root");var v={url:"fotoweb/cmdrequest/rest/SearchTreeContent.fwx"+w,async:false,datatype:"xml",success:function(z){var A=document.createElement("ul");$(z).find("SearchTreeContent > SearchNode").each(function(){var B=n(this,A,s);$(B).data("Name",y);$(B).data("Root",$(this).attr("Root"))});console.log("new created ul",A);$(t)[0].addBranch(x,A)}};$.ajax(v)};$.get("/fotoweb/cmdrequest/rest/SearchTreeList.fwx",{ar:GLOBALS.ArchiveId},function(v){$(t).empty();$(v).find("SearchTree").each(function(){var w=n(this,t,s);$(w).append($("<ul><li></li></ul>"));$(w).data("Name",$(this).attr("Name"));$(w).data("Root","/")});if($(t).find("li").length){$(t).xenview({collapsed:true,persist:"cookie",cookieId:"SearchTreeFor"+GLOBALS.ArchiveId},function(){console.log("expand process on",this);u.call(this)});$(g.SearchtreePanel).fadeIn(300)}},"xml")}function r(){if(!g.KeywordPanel){return}var u=$(g.KeywordPanel).find("ul")[0];var s=function(x){var y="";y=$(x).attr("Element")?$(x).attr("Element"):$(x).attr("Name");var w="("+a($(x).attr("id"))+" Contains ("+$(x).attr("Element")+"))";var v="";if($(x).attr("Element")){v="?search="+encodeURIComponent(w)}else{v="javascript:"}return{display:y,href:v}};var t=function(){console.log("called expand process");var x=this;var w="?ar="+GLOBALS.ArchiveId+"&id="+$(this).data("Id");var y=$(this).data("Id");var v={url:"fotoweb/cmdrequest/rest/KeywordListContent.fwx"+w,async:false,datatype:"xml",success:function(z){var A=document.createElement("ul");$(z).find("KeywordListContent > KeywordList").each(function(){$(this).attr("id",y);n(this,A,s)});console.log("new created ul",A);$(u)[0].addBranch(x,A)}};$.ajax(v)};$.get("/fotoweb/cmdrequest/rest/KeywordList.fwx",{ar:GLOBALS.ArchiveId},function(v){$(u).empty();$(v).find("KeywordList").each(function(){var w=n(this,u,s);$(w).append($("<ul><li></li></ul>"));$(w).data("Id",$(this).attr("Id"))});if($(u).find("li").length){$(u).xenview({collapsed:true,persist:"cookie",cookieId:"KeywordListFor"+GLOBALS.ArchiveId},function(){console.log("expand process on",this);t.call(this)});$(g.KeywordPanel).fadeIn(300)}},"xml")}function a(s){if(s<10){return"IPTC00"+s}if(s<100){return"IPTC0"+s}return"IPTC"+s}function l(){if(!g.StructurePanel){return}var u=$(g.StructurePanel).find("ul")[0];var s=function(w){var x=$(w).attr("DisplayName");var v="/fotoweb/Grid.fwx?search="+$(w).attr("SearchString");return{display:x,href:v}};var t=function(){console.log("called expand process");var y=this;var v=encodeURIComponent($(this).data("Root"));var x="?ar="+GLOBALS.ArchiveId+"&rt="+v+"&r=1";var w={url:"fotoweb/cmdrequest/rest/FolderList.fwx"+x,async:false,datatype:"xml",success:function(z){var A=document.createElement("ul");$(z).find("FolderList > Folder > Folder").each(function(){var B=n(this,A,s);$(B).data("Root",$(this).attr("Root"))});console.log("new created ul",A);$(u)[0].addBranch(y,A)}};$.ajax(w)};$.get("/fotoweb/cmdrequest/rest/FolderList.fwx",{ar:GLOBALS.ArchiveId,r:1},function(v){$(u).empty();$(v).find("FolderList > Folder").each(function(){var w=n(this,u,s);$(w).data("Root",$(this).attr("Root"))});if($(u).find("li").length){$(u).xenview({collapsed:true,persist:"cookie",cookieId:"StructureFor"+GLOBALS.ArchiveId},function(){console.log("expand process on",this);t.call(this)});$(g.StructurePanel).fadeIn(300)}},"xml")}function q(){if(!g.DataMiningPanel){return}var t=$(g.DataMiningPanel).find("ul")[0];var s=function(w){var x=$(w).attr("Name")?$(w).attr("Name"):$(w).attr("Display");var v=$(w).attr("Search")?"?search="+encodeURIComponent($(w).attr("Search")):"javascript:";return{display:x,href:v}};var u=function(){console.log("called expand process");var y=this;var v=$(this).data("Root");var x="?ar="+GLOBALS.ArchiveId+"&rt="+v;var w={url:"fotoweb/cmdrequest/rest/DataMining.fwx"+x,async:false,datatype:"xml",success:function(z){var A=document.createElement("ul");$(z).find("DataMining > Value").each(function(){n(this,A,s)});console.log("new created ul",A);$(t)[0].addBranch(y,A)}};$.ajax(w)};$.ajax({url:"/fotoweb/cmdrequest/rest/DataMining.fwx",data:{ar:GLOBALS.ArchiveId},contentType:"xml",success:function(v){$(t).empty();$(v).find("DataMining > Field").each(function(){var w=n(this,t,s);$(w).append($("<ul><li></li></ul>"));$(w).data("Root",$(this).attr("Root"))});if($(t).find("li").length){$(t).xenview({collapsed:true,persist:"cookie",cookieId:"DataMiningFor"+GLOBALS.ArchiveId},function(){console.log("expand process on",this);u.call(this)});$(g.DataMiningPanel).fadeIn(300)}}})}function n(y,w,x,u){u=typeof u=="undefined"?true:u;var z=x(y);var s=document.createElement("li");var t=document.createElement("a");$(t).attr("href",z.href);$(t).text(z.display);$(s).append(t);if(u&&y.hasChildNodes()){var v=document.createElement("ul");$(y).children().each(function(){n(this,v,x)});$(s).append(v)}$(w).append(s);return s}function b(){if(typeof GLOBALS=="undefined"){return}if(!g.ActionPanel||!$(g.ActionPanel).find(".ActionsList").length){return}var s=GLOBALS.PostBackUrl.match(/\?(.*)/)?GLOBALS.PostBackUrl+"&reload=1":GLOBALS.PostBackUrl+"?reload=1";var t={rn:s,at:GLOBALS.ArchiveType,rd:+new Date().getTime()};if(GLOBALS.ArchiveId){t.ar=GLOBALS.ArchiveId}if(GLOBALS.Preview){t.pm="1";t.f=GLOBALS.foxtoken}else{t.pm="0"}g.updateMenu("/fotoweb/cmdrequest/rest/ActionsMenu.fwx",t,$(g.ActionPanel).find(".ActionsList")[0])}this.processDownloadRequest=function(){console.log("process download request...");var s="";var t="";var u="single";if($(this).attr("href")&&$(this).attr("href").match(/download.dll\/ZipDownload\/SelectionList/i)){s=$(this).attr("href");u="selection"}else{if($(this).attr("href")&&$(this).attr("href").match(/download.dll/i)){t=GLOBALS.foxtoken;s=$(this).attr("href")}else{if(this.foxtoken){t=this.foxtoken;s="/fotoweb/fwbin/download.dll/"+this.filename+"?D="+this.downloadId+"&ForceSaveDialog=yes"}else{s="/fotoweb/cmdrequest/Download.fwx?incsel=1";u="selection"}}}$.ajax({url:"/fotoweb/cmdrequest/rest/ProcessingProfileList.fwx",data:{ar:GLOBALS.ArchiveId},datatype:"xml",success:function(y){console.log("response received");var v=$(y).find("DirectDownloads");var x=$(v).attr("Type");console.log("Preconfigured method by FAC",x);console.log("download invoked by",u);if(x!="Custom"){console.log("automatic profile selection");window.location=s}else{if(u=="single"){var w=new Image();w.onload=function(){console.log("profile selection by popup");d.show([w],y,s)};w.src="/fotoweb/cmdrequest/rest/Preview.fwx?rt=1&f="+t+"&sz=240"}else{c(function(){$(this).fadeIn(300)},function(z){d.show(z,y,s)})}}},error:function(){console.log("no correct response - fallback");console.log("automatic profile selection");window.location=s}});return false};function c(s,t){s=typeof s=="function"?s:function(){};$.get("/fotoweb/cmdrequest/GetSelection.fwx?sendXML=1",{sendXML:1,rd:+new Date},function(w){var z=new Array();var v;var x;var y=$(w).find("Item");var u="&sz=240";if(y.length>1){u="&as=rt&asw=82&ash=82"}$(y).each(function(){v=new Image();x=$(this).attr("foxToken");v.onload=s;v.src="/fotoweb/cmdrequest/rest/Preview.fwx?rt=1&f="+x+u+"&rd="+new Date;z.push(v)});t(z)},"xml")}function f(){var s,t,u=[];t=h.length;for(s=0;s<t;s++){u.push("f="+h[s].foxtoken)}u.push("sendXML=yes");if(t>0){$.ajax({url:"/fotoweb/cmdrequest/RemoveFromSelection.fwx",data:u.join("&"),async:false,dataType:"xml",type:"POST"})}u=[];t=p.length;for(s=0;s<t;s++){u.push("f="+p[s].foxtoken)}u.push("sendXML=yes");if(t>0){$.ajax({url:"/fotoweb/cmdrequest/AddToSelection.fwx",data:u.join("&"),async:false,dataType:"xml",type:"POST"})}g._updateSelectionStatus();p=[];h=[]}this.updateSelection=function(){var s={sendXML:1,dp:+new Date};$.ajax({url:"/fotoweb/cmdrequest/GetSelection.fwx",data:s,async:false,success:function(t){g.updateSelectionByXML(t)}})};this.updateSelectionByXML=function(A){console.log("updating selection by xml",A);var y=$(A).find("Item");var C=$(g.SelectionPanel).find(".SelectionItem.node-tpl").clone().removeClass("node-tpl");var D="";var u="";var v="";var z=0;var x=0;var F=$(g.SelectionPanel).find(".SelectionList");var E=$(F).find(".SelectionItem");var t=false;var G=y.length;var B=E.length;var w=new Array();for(z=0;z<G;z++){t=false;D=$(C).clone();u=$(y[z]).attr("foxToken");v=$(y[z]).attr("pvToken");for(x=0;x<B;x++){if(E[x].id=="foxtoken_"+u){t=true;w[x]=true;break}}if(t){continue}$(D).attr("id","foxtoken_"+u);var s=new Image();$(s).css("visibility","hidden");$(s)[0].onload=function(){$(this).hide();$(this).css("visibility","visible");$(this).fadeIn(300);$(this).closest(".SelectionItem").removeClass("loading")};$(D).find("img").replaceWith(s);$(D).addClass("loading");if(GLOBALS.PreviewAccess){$(s).attr("src","/fotoweb/cmdrequest/rest/Preview.fwx?rt=1&f="+u+"&as=rt&asw=63&ash=63&rd="+(+new Date()))}else{$(s).attr("src","/fotoweb/cmdrequest/rest/preview.fwx?f="+v)}F.append(D)}for(x=0;x<B;x++){if(w[x]==true){continue}$(E[x]).fadeOut("fast",function(){var H=this;window.setTimeout(function(){$(H).remove();delete H},3000)})}this._updateSelectionStatus()};this._updateSelectionStatus=function(){console.log("current Items in selection",$(this.SelectionPanel).find(".SelectionList .SelectionItem"));if($(g.SelectionPanel).find(".SelectionList .SelectionItem").length>0){if(g.ActionPanel){g.ActionPanel.activate();g.ActionPanel.show()}if(g.SelectionPanel){g.SelectionPanel.activate();g.hideSelectionHintText();g.SelectionPanel.show();$("#btnClearSelection").show()}}else{if(g.ActionPanel){g.ActionPanel.disable()}if(g.SelectionPanel){g.showSelectionHintText()}$("#btnClearSelection").hide()}$(g.SelectionPanel).fadeIn(300)};this.showSelectionHintText=function(){if($(g.SelectionPanel).find(".Hint").length){$(g.SelectionPanel).find(".Hint").slideDown(300);return}$(g.SelectionPanel).find(".SelectionList").load("/fotoweb/SelectionHint.fwx");g.SelectionPanel.show()};this.hideSelectionHintText=function(){$(g.SelectionPanel).find(".Hint").slideUp(300)};this.removeFromSelectionBySelectionItem=function(u){var x=$(u).closest(".SelectionItem")[0];var v=$(x).attr("id").replace(/foxtoken_/,"");var t=0;var s=false;var w;for(t in GLOBALS.ImageInfos){w=$("#imgCell"+t)[0];if(v==w.foxtoken){s=true;w.unselect()}}if(!s){$.get("/fotoweb/cmdrequest/RemoveFromSelection.fwx",{sendXML:1,fileId:v,dp:+new Date},function(){g.updateSelection()},"xml")}};this.addToSelection=function(t,s){if($("body").hasClass("loading")){return}p.push(t);this._injectIntoSelection(t);if(typeof s=="function"){s()}if(i){window.clearTimeout(i)}i=window.setTimeout(function(){f()},CONFIG.SelectionSyncDelay)};this.removeFromSelection=function(t,s){if($("body").hasClass("loading")){return}h.push(t);this._stripFromSelection(t);if(typeof s=="function"){s()}if(i){window.clearTimeout(i)}i=window.setTimeout(function(){f()},CONFIG.SelectionSyncDelay)};this._stripFromSelection=function(s){console.log("stripping from selection list",s);$(g.SelectionPanel).find(".SelectionItem").each(function(){if(this.id=="foxtoken_"+s.foxtoken){var t=this;$(this).fadeOut(300,function(){$(t).remove();delete t})}})};this._injectIntoSelection=function(u){console.log("inject into selection",u);var t=$(g.SelectionPanel).find(".SelectionItem.node-tpl").clone();t.removeClass("node-tpl");console.log("SelectionTemplate",t);$(t).attr("id","foxtoken_"+u.foxtoken);var s=new Image();$(s).css("visibility","hidden");$(s)[0].onload=function(){$(this).hide();$(this).css("visibility","visible");$(this).fadeIn(300);$(this).closest(".SelectionItem").removeClass("loading")};$(t).find("img").replaceWith(s);$(t).addClass("loading");$(g.SelectionPanel).find(".SelectionList").append(t);if(GLOBALS.PreviewAccess){$(s).attr("src","/fotoweb/cmdrequest/rest/Preview.fwx?rt=1&f="+u.foxtoken+"&as=rt&asw=63&ash=63&rd="+(+new Date()))}else{$(s).attr("src","/fotoweb/cmdrequest/rest/preview.fwx?f="+u.thumbnailId)}};this.construct()}function OpenBarView(){var a="BarView.fwx";a+="?position="+GLOBALS.postition;a+="&archiveId="+GLOBALS.ArchiveId;a+="&columns="+GLOBALS.Columns;a+="&rows="+GLOBALS.Rows;a+="&sorting="+GLOBALS.Sorting;a+="&search="+GLOBALS.Search;windowFeatures="dependent,width=200,height=800,left=0,top=0,menubar=0,scrollbars=1,status=1,titlebar=0,toolbar=0,resizable=1";window.open(a,"FWBarView",windowFeatures)}function OpenAlbumBarView(){var a="AlbumBarView.fwx";a+="?position="+GLOBALS.postition;a+="&albumId="+GLOBALS.ArchiveId;a+="&columns="+GLOBALS.Columns;a+="&rows="+GLOBALS.Rows;a+="&sorting="+GLOBALS.Sorting;windowFeatures="dependent,width=200,height=800,left=0,top=0,menubar=0,scrollbars=1,status=1,titlebar=0,toolbar=0,resizable=1";window.open(a,"FWBarView",windowFeatures)};
