/* Copyright (C) 2009 Microsoft Corporation */var _de=document.documentElement,_deScr=$Browser.isSafari()?document.body:document.documentElement;window.Function.KillEvent=function(){event.cancelBubble=true;event.returnValue=false;return false};registerNamespace("$UI");$UI.Dialog=function(m){var z=document.body.className.indexOf("rtl")>-1,c,f,t=this,e=new $Memory.Groups,a=null,l=null,i=null,p=null,s=document.body,g,j,B,d,u,h=null,b;function k(){if(c){var a=c.style,b=$Browser._isIE&&$Browser.version==7?f.offsetLeft/100:1;a.width=_deScr.scrollWidth-3+"px";a.pixelTop=Math.max(0,_deScr.scrollTop/b);a.pixelHeight=_de.clientHeight/b}}function r(){var b;if(null!=window["event"]&&event.srcElement==g)b=o(a,j,false);else b=o(a,g,true);if(b)setTimeout(function(){try{b.focus()}catch(a){}},0)}function o(b,a,c){function g(a){function c(a){while(a&&a.currentStyle&&a.currentStyle.display!="none"&&a.currentStyle.visibility!="hidden")a=a.parentNode;if(!a||!a.currentStyle)return true;return false}var b="BUTTON|TEXTAREA|FIELDSET|IFRAME|SELECT|";return a.tagName&&!a.disabled&&(b.indexOf(a.tagName+"|")>-1||a.tagName=="A"&&a.href||a.tagName=="INPUT"&&(!$Browser.isMozilla()||a.type.toLowerCase()!="file")&&c(a))}function d(b){if(!b)return null;var a=c?b.nextSibling:b.previousSibling;while(a&&a.nodeType!=1)a=c?a.nextSibling:a.previousSibling;if(!a)return d(b.parentNode);else return a}function f(b,e){var a=e;if(a&&b.contains(a))while(a!=null)if(!g(a))if(c&&a.firstChild)a=a.firstChild;else if(!c&&a.lastChild)a=a.lastChild;else a=d(a);else return a;return null}if(a)a=d(a);else a=b;var e=f(b,a);if(!e&&a&&a!=b)return f(b,b);else return e}this.dispose=function(){if(h){clearTimeout(h);h=null}if(e){e.dispose();e=null}b=null;c=null;f=null;g=null;j=null};this.setContents=function(k){e.create(null).dispose();var b=e.create(null);a=k;var h=a.parentNode;if(null==h||null==h.tagName){s.appendChild(a);b.Nodes.register(a)}var f={href:"#"},c={position:"absolute"},d=$Browser.isSafari()?"input":"a";j=b.Nodes.create(d,f,c,a);g=b.Nodes.create(d,f,c);if($Browser.isSafari())if(z)j.style.right=g.style.right="10000px";else j.style.left=g.style.left="-10000px";a.insertAdjacentElement("afterBegin",g);b.Events.register(j,{onfocus:r});b.Events.register(g,{onfocus:r});a.style.position="absolute";if(!m&&$Browser._isIE&&$Browser.version<=6){l=new $UI.FramePopup;b.Properties.register(l);p=new $UI.FramePopup;b.Properties.register(p)}i=b.Nodes.create("div",{},c,a.parentElement);i.className="UI_Dialog_Shadow";y();return a};var n=function(c,d,b,a){return {x:c,y:d,width:b,height:a,isEmpty:function(){return this.width<=0||this.height<=0}}};function q(a){if(!a)return new n(0,0,0,0);return new n(a.offsetLeft,a.offsetTop,a.offsetWidth,a.offsetHeight)}this.recalc=function(g){if(!a)return;if(h){clearTimeout(h);h=null}k();var b=a.style,c=q(a);if(!c||c.isEmpty()){var f={visibility:a.currentStyle.visibility||b.visibility||"visible",display:a.currentStyle.display||b.display||"auto"};b.visibility="hidden";b.display="block";c=q(a);b.display=f.display;b.visibility=f.visibility}if(!d)d=new n(0,0,0,0);d.x=Math.max(_de.clientWidth/2-c.width/2,25);if(g){var e=_de.clientHeight-c.height-3;d.y=_deScr.scrollTop+Math.min(Math.max(e>200?e:(_de.clientHeight-c.height)/2,0),100)}d.height=c.height;d.width=c.width;b.pixelTop=d.y;b.pixelLeft=d.x;if(l)l.positionAt(d,1e3);x(true)};function x(f){var e=q(a).height;if(e!=u||f){var b=new n,c=i.style;c.width=(b.width=d.width)+"px";c.height=(b.height=e)+"px";c.left=(b.x=d.x+(z?-3:3))+"px";c.top=(b.y=d.y+3)+"px";if(l)p.positionAt(b,1e3);u=e}h=setTimeout(x,25)}this.show=function(){i.style.backgroundColor="#000";A(i,30);t.recalc(true);a.style.display="block";if(m){var d=e.create("show");c=_ce("div");v();f=_ce("div");f.className="UI_Dialog_ZoomTest";c.className=c.id="UI_Dialog_BG";c.style.position="absolute";s.appendChild(c);s.appendChild(f);var b=Function.KillEvent;d.Events.register(c,{onfocus:r,onclick:b,onmousedown:b,onkeydown:b,onkeypress:b,ondblclick:b});d.Events.register(window,{onresize:k,onfocus:b});d.Nodes.register(c);d.Nodes.register(f);k()}function g(){try{o(a).focus()}catch(b){}}setTimeout(g,10)};this.hide=function(){e.create("show").dispose();e.create("ext").dispose();if($Browser._isIE&&$Browser.version<=6)if(b){for(var a=0;a<b.length;a++)if(typeof b[a].wlppHide!="undefined")b[a].style.visibility=b[a].wlppHide;b=null}};this.minimize=function(){i.style.display="none";a.style.visibility="hidden";if(m){c.style.display="none";f.style.display="none";if(b)for(var d=0;d<b.length;d++)b[d].style.visibility=b[d].wlppHide;k()}};this.restore=function(){i.style.display="block";a.style.visibility="visible";t.recalc(true);if(m){c.style.display="block";f.style.display="block";v();k()}};function A(b,a){var c="undefined"==typeof b.style.filter?"opacity":"filter";b.style[c]=c=="filter"?"alpha(opacity="+a+")":.01*a}function y(){e.create("ext").Events.register(window,{onresize:w,onscroll:w})}function w(){e.create("ext").dispose();t.recalc(false);y()}function v(){if($Browser._isIE&&$Browser.version<=6){b=document.getElementsByTagName("select");var e=a.getElementsByTagName("select");for(var c=0;c<b.length;c++){var f=false;for(var d=0;d<e.length;d++)if(b[c]==e[d]){f=true;break}if(!f){b[c].wlppHide=b[c].style.visibility;b[c].style.visibility="hidden"}}}}};$UI.Popover=function(){this.header=null;this.body=null;this.footerText=null;this.width=300;this.bodyPadding=true;this.showHeader=true;this.showFooter=true;this.modal=false;this.addButton=function(e,c,a,b){d.push({name:e,value:c,isDefault:a,isCancel:b})};this.show=function(u,t){if(e)return;p=u;o=t;if(!a){a=new $UI.Dialog(b.modal);c=_ce("div");c.style.display="none";c.innerHTML="<div><h3></h3></div><div></div><div><nobr></nobr></div>";a.setContents(c);r();c.className="UI_Popover";var s=c.childNodes;h=s[1];i=s[2];g=s[3];n=h.firstChild;k=g.firstChild;h.className=" Header";i.className=" Body";g.className=" Footer";var m=b.width;c.style.width=parseInt(m,10)==m?m+"px":m;q=null;j=null;f=[];for(var l=0;l<d.length;l++)w(d[l].name,d[l].value,d[l].isDefault,d[l].isCancel);if(d.length==0)b.showFooter=false;y()}a.show();e=true};this.hide=function(){if(!e)return;if(o)setTimeout(x,10);try{l.dispose();m.dispose();a.hide();a.dispose()}catch(b){}e=false;c=h=g=i=n=k=f=null};this.enableButton=function(a){f[a].disabled=false};this.disableButton=function(a){f[a].disabled=true};function x(){try{o.focus()}catch(a){}}function r(){l.Events.register(this.modal?document.body:c,$Browser.isSafari()?{onkeydown:u}:{onkeypress:u})}function v(){l.Events.dispose()}function w(b,g,c,e){k.appendChild(document.createTextNode(" "));var d=_ce("div");d.innerHTML='<button id="popover_btn_{0}" type="{1}" />'.format(b,c?"submit":"button");var a=d.firstChild;m.Nodes.register(a);if(c){a.className+="Default";q=b}else if(e)j=b;f[b]=a;a.innerHTML="<nobr>"+g+"</nobr>";m.Events.register(a,{onclick:function(a){s(b);a.returnValue=false}});k.appendChild(a)}function u(a){switch(($Browser.isSafari()?a:event).keyCode){case 27:s(j?j:"$cancel")}}function s(c){var a=true;if(p)a=p(b,c);if(a)b.hide();event.returnValue=false}function y(){function a(a,b){if(a)if(typeof a=="string")b.innerHTML=a;else{b.innerHTML="";b.appendChild(a)}}h.style.display=b.showHeader?"block":"none";g.style.display=b.showFooter?"block":"none";if(!b.bodyPadding)i.style.padding="0";a(b.header,n);a(b.body,i)}this.recalc=function(){if(!e)return;if(a)a.recalc(false)};this.minimize=function(){if(!a||!e)return;a.minimize();v()};this.restore=function(){if(!a||!e)return;a.restore();r()};var e=false,a,b=this,h,i,g,n,k,q,j,t=new $Memory.Groups,m=t.create("show"),l=t.create("showHide"),f,c,d=[],p=null,o=null}