function FormPopup(d,b){var a="icons/hide.gif";var c=this;this.div=null;this.formDiv=null;this.headerDiv=null;this.buttonsDiv=null;this.callback=null;this.cancelCallback=null;this.initValues=null;this.is_opened=false;this.create=function(f,e){this.div=document.createElement("div");this.div.className="ctrl_toolbar_dlg";this.headerDiv=this.createHeader();this.div.appendChild(this.headerDiv);this.formDiv=document.createElement("div");this.formDiv.innerHTML=f;this.div.appendChild(this.formDiv);if(e=="USE_SUBMIT_BTN"){this.useSubmitButton()}else{this.buttonsDiv=this.createButtons(e);this.div.appendChild(this.buttonsDiv)}addEvent(this.div,"keyup",this.onkeyup,true)};this.createHeader=function(){var f=document.createElement("div");f.align="right";f.innerHTML="<a><img src="+a+' style="cursor:pointer;"></a>';var e=f.getElementsByTagName("a")[0];e.onclick=this._oncancel;return f};this.createButtons=function(f){var e=document.createElement("div");e.align="center";e.style.paddingTop=10;var g='<table> <tr> <td> <input type="button" value="Ok" style="width:70; font-family:verdana; font-size:12px" /> </td>';if(f!="NO_CANCEL"){g+=' <td> <input type="button" value="Cancel" style="width:70; font-family:verdana; font-size:12px" /> </td>'}g+=" </tr></table>";e.innerHTML=g;var h=e.getElementsByTagName("input");h[0].onclick=this._onok;if(h[1]){h[1].onclick=this._oncancel}return e};this.useSubmitButton=function(){};this.changeContent=function(e){this.formDiv.innerHTML=e};this.getFormDiv=function(){return this.formDiv};this.getForm=function(f){f=f||0;var e=this.formDiv.getElementsByTagName("form");if(f<e.length){return e[f]}return null};this.show=function(g,i,h,f,e){this.callback=h;this.cancelCallback=e;PopupHandler.showRelatively(g,i,this.div,false,f,e);if(this.initValues==null){this.initValues=this._handleControlsValue()}this.is_opened=true};this._onok=function(){var f=c._handleControlsValue();var e=c.callback(f);if(typeof e!="undefined"&&e==false){return}c.hide();c.is_opened=false};this._oncancel=function(){if(typeof c.cancelCallback=="function"){c.cancelCallback()}c.hide()};this.onkeyup=function(f){var e=getKeyCode(f);var g=getEventTarget(f);if(e==13){if(g.tagName.toLowerCase()!="textarea"){c._onok()}stopEventPropagation(f)}if(e==27){c._oncancel();stopEventPropagation(f)}};this.hide=function(){PopupHandler.hide();c.is_opened=false;c._handleControlsValue(c.initValues)};this.isOpened=function(){return this.is_opened};this._handleControlsValue=function(o){var e;var g=false;if(typeof o=="undefined"){g=true;e=new Array()}var n=c.formDiv.getElementsByTagName("input");for(var j=0;j<n.length;j++){var l=n[j];var m=l.getAttribute("type");var f=l.getAttribute("name");if(m=="text"||m=="hidden"){if(g){e[f]=l.value}else{l.value=o[f]}}if(m=="checkbox"){if(g){e[f]=l.checked}else{l.checked=o[f]}}}var k=c.formDiv.getElementsByTagName("select");for(j=0;j<k.length;j++){var p=k[j];var r=p.options;var f=p.getAttribute("name");if(g){e[f]=r[p.selectedIndex].value}else{for(var j=0;j<r.length;j++){if(r[j].value==o[f]){r[j].selected=true}}}}var q=c.formDiv.getElementsByTagName("textarea");for(var j=0;j<q.length;j++){var h=q[j];var m=h.getAttribute("type");var f=h.getAttribute("name");if(g){e[f]=h.value}else{h.value=o[f]}}if(g){return e}};b=b||"";this.create(d,b)}function ToolbarButton(d,k,a,g,c,b,f,j,i,e){var h=this;this.div=null;this.index=d;this.callback=k;this.isToggle=a;this.icon=g;this.toolbar=j;this.title=i;this.titlePressed=null;this.left=b;this.top=f;this.width=null;this.height=null;this.isPressed=false;this.isDisabled=false;this.isOverflowed=false;this.create=function(l){this.div=document.createElement("div");this.div.className="tb_btn";this.div.style.left=this.left;this.div.style.top=this.top;this.div.style.padding=this.toolbar.BTN_PADDING;var m='<img src = "'+g+'" border="0" tooltip="'+this.title+'" width='+l+" height="+this.toolbar.iconHeight+">";this.div.innerHTML=m;this.div.onmouseover=this.onMouseOver;this.div.onmouseout=this.onMouseOut;this.div.onmousedown=this.onMouseDown;this.div.onmouseup=this.onMouseUp;this.width=l+2*this.toolbar.BTN_PADDING;this.height=this.toolbar.iconHeight+2*this.toolbar.BTN_PADDING};this.enable=function(){changeOpacity(this.div,1);this.div.style.cursor="pointer";this.isDisabled=false};this.disable=function(){changeOpacity(this.div,0.3);this.div.style.cursor="default";this.isDisabled=true};this.onMouseOver=function(){if(h.isDisabled){return}if(h.isPressed){return}h.div.style.borderLeftColor=h.div.style.borderTopColor="ButtonHighlight";h.div.style.borderRightColor=h.div.style.borderBottomColor="ButtonShadow";if(h.isOverflowed==false){h._addBorder()}};this.onMouseOut=function(){if(h.isDisabled){return}if(h.isPressed){return}h._removeBorder()};this.onMouseDown=function(){if(h.isDisabled){return}h.div.style.borderLeftColor=h.div.style.borderTopColor="ButtonShadow";h.div.style.borderRightColor=h.div.style.borderBottomColor="ButtonHighlight";h._addBorder();if(h.isToggle){h.isPressed=!h.isPressed;if(h.isPressed){if(h.titlePressed!=null){h.div.title=h.titlePressed}}else{h.onMouseOut();if(h.titlePressed!=null){h.div.title=h.title}}}};this.onMouseUp=function(m){m=getDocumentEvent(m);if(h.isDisabled){return}h.onMouseOver();var l=h.callback(h.isPressed,m.ctrlKey);if(h.isOverflowed&&l){PopupHandler.hide()}};this.pressToggleButton=function(){this.isPressed=true;this.div.style.borderLeftColor=h.div.style.borderTopColor="ButtonShadow";this.div.style.borderRightColor=h.div.style.borderBottomColor="ButtonHighlight";this._addBorder()};this._addBorder=function(){var l=h.div.style;if(l.borderWidth.indexOf("1px")!=-1){return}l.borderWidth="1px";l.left=parseInt(h.div.style.left,10)-1;l.top=parseInt(h.div.style.top,10)-1};this._removeBorder=function(){var l=h.div.style;if(l.borderWidth.indexOf("0px")!=-1){return}l.borderWidth="0px";l.left=parseInt(h.div.style.left,10)+1;l.top=parseInt(h.div.style.top,10)+1};this.create(c);this.onMouseOut();if(typeof e!="undefined"){this.titlePressed=e}}var PalettePopup={div:null,noClrCell:null,callback:null,hotspotIdx:-1,chosenDiv:null,CHOSEN_DIV_ID:"chosen_div_id",otherClrsDiv:null,isOtherClrsVisible:false,safeColorsDiv:null,rainbowColorsDiv:null,show:function(b,f,e,c,d,a){if(this.div==null){this.create()}if(this.hotspotIdx==b.index&&this.div.style.visibility=="visible"){PopupHandler.hide(false);this.hotspotIdx=-1;return}this.hotspotIdx=b.index;if(typeof d!="undefined"&&d!=null){this.noClrCell.innerHTML=d;this.noClrCell.style.display=""}else{this.noClrCell.style.display="none"}this.callback=e;PopupHandler.showRelatively(b,f,this.div,true,c)},create:function(){this.div=document.createElement("div");this.div.className="ctrl_toolbar_dlg pallete_dlg";var d='<table><tr><td><input type="checkbox" onclick="PalettePopup.onRainbowCheckbox(event);"></td><td style="cursor: text;">use rainbow colors</td></tr></table><div id=\'safe_clrs_div\'>'+(this.getSchemePaletteStr()+"<br />"+this.getGrayscalePaletteStr()+"</div><div style='display: none;' id='rainbow_clrs_div'>"+this.getRainbowPaletteStr()+"</div>"+this.getButtonsStr());this.div.innerHTML=d;CheckButtonMgr.prepare(this.div);this.safeColorsDiv=getChildById(this.div,"safe_clrs_div");var c=this.safeColorsDiv.getElementsByTagName("table");var f=c[0];addEvent(f,"click",this.onSchemeColorSelection,false);var e=c[1];addEvent(e,"click",this.onOtherColorSelection,false);this.rainbowColorsDiv=getChildById(this.div,"rainbow_clrs_div");c=this.rainbowColorsDiv.getElementsByTagName("table");var b=c[0];addEvent(b,"click",this.onOtherColorSelection,false);this.noClrCell=getChildById(this.div,"noClr");this.noClrCell.style.fontSize="16";this.chosenDiv=document.createElement("div");this.chosenDiv.id=this.CHOSEN_DIV_ID;var a=this.chosenDiv.style;a.width=31;a.height=31;a.borderWidth="1px";a.borderStyle="dashed"},onRainbowCheckbox:function(b){var d=PalettePopup;var a=getEventTarget(b);var c=CheckButtonMgr.isChecked(a);d.safeColorsDiv.style.display=c?"none":"block";d.rainbowColorsDiv.style.display=c?"block":"none"},showOtherColors:function(a){if(this.isOtherClrsVisible){this.otherClrsDiv.style.display="none";a.innerHTML="show other colors &#187"}else{this.otherClrsDiv.style.display="block";a.innerHTML="hide other colors &#171;"}this.isOtherClrsVisible=!this.isOtherClrsVisible},onSchemeColorSelection:function(b){var c=getEventTarget(b);var a=c.className.replace("csp_bg_","");if(a.length!=2){return}PopupHandler.hide();PalettePopup.callback(a,true)},onOtherColorSelection:function(c,a){var d=getEventTarget(c);var b=d.style.backgroundColor;if(!b&&!a){return}PopupHandler.hide();PalettePopup.callback(b)},getButtonsStr:function(){var a='<table width="100%" cellspacing="0" cellpadding="5" border="0"><tr><td id="noClr"><a href="javascript: ;" onclick = "PalettePopup.onOtherColorSelection(event, true);" class="button"><img src="images/skin/iphone/cross.png" />remove color</a></td></table>';return a},getSchemePaletteStr:function(){var a='<h3>scheme colors:</h3><table width="100%" cellpadding="0" cellspacing="1" border="0">';for(var b=1;b<=3;b++){a+="<tr>";for(var d=1;d<=5;d++){a+=('<td width="20%" class="csp_bg_'+b)+(d+'"></td>')}a+="</tr>"}a+="</table>";return a},getGrayscalePaletteStr:function(){var a=["#FFFFFF","#CCCCCC","#C0C0C0","#999999","#666666","#333333","#000000"];var b='<h3>grayscale:</h3><table  width="100%" cellpadding="0" cellspacing="1" border="0">';b+="<tr>";for(var d=0;d<a.length;d++){b+=('<td width="14.28%" style="background-color:'+a[d]+'"></td>')}b+="<tr>";b+="</table></div>";return b},getRainbowPaletteStr:function(){var a=[["#FFCCCC","#FFCC99","#FFFF99","#FFFFCC","#99FF99","#99FFFF","#CCFFFF","#CCCCFF","#FFCCFF"],["#FF6666","#FF9966","#FFFF66","#FFFF33","#66FF99","#33FFFF","#66FFFF","#9999FF","#FF99FF"],["#FF0000","#FF9900","#FFCC66","#FFFF00","#33FF33","#66CCCC","#33CCFF","#6666CC","#CC66CC"],["#CC0000","#FF6600","#FFCC33","#FFCC00","#33CC00","#00CCCC","#3366FF","#6633FF","#CC33CC"],["#990000","#CC6600","#CC9933","#999900","#009900","#339999","#3333FF","#6600CC","#993399"],["#660000","#993300","#996633","#666600","#006600","#336666","#000099","#333399","#663366"],["#330000","#663300","#663333","#333300","#003300","#003333","#000066","#330099","#330033"]];var b='<h4>other colors:</h4><table  width="100%" cellpadding="0" cellspacing="1" border="0">';for(var d=0;d<a.length;d++){b+="<tr>";for(var e=0;e<a[d].length;e++){b+=('<td width="11.111%" style="background-color:'+a[d][e]+'"></td>')}b+="<tr>"}b+="</table>";return b}};function ListItem(a,d,c,f){var e=2;var b=this;this.index=a;this.innerDiv=d;this.parent=c;this.liObj=null;this.isDisabled=false;this.create=function(){this.liObj=document.createElement("td");this.liObj.style.cursor="pointer";this.liObj.onmouseover=this.onMouseOver;this.liObj.onmouseout=this.onMouseOut;this.liObj.onmouseup=this.onMouseUp;this.liObj.appendChild(d);this.parent.curRow.appendChild(this.liObj)};this.getInnerDiv=function(){return this.innerDiv};this.changeContent=function(g){this.innerDiv.innerHTML=g};this.onMouseOver=function(){if(b.isDisabled){return}b.liObj.className="grey_highlighting"};this.onMouseOut=function(){if(b.isDisabled){return}b.liObj.className=""};this.onMouseUp=function(g){if(b.isDisabled){return}b.liObj.className="";b.parent.onItemSelection(b.index)};this.removeHighlight=function(){b.liObj.className=""};this.enable=function(){this.liObj.style.cursor="pointer";this.isDisabled=false};this.disable=function(){this.liObj.style.cursor="";this.isDisabled=true};this.create()}function MyDropdownList(a){this.div=null;this.table=null;this.tablebody=null;this.curRow=null;this.colAmt=a||1;this.itemsArr=null;this.create=function(b){this.div=document.createElement("div");this.div.className="ctrl_toolbar_dlg";this.table=document.createElement("table");this.tablebody=document.createElement("tbody");this.table.appendChild(this.tablebody);this.div.onmouseup=function(c){c=c||event;c.cancelBubble=true};this.div.appendChild(this.table)};this.show=function(c,f,e,d){this.callback=e;for(var b=0;b<this.itemsArr.length;b++){this.itemsArr[b].removeHighlight()}if(this.div.style.visibility=="visible"){PopupHandler.hide(false);return}PopupHandler.showRelatively(c,f,this.div,true,d)};this.hide=function(){PopupHandler.hide()};this.appendItem=function(c){if(this.itemsArr==null){this.itemsArr=new Array()}c.style.position="static";var b=this.itemsArr.length;if(this.isFirstRowItem(b)){this.curRow=document.createElement("tr");this.tablebody.appendChild(this.curRow)}this.itemsArr[b]=new ListItem(b,c,this)};this.changeItemContent=function(b,c){this.itemsArr[b].changeContent(c)};this.setWidth=function(b){this.table.width=b};this.isMultyColumn=function(b){if(this.colAmt>1){return true}else{return false}};this.isFirstRowItem=function(b){if(this.colAmt>1){if(b%this.colAmt==0){return true}else{return false}}return true};this.enableAllItems=function(){for(var b=0;b<this.itemsArr.length;b++){this.itemsArr[b].enable()}};this.disableAllItems=function(c){for(var b=0;b<this.itemsArr.length;b++){if(b==c){continue}this.itemsArr[b].disable()}};this.onItemSelection=function(b){if(this.callback!=null){this.callback(b);this.hide()}};this.getItemObject=function(b){return this.itemsArr[b]};this.getItemsAmount=function(){return this.itemsArr.length};this.getSelectedItem=function(b){return this.selectedItemIdx};this.create()}function DropdownList(h,n,c,i,f,l,d){var g="verdana";var k="12px";var a="images/wysiwyg/";var b=22;var e=20;var m=20;var j=this;this.index=h;this.callback=n;this.left=c;this.top=i;this.fieldWidth=f;this.title=l;this.toolbar=d;this.width=null;this.height=null;this.div=null;this.itemCloneObj=null;this.buttonDiv=null;this.btnImg=null;this.listDiv=null;this.listObj=null;this.selectedItemIdx=0;this.isOverflowed=false;this.isDisabled=false;this.create=function(){var o=this.top+b+1;this.list=new MyDropdownList();this.div=document.createElement("div");this.div.style.position="absolute";this.div.style.left=this.left;this.div.style.top=this.top;this.div.style.width=this.fieldWidth;this.div.style.height=b;this.div.style.fontFamily=g;this.div.style.fontSize=k;this.div.style.paddingLeft=this.div.style.paddingRight=4;this.div.style.paddingTop=1;this.div.style.backgroundColor=this.list.LIST_BACKGROUND;this.div.style.borderWidth="1px";this.div.style.borderStyle="solid";this.div.style.overflow="visible";this.div.title=this.title;this.toolbar.div.appendChild(this.div);this.fieldWidth=this.div.clientWidth;this.list.setWidth(this.fieldWidth);if(this.div.clientHeight!=b){this.div.style.height=2*b-this.div.clientHeight}this.buttonDiv=document.createElement("div");this.buttonDiv.style.position="absolute";this.buttonDiv.style.left=this.left+this.fieldWidth+3;this.buttonDiv.style.top=this.top+(b-m)/2;this.btnImg=document.createElement("IMG");this.btnImg.src=a+"arrow_button.gif";this.btnImg.style.cursor="pointer";this.btnImg.width=e;this.btnImg.height=m;this.buttonDiv.onmouseover=this.onMouseOverBtn;this.buttonDiv.onmouseout=this.onMouseOutBtn;this.buttonDiv.onmousedown=this.onMouseDownBtn;this.buttonDiv.onmouseup=this.onMouseUpBtn;this.buttonDiv.appendChild(this.btnImg);this.toolbar.div.appendChild(this.buttonDiv);this.width=this.fieldWidth+e;this.height=this.div.clientHeight};this.appendItem=function(o){this.list.appendItem(o)};this.getItemObject=function(o){return this.list.getItemObject(o)};this.getSelectedItem=function(o){return this.list.getItemObject(o)};this.setSelectedItem=function(o){j.selectedItemIdx=o;if(j.itemCloneObj!=null){j.div.removeChild(j.itemCloneObj)}j.itemCloneObj=j.getItemObject(o).getInnerDiv().cloneNode(true);j.div.appendChild(j.itemCloneObj);j.callback(o)};this.enable=function(){changeOpacity(this.div,1);changeOpacity(this.buttonDiv,1);this.isDisabled=false};this.disable=function(){changeOpacity(this.div,0.3);changeOpacity(this.buttonDiv,0.3);this.isDisabled=true};this.onMouseOverBtn=function(){if(j.isDisabled){return}j.btnImg.src=a+"arrow_button_over.gif"};this.onMouseOutBtn=function(){if(j.isDisabled){return}j.btnImg.src=a+"arrow_button.gif"};this.onMouseDownBtn=function(){if(j.isDisabled){return}j.btnImg.src=a+"arrow_button_pressed.gif"};this.onMouseUpBtn=function(){if(j.isDisabled){return}j.btnImg.src=a+"arrow_button.gif";var p=j.top+j.div.clientHeight+1;var o=getParentDialog(j.div);j.list.show(j,"left",j.setSelectedItem,o)};this.create()}function Titlestrip(e,c){var d=25;var b=7;var f="verdana";var a="12px";this.parentDiv=e;this.toolbar=c;this.div=null;this.height=0;this.create=function(){this.div=document.createElement("div");this.div.style.visibility="hidden";this.div.style.position="absolute";this.div.style.left=0;this.div.style.top=0;this.div.style.width="100%";this.div.style.height=d;this.div.style.borderWidth=0;this.parentDiv.appendChild(this.div);this.height=this.div.clientHeight};this.appendTitle=function(h,i){var g=document.createElement("div");g.style.position="absolute";g.style.left=h;g.style.top=b;g.style.fontFamily=f;g.style.fontSize=a;g.innerHTML=i;this.div.appendChild(g);this.div.style.visibility="visible";this.toolbar.onTitleVisible()};this.resize=function(g){};this.isVisible=function(){if(this.div.style.visibility=="visible"){return true}else{return false}};this.create()}function Toolbar(a,m,k,d,b){var h=10;var i=10;var g=4;var o=5;this.BTN_PADDING=2;var f=4;var l=this;this.parentDiv=a;this.insertBeforeObj=b;this.masterObj=m;this.iconHeight=k;this.noOverflow=d;this.controlsArr=new Array();this.div=null;this.titlestrip=null;var j=0;this.width=0;this.height=0;var c=24;var n=4;var e="more options";this.overflowBtn=null;this.overflowPopup=null;this.create=function(){this.titlestrip=new Titlestrip(this.parentDiv,this);this.div=document.createElement("div");this.div.className="ctrl_toolbar";if(this.insertBeforeObj){this.parentDiv.insertBefore(this.div,this.insertBeforeObj)}else{this.parentDiv.appendChild(this.div)}};this.appendDropdownList=function(q,s,t){var p=this.controlsArr.length;var r=(p>0)?j+f:h;this.controlsArr[p]=new DropdownList(p,t,r,g,q,s,this);this.titlestrip.appendTitle(r,s);this.resize(this.controlsArr[p]);return this.controlsArr[p]};this.appendButton=function(x,p,u,v,s,r){var w=this.controlsArr.length;var q=(w>0)?j+f:h;var t=0;r=r||this.iconHeight;this.controlsArr[w]=new ToolbarButton(w,x,p,u,r,q,g,this,v,s);if(this.isOverflow(this.controlsArr[w])){if(this.overflowPopup==null){this.prepareToOverflow()}this.overflowPopup.appendItem(this.controlsArr[w].div);this.controlsArr[w].isOverflowed=true}else{this.div.appendChild(this.controlsArr[w].div);this.resize(this.controlsArr[w])}return this.controlsArr[w]};this.resize=function(q){var p=q.height+(g+o);if(this.height<p){this.height=p}if(this.controlsArr.length==1){this.width=h+q.width+i}else{this.width+=f+q.width}j=this.width-i;this.div.style.height=this.height;this.titlestrip.resize(this.width)};this.getControlObj=function(p){return this.controlsArr[p]};this.getNextControlObj=function(q){var p=q.index+1;if(typeof this.controlsArr[p]!="undefined"){return this.controlsArr[p]}return null};this.getPrevControlObj=function(q){var p=q.index-1;if(typeof this.controlsArr[p]!="undefined"){return this.controlsArr[p]}return null};this.getWidth=function(){return this.width};this.getHeight=function(){if(this.titlestrip.isVisible()){return(this.height+this.titlestrip.height)}else{return this.height}};this.show=function(){this.div.style.visibility="visible"};this.hide=function(){this.div.style.visibility="hidden"};this.isVisible=function(){return isVisible(this.div)};this.onTitleVisible=function(){this.div.style.top=this.titlestrip.height};this.enableAllControls=function(){for(var p=0;p<this.controlsArr.length;p++){this.controlsArr[p].enable()}if(this.overflowPopup){this.overflowPopup.enableAllItems()}};this.disableAllControls=function(q){var s=-1;if(typeof q!="undefined"){s=q.index}for(var r=0;r<this.controlsArr.length;r++){if(r!=s){this.controlsArr[r].disable()}}if(this.overflowPopup){var p=this.overflowPopup.getItemsAmount()-1;this.overflowPopup.disableAllItems(p)}};this.isOverflow=function(q){if(this.noOverflow){return false}if(this.overflowPopup!=null){return true}if(this.parentDiv.offsetWidth==0){return}var p=j+f+q.width+f+c+this.BTN_PADDING*2+i+2;if(this.parentDiv.offsetWidth<=p){return true}return false};this.prepareToOverflow=function(){var p=this.controlsArr.length;var r=j+f;var q="images/wysiwyg/overflow.png";this.overflowBtn=new ToolbarButton(p,this.showOverflowPopup,false,q,c,r,g,this,e);this.div.appendChild(this.overflowBtn.div);this.resize(this.overflowBtn);this.overflowPopup=new MyDropdownList(n)};this.showOverflowPopup=function(){var p=getParentDialog(this.div);if(typeof l.masterObj.onOverflowBtn!="undefined"){l.masterObj.onOverflowBtn()}if(l.overflowPopup.div.parentNode!=document.body){document.body.appendChild(l.overflowPopup.div)}l.overflowPopup.show(l.overflowBtn,"right",null,p,false)};this.create()}var PopupHandler={CLOSE_TIMEOUT:500,popupDiv:null,parentDlg:null,oldOnKeyUp:null,oldOnClick:null,timerid:0,firstClick:true,isAutoHide:true,onHideCallback:null,x:0,y:0,oldOnScroll:null,overflowPopup:null,noCloseTimeout:false,showRelatively:function(c,g,f,a,d,b,e){if(this.popupDiv!=null){this.hide(typeof c.isOverflowed!="undefined"&&c.isOverflowed)}if(this.overflowPopup!=null){f.style.zIndex=this.overflowPopup.style.zIndex+1}if(d!=null){d.appendChild(f)}else{document.body.appendChild(f)}this.align(c,g,f,a,d);this.popupDiv=f;this.parentDlg=d;this.onHideCallback=b;this.noCloseTimeout=e;this._show(a);setTimeout("PopupHandler.setFocusInInput()",50)},show:function(b,a){this.popupDiv=b;this._show(a)},_show:function(a){if(typeof a=="undefined"||a){this.isAutoHide=true}else{this.isAutoHide=false}this.setHandlers();this.firstClick=true;this.popupDiv.style.display="block";this.popupDiv.style.visibility="visible";Tooltip.hide(true)},align:function(c,j,b,f,i){var g=7;var e=c.div||c.obj||c;var l;if(Browser.ie&&(!i||isParentDialogOnPage(i))){l=this.findObjectPosition(e,document.body)}else{l=this.findObjectPosition(e,i)}if(j=="inside"){var d=(e.clientWidth-b.clientWidth)/2;this.x=l.left+d;var k=(e.clientHeight-b.clientHeight)/2;this.y=l.top+k}else{if(j=="left"){this.x=l.left}else{if(j=="center"){this.x=l.left-(b.clientWidth-c.width)/2}else{this.x=l.left-(b.clientWidth-c.width)}}}if(j=="inside"){var h=getElemInsideScreenPosition(this.x,this.y,b);this.x=h[0];this.y=h[1]}else{var a=getScrollXY();var m=getWindowSize();this.y=l.top+c.height+g;if(m[1]<this.y-a[1]+b.clientHeight){this.y=l.top-b.clientHeight-g}}b.style.left=this.x;b.style.top=this.y},hide:function(a){if(this.popupDiv==null){return}if(a&&this.overflowPopup==null){this.overflowPopup=this.popupDiv}else{this.popupDiv.style.visibility="hidden";if(this.overflowPopup!=null){this.overflowPopup.style.visibility="hidden";document.body.appendChild(this.overflowPopup);this.overflowPopup=null}}this.resetHandlers()},suspendedHide:function(){clearInterval(PopupHandler.timerid);PopupHandler.hide()},findObjectPosition:function(d,b){var c=0;var a=0;b=b||document.body;if(d.offsetParent){while(b!=d&&d.offsetParent){c+=d.offsetLeft;a+=d.offsetTop;d=d.offsetParent}}else{if(d.x){c=d.x}if(d.y){a=d.y}}return{left:c,top:a}},setHandlers:function(){if(this.isAutoHide){this.oldOnClick=document.onclick;document.onclick=this._onclick;this.popupDiv.onmouseover=this._onmouseover;this.popupDiv.onmouseout=this._onmouseout}this.oldOnKeyUp=document.onkeyup;document.onkeyup=this._onkeyup;if(this.isFixedPosition){this.oldOnScroll=window.onscroll;window.onscroll=this._onscroll}},resetHandlers:function(){if(this.isAutoHide){document.onclick=this.oldOnClick;this.popupDiv.onmouseover=null;this.popupDiv.onmouseout=null}document.onkeyup=this.oldOnKeyUp;if(this.isFixedPosition){window.onscroll=this.oldOnScroll}this.popupDiv=null},checkHidingDiv:function(a){if(this.parentDlg==null){return}if(this.parentDlg.id==a.id){this.hide()}},_onkeyup:function(b){var c=PopupHandler;b=(b)?b:event;var a=(b.charCode)?b.charCode:((b.keyCode)?b.keyCode:((b.which)?b.which:0));if(a==27){c.hide();if(c.onHideCallback&&typeof c.onHideCallback=="function"){c.onHideCallback()}stopEventPropagation(b)}},_onclick:function(a){if(PopupHandler.firstClick){PopupHandler.firstClick=false;return}var a=a||window.event;var b=a.target||a.srcElement;if(PopupHandler.contains(PopupHandler.popupDiv,b)==false){PopupHandler.hide()}},_onmouseover:function(a){var b;if(window.event){b=window.event.toElement}else{b=a.relatedTarget}if(PopupHandler.popupDiv==b||PopupHandler.contains(PopupHandler.popupDiv,b)){clearInterval(PopupHandler.timerid)}},_onmouseout:function(a){var c=PopupHandler;var b;if(window.event){b=window.event.toElement}else{b=a.relatedTarget}if(b==null){return}if(c.popupDiv!=b&&!c.contains(c.popupDiv,b)){if(c.noCloseTimeout){c.hide()}else{c.timerid=setInterval(c.suspendedHide,c.CLOSE_TIMEOUT)}}},setMouseoutTimeout:function(a){this.mouseoutTimeout=a},_onscroll:function(b){var a=getScrollXY();PopupHandler.popupDiv.style.left=PopupHandler.x-a[0];PopupHandler.popupDiv.style.top=PopupHandler.y-a[1]},setFocusInInput:function(){var a=PopupHandler.popupDiv.getElementsByTagName("input");var b=null;for(var c=0;c<a.length;c++){if(a[c].type=="text"||a[c].type=="file"){b=a[c];break}}if(b){try{b.focus()}catch(d){}}},contains:function(d,c){if(d==null||c==null){return false}while(c.parentNode){if((c=c.parentNode)==d){return true}}return false},isVisible:function(){return this.popupDiv!=null&&this.popupDiv.style.visibility=="visible"}};
