//Version:20090901
window._open=window.open;window.open=function(d,b,c,a){if(arguments.length==3&&typeof(arguments[2])=="string"){return window._open(arguments[0],arguments[1],arguments[2])}else{new TSPopup(b,d,true,true,false,c,a).show()}};var TSPopup=function(i,d,c,a,f,e,b,h){if(i==null){i="__default__instance__"}this.id=i;var g=TSPopup["_"+i];if(!g){g=TSPopup["_"+i]=this}if(typeof(d)=="string"){g.DivMode=false;g.URL=d;g.Layer=null}else{g.DivMode=true;g.Layer=d}g.showTitle=c||false;g.showCurtain=a||false;g.curtainColor=TSPopup.curtainColor;g.curtainOpacity=g.showCurtain?TSPopup.curtainOpacity:0;g.showCurtain=true;g.borderColor=TSPopup.borderColor;g.autoSnapping=f||false;g.autoClose=e||false;g.width=b;g.height=h;return g};TSPopup.showDiv=function(c,b,a){if(typeof(b)=="undefined"){b=true}if(typeof(a)=="undefined"){a=false}TSPopup._divHandler=new TSPopup(null,document.getElementById(c),false,b,a);TSPopup._divHandler.show()};TSPopup.closeDiv=function(){TSPopup._divHandler.close()};TSPopup.version="1.3.0";TSPopup.file="popup.js";TSPopup.minWidth=200;TSPopup.minHeight=150;TSPopup.borderColor="#3399FF";TSPopup.curtainColor="#000";TSPopup.curtainOpacity=50;TSPopup.debugMode=false;TSPopup.debug=function(){if(!TSPopup.debugMode){return}var d=arguments[0];for(var b=1;b<arguments.length;b++){d=d.replace("{}",arguments[b])}if(!TSPopup.debugWin){TSPopup.debugWin=window._open("about:blank ","debugConsole","height=300,width=500,menubar=no,toolbar=no,titlebar=no,status=no,scrollbars=yes")}var a=new Date();var c=(a.getHours()>9?a.getHours():"0"+a.getHours())+":"+(a.getMinutes()>9?a.getMinutes():"0"+a.getMinutes())+":"+(a.getSeconds()>9?a.getSeconds():"0"+a.getSeconds())+"."+(a.getMilliseconds()>99?a.getMilliseconds():"0"+(a.getMilliseconds()>9?a.getMilliseconds():"0"+a.getMilliseconds()));TSPopup.debugWin.document.body.innerHTML+="["+c+"] "+d+"<br/>"};TSPopup.prototype.initCurtain=function(){TSPopup.debug("initCurtain");if(!this.curtain){var b=document.createElement("DIV");b.style.position="absolute";b.style.zIndex="100";b.style.top="0px";b.style.left="0px";b.style.width="100px";b.style.height="100px";b.style.display="none";b.style.border="0";b.style.backgroundColor=this.curtainColor;document.all?b.style.filter="alpha(opacity="+this.curtainOpacity+");":b.style.opacity=(this.curtainOpacity/100);document.body.appendChild(b);if(document.all&&([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1]==6)){b.innerHTML='<iframe allowTransparency style="position:absolute;z-index:10;filter:alpha(opacity=0);width:100%;height:100%;" scrolling="no" frameborder="0"></iframe><div style="position:absolute;z-index:50;background-color:#000;filter:alpha(opacity=0);width:100%;height:100%" onclick="this.parentElement.onclick()"></div>'}this.curtain={coverDiv:b,show:function(){if(window._popupHandler){TSPopup.debug("parent cutain color: {}",window._popupHandler.curtain.coverDiv.style.backgroundColor)}this.resize();this.coverDiv.style.display=""},resize:function(){this.coverDiv.style.height=0;this.coverDiv.style.width=0;var d=TSPopup.stage();var e=(d.offsetWidth>d.width?d.offsetWidth-1:d.width)+"px";var c=(d.offsetHeight>d.height?d.offsetHeight-1:d.height)+"px";this.coverDiv.style.height=c;this.coverDiv.style.width=e},hide:function(){this.coverDiv.style.display="none"}}}this.curtain.coverDiv.style.backgroundColor=this.curtainColor;document.all?this.curtain.coverDiv.style.filter="alpha(opacity="+this.curtainOpacity+");":this.curtain.coverDiv.style.opacity=(this.curtainOpacity/100);if(this.autoClose||this.curtainOpacity==0){var a=this;this.curtain.coverDiv.onclick=function(){a.close()}}else{this.curtain.coverDiv.onclick=function(){}}};TSPopup.prototype.initLayer=function(){TSPopup.debug("initLayer");if(!this.Layer&&TSPopup.Layer){this.Layer=TSPopup.Layer;this.Layer.innerHTML=""}else{var b=this.Layer=TSPopup.Layer=document.createElement("DIV");b.id=this.id;b.style.position="absolute";b.style.zIndex="9000";b.style.display="none";b.style.backgroundColor="#fff";document.body.appendChild(b)}if(this.borderColor){this.Layer.style.border="1px solid "+this.borderColor}else{this.Layer.style.border="0px none"}if(this.showTitle){var c=TSPopup.getBaseURL();this.Layer.innerHTML='<div style="height:22px; background: url('+c+'popup_bg.gif) repeat-x;"><img style="float:left; margin:2px 0 0 12px;" src="'+c+'popup_title.gif" width="20" height="18" /><div id="'+this.id+'_title" style="float:left; margin:3px 0px 0px 10px; color:#FFF;"></div><div style="float:right; margin-right:4px;"><img src="'+c+'popup_close.gif" width="31" height="19" onclick="TSPopup[\'_'+this.id+'\'].close();" style="cursor:pointer;"/></div></div>';this.Layer.Title=document.getElementById(this.id+"_title")}var a=this.Layer.Frame=document.createElement("iframe");a.frameBorder="0";a.allowTransparency=false;this.Layer.appendChild(a)};TSPopup.prototype.show=function(){TSPopup.debug("show");if(window._popupHandler){window._popupHandler.maximize()}var b=this;document.documentElement.style.overflow="hidden";document.oncontextmenu=function(){return false};if(this.showCurtain){this.initCurtain();this.curtain.show()}var c=TSPopup.getEvent();if(c){this.snappingElement=c.srcElement||c.target}else{this.autoSnapping=false}if(this.autoSnapping){this.showCurtain&&TSPopup.attachEvent(window,"resize",function(){b.curtain.resize()})}else{TSPopup.attachEvent(window,"resize",function(){b.rePosition()})}this.isClosed=false;if(this.DivMode){this.fadeOut();this.Layer.style.position="absolute";this.Layer.style.display="";this.autoSnapping?this.snapping():this.rePosition();this.fadeIn()}else{this.initLayer();var a=this.Layer.Frame;TSPopup.attachEvent(a,"load",function(){if(a.contentWindow._popupHandler){return}a.contentWindow._popupHandler=b;b.render();b.registerAPI()});this.fadeOut();a.src=this.URL}};TSPopup.prototype.render=function(){TSPopup.debug("render");if(this.isClosed){return}var a=this.Layer;var d=a.Frame;d.width=1;d.height=1;a.style.top="0";a.style.left="0";a.style.display="";var g=50*2;var b=TSPopup.stage();var h=d.contentWindow.document;var c=h.documentElement.scrollWidth;if(this.showTitle){c=TSPopup.minWidth>c?TSPopup.minWidth:c}if(b.width<c+g){d.width=b.width-g}else{if(this.width){d.width=(b.width>this.width+g?this.width:b.width-g)}else{if(h.body.style.width||h.documentElement.style.width){if(h.documentElement.scrollWidth>c){c=h.documentElement.scrollWidth}if(h.body.scrollWidth>c){c=h.body.scrollWidth}d.width=(b.width>c+g?c:b.width-g)}else{d.width=b.width-g}}}a.normalWidth=d.width;a.style.width=a.normalWidth+"px";var e=h.documentElement.scrollHeight;if(h.body.scrollHeight>e){e=h.body.scrollHeight}if(this.showTitle){e=TSPopup.minHeight>e?TSPopup.minHeight:e}var f=d.offsetTop;if(b.height<f+e+g){d.height=b.height-f-g;h.documentElement.style.overflowX="hidden"}else{if(this.height){d.height=(b.height>this.height+f+g?this.height:b.height-f-g)}else{d.height=e}}a.normalHeight=parseInt(d.height)+parseInt(d.offsetTop);a.style.height=a.normalHeight+"px";this.autoSnapping?this.snapping():this.rePosition();if(a.Title){a.Title.innerHTML=h.title}this.fadeIn()};TSPopup.prototype.fadeOut=function(b,c,a){TSPopup.debug("fadeout");this.Layer.style.zIndex="8990";document.all?this.Layer.style.filter="alpha(opacity=1);":this.Layer.style.opacity=0.01};TSPopup.prototype.fadeIn=function(d,e,c){TSPopup.debug("fadein");if(!d){d=70;e=c=5;document.all?this.Layer.style.filter="alpha(opacity="+d+");":this.Layer.style.opacity=(d/100);this.Layer.style.zIndex="9000"}d=d>100?100:d;var b=this.Layer;document.all?b.style.filter="alpha(opacity="+d+");":b.style.opacity=(d/100);if(d!=100){d+=e;e+=c;var a=this;setTimeout(function(){a.fadeIn(d,e,c)},100)}};TSPopup.prototype.registerAPI=function(){TSPopup.debug("registerAPI");var b=this.Layer.Frame.contentWindow;var a=this;b.close=function(){a.close()};b.document.oncontextmenu=function(){return false}};TSPopup.prototype.snapping=function(){TSPopup.debug("snapping");if(this.showCurtain){this.curtain.resize()}var b=TSPopup.getAbsolutePosition(this.snappingElement);var a=TSPopup.stage();if(a.top+a.height<b.top+b.height+this.Layer.offsetHeight&&b.top-this.Layer.offsetHeight>a.top){this.Layer.style.top=b.top-this.Layer.offsetHeight+"px"}else{this.Layer.style.top=(b.top+b.height)+"px"}if(a.left+a.width<b.left+this.Layer.offsetWidth){this.Layer.style.left=a.left+a.width-this.Layer.offsetWidth-3+"px"}else{this.Layer.style.left=b.left+"px"}};TSPopup.prototype.rePosition=function(){TSPopup.debug("rePosition");if(this.isClosed||!this.Layer){return}if(this.showCurtain){this.curtain.resize()}var b=TSPopup.stage();var a=this.Layer;a.style.top=b.top+(b.height-a.offsetHeight)/2+"px";a.style.left=b.left+(b.width-a.offsetWidth)/2+"px"};TSPopup.prototype.maximize=function(){TSPopup.debug("maximize");var a=this.Layer;a.style.top="0px";a.style.left="0px";var b=TSPopup.stage();var d=parseInt(b.width)-(parseInt(a.offsetWidth)-parseInt(a.clientWidth));a.style.width=d+"px";a.Frame.width=d;var c=parseInt(b.height)-(parseInt(a.offsetHeight)-parseInt(a.clientHeight));a.style.height=c+"px";a.Frame.height=c-a.Frame.offsetTop;this.rePosition()};TSPopup.prototype.normalize=function(){TSPopup.debug("normalize");this.fadeOut();this.Layer.style.width=this.Layer.normalWidth+"px";this.Layer.Frame.width=this.Layer.normalWidth;this.Layer.style.height=this.Layer.normalHeight+"px";this.Layer.Frame.height=this.Layer.normalHeight-this.Layer.Frame.offsetTop;this.rePosition();this.fadeIn()};TSPopup.prototype.close=function(){TSPopup.debug("close");this.isClosed=true;this.Layer.style.display="none";if(this.showCurtain){this.curtain.hide()}window.document.documentElement.style.overflow="auto";window.document.oncontextmenu=null;if(window._popupHandler){window._popupHandler.normalize()}};TSPopup.getBaseURL=function(){var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;i++){if(eval("/"+TSPopup.file.replace(".","\\.")+"$/").test(scripts[i].src)){return scripts[i].src.substring(0,scripts[i].src.length-TSPopup.file.length)}}};TSPopup.attachEvent=function(c,a,b){if(document.all){c.attachEvent("on"+a,b)}else{c.addEventListener(a,b,false)}};TSPopup.detachEvent=function(c,a,b){if(document.all){c.detachEvent("on"+a,b)}else{c.removeEventListener(a,b,false)}};TSPopup.stage=function(){var b=false;try{b=document.compatMode=="CSS1Compat"}catch(c){}var a=b?document.documentElement:document.body;return{top:a.scrollTop,left:a.scrollLeft,width:a.clientWidth,height:a.clientHeight,offsetWidth:a.scrollWidth,offsetHeight:a.scrollHeight}};TSPopup.getEvent=function(){if(document.all){return window.event}func=arguments.callee.caller;while(func!=null){var a=func.arguments[0];if(a){if((a.constructor==Event||a.constructor==MouseEvent)||(typeof(a)=="object"&&a.preventDefault&&a.stopPropagation)){return a}}func=func.caller}return null};TSPopup.getAbsolutePosition=function(c){var e=0,d=0;var b=c.offsetWidth,a=c.offsetHeight;while(c.offsetParent){e+=c.offsetTop;d+=c.offsetLeft;c=c.offsetParent}return{top:e,left:d,width:b,height:a}};TSPopup.getScrollerWidth=function(){if(TSPopup._scrollerWidth){return TSPopup._scrollerWidth}var a=0;var b=0;var d=document.createElement("div");d.style.position="absolute";d.style.top="-1000px";d.style.left="-1000px";d.style.width="100px";d.style.height="100px";d.style.overflow="hidden";document.body.appendChild(d);a=d.clientWidth;var c=document.createElement("div");c.style.width="200px";c.style.height="200px";d.style.overflow="auto";d.appendChild(c);b=d.clientWidth;document.body.removeChild(d);TSPopup._scrollerWidth=a-b;return TSPopup._scrollerWidth};
