﻿var PFLY=new function(){function o(a){a&&a.addClass("InputChanged")}function p(a){if(l&&(a=a.attr("id"))&&0<a.length){var a="["+a+"]",b=l.attr("value");0>b.indexOf(a)&&(0==b.length?m&&m.addClass("Active"):b+=",",l.attr("value",b+a))}}function s(a){this.Run=function(){window.status="KeepSessionAlive #"+ ++PFLY.KeepSessionAliveCount;var b=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");b.onreadystatechange=function(){4==b.readyState&&200==b.status&&PFLY.KeepSessionAlive(a)};
b.open("GET",a+"/common/KeepSessionAlive.ashx",!0);b.send(null)}}function r(a){a=a.getAttributeNode("class");return null!=a?a.value:!1}var l,m;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");0<a.length&&a[0].focus()},100)})};this.EnableDefaultButton=function(a,b){jQuery(function(){var c=jQuery(b);0<c.length&&jQuery(a).keypress(function(a){if(13==a.which){try{var b=c.attr("onclick");null!=
b&&0<b.length?c.click():eval(c.attr("href"))}catch(i){}return!1}})})};this.InitDialogLinks=function(){jQuery(function(){jQuery("a").each(function(){var a=jQuery(this);"dialog"==a.attr("target")&&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);null==b&&(b=a.find(".GroupTogglerStateholderId").text());
null==c&&(c=a.find(".GroupTogglerContentId").text());var b=jQuery("#"+b),d="1"!=b.val();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",f);a.unbind("keypress",d);a.unbind("change",c);a.unbind("click",c)}function c(){b();return!0}function d(a){0!=a.which&&b();return!0}
function f(a){(8==a.which||46==a.which)&&b();return!0}a.bind("keydown",f);a.bind("keypress",d);a.bind("change",c);("checkbox"==a.attr("type")||"radio"==a.attr("type"))&&a.bind("click",c)};this.HighlightChangedElements=function(a){jQuery(function(){l=jQuery("#"+a);m=jQuery(".SaveButton");PFLY.MarkChangedElements();jQuery("input, textarea, select").each(function(){var a=jQuery(this),c;a:if(a.hasClass("NoHighlight")||a.parent().hasClass("NoHighlight")||"readonly"==a.attr("readonly")||"disabled"==a.attr("disabled"))c=
!1;else{if("checkbox"==a.attr("type")&&(c=a.attr("name"))&&8<=c.length&&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&&2<d.length&&(d=d.substring(1,d.length-1),b&&(m&&m.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"),e=jQuery(".Pf_Content"),j=jQuery("#Pf_Footer"),h=jQuery("#Pf_AdminBottom").offset().top,n=j.height();c&&(h+=15);b&&0<j.children().length&&j.show();var t=e.offset().left,l=e.offset().top;0<g.length&&g.height(h-g.offset().top);a.each(function(){var a=jQuery(this);a.height(h-a.offset().top-n-1)});d.each(function(){var a=jQuery(this);a.width(k-a.offset().left)});e.height(h-l-n);e.width(k-t)}catch(m){}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=null==a||""==a?jQuery(window):jQuery("#"+a),d=jQuery("#"+b);c.scrollTop(d.val());c.scroll(function(){d.val(c.scrollTop());
return!0})})};this.IsFlashPlayerInstalled=function(){var a=-1!=navigator.appVersion.indexOf("MSIE")?!0:!1,b=-1!=navigator.appVersion.toLowerCase().indexOf("win")?!0:!1,c=-1!=navigator.userAgent.indexOf("Opera")?!0:!1,d=this.ResourceStrings.RequiredFlashVersion.split(".");return function(d,i,k){var g;g=-1;if(null!=navigator.plugins&&0<navigator.plugins.length){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 e=g[2].split("."),j=e[0],e=e[1],h=g[3];""==h&&(h=g[4]);"d"==h[0]?h=h.substring(1):"r"==h[0]&&(h=h.substring(1),0<h.indexOf("d")&&(h=h.substring(0,h.indexOf("d"))));g=j+"."+e+"."+h}}else if(-1!=navigator.userAgent.toLowerCase().indexOf("webtv/2.6"))g=4;else if(-1!=navigator.userAgent.toLowerCase().indexOf("webtv/2.5"))g=3;else if(-1!=navigator.userAgent.toLowerCase().indexOf("webtv"))g=2;else if(a&&b&&!c){try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"),
j=e.GetVariable("$version")}catch(n){}if(!j)try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"),j="WIN 6,0,21,0",e.AllowScriptAccess="always",j=e.GetVariable("$version")}catch(l){}if(!j)try{e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"),j=e.GetVariable("$version")}catch(m){}if(!j)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"),j="WIN 3,0,18,0"}catch(o){}if(!j)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash"),j="WIN 2,0,0,11"}catch(q){j=-1}g=j}if(-1==g)return!1;if(0!=g){a&&
b&&!c?(tempArray=g.split(" "),tempString=tempArray[1],versionArray=tempString.split(",")):versionArray=g.split(".");g=versionArray[0];j=versionArray[1];e=versionArray[2];if(g>parseFloat(d))return!0;if(g==parseFloat(d)){if(j>parseFloat(i))return!0;if(j==parseFloat(i)&&e>=parseFloat(k))return!0}return!1}}(d[0],void 0!=d[1]?d[1]:"0",void 0!=d[2]?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,f=b.onsubmit;this.onsubmit=function(){var i=!0;if(null!=b){if(null!=f&&"function"==typeof f)with(b)i=f();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(null!=c)try{c.eval(a)}catch(d){c.alert("Executing '"+a+"' failed, error: "+d.Message)}};this.BuildUrl=function(a,b){for(var c=0<=a.indexOf("?")?"&":"?",d=1;d<arguments.length;d+=2)a+=c+arguments[d]+"="+escape(arguments[d+1]),c="&";return a};this.jQueryExist=function(){return"function"==typeof jQuery};this.useJQ=function(){return this.jQueryExist()};this.dialogNumber=0;this.ShowDialog=function(a,b,c,d){var f="DynamicDialog_"+this.dialogNumber++;
jQuery("body").append("<div id='"+f+"'><div class='"+c+"'>"+b+"</div></div>");var i=jQuery("#"+f),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(null!=b&&100<b.length)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&&"6.0"==jQuery.browser.version&&!window.XMLHttpRequest};this.OpenFlashTask=function(a,b,c,d,f,i){function k(){window.open(g,f,"status=yes,resizable=yes")}var g=a;if(void 0==f||0==f.lenght)f="FlashApplication";void 0==i&&(i="Reload");g=0<=g.indexOf("?")?g+("&cb="+i):g+("?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||1>b)b=jQuery(window).width()-
100;if(!c||1>c)c=jQuery(window).height()-100;if(this.IsIE6()){var f;f="width="+b+", height="+c+(", top="+(screen.height-c)/2+", left="+(screen.width-b)/2);var i=window.open(a,"_blank",f+", directories=no, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no");if(d)var k=null,k=window.setInterval(function(){i.closed&&(window.clearInterval(k),eval(d))},1E3);i.focus&&i.focus();return i}var g=!1,e=jQuery("body"),j=e.css("overflow");e.css("overflow","hidden");var h=jQuery("<div class='UrlDialog' style='display:none;'></div>"),
n=jQuery('<div style="display:none;"></div>'),l=jQuery('<iframe class="UrlDialogIFrame" marginheight="0" marginwidth="0" frameborder="0" src="'+a+'"></iframe>');n.append(l);h.append(n);var m=null,o=function(){if(null!=m)try{return m()}catch(a){}return!0},q=function(){l.height(h.height());l.width(h.width());n.show()},p=!1;l.load(function(){try{var a=this.contentWindow;if(!p){p=!0;var d;b:{try{if("not possible"==a.document.domain){d=!1;break b}}catch(e){d=!1;break b}d=!0}if(d){if("function"==typeof a.DialogCloseAccepted)m=
a.DialogCloseAccepted;if("function"==typeof a.DialogOptions){var f=a.DialogOptions();d=a=null;f.width&&(a=f.width+30,a>b&&(a=null));f.height&&(d=f.height+40,d>c&&(d=null));if(a||d)n.hide(),a&&h.dialog("option","width",a),d&&h.dialog("option","height",d),h.dialog("option","position","center"),g&&q();f.title&&h.dialog("option","title",f.title)}}}}catch(i){}g||(g=!0,h.dialog("open"),q())});h.dialog({bgiframe:!0,modal:!0,autoOpen:!1,closeOnEscape:!1,resizable:!0,minHeight:0,minWidth:0,height:c+40,width:b+
30,resizeStart:function(){n.hide()},resizeStop:q,dragStart:function(){n.hide()},dragStop:function(){n.show()},close:function(){o()&&(l.attr("src",""),h.dialog("destroy"),h.remove(),e.css("overflow",j),d&&eval(d))},beforeClose:o});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;null!=c&&(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,f=0;f<d.length;f++){var i=a?b:c,a=!a,k=d[f];if(!r(k)&&!k.style.backgroundColor)for(var k=
k.cells,g=0;g<k.length;g++){var e=k[g];if(!r(e)&&!e.style.backgroundColor)e.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 f=c.offset();(b.pageX<f.left||b.pageX>f.left+c.outerWidth()||b.pageY<
f.top||b.pageY>f.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(void 0==c)c=this.ResourceStrings.CurrentLanguageId;for(var a=a.substr(5).split("|"),d=-1,f=
0;f<a.length;f++){var i=a[f];if(i.length>c.length&&i.substr(1,c.length)==c){d=f;break}}null!=b&&(b=b.replace("|","?").replace(c+"]","?"));b="["+c+" "+b+" "+c+"]";0<=d?a[d]=b:a.push(b);return"|LDT|"+(1==a.length?a[0]:a.join("|"))};this.LdtGet=function(a,b){for(var c=a.substr(5).split("|"),d=0;d<c.length;d++){var f=c[d];if(f.length>=b.length&&f.substr(1,b.length)==b)return f.length>=2*(b.length+1)?f.substr(b.length+2,f.length-2*(b.length+2)):""}return""};this.LdtEdit=function(a,b){var c=this.ResourceStrings.CurrentLanguageId,
d=this.ResourceStrings.AciveLanguages,f=a.val();this.ShowDialog(this.ResourceStrings.LdtEditTitle,function(){for(var a=" style='width:"+b.css("width")+";height:"+b.css("height")+"'",c=void 0==b.attr("rows"),g=c?null:" rows='"+b.attr("rows")+"' cols='"+b.attr("rows")+"'",e="<table class='LdtInputDialog'>",j=0;j<d.length;j++){var h=d[j],e=e+"<tr>",e=e+"<td>",e=e+h.name,e=e+"</td><td>";c?(e+="<input type='text'",e+=" id='langinput-",e+=h.id+"'",e+=" value='",e+=PFLY.LdtGet(f,h.id)+"'",e+=a,e+=" />"):
(e+="<textarea",e+=" id='langinput-",e+=h.id+"'",e+=a,e+=g,e+=">",e+=PFLY.LdtGet(f,h.id),e+="</textarea>");e+="</td></tr>"}return e+"</table>"}(),null,function(){var i={};i[PFLY.ResourceStrings.OkButton]=function(){for(var i=0;i<d.length;i++){var g=d[i],e=jQuery("#langinput-"+g.id);f=PFLY.LdtSet(f,e.val(),g.id)}a.val(f);b.val(PFLY.LdtGet(f,c));PFLY.MarkAsChanged(b);jQuery(this).dialog("close")};i[PFLY.ResourceStrings.CancelButton]=function(){jQuery(this).dialog("close")};return i}())}};
function Papirfly(){return PFLY};
