var PFLY=new function(){function o(a){a&&a.addClass("InputChanged")}function p(a){if(l&&(a=a.attr("id"))&&a.length>0){var a="["+a+"]",b=l.attr("value");b.indexOf(a)<0&&(b.length==0?n&&n.addClass("Active"):b+=",",b+=a,l.attr("value",b))}}function s(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",!0);b.send(null)}}function r(a){a=a.getAttributeNode("class");return a!=null?a.value:!1}var l,n;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)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 a=jQuery(":input:not(:checkbox):visible:enabled:first");a.length>0&&a[0].focus()},100)})};this.EnableDefaultButton=function(a,b){jQuery(function(){var c=jQuery(b);c.length>0&&jQuery(a).keypress(function(a){if(a.which==13){try{c.click()}catch(b){}return!1}})})};
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!1})})})};this.HideGroups=function(a,b){jQuery(".GroupToggler.Collapse").each(function(){this!=a&&jQuery(this).find(".GroupTogglerCollectionName").text()==b&&PFLY.ToggleGroup(this)})};this.ToggleGroup=function(a,b,c){a=jQuery(a);b==null&&(b=a.find(".GroupTogglerStateholderId").text());c==null&&(c=a.find(".GroupTogglerContentId").text());
var b=jQuery("#"+b),d=b.val()!="1";b.val(d?"1":"0");jQuery("#"+c).toggle(d);d?a.addClass("Collapse"):a.removeClass("Collapse")};this.MarkAsChanged=function(a){if(a.hasClass("NoHighlight")||a.parent().hasClass("NoHighlight"))return!1;o(a);p(a)};this.ListenForChanges=function(a){function b(){o(a);p(a);a.unbind("keydown",e);a.unbind("keypress",d);a.unbind("change",c);a.unbind("click",c)}function c(){b();return!0}function d(a){a.which!=0&&b();return!0}function e(a){(a.which==8||a.which==46)&&b();return!0}
a.bind("keydown",e);a.bind("keypress",d);a.bind("change",c);(a.attr("type")=="checkbox"||a.attr("type")=="radio")&&a.bind("click",c)};this.HighlightChangedElements=function(a){jQuery(function(){l=jQuery("#"+a);n=jQuery(".SaveButton");PFLY.MarkChangedElements();jQuery("input, textarea, select").each(function(){var a=jQuery(this),c;a:if(a.hasClass("NoHighlight")||a.parent().hasClass("NoHighlight")||a.attr("readonly")==!0)c=!1;else{if(a.attr("type")=="checkbox"&&(c=a.attr("name"))&&c.length>=8&&c.lastIndexOf("selector")==
c.length-8){c=!1;break a}c=!0}c&&PFLY.ListenForChanges(a)})})};this.MarkChangedElements=function(a){if(l){a&&l.val(a);for(var a=l.val().split(","),b=!0,c=0;c<a.length;c++){var d=a[c];d&&d.length>2&&(d=d.substring(1,d.length-1),b&&(n&&n.addClass("Active"),b=!1),o(jQuery("#"+d)))}}};this.AdjustContainerHeights=function(){jQuery(function(){function a(){try{var a=jQuery(".DoMaxHeight"),d=jQuery(".DoMaxWidth"),k=jQuery(window).width(),g=jQuery("#NodeMenuContainer"),f=jQuery(".Pf_Content"),j=jQuery("#Pf_Footer"),
h=jQuery("#Pf_AdminBottom").offset().top,m=j.height();c&&(h+=15);b&&j.children().length>0&&j.show();var l=f.offset().left,n=f.offset().top;g.length>0&&g.height(h-g.offset().top);a.each(function(){var a=jQuery(this);a.height(h-a.offset().top-m-1)});d.each(function(){var a=jQuery(this);a.width(k-a.offset().left)});f.height(h-n-m);f.width(k-l)}catch(q){}b&&jQuery("body").css("visibility","visible");b=!1}var b=!0,c=PFLY.IsIE6(),d=null;c?setTimeout(a,200):(a(),jQuery.browser.msie&&setTimeout(a,100));jQuery(window).resize(function(){c?
(clearTimeout(d),d=setTimeout(a,200)):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!0})})};this.IsFlashPlayerInstalled=function(){var a=navigator.appVersion.indexOf("MSIE")!=-1?!0:!1,b=navigator.appVersion.toLowerCase().indexOf("win")!=
-1?!0:!1,c=navigator.userAgent.indexOf("Opera")!=-1?!0:!1,d=this.ResourceStrings.RequiredFlashVersion.split(".");return function(d,i,k){var g;g=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){g=navigator.plugins["Shockwave Flash"+(navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"")].description.split(" ");var f=g[2].split("."),j=f[0],f=f[1],h=g[3];h==""&&(h=g[4]);h[0]=="d"?h=h.substring(1):h[0]=="r"&&(h=
h.substring(1),h.indexOf("d")>0&&(h=h.substring(0,h.indexOf("d"))));g=j+"."+f+"."+h}}else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.6")!=-1)g=4;else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.5")!=-1)g=3;else if(navigator.userAgent.toLowerCase().indexOf("webtv")!=-1)g=2;else if(a&&b&&!c){try{f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"),j=f.GetVariable("$version")}catch(m){}if(!j)try{f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"),j="WIN 6,0,21,0",f.AllowScriptAccess=
"always",j=f.GetVariable("$version")}catch(l){}if(!j)try{f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"),j=f.GetVariable("$version")}catch(n){}if(!j)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"),j="WIN 3,0,18,0"}catch(q){}if(!j)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash"),j="WIN 2,0,0,11"}catch(o){j=-1}g=j}if(g==-1)return!1;else if(g!=0){a&&b&&!c?(tempArray=g.split(" "),tempString=tempArray[1],versionArray=tempString.split(",")):versionArray=g.split(".");g=versionArray[0];
j=versionArray[1];f=versionArray[2];if(g>parseFloat(d))return!0;else if(g==parseFloat(d))if(j>parseFloat(i))return!0;else if(j==parseFloat(i)&&f>=parseFloat(k))return!0;return!1}}(d[0],d[1]!=void 0?d[1]:"0",d[2]!=void 0?d[2]:"0")};this.CloseDialog=function(){if(window.opener&&!window.opener.closed)window.opener.focus(),window.close();else if(window.parent){var a=window.parent.jQuery(".UrlDialog");a.find(".UrlDialogIFrame").attr("src","");a.dialog("close")}};this.DisableInputWhileProcessing=function(a,
b){jQuery(function(){function c(){jQuery(b).dialog({modal:!0,resizable:!1,draggable:!1,dialogClass:"DisableInputWhileProcessingDialog"})}jQuery("form").each(function(){var b=this,e=b.onsubmit;this.onsubmit=function(){var i=!0;if(b!=null){if(e!=null&&typeof e=="function")with(b)i=e();i&&(setTimeout(c,a),b=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:!0,
modal:!0,autoOpen:!0,closeOnEscape:!0,resizable:!1,minWidth:0,minHeight:0,title:a,close:function(){i.dialog("destroy");i.remove()}};if(b!=null&&b.length>100)b=jQuery(window),a.width=Math.min(b.width()-10,800),a.height="auto";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.OpenFlashTask=function(a,b,c,d,e,i){function k(){window.open(g,e,"status=yes,resizable=yes")}var g=a;if(e==void 0||e.lenght==0)e="FlashApplication";i==void 0&&(i="Reload");g+=g.indexOf("?")>=0?"&cb="+i:"?cb="+i;g+="&id="+b;g+="&node="+d;g+="&taskId="+c;jQuery.browser.mozilla?setTimeout(k,0):k()};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(){i.closed&&(window.clearInterval(k),eval(d))},1E3);i.focus&&i.focus();return i}else{var g=!1,f=jQuery("body"),j=f.css("overflow");f.css("overflow","hidden");var h=jQuery("<div class='UrlDialog' style='display:none;'></div>"),m=jQuery('<iframe class="UrlDialogIFrame"  style="display:none;" marginheight="0" marginwidth="0" frameborder="0" src="'+
a+'"></iframe>');h.append(m);var l=null,n=function(){if(l!=null)try{return l()}catch(a){}return!0},q=function(){m.height(h.height());m.width(h.width());m.show()},o=function(){g||(g=!0,h.dialog("open"),q())},p=!1;h.dialog({bgiframe:!0,modal:!0,autoOpen:!1,closeOnEscape:!1,resizable:!0,minHeight:0,minWidth:0,height:c+40,width:b+30,resizeStart:function(){m.hide()},resizeStop:q,dragStart:function(){m.hide()},dragStop:function(){m.show()},close:function(){n()&&(m.attr("src",""),h.dialog("destroy"),h.remove(),
f.css("overflow",j),d&&eval(d))},beforeClose:n});m.load(function(){var a=this.contentWindow;if(!p){p=!0;if(typeof a.DialogCloseAccepted=="function")l=a.DialogCloseAccepted;if(typeof a.DialogOptions=="function"){var a=a.DialogOptions(),d=null,e=null;a.width&&(d=a.width+30,d>b&&(d=null));a.height&&(e=a.height+40,e>c&&(e=null));if(d||e)m.hide(),d&&h.dialog("option","width",d),e&&h.dialog("option","height",e),h.dialog("option","position","center"),g&&q();a.title&&h.dialog("option","title",a.title)}o()}});
setTimeout(o,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)PFLY.DateSelectedTarget=jQuery("#"+b),b=PFLY.DateSelectedTarget.attr("value"),c=PFLY.DateSelectedTarget.is(":enabled")?"PFLY.DateSelectedCallback":null;a+="?SelectedDate="+b;c!=null&&(a+="&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 s(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");for(var a=!1,d=d.rows,e=0;e<d.length;e++){var i=a?b:c,a=!a,k=d[e];if(!r(k)&&!k.style.backgroundColor)for(var k=k.cells,g=0;g<k.length;g++){var f=k[g];if(!r(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(b){var e=c.offset();(b.pageX<e.left||b.pageX>e.left+c.outerWidth()||b.pageY<e.top||b.pageY>e.top+c.outerHeight())&&PFLY.HideDropDownList(a);return!0})};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==void 0)c=this.ResourceStrings.CurrentLanguageId;for(var a=a.substr(5).split("|"),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}}b!=null&&(b=b.replace("|","?").replace(c+"]","?"));b="["+c+" "+b+" "+c+"]";d>=0?a[d]=b: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 a=" style='width:"+b.css("width")+";height:"+b.css("height")+"'",c=b.attr("rows")==
void 0,g=c?null:" rows='"+b.attr("rows")+"' cols='"+b.attr("rows")+"'",f="<table class='LdtInputDialog'>",j=0;j<d.length;j++){var h=d[j];f+="<tr>";f+="<td>";f+=h.name;f+="</td><td>";c?(f+="<input type='text'",f+=" id='langinput-",f+=h.id+"'",f+=" value='",f+=PFLY.LdtGet(e,h.id)+"'",f+=a,f+=" />"):(f+="<textarea",f+=" id='langinput-",f+=h.id+"'",f+=a,f+=g,f+=">",f+=PFLY.LdtGet(e,h.id),f+="</textarea>");f+="</td></tr>"}f+="</table>";return f}(),null,function(){var i={};i[PFLY.ResourceStrings.OkButton]=
function(){for(var i=0;i<d.length;i++){var g=d[i],f=jQuery("#langinput-"+g.id);e=PFLY.LdtSet(e,f.val(),g.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};
