﻿
Modalbox._insertContent=function(content)
{$(this.MBcontent).hide().update("");if(typeof content=='string'){setTimeout(function(){this.MBcontent.update(content);}.bind(this),1);}else if(typeof content=='object'){var _htmlObj=content.parentNode!=null&&typeof content.parentNode!="undefined"?content.parentNode.removeChild(content):content;this.MBcontent.appendChild(_htmlObj);this.MBcontent.down().show();if(Prototype.Browser.IE)
$$("#MB_content select").invoke('setStyle',{'visibility':''});}}
Modalbox._setPosition=function()
{$(this.MBwindow).setStyle({left:Math.round((document.viewport.getWidth()-Element.getWidth(this.MBwindow))/2)+"px",top:Math.round((document.viewport.getHeight()-Element.getHeight(this.MBwindow))/2)+"px"});}
Modalbox.resize=function(byWidth,byHeight,options)
{var wHeight=$(this.MBwindow).getHeight();var wWidth=$(this.MBwindow).getWidth();var hHeight=$(this.MBheader).getHeight();var cHeight=$(this.MBcontent).getHeight();var newHeight=((wHeight-hHeight+byHeight)<cHeight)?(cHeight+hHeight-wHeight):byHeight;if(options)this.setOptions(options);if(this.options.transitions){new Effect.ScaleBy(this.MBwindow,byWidth,newHeight,{duration:this.options.resizeDuration,scaleFromTop:false,afterFinish:function(){this.event("_afterResize");this.event("afterResize");}.bind(this)});}else{this.MBwindow.setStyle({width:wWidth+byWidth+"px",height:((wHeight+newHeight)>0?(wHeight+newHeight):0)+"px"});setTimeout(function(){this.event("_afterResize");this.event("afterResize");}.bind(this),1);}}
Modalbox._appear=function()
{if(Prototype.Browser.IE&&!navigator.appVersion.match(/\b7.0\b/)){window.scrollTo(0,0);this._prepareIE("100%","hidden");}
this._setWidth();this._setPosition();if(this.options.transitions){$(this.MBoverlay).setStyle({opacity:0});new Effect.Fade(this.MBoverlay,{from:0,to:this.options.overlayOpacity,duration:this.options.overlayDuration,afterFinish:function(){$(this.MBwindow).show();this._setPosition();this.loadContent();}.bind(this)});}else{$(this.MBoverlay).setStyle({opacity:this.options.overlayOpacity});$(this.MBwindow).show();this._setPosition();this.loadContent();}
this._setPosition=this._setPosition.bindAsEventListener(this);Event.observe(window,"resize",this._setPosition);}
Modalbox.hide=function(options)
{if(this.initialized){if(options&&typeof options.element!='function')Object.extend(this.options,options);this.event("beforeHide");$(this.MBwindow).hide();this._deinit();}else throw("Modalbox is not initialized.");}