text: Type.registerNamespace("Sys.Extended.UI"),Sys.Extended.UI.PopupBehavior=function(e){Sys.Extended.UI.PopupBehavior.initializeBase(this,[e]),this._x=0,this._y=0,this._positioningMode=Sys.Extended.UI.PositioningMode.Absolute,this._parentElement=null,this._parentElementID=null,this._moveHandler=null,this._firstPopup=!0,this._originalParent=null,this._visible=!1,this._unselectable=null,this._onShow=null,this._onHide=null,this._onShowEndedHandler=Function.createDelegate(this,this._onShowEnded),this._onHideEndedHandler=Function.createDelegate(this,this._onHideEnded)},Sys.Extended.UI.PopupBehavior.prototype={initialize:function(){Sys.Extended.UI.PopupBehavior.callBaseMethod(this,"initialize"),this._hidePopup(),this.get_element().style.position="absolute"},dispose:function(){var e=this.get_element();e&&(this._visible&&this.hide(),this._originalParent&&(e.parentNode.removeChild(e),this._originalParent.appendChild(e),this._originalParent=null),e._hideWindowedElementsIFrame=null),this._parentElement=null,this._onShow&&this._onShow.get_animation()&&this._onShow.get_animation().remove_ended(this._onShowEndedHandler),this._onShow=null,this._onHide&&this._onHide.get_animation()&&this._onHide.get_animation().remove_ended(this._onHideEndedHandler),this._onHide=null,Sys.Extended.UI.PopupBehavior.callBaseMethod(this,"dispose")},show:function(){if(!this._visible){var e=new Sys.CancelEventArgs;if(this.raise_showing(e),!e.get_cancel()){this._visible=!0;var t=this.get_element();$common.setVisible(t,!0),this.setupPopup(),this._onShow?($common.setVisible(t,!1),this.onShow()):this.raise_shown(Sys.EventArgs.Empty)}}},hide:function(){if(this._visible){var e=new Sys.CancelEventArgs;this.raise_hiding(e),e.get_cancel()||(this._visible=!1,this._onHide?this.onHide():(this._hidePopup(),this._hideCleanup()))}},getBounds:function(){var e,t,n=this.get_element(),i=n.offsetParent||document.documentElement;if(this.get_parentElement()){t=$common.getBounds(this.get_parentElement());var o=$common.getLocation(i);e={x:t.x-o.x,y:t.y-o.y}}else t=$common.getBounds(i),e={x:0,y:0};var s=n.offsetWidth-(n.clientLeft?2*n.clientLeft:0),d=n.offsetHeight-(n.clientTop?2*n.clientTop:0);this._firstpopup&&(n.style.width=s+"px",this._firstpopup=!1);var h,r;switch(this._positioningMode){case Sys.Extended.UI.PositioningMode.Center:r={x:Math.round(t.width/2-s/2),y:Math.round(t.height/2-d/2),altX:Math.round(t.width/2-s/2),altY:Math.round(t.height/2-d/2)};break;case Sys.Extended.UI.PositioningMode.BottomLeft:r={x:0,y:t.height,altX:t.width-s,altY:0-d};break;case Sys.Extended.UI.PositioningMode.BottomRight:r={x:t.width-s,y:t.height,altX:0,altY:0-d};break;case Sys.Extended.UI.PositioningMode.TopLeft:r={x:0,y:-n.offsetHeight,altX:t.width-s,altY:t.height};break;case Sys.Extended.UI.PositioningMode.TopRight:r={x:t.width-s,y:-n.offsetHeight,altX:0,altY:t.height};break;case Sys.Extended.UI.PositioningMode.Right:r={x:t.width,y:0,altX:-n.offsetWidth,altY:t.height-d};break;case Sys.Extended.UI.PositioningMode.Left:r={x:-n.offsetWidth,y:0,altX:t.width,altY:t.height-d};break;default:r={x:0,y:0,altX:0,altY:0}}return r.x+=this._x+e.x,r.altX+=this._x+e.x,r.y+=this._y+e.y,r.altY+=this._y+e.y,h=this._verifyPosition(r,s,d,t),new Sys.UI.Bounds(h.x,h.y,s,d)},_verifyPosition:function(e,t,n,i){var o=0,s=0,d=this._getWindowBounds();if(e.x+t>d.x+d.width||e.x<d.x){if(o=e.altX,e.altX<d.x)e.x>e.altX&&(o=e.x);else if(d.width+d.x-e.altX<t){var h=e.x>e.altX?Math.abs(d.x-e.x):d.x-e.x;h<t-d.width-d.x+e.altX&&(o=e.x)}}else o=e.x;return e.y+n>d.y+d.height||e.y<d.y?(s=e.altY,e.altY<d.y?d.y-e.altY>n-d.height-d.y+e.y&&(s=e.y):d.height+d.y-e.altY<n&&d.y-e.y<n-d.height-d.y+e.altY&&(s=e.y)):s=e.y,{x:o,y:s}},_getWindowBounds:function(){var e={x:this._getWindowScrollLeft(),y:this._getWindowScrollTop(),width:this._getWindowWidth(),height:this._getWindowHeight()};return e},_getWindowHeight:function(){var e=0;return document.documentElement&&document.documentElement.clientHeight?e=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(e=document.body.clientHeight),e},_getWindowWidth:function(){var e=0;return document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),e},_getWindowScrollTop:function(){var e=0;return"number"==typeof window.pageYOffset&&(e=window.pageYOffset),document.body&&document.body.scrollTop?e=document.body.scrollTop:document.documentElement&&document.documentElement.scrollTop&&(e=document.documentElement.scrollTop),e},_getWindowScrollLeft:function(){var e=0;return"number"==typeof window.pageXOffset?e=window.pageXOffset:document.body&&document.body.scrollLeft?e=document.body.scrollLeft:document.documentElement&&document.documentElement.scrollLeft&&(e=document.documentElement.scrollLeft),e},adjustPopupPosition:function(e){var t=this.get_element();e||(e=this.getBounds());var n=$common.getBounds(t),i=!1;n.x<0&&(e.x-=n.x,i=!0),n.y<0&&(e.y-=n.y,i=!0),i&&$common.setLocation(t,e)},addBackgroundIFrame:function(){var e=this.get_element();if(Sys.Browser.agent===Sys.Browser.InternetExplorer&&Sys.Browser.version<7){var t=e._hideWindowedElementsIFrame;t||(t=document.createElement("iframe"),t.src="javascript:'<html></html>';",t.style.position="absolute",t.style.display="none",t.scrolling="no",t.frameBorder="0",t.tabIndex="-1",t.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)",e.parentNode.insertBefore(t,e),e._hideWindowedElementsIFrame=t,this._moveHandler=Function.createDelegate(this,this._onMove),Sys.UI.DomEvent.addHandler(e,"move",this._moveHandler)),$common.setBounds(t,$common.getBounds(e)),t.style.left=e.style.left,t.style.top=e.style.top,t.style.display=e.style.display,e.currentStyle&&e.currentStyle.zIndex?t.style.zIndex=e.currentStyle.zIndex:e.style.zIndex&&(t.style.zIndex=e.style.zIndex)}},setupPopup:function(){var e=this.get_element(),t=this.getBounds();$common.setLocation(e,t),this.adjustPopupPosition(t),e.style.zIndex=Sys.Extended.UI.zIndex.Popup,this.addBackgroundIFrame()},_hidePopup:function(){var e=this.get_element();$common.setVisible(e,!1),e.originalWidth&&(e.style.width=e.originalWidth+"px",e.originalWidth=null)},_hideCleanup:function(){var e=this.get_element();if(this._moveHandler&&(Sys.UI.DomEvent.removeHandler(e,"move",this._moveHandler),this._moveHandler=null),Sys.Browser.agent===Sys.Browser.InternetExplorer){var t=e._hideWindowedElementsIFrame;t&&(t.style.display="none")}this.raise_hidden(Sys.EventArgs.Empty)},_onMove:function(){var e=this.get_element();e._hideWindowedElementsIFrame&&(e.parentNode.insertBefore(e._hideWindowedElementsIFrame,e),e._hideWindowedElementsIFrame.style.top=e.style.top,e._hideWindowedElementsIFrame.style.left=e.style.left)},get_onShow:function(){return this._onShow?this._onShow.get_json():null},set_onShow:function(e){this._onShow||(this._onShow=new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element()),this._onShow.initialize()),this._onShow.set_json(e);var t=this._onShow.get_animation();t&&t.add_ended(this._onShowEndedHandler),this.raisePropertyChanged("onShow")},get_onShowBehavior:function(){return this._onShow},onShow:function(){this._onShow&&(this._onHide&&this._onHide.quit(),this._onShow.play())},_onShowEnded:function(){this.adjustPopupPosition(),this.addBackgroundIFrame(),this.raise_shown(Sys.EventArgs.Empty)},get_onHide:function(){return this._onHide?this._onHide.get_json():null},set_onHide:function(e){this._onHide||(this._onHide=new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element()),this._onHide.initialize()),this._onHide.set_json(e);var t=this._onHide.get_animation();t&&t.add_ended(this._onHideEndedHandler),this.raisePropertyChanged("onHide")},get_onHideBehavior:function(){return this._onHide},onHide:function(){this._onHide&&(this._onShow&&this._onShow.quit(),this._onHide.play())},_onHideEnded:function(){this._hideCleanup()},get_parentElement:function(){return!this._parentElement&&this._parentElementID&&this.set_parentElement($get(this._parentElementID)),this._parentElement},set_parentElement:function(e){this._parentElement=e,this.raisePropertyChanged("parentElement")},get_parentElementID:function(){return this._parentElement?this._parentElement.id:this._parentElementID},set_parentElementID:function(e){this._parentElementID=e,this.get_isInitialized()&&this.set_parentElement($get(e))},get_positioningMode:function(){return this._positioningMode},set_positioningMode:function(e){this._positioningMode=e,this.raisePropertyChanged("positioningMode")},get_x:function(){return this._x},set_x:function(e){e!=this._x&&(this._x=e,this._visible&&this.setupPopup(),this.raisePropertyChanged("x"))},get_y:function(){return this._y},set_y:function(e){e!=this._y&&(this._y=e,this._visible&&this.setupPopup(),this.raisePropertyChanged("y"))},get_visible:function(){return this._visible},add_showing:function(e){this.get_events().addHandler("showing",e)},remove_showing:function(e){this.get_events().removeHandler("showing",e)},raise_showing:function(e){var t=this.get_events().getHandler("showing");t&&t(this,e)},raiseShowing:function(e){Sys.Extended.Deprecated("raiseShowing(eventArgs)","raise_showing(eventArgs)"),this.raise_showing(e)},add_shown:function(e){this.get_events().addHandler("shown",e)},remove_shown:function(e){this.get_events().removeHandler("shown",e)},raise_shown:function(e){var t=this.get_events().getHandler("shown");t&&t(this,e)},raiseShown:function(e){Sys.Extended.Deprecated("raiseShown(eventArgs)","raise_shown(eventArgs)"),this.raise_shown(e)},add_hiding:function(e){this.get_events().addHandler("hiding",e)},remove_hiding:function(e){this.get_events().removeHandler("hiding",e)},raise_hiding:function(e){var t=this.get_events().getHandler("hiding");t&&t(this,e)},raiseHiding:function(e){Sys.Extended.Deprecated("raiseHiding(eventArgs)","raise_hiding(eventArgs)"),this.raise_hiding(e)},add_hidden:function(e){this.get_events().addHandler("hidden",e)},remove_hidden:function(e){this.get_events().removeHandler("hidden",e)},raise_hidden:function(e){var t=this.get_events().getHandler("hidden");t&&t(this,e)},raiseHidden:function(e){Sys.Extended.Deprecated("raiseHidden(eventArgs)","raise_hidden(eventArgs)"),this.raise_hidden(e)},get_unselectable:function(){return this._unselectable},set_unselectable:function(e){this._unselectable=e,this.raisePropertyChanged("unselectable")}},Sys.Extended.UI.PopupBehavior.registerClass("Sys.Extended.UI.PopupBehavior",Sys.Extended.UI.BehaviorBase),Sys.Extended.UI.PositioningMode=function(){throw Error.invalidOperation()},Sys.Extended.UI.PositioningMode.prototype={Absolute:0,Center:1,BottomLeft:2,BottomRight:3,TopLeft:4,TopRight:5,Right:6,Left:7},Sys.Extended.UI.PositioningMode.registerEnum("Sys.Extended.UI.PositioningMode");