var jQImageBox_imageEl="";
jQuery.ImageBox={options:{border:10,loaderSRC:"images/loading.gif",closeHTML:'<img src="images/close.jpg" />',overlayOpacity:0.8,textImage:"Showing image",textImageFrom:"from",fadeDuration:400,showTextImage:true},imageLoaded:false,firstResize:false,currentRel:null,animationInProgress:false,opened:false,minWidth:0,heightClose:0,keyPressed:function(a){if(!(!jQuery.ImageBox.opened||jQuery.ImageBox.animationInProgress))switch(a.charCode||a.keyCode||-1){case 35:jQuery.ImageBox.currentRel&&jQuery.ImageBox.start(null,
jQuery("a[rel="+jQuery.ImageBox.currentRel+"]:last").get(0));break;case 36:jQuery.ImageBox.currentRel&&jQuery.ImageBox.start(null,jQuery("a[rel="+jQuery.ImageBox.currentRel+"]:first").get(0));break;case 37:case 8:case 33:case 80:case 112:a=jQuery("#ImageBoxPrevImage");a.get(0).onclick!=null&&a.get(0).onclick.apply(a.get(0));break;case 38:break;case 39:case 34:case 32:case 110:case 78:a=jQuery("#ImageBoxNextImage");a.get(0).onclick!=null&&a.get(0).onclick.apply(a.get(0));break;case 40:break;case 27:jQuery.ImageBox.hideImage();
break}},init:function(a){a&&jQuery.extend(jQuery.ImageBox.options,a);window.event?jQuery("body",document).bind("keyup",jQuery.ImageBox.keyPressed):jQuery(document).bind("keyup",jQuery.ImageBox.keyPressed);jQuery("a").each(function(){el=jQuery(this);relAttr=el.attr("rel")||"";hrefAttr=el.attr("href")||"";imageTypes=/\.jpg|\.jpeg|\.png|\.gif|\.bmp/g;hrefAttr.toLowerCase().match(imageTypes)!=null&&relAttr.toLowerCase().indexOf("imagebox")==0&&el.bind("click",jQuery.ImageBox.start)});if(jQuery.browser.msie){iframe=
document.createElement("iframe");jQuery(iframe).attr({id:"ImageBoxIframe",src:"javascript:false;",frameborder:"no",scrolling:"no"}).css({display:"none",position:"absolute",top:"0",left:"0",filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"});jQuery("body").append(iframe)}overlay=document.createElement("div");jQuery(overlay).attr("id","ImageBoxOverlay").css({position:"absolute",display:"none",top:"0",left:"0",opacity:0}).append(document.createTextNode(" ")).bind("click",jQuery.ImageBox.hideImage);
captionText=document.createElement("div");jQuery(captionText).attr("id","ImageBoxCaptionText").css({paddingLeft:jQuery.ImageBox.options.border+"px"}).append(document.createTextNode(" "));captionImages=document.createElement("div");jQuery(captionImages).attr("id","ImageBoxCaptionImages").css({paddingLeft:jQuery.ImageBox.options.border+"px",paddingBottom:jQuery.ImageBox.options.border+"px"}).append(document.createTextNode(" "));closeEl=document.createElement("a");jQuery(closeEl).attr({id:"ImageBoxClose",
href:"#"}).css({position:"absolute",right:jQuery.ImageBox.options.border+"px",top:"0"}).append(jQuery.ImageBox.options.closeHTML).bind("click",jQuery.ImageBox.hideImage);captionEl=document.createElement("div");jQuery(captionEl).attr("id","ImageBoxCaption").css({position:"relative",textAlign:"left",margin:"0 auto",zIndex:1}).append(captionText).append(captionImages).append(closeEl);loader=document.createElement("img");loader.src=jQuery.ImageBox.options.loaderSRC;jQuery(loader).attr("id","ImageBoxLoader").css({position:"absolute"});
prevImage=document.createElement("a");jQuery(prevImage).attr({id:"ImageBoxPrevImage",href:"#"}).css({position:"absolute",display:"none",overflow:"hidden",textDecoration:"none"}).append(document.createTextNode(" "));nextImage=document.createElement("a");jQuery(nextImage).attr({id:"ImageBoxNextImage",href:"#"}).css({position:"absolute",overflow:"hidden",textDecoration:"none"}).append(document.createTextNode(" "));container=document.createElement("div");jQuery(container).attr("id","ImageBoxContainer").css({display:"none",
position:"relative",overflow:"hidden",textAlign:"left",margin:"0 auto",top:"0",left:"0",zIndex:2}).append([loader,prevImage,nextImage]);outerContainer=document.createElement("div");jQuery(outerContainer).attr("id","ImageBoxOuterContainer").css({display:"none",position:"absolute",overflow:"hidden",top:"0",left:"0",textAlign:"center",backgroundColor:"transparent",lineHeight:"0"}).append([container,captionEl]);jQuery("body").append(overlay).append(outerContainer);prevImageEl=jQuery("#ImageBoxPrevImage");
if(prevWidth=prevImageEl.css("width")){if(prevWidth!="")prevWidth=prevWidth.replace(/px/g,"")}else prevWidth="";nextImageEl=jQuery("#ImageBoxNextImage");if(nextWidth=nextImageEl.css("width")){if(nextWidth!="")nextWidth=nextWidth.replace(/px/g,"")}else nextWidth="";jQuery.ImageBox.minWidth=-(-(jQuery.ImageBox.options.border*2)-nextWidth-prevWidth)},start:function(a,e){el=e?jQuery(e):jQuery(this);linkRel=el.attr("rel");var f,b,g,c;if(linkRel!="imagebox"){jQuery.ImageBox.currentRel=linkRel;gallery=jQuery("a[rel="+
linkRel+"]");f=gallery.size();b=gallery.index(e?e:this);g=gallery.get(b-1);c=gallery.get(b+1)}imageSrc=el.attr("href");captionText=el.attr("title");caption2=el.attr("content")||"";if(caption2!="")captionText+="<br>"+caption2;pageSize=jQuery.iUtil.getScroll();overlay=jQuery("#ImageBoxOverlay");if(jQuery.ImageBox.opened){jQuery("#ImageBoxPrevImage").get(0).onclick=null;jQuery("#ImageBoxNextImage").get(0).onclick=null;jQuery.ImageBox.loadImage(imageSrc,captionText,pageSize,f,b,g,c)}else{jQuery.ImageBox.opened=
true;jQuery.browser.msie&&jQuery("#ImageBoxIframe").css("height",Math.max(pageSize.ih,pageSize.h)+"px").css("width",Math.max(pageSize.iw,pageSize.w)+"px").show();overlay.css("height",Math.max(pageSize.ih,pageSize.h)+"px").css("width",Math.max(pageSize.iw,pageSize.w)+"px").show().fadeTo(300,jQuery.ImageBox.options.overlayOpacity,function(){jQuery.ImageBox.loadImage(imageSrc,captionText,pageSize,f,b,g,c)});jQuery("#ImageBoxOuterContainer").css("width",Math.max(pageSize.iw,pageSize.w)+"px")}return false},
loadImage:function(a,e,f,b,g,c,h){jQuery("#ImageBoxCurrentImage").remove();prevImageEl=jQuery("#ImageBoxPrevImage");prevImageEl.hide();nextImageEl=jQuery("#ImageBoxNextImage");nextImageEl.hide();loader=jQuery("#ImageBoxLoader");container=jQuery("#ImageBoxContainer");outerContainer=jQuery("#ImageBoxOuterContainer");captionEl=jQuery("#ImageBoxCaption").css("visibility","hidden");jQuery("#ImageBoxCaptionText").html("<div id='ImageBoxCaptextcontainer' style='padding-right:4px'>"+captionText+"</div>");
jQuery.ImageBox.animationInProgress=true;b&&jQuery.ImageBox.options.showTextImage&&jQuery("#ImageBoxCaptionImages").html(jQuery.ImageBox.options.textImage+" "+(g+1)+" "+jQuery.ImageBox.options.textImageFrom+" "+b);if(c)prevImageEl.get(0).onclick=function(){this.blur();jQuery.ImageBox.start(null,c);return false};if(h)nextImageEl.get(0).onclick=function(){this.blur();jQuery.ImageBox.start(null,h);return false};loader.show();containerSize=jQuery.iUtil.getSize(container.get(0));containerW=Math.max(containerSize.wb,
loader.get(0).width+jQuery.ImageBox.options.border*2);containerH=Math.max(containerSize.hb,loader.get(0).height+jQuery.ImageBox.options.border*2);loader.css({left:(containerW-loader.get(0).width)/2+"px",top:(containerH-loader.get(0).height)/2+"px"});container.css({width:containerW+"px",height:containerH+"px"}).show();clientSize=jQuery.iUtil.getClient();outerContainer.css("top",f.t+clientSize.h/15+"px");outerContainer.css("display")=="none"&&outerContainer.show().fadeIn(jQuery.ImageBox.options.fadeDuration);
imageEl=new Image;imageEl.id="ImageBoxCurrentImage";imageEl.onerror=function(){loader.hide();jQuery.ImageBox.hideImage();alert("Error loading images.");window.setTimeout("jQuery.ImageBox.hideImage();",300);return false};imageEl.onload=function(){if(jQImageBox_imageEl.width<=0||jQImageBox_imageEl.height<=0){imageEl.onerror();return false}if(jQuery.browser.safari){containerW=jQImageBox_imageEl.width+jQuery.ImageBox.options.border*2;containerH=jQImageBox_imageEl.height+jQuery.ImageBox.options.border*
2}containerW=imageEl.width+jQuery.ImageBox.options.border*2;containerH=imageEl.height+jQuery.ImageBox.options.border*2;if(jQuery.ImageBox.minWidth>containerW)containerW=jQuery.ImageBox.minWidth+jQuery.ImageBox.options.border*2;loader.hide();container.animate({height:containerH},containerSize.hb!=containerH?jQuery.ImageBox.options.fadeDuration:1,function(){container.animate({width:containerW},containerSize.wb!=containerW?jQuery.ImageBox.options.fadeDuration:1,function(){if(jQuery.browser.safari){var d=
"<img src='"+jQImageBox_imageEl.src+"' id='imgboxtmp' style='display:none' >";container.prepend(d);for(d=jQuery("#imgboxtmp").width();d==0;)d=jQuery("#imgboxtmp").width();jqi_height=jQuery("#imgboxtmp").height();jQuery("#imgboxtmp").remove();d-=2*jQuery.ImageBox.options.border;d="<img src='"+jQImageBox_imageEl.src+"' id='"+jQImageBox_imageEl.id+"' >";container.prepend(d)}else container.prepend(imageEl);jQuery("#ImageBoxCurrentImage").css({position:"absolute",left:(containerW-jQuery("#ImageBoxCurrentImage").width())/
2+"px",top:jQuery.ImageBox.options.border+"px"}).fadeIn(jQuery.ImageBox.options.fadeDuration,function(){captionSize=jQuery.iUtil.getSize(captionEl.get(0));if(jQuery.ImageBox.minWidth>containerW)containerW=jQuery.ImageBox.minWidth;c&&prevImageEl.css({left:jQuery.ImageBox.options.border+"px",top:jQuery.ImageBox.options.border+"px",width:containerW/2,height:containerH-jQuery.ImageBox.options.border*2+"px"}).show();h&&nextImageEl.css({left:containerW/2+jQuery.ImageBox.options.border*2+1+"px",top:jQuery.ImageBox.options.border+
"px",width:containerW/2-jQuery.ImageBox.options.border*3+"px",height:containerH-jQuery.ImageBox.options.border*2+"px"}).show();jQuery("#ImageBoxCaptextcontainer").css("padding-top",jQuery("#ImageBoxClose").height());captionEl.css({width:containerW+"px",top:-captionSize.hb+"px",visibility:"visible"}).animate({top:-1},jQuery.ImageBox.options.fadeDuration,function(){jQuery.ImageBox.animationInProgress=false})})})})};imageEl.src=a;jQImageBox_imageEl=imageEl},hideImage:function(){jQuery("#ImageBoxCurrentImage").remove();
jQuery("#ImageBoxOuterContainer").hide();jQuery("#ImageBoxCaption").css("visibility","hidden");jQuery("#ImageBoxOverlay").fadeTo(300,0,function(){jQuery(this).hide();jQuery.browser.msie&&jQuery("#ImageBoxIframe").hide()});jQuery("#ImageBoxPrevImage").get(0).onclick=null;jQuery("#ImageBoxNextImage").get(0).onclick=null;jQuery.ImageBox.currentRel=null;jQuery.ImageBox.opened=false;return jQuery.ImageBox.animationInProgress=false}};

