
function PopupManager()
{this.webServiceUrl="";this.windowTitleText="";this.initContent="";this.inputValues="";this.width=0;this.height=0;this.iframeUrl="";this.isDraggable=true;this.OpenPopup=function(webServiceUrl,windowTitleText,initContent,inputValues,width,height)
{if(webServiceUrl)
this.webServiceUrl=webServiceUrl;if(windowTitleText)
this.windowTitleText=windowTitleText;if(initContent)
this.initContent=initContent;if(inputValues)
this.inputValues=inputValues;if(width)
this.width=width;if(height)
this.height=height;if(jQueryPopUp)
jQueryPopUp.dialog('destroy');jQueryPopUp=$(this.initContent).dialog({autoOpen:false,title:this.windowTitleText,height:this.height,width:this.width,open:function(target){target.OnPopupOpenHandler();}(this)});jQueryPopUp.dialog('open');return false;}
this.OpenPopupIframe=function(iframeUrl,windowTitleText,width,height)
{if(iframeUrl)
this.iframeUrl=iframeUrl;if(windowTitleText)
this.windowTitleText=windowTitleText;if(width)
this.width=width;if(height)
this.height=height;if(jQueryPopUp)
jQueryPopUp.dialog('destroy');jQueryPopUp=$("<div><iframe src='"+this.iframeUrl+"' width='600' height='600' frameborder='0'></iframe></div>").dialog({autoOpen:false,title:this.windowTitleText,height:this.height,width:this.width,resizable:false});jQueryPopUp.dialog('open');return false;}
this.OpenPopupPharos=function(iframeUrl,windowTitleText,width,height,webServiceUrl,inputValues)
{if(iframeUrl)
this.iframeUrl=iframeUrl;if(windowTitleText)
this.windowTitleText=windowTitleText;if(width)
this.width=width;if(height)
this.height=height;if(webServiceUrl)
this.webServiceUrl=webServiceUrl;if(inputValues)
this.inputValues=inputValues;if(jQueryPopUp)
jQueryPopUp.dialog('destroy');jQueryPopUp=$("<div><iframe src='"+this.iframeUrl+"' width='600' height='600' frameborder='0'></iframe></div>").dialog({autoOpen:false,title:this.windowTitleText,height:this.height,width:this.width,position:'left',resizable:false,open:function(target){target.OnPopupSetPharosVariable();}(this)});jQueryPopUp.dialog('open');return false;}
this.OpenTooltipAtPosition=function(posElement,webServiceUrl,windowTitleText,initContent,inputValues,width,height,isDraggable)
{if(isDraggable==false)
this.isDraggable=isDraggable;if(webServiceUrl)
this.webServiceUrl=webServiceUrl;if(windowTitleText)
this.windowTitleText=windowTitleText;if(initContent)
this.initContent=initContent;if(inputValues)
this.inputValues=inputValues;if(width)
this.width=width;if(height)
this.height=height;var pos=this.GetWinPos(Sys.UI.DomElement.getBounds(posElement));if(jQueryPopUp)
{jQueryPopUp.dialog('destroy');}
jQueryPopUp=$(this.initContent).dialog({autoOpen:false,title:this.windowTitleText,height:this.height,width:this.width,position:[pos.Left,pos.Top],resizable:false,draggable:this.isDraggable,open:function(target){target.OnPopupOpenHandler();}(this)});jQueryPopUp.dialog('open');return false;}
this.GetWinPos=function(bounds,moveFromElementTop,moveFromElementLeft)
{var popupLeft;var popupTop;var clientBounds=$common.getClientBounds();var clientWidth=clientBounds.width;var clientHeight=clientBounds.height;var scrollLeft=(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);var scrollTop=(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);popupLeft=bounds.x;if(moveFromElementLeft){if(!isNaN(moveFromElementLeft)){popupLeft=bounds.y+moveFromElementLeft;}}else{popupLeft=bounds.x-scrollLeft-(this.width/2);}
popupTop=bounds.y;if(moveFromElementTop){if(!isNaN(moveFromElementTop)){popupTop=bounds.y+moveFromElementTop;}}else{popupTop=bounds.y-scrollTop-(this.height/2);}
return{Left:popupLeft,Top:popupTop};}
this.OnPopupOpenHandler=function()
{if(this.webServiceUrl==""||this.inputValues==null)
return;$.ajax({type:'POST',contentType:'application/json; charset=utf-8',dataType:'json',url:this.webServiceUrl,data:JSON.stringify(this.inputValues),success:function(respSuccess){this.caller.OnAjaxPopupCallSuccess(respSuccess.Caption,respSuccess.InnerHTML,respSuccess.JavaScript);},error:function(){},caller:this});}
this.OnPopupSetPharosVariable=function()
{if(this.webServiceUrl=="")
return;$.ajax({type:'POST',contentType:'application/json; charset=utf-8',dataType:'json',url:this.webServiceUrl,data:JSON.stringify(this.inputValues),success:function(){},error:function(){},caller:this});}
this.OnAjaxPopupCallSuccess=function(caption,innerHTML,javascript)
{if(jQueryPopUp)
{jQueryPopUp.html(innerHTML);if(javascript.length>0)
{eval(javascript);}
if(caption.length>0)
{jQueryPopUp.dialog('option','title',caption);}}}
this.OnAjaxPopupCallError=function(errorResponse)
{alert("ajax error");}
this.CloseAllOpenPopupsAndTooltips=function()
{if(jQueryPopUp)
{jQueryPopUp.dialog('destroy');}
return false;}}