(function($){$.fn.thickBox=function(){this.click($.thickBox.show)};$.thickBox=new function(){var j=this;this.widgets={'shade':$('<div id="TB_overlay"></div>'),'dialogue':$('<div id="TB_window"></div>'),'throbber':$('<div id="TB_load"></div>'),'titleBar':$('<div id="TB_title"></div>'),'title':$('<div id="TB_ajaxWindowTitle"></div>'),'closeContainer':$('<div id="TB_closeAjaxWindow"></div>'),'closeButton':$('<a id="TB_closeWindowButton">Close</a>'),'captionBar':$('<div id="TB_caption"></div>'),'caption':$('<div></div>'),'previousButton':$('<a id="TB_prev">« Previous</a>'),'nextButton':$('<a id="TB_next">Next »</a>'),'content':null};this.active=false;this.modal=false;this.currentGroup=[];this.currentIndex=-1;this.throbber=new Image();this.throbber.src=window.theme_location+'/images/throbber.gif';this.contentLoader=undefined;this.contentWidth=-1;this.contentHeight=-1;this.activate=function(){if(this.rel){j.currentGroup=$('*[rel="'+this.rel+'"]')}else{j.currentGroup=$(this)}j.widgets.shade.show();j.widgets.dialogue.hide();$(document.body).append(j.widgets.shade).append(j.widgets.dialogue).append(j.widgets.throbber);this.active=true};this.show=function(e){e.stopPropagation();e.preventDefault();if(!this.active){j.activate.call(this)}if(typeof document.body.style.maxHeight=='undefined'){$('html, body').css({'height':'100%','width':'100%'});$('html').css('overflow','hidden');$(document.body).append('<iframe id="TB_HideSelect"></iframe>')}$(document).keypress(j.onKeyPressed);j.currentIndex=j.currentGroup.index(this);j.widgets.throbber.show();j.widgets.previousButton[j.currentIndex>0?'show':'hide']();j.widgets.nextButton[j.currentIndex<j.currentGroup.length-1?'show':'hide']();var a=this.href.indexOf("?")!=-1?this.href.substr(0,this.href.indexOf('?')):this.href;if(j.contentLoader!=undefined){$(j.contentLoader).unbind('load',j.onContentLoaded);$(j.contentLoader).remove();j.contentLoader=undefined}var b=[],pairs,pair,safeUrl=this.href.split(/[?&]TB_/)[0],isImage=/\.(jpe?g|jfif?|png|gif|bmp)$/i.test(a),isObject=/\.(swf|svgz?)$/i.exec(a),isIframe=this.href.indexOf('TB_iframe')!=-1,isInline=this.href.indexOf('TB_inline')!=-1,isAjax=!isImage&&!isObject&&!isIframe&&!isInline;if(this.href.indexOf('?')!=-1){pairs=this.href.substr(this.href.indexOf('?')+1).split('&');for(var i=pairs.length-1;i>=0;--i){pair=pairs[i].split('=');if(pair.length==1){b.push(decodeURIComponent(pair[0]))}else{b[decodeURIComponent(pair[0])]=decodeURIComponent(pair[1])}}}delete pairs;delete pair;j.contentWidth=b.width?(parseInt(b.width,10)+(isIframe?30:0)):630;j.contentHeight=b.height?(parseInt(b.height,10)+(isIframe?40:0)):440;j.modal=b.modal||false;if(isImage){j.contentLoader=$('<img />').load(j.onContentLoaded).attr('src',safeUrl)}if(isObject){var c=/\.(swf|svgz?)$/i.exec(a)[1];var d;switch(c){case'swf':d='application/x-shockwave-flash';break;case'svg':case'svgz':d='image/svg+xml';break}j.contentLoader=$('<object type="'+d+'" width="'+j.contentWidth+'" height="'+j.contentHeight+'"></object>').load(j.onContentLoaded);if(c=='swf'){j.contentLoader.append('<param name="movie" value="'+safeUrl+'" />')}j.contentLoader.attr('data',safeUrl)}if(isIframe){j.contentLoader=$('<iframe id="TB_iframeContent" frameborder="no" framespacing="0" scrolling="'+(b.scrolling||'auto')+'"></iframe>').load(j.onContentLoaded).attr('src',safeUrl)}if(isInline){j.contentLoader=$('<div id="TB_ajaxContent"></div>').append($('#'+b.inlineId).html()).insertAfter(j.widgets.titleBar);j.onContentLoaded.call(j.contentLoader);return}if(isAjax){j.contentLoader=$('<div id="TB_ajaxContent"></div>').load(safeUrl,j.onContentLoaded)}j.contentLoader.hide().insertAfter(j.widgets.titleBar)};this.onContentLoaded=function(e){var a=j.currentGroup[j.currentIndex];if(a.title){j.widgets.title.html(a.title)}if(j.widgets.content){j.widgets.content.remove()}j.widgets.content=$(this).unbind('load',arguments.callee);j.contentLoader=undefined;j.widgets.throbber.fadeOut();j.widgets.dialogue.fadeIn();j.widgets.content.fadeIn();var b=j.widgets.content.outerWidth(true)-j.widgets.content.width();var c=(j.widgets.content.outerHeight(true)-j.widgets.content.height())+j.widgets.titleBar.outerHeight(true)+j.widgets.captionBar.outerHeight(true);if(/^(img|object)$/i.test(this.nodeName)){var x=$(window).width()-b-80;var y=$(window).height()-c-50;var d=this.width;var f=this.height;if(d>x){f=f*(x/d);d=x;if(f>y){d=d*(y/f);f=y}}else if(f>y){d=d*(y/f);f=y;if(d>x){f=f*(x/d);d=x}}j.contentWidth=d;j.contentHeight=f;delete d;delete f;delete x;delete y}j.widgets.content.css({'width':j.contentWidth+'px','height':j.contentHeight+'px'});var g=b+j.widgets.content.width();var h=c+j.widgets.content.height();j.widgets.dialogue.css({'margin-top':'-'+(h*0.5)+'px','margin-left':'-'+(g*0.5)+'px','width':g+'px','height':h+'px'});if(typeof document.body.style.maxHeight=='undefined'){j.widgets.dialogue.css('margin-top','')}};this.next=function(e){j.show.call(j.currentGroup[j.currentIndex+1],e)};this.previous=function(e){j.show.call(j.currentGroup[j.currentIndex-1],e)};this.close=function(e){$(document).unbind('keypress',j.onKeyPressed);j.widgets.throbber.fadeOut();j.widgets.dialogue.fadeOut('normal',function(){if(typeof document.body.style.maxHeight=='undefined'){$('#TB_HideSelect').remove();$('html, body').css({'height':'','width':''});$('html').css('overflow','');$('#TB_HideSelect').remove()}j.widgets.content.remove();j.widgets.content=undefined;j.widgets.shade.hide()})};this.onKeyPressed=function(e){if(e.keyCode==27){j.close(e)}else if(e.keyCode==190&&j.currentIndex<j.currentGroup.length-1){this.next(e)}else if(e.keyCode==188&&j.currentIndex>0){this.previous(e)}};with(this.widgets){closeContainer.append(closeButton);titleBar.append(title).append(closeContainer);captionBar.append(previousButton).append(nextButton).append(caption);dialogue.append(titleBar).append(captionBar);throbber.click(this.close);shade.click(this.close);closeButton.click(this.close);previousButton.click(this.previous);nextButton.click(this.next)}}})(jQuery);$(function(){$('a.thickbox, area.thickbox, input.thickbox').thickBox()});
