var ___sbE=null;jQuery.fn.extend({openStagaBox:function(a){return this.each(function(){___sbE=this;$e=$(this);var b=$e.html();$e.find("*").each(function(c,d){if(typeof $(d).attr("id")!="undefined"&&$(d).attr("id")!=""){if(!$(d).hasClass("sbIdChanged")){$(d).attr("id","___sb"+$(d).attr("id")).addClass("sbIdChanged");}}});a.message=b;staga.UI.displayMessage(a);});},closeStagaBox:function(){$(document).trigger("close.stagaBox");},processcloseStagaBox:function(){return this.each(function(){$e=$(this);$e.find("*.sbIdChanged").each(function(a,b){$(b).attr("id",$(b).attr("id").substr(5)).removeClass("sbIdChanged");});if(typeof $.stagaBox.settings.params.onClose=="function"){$.stagaBox.settings.params.onClose.call($);}});},loadImageBox:function(a){if(typeof $.stagaBox.settings.imageBoxList=="undefined"){$.stagaBox.settings.imageBoxList=[];}delete $.stagaBox.settings.preloadList;return this.each(function(c,d){var b=$(this).attr("rel").replace(" ","_");if(b==""){b="default";}if(a){$.stagaBox.settings.imageBoxList[b]=[];a=false;}else{if(typeof $.stagaBox.settings.imageBoxList[b]=="undefined"){$.stagaBox.settings.imageBoxList[b]=[];}}$.stagaBox.settings.imageBoxList[b].push({imageId:c,imageUrl:this.href});$(this).unbind("click").click(function(){try{$.stagaBox.displayImage(b,c);}catch(e){staga.log(e);}return false;});});}});(function(a){a.stagaBox=function(b){b=a.extend({},staga.UI.stagaBoxDefaults,b);a.stagaBox.init({},b);a.stagaBox.loading();a.stagaBox.reveal(b.message,b.title,b.css,b);};a.stagaBox.settings={loading_image:"/style/themes/common/loading.gif",close_image:"/style/themes/common/closelabel.gif",image_types:["png","jpg","jpeg","gif"],stagaBox_html:'<div id="stagaBox" style="display:none;"> <div class="popup"> <table> <tbody> <tr> <td class="tl"/><td class="b"/><td class="tr"/> </tr> <tr> <td class="b"/><td class="body"><div class="header"></div> <div class="content"> </div> <div class="footer" style="border:none; padding:0;"> </div> </td> <td class="b"/> </tr> <tr> <td class="bl"/><td class="b"/><td class="br"/> </tr> </tbody> </table> </div> </div>'};a.stagaBox.loading=function(c){if(a("#stagaBox .loading").length==1){return true;}a("#stagaBox .content").empty();a("#stagaBox .body").children().hide().end().append('<div class="loading"><img src="'+a.stagaBox.settings.loading_image+'"/></div>');var b=a.stagaBox.getPageScroll();a("#stagaBox").css({top:b[1]+(a.stagaBox.getPageHeight()/10),left:b[0]}).show();a(document).unbind("keydown.stagaBox").bind("keydown.stagaBox",function(d){if(d.keyCode==27){a.stagaBox.close();}if(a.stagaBox.settings.params.imageBox){if(d.keyCode==37){a.stagaBox.switchImage(a.stagaBox.settings.params.imageIndex-1);}if(d.keyCode==39){a.stagaBox.switchImage(a.stagaBox.settings.params.imageIndex+1);}}});};a.stagaBox.imageBox=function(){a(".post-gallery-item a.post-image-enlarge").each(function(b,c){a(c).unbind().click(function(){staga.UI.displayMessage({message:'<img src="'+this.href+'" alt="" />',title:"Uploaded Image",imageBox:true,imageList:postImages,imageIndex:b});return false;});});};a.stagaBox.displayImage=function(b,c){a.stagaBox.settings.currentImageList=b;a.stagaBox.preloadImages(b,function(){staga.UI.displayMessage({message:'<img src="'+a.stagaBox.settings.imageBoxList[b][c].imageUrl+'" alt="" />',title:"Uploaded Image",imageBox:true,imageIndex:c,onLoad:function(){var d=a("#stagaBox .content");d.width(d.find("img").width()).height(d.find("img").height()).addClass("content-loading");}});});};a.stagaBox.preloadImages=function(c,h){if(typeof a.stagaBox.settings.preloadList=="undefined"){a.stagaBox.settings.preloadList={};}if(typeof a.stagaBox.settings.preloadList[c]!="undefined"){h();return false;}var e=a("body");var g=a.stagaBox.settings.imageBoxList[c];a.stagaBox.settings.preloadList[c]=true;for(var d=0,b=g.length;d<b;d++){var f="_stagaBox-"+c+d;if(a("#"+f).length==0){a("<img />").attr("id",f).attr("rel",c).attr("src",g[d].imageUrl).addClass("stagaBoxImage").load(function(){h();}).appendTo(e).hide();
}}};a.stagaBox.switchImage=function(f){var h=a.stagaBox.settings.imageBoxList[a.stagaBox.settings.currentImageList];var d=h[f];if(typeof d!="undefined"){a.stagaBox.settings.params.imageIndex=f;var c=a("#stagaBox .content");var g=a("img#_stagaBox-"+a.stagaBox.settings.currentImageList+f);var e;if(g.length!=0){e=g.clone().appendTo(c);}else{staga.log("img#_stagaBox-"+a.stagaBox.settings.currentImageList+f,"does not exist");return;}var b=a("#stagaBox .content img:visible");b.animate({opacity:0},200,function(){c.animate({height:e.height(),width:e.width()},500,function(){e.fadeIn(300);});}).remove();}};a.stagaBox.reveal=function(d,f,b,e){f=f?f:"";var c;if(a.stagaBox.settings.params.closeButton){c="<span class='text'>{0}</span><span class='close' onclick='$.stagaBox.close();'>X</span>".format(f);}else{c=f;}a("#stagaBox .header").removeAttr("class").addClass("header").html(c).addClass(b?b:"");if(typeof e.formatData!="undefined"){d=d.format.apply(d,e.formatData);}if(typeof e.height=="number"){a("#stagaBox .content").css("height",e.height);}if(typeof e.width=="number"){a("#stagaBox .content").css("width",e.width);}a("#stagaBox .loading").remove();a("#stagaBox .content").removeAttr("style").append(d);a("#stagaBox .body").children().fadeIn("normal");if(typeof e.onLoad=="function"){e.onLoad(d);}if(e.keepCentered){a(document).scroll(function(){clearTimeout(e.timer);e.timer=setTimeout(function(){var g=a(window).scrollTop()+30;a("#stagaBox").animate({top:g},350);},200);});}};a.stagaBox.center=function(){};a.stagaBox.close=function(){a(document).trigger("close.stagaBox");return false;};a(document).bind("close.stagaBox",function(){a(document).unbind("keydown.stagaBox");a("#stagaBox").fadeOut(function(){a("#stagaBox .content").removeClass().addClass("content");staga.UI.dimScreenStop();});if(typeof ___sbE!=null){a(___sbE).processcloseStagaBox();}});a.fn.stagaBox=function(c){a.stagaBox.init(c);var b=a.stagaBox.settings.image_types.join("|");b=new RegExp("."+b+"$","i");function d(){a.stagaBox.loading(true);var e=this.rel.match(/stagaBox\[\.(\w+)\]/);if(e){e=e[1];}if(this.href.match(/#/)){var f=window.location.href.split("#")[0];var h=this.href.replace(f,"");a.stagaBox.reveal(a(h).clone().show(),e);}else{if(this.href.match(b)){var g=new Image();g.onload=function(){a.stagaBox.reveal('<div class="image"><img src="'+g.src+'" /></div>',e);};g.src=this.href;}else{a.get(this.href,function(i){a.stagaBox.reveal(i,e);});}}return false;}this.click(d);return this;};a.stagaBox.init=function(c,d){a("#stagaBox .close").show();a("#stagaBox").remove();a.stagaBox.settings.inited=true;a.stagaBox.settings.params=d;if(c){a.extend(a.stagaBox.settings,c);}a("body").append(a.stagaBox.settings.stagaBox_html);var b=[new Image(),new Image()];b[0].src=a.stagaBox.settings.close_image;b[1].src=a.stagaBox.settings.loading_image;a("#stagaBox").find(".b:first, .bl, .br, .tl, .tr").each(function(){b.push(new Image());b.slice(-1).src=a(this).css("background-image").replace(/url\((.+)\)/,"$1");});a("#stagaBox .close").click(function(){a(this).hide();a.stagaBox.close();return false;});a("#stagaBox .close_image").attr("src",a.stagaBox.settings.close_image);};a.stagaBox.getPageScroll=function(){var c,b;if(self.pageYOffset){b=self.pageYOffset;c=self.pageXOffset;}else{if(document.documentElement&&document.documentElement.scrollTop){b=document.documentElement.scrollTop;c=document.documentElement.scrollLeft;}else{if(document.body){b=document.body.scrollTop;c=document.body.scrollLeft;}}}return new Array(c,b);};a.stagaBox.getPageHeight=function(){var b;if(self.innerHeight){b=self.innerHeight;}else{if(document.documentElement&&document.documentElement.clientHeight){b=document.documentElement.clientHeight;}else{if(document.body){b=document.body.clientHeight;}}}return b;};})(jQuery);