﻿Type.registerNamespace("PhotoSite.Framework");PhotoSite.Framework.PopupControl=function(A){PhotoSite.Framework.PopupControl.initializeBase(this,[A]);this._popupContentsID=null;this._cancelControlID=null;this._okControlID=null;this._targetControlID=null;this._backgroundCssClass=null;this._modalBackground=null;this._visible=false;this._okHandler=Function.createDelegate(this,this._onOk);this._cancelHandler=Function.createDelegate(this,this._onCancel);this._showPopupHandler=Function.createDelegate(this,this._showPopup);this._resizeHandler=Function.createDelegate(this,this._onResize);this._scrollHandler=Function.createDelegate(this,this._onScroll);this._keyupHandler=Function.createDelegate(this,this._onKeyUp);this._keydownHandler=Function.createDelegate(this,this._onKeyDown);this._placePopupTimerTimeout=1;this._placePopupTimerId=null;this._placePopupTimerTickHandler=Function.createDelegate(this,this._onPlacePopupTimerTick);this._onOkScript=null;this._onCancelScript=null;this._onShowScript=null;this._escapeControlID=null;this._enterKeyControlID=null;this._onOkValidationGroup=null;this._doNotReposition=false;};PhotoSite.Framework.PopupControl.prototype={_savedSelectElements:null,_savedObjectElements:null,_showPopupEffectID:null,_hidePopupEffectID:null,_showEffect:null,_hideEffect:null,_hideElementsByTagName:function(C){var A=document.getElementsByTagName(C);for(var B=0;B<A.length;B++){var D=A.item(B);this._savedObjectElements.push({element:D,zIndex:D.style.zIndex});D.style.zIndex=0;}},_hideObjectElements:function(){this._savedObjectElements=[];this._hideElementsByTagName(Sys.Browser.agent===Sys.Browser.InternetExplorer?"OBJECT":"EMBED");},_restoreObjectElements:function(){for(var A=0;A<this._savedObjectElements.length;A++){var B=this._savedObjectElements[A];B.element.style.zIndex=B.zIndex;}this._savedObjectElements=null;},_hideSelectElements:function(){if((Sys.Browser.agent===Sys.Browser.InternetExplorer)&&(Sys.Browser.version>=7)){return;}var C=this._popupContentsID?$get(this._popupContentsID).getElementsByTagName("SELECT"):new Array();var G=document.getElementsByTagName("SELECT");this._savedSelectElements=new Array();for(var E=0;E<G.length;E++){var A=G[E];var B=false;for(var F=0;F<C.length;F++){if(A==C[F]){B=true;break;}}if(B){continue;}var D=A.style.visibility;if(D!="hidden"){this._savedSelectElements.push({element:A,visibility:D});A.style.visibility="hidden";}}},_restoreSelectElements:function(){if(!this._savedSelectElements){return;}for(var B=0;B<this._savedSelectElements.length;B++){var A=this._savedSelectElements[B];A.element.style.visibility=A.visibility;}this._savedSelectElements=null;},_onPlacePopupTimerTick:function(){this._placePopup();if(this._placePopupTimerId){this._placePopupTimerTimeout*=2;this._placePopupTimerId=setTimeout(this._placePopupTimerTickHandler,this._placePopupTimerTimeout);}},show:function(){this._showPopup();},hide:function(){this._hidePopup();},_stopEffects:function(){if(this._showEffect){this._showEffect.stop();this._showEffect=null;}if(this._hideEffect){this._hideEffect.stop();this._hideEffect=null;}},_onPopupHideEffectComplete:function(){this._hidePopupInternal();},_runShowPopupEffect:function(){this._stopEffects();if(this._showPopupEffectID){this._showEffect=$get(this._showPopupEffectID).Effect.createInstance($get(this._popupContentsID));this._showEffect.start();return true;}return false;},_runHidePopupEffect:function(){if(this._hideEffect){return true;}this._stopEffects();if(this._hidePopupEffectID){this._hideEffect=$get(this._hidePopupEffectID).Effect.createInstance($get(this._popupContentsID));this._hideEffect.add_effectComplete(Function.createDelegate(this,this._onPopupHideEffectComplete));this._hideEffect.start();return true;}return false;},_showPopup:function(){if(this._visible){return;}this._runShowPopupEffect();this._showModalBackground();this._updateControlDisplay(true);this._placePopup();this._visible=true;if(this._onShowScript){eval(this._onShowScript);}PhotoSite.Framework.PopupControl.addVisiblePopup(this);this._placePopupTimerTimeout=1;if(!this._doNotReposition){this._placePopupTimerId=setTimeout(this._placePopupTimerTickHandler,this._placePopupTimerTimeout);}this._hideSelectElements();this._hideObjectElements();},_hidePopupInternal:function(){this._hideModalBackground();this._updateControlDisplay(false);this._visible=false;PhotoSite.Framework.PopupControl.removeVisiblePopup(this);if(this._placePopupTimerId){clearTimeout(this._placePopupTimerId);this._placePopupTimerId=null;}this._restoreSelectElements();this._restoreObjectElements();},_onKeyUp:function(A){if(!A||!A.keyCode){return;}if(A.keyCode==27){A.preventDefault();this._onCancel();return false;}},_onKeyDown:function(A){if(!A||!A.keyCode){return;}if(A.keyCode==13){A.preventDefault();this._onOk();return false;}},_onOk:function(event){if(this._onOkValidationGroup&&typeof(Page_ClientValidate)=="function"&&!Page_ClientValidate(this._onOkValidationGroup)){return;}if(this._onOkScript){eval(this._onOkScript);}this._hidePopup();},_onCancel:function(event){if(this._onOkValidationGroup){Page_ResetValidation(this._onOkValidationGroup);}if(this._onCancelScript){eval(this._onCancelScript);}this._hidePopup();},_hidePopup:function(){if(this._visible){if(!this._runHidePopupEffect()){this._hidePopupInternal();}}},_updateControlDisplay:function(A){if(this._popupContentsID){var B=PhotoSite.Framework.PopupControl.getNextZIndex()+1000;this._modalBackground.style.zIndex=B-1;var C=$get(this._popupContentsID);C.style.display=(A==true)?"":"none";C.style.zIndex=B;}},_createModalBackground:function(){this._modalBackground=document.createElement("div");this._modalBackground.style.position="absolute";this._modalBackground.style.zIndex=PhotoSite.Framework.PopupControl.getNextZIndex();this._modalBackground.style.display="none";document.body.appendChild(this._modalBackground);Sys.UI.DomElement.addCssClass(this._modalBackground,this._backgroundCssClass);},_showModalBackground:function(){if(!this._modalBackground){this._createModalBackground();}this._placeModalBackground();this._modalBackground.style.display="";},_hideModalBackground:function(){if(this._modalBackground){this._modalBackground.style.display="none";}},_onResize:function(){if(this._visible){this._placeModalBackground();this._placePopup();}},_onScroll:function(){if(this._visible){this._placePopup();}},_placeModalBackground:function(){this._modalBackground.style.left="0px";this._modalBackground.style.top="0px";var A=PhotoSite.Framework.UI.getClientDimensions();this._modalBackground.style.width=A.width+"px";this._modalBackground.style.height=A.height+"px";},_placePopup:function(){if(this._popupContentsID){var G=$get(this._popupContentsID);var F=PhotoSite.Framework.UI.getWindowDimensions();var C=Sys.UI.DomElement.getBounds(G);var E=(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);var D=(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);var A=(F.width/2)-((C.width>0)?(C.width/2):0)+E;var B=(F.height/2)-((C.height>0)?(C.height/2):0)+D;Sys.UI.DomElement.setLocation(G,parseInt(A),parseInt(B));}},initialize:function(){PhotoSite.Framework.PopupControl.callBaseMethod(this,"initialize");$addHandler(window,"resize",this._resizeHandler);$addHandler(window,"scroll",this._scrollHandler);if(this._targetControlID){$addHandler($get(this._targetControlID),"click",this._showPopupHandler);}if(this._cancelControlID){$addHandler($get(this._cancelControlID),"click",this._cancelHandler);}if(this._okControlID){$addHandler($get(this._okControlID),"click",this._okHandler);}if(this._escapeControlID){$addHandler($get(this._escapeControlID),"keyup",this._keyupHandler);}if(this._enterKeyControlID){$addHandler($get(this._enterKeyControlID),"keydown",this._keydownHandler);}this.get_element().show=Function.createDelegate(this,this.show);this.get_element().hide=Function.createDelegate(this,this.hide);this.get_element().PopupControl=this;},dispose:function(){if(!this._disposed){this.get_element().show=null;this.get_element().hide=null;try{$removeHandler(window,"resize",this._resizeHandler);}catch(A){}try{$removeHandler(window,"scroll",this._scrollHandler);}catch(A){}try{if(this._escapeControlID){$removeHandler($get(this._escapeControlID),"keyup",this._cancelHandler);}}catch(A){}try{if(this._enterKeyControlID){$removeHandler($get(this._enterKeyControlID),"keydown",this._okHandler);}}catch(A){}try{if(this._targetControlID){$removeHandler($get(this._targetControlID),"click",this._showPopupHandler);}}catch(A){}try{if(this._cancelControlID){$removeHandler($get(this._cancelControlID),"click",this._keyupHandler);}}catch(A){}try{if(this._okControlID){$removeHandler($get(this._okControlID),"click",this._keydownHandler);}}catch(A){}this.get_element().PopupControl=null;PhotoSite.Framework.PopupControl.callBaseMethod(this,"dispose");this._disposed=true;}},get_popupContentsID:function(){return this._popupContentsID;},set_popupContentsID:function(A){if(this._popupContentsID!==A){this._popupContentsID=A;this.raisePropertyChanged("popupContentsID");}},get_cancelControlID:function(){return this._cancelControlID;},set_cancelControlID:function(A){if(this._cancelControlID!==A){this._cancelControlID=A;this.raisePropertyChanged("cancelControlID");}},get_okControlID:function(){return this._okControlID;},set_okControlID:function(A){if(this._okControlID!==A){this._okControlID=A;this.raisePropertyChanged("okControlID");}},get_targetControlID:function(){return this._targetControlID;},set_targetControlID:function(A){if(this._targetControlID!==A){this._targetControlID=A;this.raisePropertyChanged("targetControlID");}},get_backgroundCssClass:function(){return this._backgroundCssClass;},set_backgroundCssClass:function(A){if(this._backgroundCssClass!==A){this._backgroundCssClass=A;this.raisePropertyChanged("backgroundCssClass");}},get_showPopupEffectID:function(){return this._showPopupEffectID;},set_showPopupEffectID:function(A){if(this._showPopupEffectID!==A){this._showPopupEffectID=A;this.raisePropertyChanged("showPopupEffectID");}},get_hidePopupEffectID:function(){return this._hidePopupEffectID;},set_hidePopupEffectID:function(A){if(this._hidePopupEffectID!==A){this._hidePopupEffectID=A;this.raisePropertyChanged("hidePopupEffectID");}},get_visible:function(){return this._visible;},set_visible:function(A){if(A){this.show();}else{this.hide();}},get_onOkScript:function(){return this._onOkScript;},set_onOkScript:function(A){this._onOkScript=A;},get_onCancelScript:function(){return this._onCancelScript;},set_onCancelScript:function(A){this._onCancelScript=A;},set_onShowScript:function(A){this._onShowScript=A;},get_onShowScript:function(){return this._onShowScript;},get_enterKeyControlID:function(){return this._enterKeyControlID;},set_enterKeyControlID:function(A){this._enterKeyControlID=A;},get_escapeControlID:function(){return this._escapeControlID;},set_escapeControlID:function(A){this._escapeControlID=A;},set_onOkValidationGroup:function(A){this._onOkValidationGroup=A;},get_onOkValidationGroup:function(){return this._onOkValidationGroup;},set_doNotReposition:function(A){this._doNotReposition=A;},get_doNotReposition:function(){return this._doNotReposition;}};PhotoSite.Framework.PopupControl.visiblePopups=new Array();PhotoSite.Framework.PopupControl.addVisiblePopup=function(A){PhotoSite.Framework.PopupControl.visiblePopups.push(A);};PhotoSite.Framework.PopupControl.removeVisiblePopup=function(A){Array.remove(PhotoSite.Framework.PopupControl.visiblePopups,A);};PhotoSite.Framework.PopupControl.getNextZIndex=function(){return PhotoSite.Framework.PopupControl.visiblePopups.length*2;};PhotoSite.Framework.PopupControl.registerClass("PhotoSite.Framework.PopupControl",Sys.UI.Behavior);if(typeof(Sys)!=="undefined"){Sys.Application.notifyScriptLoaded();}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();