var Probox=Class.create({initialize:function(a,c){var b=navigator.userAgent.toLowerCase();Prototype.Browser.Version=(b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];this.body=$$("body")[0];this.html=$$("html")[0];this.loadingImageSrc=c;this.loadingImage=new Image();this.loadingImage.src=this.loadingImageSrc;this.body.setStyle({width:"100%",height:"100%"});this.initOverlay();this.initLoading();this.initWindow();$$(a).each(function(d){d.observe("click",function(e){e.stop();this.show(d)}.bindAsEventListener(this))}.bind(this))},show:function(el){this.clearElements();this.bhide=this.hide.bindAsEventListener(this);$("PB_HideSelect").show();$("PB_Overlay").show();this.showLoading();var title=el.title||el.name||"";var parameters=el.getAttribute("params").split(",");for(var i=0;i<parameters.length;i++){var curpar=parameters[i].split("=");eval("this."+curpar[0]+"='"+curpar[1]+"'")}var url=el.href||el.alt;var group=el.rel||false;this.setTitle(title);var imageRule=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;if(url.match(imageRule)){this.loadImage(url,group)}else{if(!this.width){this.width=400;this.height=400}this.windowDimensions(this.width,this.height);this.loadHTML(url)}},clearElements:function(){$("PB_Window").update("")},setTitle:function(b){var a=new Element("div",{id:"PB_Title"}).update(b+' (press ESC to <a href="javascript: {}" id="PB_Close">close</a>)')},showLoading:function(){$("PB_Load").appear()},hideLoading:function(){$("PB_Load").hide()},initOverlay:function(){var b=new Element("iframe",{id:"PB_HideSelect",style:"display: none;"});this.body.appendChild(b);var a=new Element("div",{id:"PB_Overlay",style:"display: none;"});a.addClassName("PB_OverlayBG");this.body.appendChild(a)},initLoading:function(){var a=new Element("div",{id:"PB_Load",style:"display: none;"});var b=new Element("img",{src:this.loadingImageSrc});a.appendChild(b);this.body.appendChild(a)},initWindow:function(){var a=new Element("div",{id:"PB_Window",style:"display: none;"});this.body.appendChild(a)},hide:function(){if($(this.iframeId)!=null){$(this.iframeId).remove()}if($("PB_Image")!=null){$("PB_Image").remove()}this.hideLoading();$("PB_HideSelect").hide();$("PB_Overlay").hide();$("PB_Window").fade({duration:0.3})},windowDimensions:function(c,a){this.width=c;this.height=a;var d="-"+parseInt((c/2),10)+"px";var b="";if(!(Prototype.Browser.IE&&Prototype.Browser.Version<7)){$("PB_Window").setStyle({marginTop:"-"+parseInt((a/2),10)+"px"})}$("PB_Window").setStyle({width:c+"px",height:a+"px",marginLeft:d})},loadImage:function(b,a){setTimeout("this.hideLoading",300);imgPreloader=new Image();imgPreloader.onload=function(){imgPreloader.onload=null;var d=document.viewport.getWidth();var g=document.viewport.getHeight();var e=imgPreloader.width;var c=imgPreloader.height;if(e>d){c=c*(d/e);e=d;if(c>g){e=e*(g/c);c=g}}else{if(c>g){e=e*(g/c);c=g;if(e>d){c=c*(d/e);e=d}}}this.windowDimensions((e+30),(c+60));var f=new Element("img",{id:"PB_Image",src:b});this.hideLoading();$("PB_Window").show();$("PB_WindowConetnt").appendChild(f)}.bind(this);imgPreloader.src=b},loadHTML:function(a){this.iframeId="PB_AjaxContent"+Math.round(Math.random()*1000);var b=new Element("div",{name:this.iframeId,frameborder:0,id:this.iframeId});b.setStyle({width:(this.width)+"px",height:(this.height-45)+"px"});$("PB_Window").appendChild(b);new Ajax.Request(a,{method:"get",evalScripts:"true",onComplete:function(c){$(this.iframeId).update(c.responseText);setupKnopHandlers();$("PB_Window").appear({duration:0.3});this.hideLoading()}.bind(this)})}});