/* Copyright (C) 2010 Microsoft Corporation */var _de=document.documentElement,_deScr=$B.RE_WebKit?document.body:document.documentElement;window.Function.KillEvent=function(){event.cancelBubble=true;event.returnValue=false;return false};registerNamespace("$UI");$UI.Dialog=function(o,e){var v=document.body.className.indexOf("rtl")>-1,c,h,u=this,f=new $Memory.Groups,a=null,g=null,j=null,l=null,t=document.body,i,m,C,d,w,k=null,b;if(e&&e<5)e=5;function n(){if(c){var b=c.style,a=$B.IE&&$B.V==7?h.offsetLeft/100:1;if(a==0)a=1;b.width=_deScr.scrollWidth/a-3+"px";b.pixelTop=Math.max(0,_deScr.scrollTop/a);b.pixelHeight=_de.clientHeight/a}}function s(){var b;if(null!=window["event"]&&event.srcElement==i)b=q(a,m,false);else b=q(a,i,true);if(b)setTimeout(function(){try{b.focus()}catch(a){}},0)}function q(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"&&(!$B.Firefox||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(k){clearTimeout(k);k=null}if(f){f.dispose();f=null}b=null;c=null;h=null;i=null;m=null};this.setContents=function(k){f.create(null).dispose();var b=f.create(null);a=k;var h=a.parentNode;if(null==h||null==h.tagName){t.appendChild(a);b.Nodes.register(a)}var e={href:"#"},c={position:"absolute"},d=$B.RE_WebKit?"input":"a";m=b.Nodes.create(d,e,c,a);i=b.Nodes.create(d,e,c);if($B.RE_WebKit)if(v)m.style.right=i.style.right="10000px";else m.style.left=i.style.left="-10000px";a.insertAdjacentElement("afterBegin",i);b.Events.register(m,{onfocus:s});b.Events.register(i,{onfocus:s});a.style.position="absolute";if(!o&&$B.IE&&$B.V<7){g=new $UI.FramePopup;b.Properties.register(g);l=new $UI.FramePopup;b.Properties.register(l)}j=b.Nodes.create("div",{},c,a.parentElement);j.className="UI_Dialog_Shadow";A();return a};var p=function(c,d,b,a){return {x:c,y:d,width:b,height:a,isEmpty:function(){return this.width<=0||this.height<=0}}};function r(a){if(!a)return new p(0,0,0,0);return new p(a.offsetLeft,a.offsetTop,a.offsetWidth,a.offsetHeight)}this.recalc=function(j){if(!a)return;if(k){clearTimeout(k);k=null}n();var c=a.style,b=r(a);if(!b||b.isEmpty()){var i={visibility:a.currentStyle.visibility||c.visibility||"visible",display:a.currentStyle.display||c.display||"auto"};c.visibility="hidden";c.display="block";b=r(a);c.display=i.display;c.visibility=i.visibility}if(!d)d=new p(0,0,0,0);var h=_de.clientWidth/2-b.width/2;if(v)d.x=Math.min(h,0-(b.width-_de.clientWidth)-25);else d.x=Math.max(h,25);if(j){var f=_de.clientHeight-b.height-3;d.y=_deScr.scrollTop+Math.min(Math.max(f>200?f:(_de.clientHeight-b.height)/2,0),100)}d.height=b.height;d.width=b.width;c.pixelTop=d.y;c.pixelLeft=d.x;if(g)g.positionAt(d,e?1e3:e-2);z(true)};function z(h){var f=r(a).height;if(f!=w||h){var b=new p,c=j.style;c.width=(b.width=d.width)+"px";c.height=(b.height=f)+"px";c.left=(b.x=d.x+(v?-3:3))+"px";c.top=(b.y=d.y+3)+"px";if(g)l.positionAt(b,e?1e3:e-2);w=f}k=setTimeout(z,25)}this.show=function(g,i){j.style.backgroundColor="#000";B(j,30);u.recalc(true);a.style.display="block";if(e){j.style.zIndex=e-1;a.style.zIndex=e}if(o){var d=f.create("show");c=_ce("div");x();h=_ce("div");h.className="UI_Dialog_ZoomTest";c.className=c.id="UI_Dialog_BG";c.style.position="absolute";if(e)c.style.zIndex=e-1;t.appendChild(c);t.appendChild(h);var b=Function.KillEvent;d.Events.register(c,{onfocus:s,onclick:b,onmousedown:b,onkeydown:b,onkeypress:b,ondblclick:b});d.Events.register(window,{onresize:n,onfocus:b});d.Nodes.register(c);d.Nodes.register(h);n()}function k(){try{(g?g:q(a)).focus()}catch(b){}}if(!i)setTimeout(k,10)};this.hide=function(){f.create("show").dispose();f.create("ext").dispose();if($B.IE&&$B.V<7)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(){j.style.display="none";if(g)g.minimize();if(l)l.minimize();a.style.visibility="hidden";if(o){c.style.display="none";h.style.display="none";if(b)for(var d=0;d<b.length;d++)b[d].style.visibility=b[d].wlppHide;n()}};this.restore=function(){j.style.display="block";a.style.visibility="visible";if(g)g.restore();if(l)l.restore();u.recalc(true);if(o){c.style.display="block";h.style.display="block";x();n()}};function B(b,a){var c="undefined"==typeof b.style.filter?"opacity":"filter";b.style[c]=c=="filter"?"alpha(opacity="+a+")":.01*a}function A(){f.create("ext").Events.register(window,{onresize:y,onscroll:y})}function y(){f.create("ext").dispose();u.recalc(false);A()}function x(){if($B.IE&&$B.V<7){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.zIndex=null;this.addButton=function(e,c,a,b){d.push({name:e,value:c,isDefault:a,isCancel:b})};this.show=function(w,u,s,t){if(e)return;p=w;o=u;if(!a){a=new $UI.Dialog(b.modal,b.zIndex);c=_ce("div");c.style.display="none";c.innerHTML="<div><h3></h3></div><div></div><div><nobr></nobr></div>";a.setContents(c);q();c.className="UI_Popover";var r=c.childNodes;h=r[1];i=r[2];g=r[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;j=null;f=[];for(var l=0;l<d.length;l++)v(d[l].name,d[l].value,d[l].isDefault,d[l].isCancel);if(d.length==0)b.showFooter=false;x()}a.show(s?f[s]:null,t);e=true};this.hide=function(){if(!e)return;if(o)setTimeout(w,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 w(){try{o.focus()}catch(a){}}function q(){l.Events.register(this.modal?document.body:c,$B.RE_WebKit?{onkeydown:t}:{onkeypress:t})}function u(){l.Events.dispose()}function v(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";else if(e)j=b;f[b]=a;a.innerHTML="<nobr>"+g+"</nobr>";m.Events.register(a,{onclick:function(a){r(b);a.returnValue=false}});k.appendChild(a)}function t(a){switch(($B.RE_WebKit?a:event).keyCode){case 27:r(j?j:"$cancel")}}function r(c){var a=true;if(p)a=p(b,c);if(a)b.hide();event.returnValue=false}function x(){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();u()};this.restore=function(){if(!a||!e)return;a.restore();q()};var e=false,a,b=this,h,i,g,n,k,j,s=new $Memory.Groups,m=s.create("show"),l=s.create("showHide"),f,c,d=[],p=null,o=null};$UI.MsgBoxEx=function(p,l,i,f,q,g,h,j,n){var e="ok",b="cancel",a=new $UI.Popover,k=_ce("div"),o=function(f,d){var c=true;if(d==e){if(q({Popover:f})==false)c=false}else if(d==b&&!!g)g();if(c)a=null;return c};if(h){var c=temp=h;for(var m=0;m<10&&temp;m++){var d=temp.tagName.toLowerCase();if(d=="a"||d=="button"||d=="input"){c=temp;break}temp=temp.parentElement;if(!temp){c=null;break}}}if(l)k.innerHTML='<div style="margin-bottom:10px">'+l+"</div>";a.width=j?j:"416px";a.header=p;a.body=k;a.modal=true;if(i!=false)a.addButton(e,i,true,false);if(f!=false)a.addButton(b,f,false,true);a.show(o,c,n?b:null)};$UI.MsgBox=function(d,e,c,a,b,f){$UI.MsgBoxEx(d,e,c,a,f,null,b,null,false)}