var PopHtml=Class.create({initialize:function(a,b,e,d,c){this._name=a;this._target=b;this._params=e;this._onEvent=d;this._content=this._bg=null;if(c){this._contentURL=c.contentURL;this._methodURL=c.methodURL}this._targetHtmlStatic=b;this._bgColor="#fff";this._bgAlpha=50;if(c){this._bgColor="#000";if(c.bgColor){this._bgColor=c.bgColor}if(c.bgAlpha){this._bgAlpha=c.bgAlpha}if(c.posy){this._posy=c.posy}}this.IE6=(navigator.appVersion.indexOf("MSIE 6")!=-1)?true:false;this.Safari=(navigator.appVersion.indexOf("Safari")!=-1)?true:false;this._doc=(!this.Safari)?document.documentElement:document.body;this._intervalFixFirefox=null;Event.observe(window,"resize",this._onWindowResize.bind(this));this._writeBg();this._writeContent()},_onWindowResize:function(){this._startSetContentPosition(this._content);Axis.each(this._setBgSize.bind(this,this._bg))},_getPageSize:function(a){return(this._doc[a.scrollscale]<this._getWindowSize(a))?this._getWindowSize(a):this._doc[a.scrollscale]},_getWindowSize:function(a){return document.documentElement[a.clientscale]},_getCenter:function(b,a){return this._doc[a.scrollpos]+(this._getWindowSize(a)/2)-(b[a.offsetscale]/2)},_writeContent:function(){if(this._contentURL){new Ajax.Request(this._contentURL,{method:this._methodURL,postBody:$H(this._ajaxParams).toQueryString(),parameters:"navid="+this._params.navid,onComplete:function(a){this._content.innerHTML=a.responseText;this._setInterval()}.bind(this)})}else{this._setInterval()}},_setInterval:function(){if(this._intervalFixFirefox==null){this._intervalFixFirefox=new PeriodicalExecuter(this._setContent.bind(this),0)}else{this._intervalFixFirefox.callback=this._setContent.bind(this);this._intervalFixFirefox.registerCallback()}},_writeBg:function(){var a='<div id="PopHtmlBg" style="z-index:1004;position:absolute;top:0;left:0;background:'+this._bgColor+";filter:alpha(opacity="+this._bgAlpha+");-moz-opacity:0."+this._bgAlpha+";opacity:0."+this._bgAlpha+';"></div><div id="PopHtmlContent" style="z-index:1005;position:absolute;top:0;left:0;"></div>';if(this.IE6){a+='<iframe id="PopHtmlIframeIE6Hack" style="z-index:1003;position:absolute;top:0;left:0;filter:alpha(opacity=0);"></iframe>'}this._target.innerHTML=a;this._target.setStyle({display:"block"});this._bg=$("PopHtmlBg");if(this._contentURL){this._content=$("PopHtmlContent");this._content.style.visibility="hidden"}else{this._content=$(this._name)}this._content.setStyle({visibility:"hidden",zIndex:1006});Axis.each(this._setBgSize.bind(this,this._bg));this._onWindowResize();if(this.IE6){this._IframeIE6Hack=$("PopHtmlIframeIE6Hack");Axis.each(this._setBgSize.bind(this,this._IframeIE6Hack))}if(!this._contentURL){this._content.style.visibility="visible"}},_setBgSize:function(b,a){b.style[a.scale]=this._getPageSize(a)+"px"},_setContent:function(){this._intervalFixFirefox.stop();if(this._onEvent){this._onEvent("onReady",this._name)}this._startSetContentPosition(this._content);this._content.focus()},_startSetContentPosition:function(a){Axis.each(this._setContentPosition.bind(this,a));if(this._contentURL){a.style.visibility="visible"}},_setContentPosition:function(d,a){var b=d;var c=0;if(a.pos=="left"){while(b!=null&&b.offsetParent!=null){b=b.offsetParent;c+=b.offsetLeft}}c=this._getCenter(d,a)-c;d.style[a.pos]=c+"px"},close:function(){if(this._contentURL){this._target.innerHTML=""}this._target.setStyle({display:"none"});this._content.setStyle({visibility:"hidden"})}});
