var PFLY=new function(){function r(a){a&&a.addClass("InputChanged")}function s(a){if(n)if((a=a.attr("id"))&&a.length>0){a="["+a+"]";var b=n.attr("value");if(b.indexOf(a)<0){if(b.length==0)p&&p.addClass("Active");else b+=",";b+=a;n.attr("value",b)}}}function u(a){this.Run=function(){window.status="KeepSessionAlive #"+ ++PFLY.KeepSessionAliveCount;var b=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");b.onreadystatechange=function(){b.readyState==4&&b.status==200&&PFLY.KeepSessionAlive(a)};
b.open("GET",a+"/common/KeepSessionAlive.ashx",true);b.send(null)}}function t(a){a=a.getAttributeNode("class");return a!=null?a.value:false}var n,p;this.ResourceStrings={ErrorTitle:"Error",InfoTitle:"Information",ConfirmTitle:"Please confirm",OkButton:"Ok",CancelButton:"Cancel",LdtEditTitle:"Edit texts",RequiredFlashVersion:9,CurrentLanguageId:"en-GB",AciveLanguages:[{id:"en-GB",name:"English"}]};this.SetResourceStrings=function(a){for(var b in a)if(this.ResourceStrings.hasOwnProperty(b))this.ResourceStrings[b]=
a[b]};this.DecorateSelectionDependant=function(a){jQuery(".SelectionDependant").each(function(){var b=jQuery(this);a?b.addClass("Active"):b.removeClass("Active")})};this.FocusFirstInput=function(a){a||jQuery(function(){setTimeout(function(){var b=jQuery(":input:not(:checkbox):visible:enabled:first");b.length>0&&b[0].focus()},100)})};this.EnableDefaultButton=function(a,b){jQuery(function(){var c=jQuery(b);c.length>0&&jQuery(a).keypress(function(d){if(d.which==13){c.click();return false}})})};this.InitDialogLinks=
function(){jQuery(function(){jQuery("a").each(function(){var a=jQuery(this);a.attr("target")=="dialog"&&a.click(function(){PFLY.OpenDialog(a.attr("href"));return false})})})};this.ToggleGroup=function(a,b,c){b=jQuery("#"+b);var d=b.val()!="1";b.val(d?"1":"0");c=jQuery("#"+c);c.toggle(d);a=jQuery(a);d?a.addClass("Collapse"):a.removeClass("Collapse")};this.MarkAsChanged=function(a){if(a.hasClass("NoHighlight")||a.parent().hasClass("NoHighlight"))return false;r(a);s(a)};this.ListenForChanges=function(a){function b(){r(a);
s(a);a.unbind("keydown",e);a.unbind("keypress",d);a.unbind("change",c);a.unbind("click",c)}function c(){b();return true}function d(i){i.which!=0&&b();return true}function e(i){if(i.which==8||i.which==46)b();return true}a.bind("keydown",e);a.bind("keypress",d);a.bind("change",c);if(a.attr("type")=="checkbox"||a.attr("type")=="radio")a.bind("click",c)};this.HighlightChangedElements=function(a){jQuery(function(){n=jQuery("#"+a);p=jQuery(".SaveButton");PFLY.MarkChangedElements();jQuery("input, textarea, select").each(function(){var b=
jQuery(this),c;a:if(b.hasClass("NoHighlight")||b.parent().hasClass("NoHighlight")||b.attr("readonly")==true)c=false;else{if(b.attr("type")=="checkbox")if((c=b.attr("name"))&&c.length>=8&&c.lastIndexOf("selector")==c.length-8){c=false;break a}c=true}c&&PFLY.ListenForChanges(b)})})};this.MarkChangedElements=function(a){if(n){a&&n.val(a);a=n.val().split(",");for(var b=true,c=0;c<a.length;c++){var d=a[c];if(d&&d.length>2){d=d.substring(1,d.length-1);if(b){p&&p.addClass("Active");b=false}r(jQuery("#"+
d))}}}};this.AdjustContainerHeights=function(){jQuery(function(){function a(){var e=jQuery(".DoMaxHeight"),i=jQuery(".DoMaxWidth"),k=jQuery(window).width(),h=jQuery("#NodeMenuContainer"),f=jQuery(".Pf_Content"),g=jQuery("#Pf_Footer"),j=jQuery("#Pf_AdminBottom").offset().top,o=g.height();if(c)j+=15;b&&g.children().length>0&&g.show();g=f.offset().left;var q=f.offset().top;h.length>0&&h.height(j-h.offset().top);e.each(function(){var m=jQuery(this);m.height(j-m.offset().top-o-1)});i.each(function(){var m=
jQuery(this);m.width(k-m.offset().left)});f.height(j-q-o);f.width(k-g);b=false}var b=true,c=PFLY.IsIE6(),d=null;if(c)setTimeout(a,200);else{a();setTimeout(a,1)}jQuery(window).resize(function(){if(c){clearTimeout(d);d=setTimeout(a,200)}else a()})})};this.SetParentWindowDialogTitle=function(a){jQuery(function(){window.parent&&window.parent.jQuery("#UrlDialog").dialog("option","title",a)})};this.MaintainScrollPosition=function(a,b){PFLY.jQueryExist()&&jQuery(function(){var c=jQuery("#"+a),d=jQuery("#"+
b);c.scrollTop(d.val());c.scroll(function(){d.val(c.scrollTop());return true})})};this.IsFlashPlayerInstalled=function(){var a=navigator.appVersion.indexOf("MSIE")!=-1?true:false,b=navigator.appVersion.toLowerCase().indexOf("win")!=-1?true:false,c=navigator.userAgent.indexOf("Opera")!=-1?true:false,d=this.ResourceStrings.RequiredFlashVersion.split(".");return function(e,i,k){var h;h=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){h=
navigator.plugins["Shockwave Flash"+(navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"")].description.split(" ");var f=h[2].split("."),g=f[0];f=f[1];var j=h[3];if(j=="")j=h[4];if(j[0]=="d")j=j.substring(1);else if(j[0]=="r"){j=j.substring(1);if(j.indexOf("d")>0)j=j.substring(0,j.indexOf("d"))}h=g+"."+f+"."+j}}else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.6")!=-1)h=4;else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.5")!=-1)h=3;else if(navigator.userAgent.toLowerCase().indexOf("webtv")!=
-1)h=2;else if(a&&b&&!c){try{f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");g=f.GetVariable("$version")}catch(o){}if(!g)try{f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");g="WIN 6,0,21,0";f.AllowScriptAccess="always";g=f.GetVariable("$version")}catch(q){}if(!g)try{f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");g=f.GetVariable("$version")}catch(m){}if(!g)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");g="WIN 3,0,18,0"}catch(l){}if(!g)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
g="WIN 2,0,0,11"}catch(v){g=-1}h=g}h=h;if(h==-1)return false;else if(h!=0){if(a&&b&&!c){tempArray=h.split(" ");tempString=tempArray[1];versionArray=tempString.split(",")}else versionArray=h.split(".");h=versionArray[0];g=versionArray[1];f=versionArray[2];if(h>parseFloat(e))return true;else if(h==parseFloat(e))if(g>parseFloat(i))return true;else if(g==parseFloat(i))if(f>=parseFloat(k))return true;return false}}(d[0],d[1]!=undefined?d[1]:"0",d[2]!=undefined?d[2]:"0")};this.CloseDialog=function(){if(window.opener&&
!window.opener.closed){window.opener.focus();window.close()}else window.parent&&window.parent.jQuery("#UrlDialog").dialog("close")};this.DisableInputWhileProcessing=function(a,b){jQuery(function(){function c(){jQuery(b).dialog({modal:true,resizable:false,draggable:false,dialogClass:"DisableInputWhileProcessingDialog"})}jQuery("form").each(function(){var d=this,e=d.onsubmit;this.onsubmit=function(){var i=true;if(d!=null){if(e!=null&&typeof e=="function")with(d)i=e();if(i){setTimeout(c,a);d=null}}return i}})})};
this.ExecuteCallback=function(a,b){var c;c=window.opener&&!window.opener.closed?window.opener:window.parent?window.parent:null;b&&this.CloseDialog();if(c!=null)try{c.eval(a)}catch(d){c.alert("Executing '"+a+"' failed, error: "+d.Message)}};this.BuildUrl=function(a){for(var b=a.indexOf("?")>=0?"&":"?",c=1;c<arguments.length;c+=2){a+=b+arguments[c]+"="+escape(arguments[c+1]);b="&"}return a};this.jQueryExist=function(){return typeof jQuery=="function"};this.useJQ=function(){return this.jQueryExist()};
this.dialogNumber=0;this.ShowDialog=function(a,b,c,d){var e="DynamicDialog_"+this.dialogNumber++;jQuery("body").append("<div id='"+e+"'><div class='"+c+"'>"+b+"</div></div>");var i=jQuery("#"+e);a={bgiframe:true,modal:true,autoOpen:true,closeOnEscape:true,resizable:false,minWidth:0,minHeight:0,title:a,close:function(){i.dialog("destroy");i.remove()}};if(b!=null&&b.length>100)a.width=800;if(d)a.buttons=d;i.dialog(a);return i};this.ShowErrorDialog=function(a,b){var c={};c[this.ResourceStrings.OkButton]=
function(){jQuery(this).dialog("close");b&&b()};this.ShowDialog(this.ResourceStrings.ErrorTitle,a,"ErrorDialog",c)};this.ShowConfirmDialog=function(a,b){var c={};c[this.ResourceStrings.OkButton]=function(){jQuery(this).dialog("close");b&&b()};c[this.ResourceStrings.CancelButton]=function(){jQuery(this).dialog("close")};this.ShowDialog(this.ResourceStrings.ConfirmTitle,a,"ConfirmDialog",c)};this.ShowInfoDialog=function(a,b){var c={};c[this.ResourceStrings.OkButton]=function(){jQuery(this).dialog("close");
b&&b()};this.ShowDialog(this.ResourceStrings.InfoTitle,a,"InfoDialog",c)};this.IsIE6=function(){return jQuery.browser.msie&&jQuery.browser.version=="6.0"&&!window.XMLHttpRequest};this.OpenDialog=function(a,b,c,d){if(!b||b<1)b=jQuery(window).width()-100;if(!c||c<1)c=jQuery(window).height()-100;if(this.IsIE6()){var e="width="+b+", height="+c;e+=", top="+(screen.height-c)/2+", left="+(screen.width-b)/2;e+=", directories=no";e+=", location=no";e+=", menubar=no";e+=", resizable=yes";e+=", scrollbars=yes";
e+=", status=no";e+=", toolbar=no";var i=window.open(a,"_blank",e);if(d){var k=null;k=window.setInterval(function(){if(i.closed){window.clearInterval(k);eval(d)}},1E3)}i.focus&&i.focus();return i}else{var h=jQuery("body"),f=h.css("overflow");h.css("overflow","hidden");h.append("<div id='UrlDialog' style='display:none;'></div>");var g=jQuery("#UrlDialog");g.append('<iframe id="UrlDialogIFrame" style="display:none;" marginheight="0" marginwidth="0" frameborder="0" src="'+a+'"></iframe>');var j=jQuery("#UrlDialogIFrame"),
o=function(){j.height(g.height());j.width(g.width());j.show()},q=function(){if(!m){m=true;g.dialog("open");o()}},m=false;g.dialog({bgiframe:true,modal:true,autoOpen:false,closeOnEscape:false,resizable:true,minHeight:0,minWidth:0,height:c+40,width:b+30,resizeStart:function(){j.hide()},resizeStop:o,dragStart:function(){j.hide()},dragStop:function(){j.show()},close:function(){g.dialog("destroy");g.remove();h.css("overflow",f);d&&eval(d)}});j.load(function(){var l=this.contentWindow;if(typeof l.DialogOptions==
"function"){l=l.DialogOptions();if(l.width||l.height){j.hide();l.width&&g.dialog("option","width",l.width+30);l.height&&g.dialog("option","height",l.height+40);g.dialog("option","position","center");m&&o()}l.title&&g.dialog("option","title",l.title)}q()});setTimeout(q,1E3);return window}};this.DateSelectedTarget=null;this.DateSelectedCallback=function(a){PFLY.DateSelectedTarget.attr("value",a);PFLY.MarkAsChanged(PFLY.DateSelectedTarget)};this.BuildCalendarUrl=function(a,b,c){if(c){b=b;c=c}else{PFLY.DateSelectedTarget=
jQuery("#"+b);b=PFLY.DateSelectedTarget.attr("value");c="PFLY.DateSelectedCallback"}a+="?SelectedDate="+b+"&CB="+c;return a};this.OpenCalendar=function(a,b,c){return this.OpenDialog(this.BuildCalendarUrl(a,b,c),180,180)};this.KeepSessionAlive=function(a){a=new u(a);setTimeout(a.Run,3E5)};this.KeepSessionAliveCount=0;this.Stripe=function(a,b,c){var d=document.getElementById(a);if(d){b||(b="#ffffff");c||(c="#e0e0e0");a=false;d=d.rows;for(var e=0;e<d.length;e++){var i=a?b:c;a=!a;var k=d[e];if(!t(k)&&
!k.style.backgroundColor){k=k.cells;for(var h=0;h<k.length;h++){var f=k[h];if(!t(f)&&!f.style.backgroundColor)f.style.backgroundColor=i}}}}};this.SetCheckboxes=function(a,b){jQuery("input[name='"+a+"']:not(:disabled)").each(function(){this.checked=b})};this.GetSelectedCount=function(a){var b=0;jQuery("input[name='"+a+"']:checked:not(:disabled)").each(function(){b++});return b};this.GetSelectedValues=function(a){var b="",c="";jQuery("input[name='"+a+"']:checked:not(:disabled)").each(function(){b+=
c+this.value;c=","});return b};this.OpenWindow=function(a,b,c){a=window.open(a,"_blank","top="+(window.screen.availHeight-c)/2+",left="+(window.screen.availWidth-b)/2+",width="+b+",height="+c+",resizable=1,scrollbars=0,status=0");a.focus();return a};this.ShowDropDownList=function(a){var b=jQuery("#"+a+"_opener"),c=jQuery("#"+a+"_selector");c.css("top",b.position().top);c.css("left",b.position().left);c.slideDown("fast");jQuery(document).bind("mousedown.papirfly",function(d){var e=c.offset();if(d.pageX<
e.left||d.pageX>e.left+c.outerWidth()||d.pageY<e.top||d.pageY>e.top+c.outerHeight())PFLY.HideDropDownList(a);return true})};this.HideDropDownList=function(a){jQuery("#"+a+"_opener");jQuery("#"+a+"_selector").hide();jQuery(document).unbind("mousedown.papirfly")};this.SelectDropDownItem=function(a,b){var c=jQuery("#"+a+"_opener"),d=jQuery("#"+a);d.val(b);c.html(d.find(":selected").text());this.HideDropDownList(a);d.change()};this.LdtSet=function(a,b,c){if(c==undefined)c=this.ResourceStrings.CurrentLanguageId;
a=a.substr(5).split("|");for(var d=-1,e=0;e<a.length;e++){var i=a[e];if(i.length>c.length&&i.substr(1,c.length)==c){d=e;break}}if(b!=null)b=b.replace("|","?").replace(c+"]","?");b="["+c+" "+b+" "+c+"]";if(d>=0)a[d]=b;else a.push(b);return"|LDT|"+(a.length==1?a[0]:a.join("|"))};this.LdtGet=function(a,b){for(var c=a.substr(5).split("|"),d=0;d<c.length;d++){var e=c[d];if(e.length>=b.length&&e.substr(1,b.length)==b)return e.length>=2*(b.length+1)?e.substr(b.length+2,e.length-2*(b.length+2)):""}return""};
this.LdtEdit=function(a,b){var c=this.ResourceStrings.CurrentLanguageId,d=this.ResourceStrings.AciveLanguages,e=a.val();this.ShowDialog(this.ResourceStrings.LdtEditTitle,function(){for(var i=" style='width:"+b.css("width")+";height:"+b.css("height")+"'",k=b.attr("rows")==undefined,h=k?null:" rows='"+b.attr("rows")+"' cols='"+b.attr("rows")+"'",f="<table class='LdtInputDialog'>",g=0;g<d.length;g++){var j=d[g];f+="<tr>";f+="<td>";f+=j.name;f+="</td><td>";if(k){f+="<input type='text'";f+=" id='langinput-";
f+=j.id+"'";f+=" value='";f+=PFLY.LdtGet(e,j.id)+"'";f+=i;f+=" />"}else{f+="<textarea";f+=" id='langinput-";f+=j.id+"'";f+=i;f+=h;f+=">";f+=PFLY.LdtGet(e,j.id);f+="</textarea>"}f+="</td></tr>"}f+="</table>";return f}(),null,function(){var i={};i[PFLY.ResourceStrings.OkButton]=function(){for(var k=0;k<d.length;k++){var h=d[k],f=jQuery("#langinput-"+h.id);e=PFLY.LdtSet(e,f.val(),h.id)}a.val(e);b.val(PFLY.LdtGet(e,c));PFLY.MarkAsChanged(b);jQuery(this).dialog("close")};i[PFLY.ResourceStrings.CancelButton]=
function(){jQuery(this).dialog("close")};return i}())}};function Papirfly(){return PFLY};
