var ThinBox={modals:[],remove:function(){$(this.modals[0]).data("thinbox").remove();return false},resize:function(b,a){$(this.modals[0]).data("thinbox").resize(b,a);return false},onShow:function(a){}};(function(c){var b={width:"420px",height:"300px",margin:"0 auto",top:"10%",clickClose:true,fullHeight:false,animateResize:true,showCloseButton:true,fullHeightPadding:"30",thinboxModalBG:"thinboxModalBG",thinboxModalContent:"thinboxModalContent",thinboxModalContentBG:"thinboxModalContentBG",thinboxModalCloseButton:"thinboxModalCloseButton",thinboxModalContentBGColor:"#000",thinboxModalContentBGOpacity:"40",closeButton:"/ui/images/buttons/tb-close-button.gif",onShow:function(){}};var a=function(f,e){if(f==null){var g=true}else{var g=false;f=c(f)}var d=this;this.settings=c.extend(b,e||{});this.init=function(){if(!g){d.bindClick()}};this.bindClick=function(){f.bind("click",function(){d.showModal(f);return false})};this.getContentElement=function(){return c("#"+d.settings.thinboxModalContent)};this.setupModal=function(n){var k=c("<div/>").attr("id",d.settings.thinboxModalBG);var i=c("<div/>").attr("id",d.settings.thinboxModalContent).addClass(d.settings.thinboxModalContent);var j=c("<div/>").attr("id",d.settings.thinboxModalContentBG);c(k).css({height:c(window).height(),width:c(window).width(),position:"fixed",display:"none",top:"0",left:"0"}).appendTo("body");c(j).css({height:c(window).height(),width:c(window).width(),position:"absolute",top:"0",left:"0",background:d.settings.thinboxModalContentBGColor,opacity:"."+d.settings.thinboxModalContentBGOpacity,filter:"alpha(opacity="+d.settings.thinboxModalContentBGOpacity+")",zIndex:"999999"}).appendTo(k);var o=d.settings.height;var m=d.settings.width;if(n.isImage){o="";m=n.thinboxImage.width;var h={"float":"left"};if(m>950){m=950;h.width=950;h.height="auto"}if(n.thinboxImage.height>500){m=n.thinboxImage.width/n.thinboxImage.height*500;h.height=500;h.width="auto"}c(n.thinboxContent).css(h)}c(i).css({height:o,width:m,margin:d.settings.margin,top:d.settings.top,position:"relative",zIndex:"9999999"}).html(n.thinboxContent).appendTo(k);if(n.isImage&&n.imageDesc){c(n.imageDesc).appendTo(i)}if(n.isImage&&d.settings.showCloseButton){var l='<a class="jsThinboxClose '+d.settings.thinboxModalCloseButton+'"><img src="'+d.settings.closeButton+'" alt="Close" /></a>';c(l).appendTo(i)}if(n.inIframe){c(i).css({overflow:"hidden"})}if(d.settings.clickClose){c(k).bind("click",function(){d.remove()});c(i).bind("click",function(p){if(p.stopPropagation){p.stopPropagation()}else{p.cancelBubble=true}})}if(d.settings.fullHeight){d.resizeHeight()}c(".jsThinboxClose",i).bind("click",function(){d.remove();return false});c(window).bind("resize",function(){d.resizeBG();d.resizeBG();if(d.settings.fullHeight){d.resizeHeight()}});c(k).show();d.settings.onShow(d);if(c.browser.msie&&c.browser.version<=6){window.location="#"}};this.showModal=function(m,h){if(h!=null){var i=h}else{var i=c(m).attr("href")||c(m).attr("alt")||""}var q=/\.(jpe?g|png|gif|bmp)/gi;var k=false;if(i.substr(0,1)=="#"){var p=c(i).html();var l=false}else{if(i.match(q)){var o=new Image();var p=c("<img>").attr("src",i);var j=c(m).attr("title")?c(c(m).attr("title")).html():null;var l=false;var k=true}else{if(i==""){return false}else{var p=c("<iframe height='100%' width='100%' frameborder='0' style='border:0'></iframe>");p.attr("src",i);var l=true}}}var n={thinboxContent:p,inIframe:l,thinboxImage:o,imageDesc:j,isImage:k};if(k){o.onload=function(){d.setupModal(n)};o.src=i}else{this.setupModal(n)}return false};this.resizeBG=function(){c("#"+d.settings.thinboxModalBG).css({height:c(window).height(),width:c(window).width()});c("#"+d.settings.thinboxModalContentBG).css({height:c(window).height(),width:c(window).width()})};this.resizeHeight=function(){var h=parseInt(c(window).height())-(parseInt(d.settings.fullHeightPadding)*2);c("#"+d.settings.thinboxModalContent).css({height:h,top:d.settings.fullHeightPadding+"px"})};this.remove=function(){c("#"+d.settings.thinboxModalBG).remove();return false};this.resize=function(i,h){var j={height:h+"px",width:i+"px"};if(d.settings.animateResize){c("#"+d.settings.thinboxModalContent).animate(j)}else{c("#"+d.settings.thinboxModalContent).css(j)}};this.init()};c.fn.thinbox=function(d){ThinBox.options=d;return this.each(function(){var f=c(this);if(f.data("thinbox")){return}var e=new a(this,d);f.data("thinbox",e)})};c(document).ready(function(){ThinBox.modals=c("a[rel*='thinbox'],a.thinbox,input.thinbox").thinbox({onShow:function(){ThinBox.onShow(self)}})});ThinBox.open=function(e,d){settings=c.extend(b,d||{});thinbox=new a(null,settings);ThinBox.modals.push(c(document).data("thinbox",thinbox));thinbox.showModal("",e)}})(jQuery);
