//ceebox
/*
 * CeeBox 2.0.4 jQuery Plugin (minimized version)
 * Requires jQuery 1.3.2 and swfobject.jquery.js plugin to work
 * Code hosted on GitHub (http://github.com/catcubed/ceebox) Please visit there for version history information
 * By Colin Fahrion (http://www.catcubed.com)
 * Inspiration for ceebox comes from Thickbox (http://jquery.com/demo/thickbox/) and Videobox (http://videobox-lb.sourceforge.net/)
 * However, along the upgrade path ceebox has morphed a long way from those roots.
 * Copyright (c) 2009 Colin Fahrion
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/

(function(c){function v(b,a){b=b.match(a);a=[];var d=b.length;if(d>1){a[0]=b[0];a[1]=b[1];a[2]=d==2?b[0]:b[2];a[3]=d==4?b[3]:b[1]}else a=[b,b,b,b];return a}function C(b,a,d){document.onkeydown=function(e){e=e||window.event;e=e.keyCode||e.which;switch(e){case 27:c.fn.ceebox.closebox(d);document.onkeydown=null;break;case 188:case 37:b&&b.prevId!=null&&s(a,b.prevId,d);break;case 190:case 39:b&&b.nextId!=null&&s(a,b.nextId,d);break}}}function D(b,a,d){function e(j,m){var l,n=k-2E3+"px",q=k+"px";j=="prev"?
(l=[{left:0},"left"]):(l=[{right:0},x="right"]);function o(p){return c.extend({width:f+"px",height:g+"px",position:"absolute",top:i},l[0],{backgroundPosition:l[1]+" "+p})}c("<a href='#'></a>").text(j).attr("id","cee_"+j).css(o(n)).hover(function(){c(this).css(o(q))},function(){c(this).css(o(n))}).one("click",function(p){p.preventDefault();s(a,m,d.fadeOut)}).appendTo("#cee_box")}var f=parseInt(d.width/2),g=d.height-d.titleHeight-2*d.padding,i=d.padding,k=g/2;if(d.type=="video"||d.type=="html"){f=60;
g=80;i=parseInt((d.height-d.titleHeight-2*d.padding-10)/2);k=24}if(d.type=="html")i=parseInt((d.height-d.titleHeight-10)/2);b.prevId!=null&&e("prev",b.prevId);b.nextId&&e("next",b.nextId);c("#cee_title").append("<div id='cee_count'>Item "+(b.cbId+1)+" of "+b.cbLen+"</div>")}function s(b,a,d){c("#cee_prev,#cee_next").unbind().click(function(){return false});document.onkeydown=null;var e=c("#cee_box").children(),f=e.length;e.fadeOut(d,function(){c(this).remove();this==e[f-1]&&b.eq(a).trigger("click")})}
function r(b,a){return b&&b<a||!a?b:a}function w(b){return typeof b=="function"}function E(b){return typeof b=="number"&&isFinite(b)}c.ceebox={version:"2.0.4"};c.fn.ceebox=function(b){b=c.extend({selector:c(this).selector},c.fn.ceebox.defaults,b);c(".cee_close").live("click",function(){c.fn.ceebox.closebox(b.fadeOut);return false});c(this).each(function(a){c.ceebox(this,a,b)});return this};c.fn.ceebox.defaults={html:true,image:true,video:true,modal:false,titles:true,htmlGallery:true,imageGallery:true,
videoGallery:true,videoWidth:false,videoHeight:false,videoRatio:"16:9",htmlWidth:false,htmlHeight:false,htmlRatio:false,imageWidth:false,imageHeight:false,animSpeed:"normal",easing:"swing",fadeOut:400,fadeIn:400,overlayColor:"#000",overlayOpacity:0.8,boxColor:"",textColor:"",borderColor:"",borderWidth:"3px",padding:15,margin:150,onload:null};c.fn.ceebox.ratios={"4:3":1.667,"3:2":1.5,"16:9":1.778,"1:1":1,square:1};c.fn.ceebox.relMatch={width:/\bwidth:[0-9]+\b/i,height:/\bheight:[0-9]+\b/i,modal:/\bmodal:true|false\b/i};
c.fn.ceebox.loader="<div id='cee_load' style='z-index:105;top:50%;left:50%;position:fixed'></div>";c.ceebox=function(b,a,d){var e,f=[],g=0;c(b).is("a[href],area[href],input[href]")?(e=c(b)):(e=c(b).children().andSelf().find("a[href],area[href],input[href]"));var i={image:function(j){return j.match(/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/i)||false},video:function(j){return j.match(F)||false},html:function(){return true}};e.each(function(j){var m=this,l=c.metadata?c.extend({},d,c(m).metadata()):d;c.each(i,
function(n){if(i[n](c(m).attr("href"))&&l[n]){if(d.htmlGallery==true&&n=="html"){f[g]=j;g++}else if(d.imageGallery==true&&n=="image"){f[g]=j;g++}else if(d.videoGallery==true&&n=="video"){f[g]=j;g++}c(m).unbind("click").bind("click",function(q){q.preventDefault();q.stopPropagation();c.fn.ceebox.overlay(l);if(n=="image"){var o=new Image;o.onload=function(){var p=o.width,y=o.height;l.imageWidth=r(p,c.fn.ceebox.defaults.imageWidth);l.imageHeight=r(y,c.fn.ceebox.defaults.imageHeight);l.imageRatio=p/y;
c.fn.ceebox.popup(m,c.extend(l,{type:n}))};o.src=c(m).attr("href")}else c.fn.ceebox.popup(m,c.extend(l,{type:n}))});return false}})});var k=f.length;c.each(f,function(j){var m=e[f[j]];if(k>1){var l={parentId:a,cbId:j,cbLen:k};if(j>0)l.prevId=f[j-1];if(j<k-1)l.nextId=f[j+1];c.data(m,"ceeboxGallery",l)}})};c.fn.ceebox.overlay=function(b){b=c.extend({width:60,height:30,type:"html"},c.fn.ceebox.defaults,b);c("#cee_overlay").size()==0&&c("<div id='cee_overlay'></div>").css({opacity:b.overlayOpacity,position:"absolute",
top:0,left:0,backgroundColor:b.overlayColor,width:"100%",height:c(document).height(),zIndex:100}).appendTo(c("body"));if(c("#cee_box").size()==0){var a=z(b);a={position:a.position,zIndex:102,top:"50%",left:"50%",height:b.height+"px",width:b.width+"px",marginLeft:a.mleft+"px",marginTop:a.mtop+"px",opacity:0,borderWidth:b.borderWidth,borderColor:b.borderColor,backgroundColor:b.boxColor,color:b.textColor};c("<div id='cee_box'></div>").css(a).appendTo("body").animate({opacity:1},b.animSpeed,function(){c("#cee_overlay").addClass("cee_close")})}c("#cee_box").removeClass().addClass("cee_"+
b.type);c("#cee_load").size()==0&&c(c.fn.ceebox.loader).appendTo("body").show("fast");c("#cee_load").show("fast").animate({opacity:1},"fast")};c.fn.ceebox.popup=function(b,a){function d(){c("#cee_load").hide(300).fadeOut(600,function(){c(this).remove()});w(a.action)&&a.action();w(a.onload)&&a.onload()}var e=A(a.margin);a=c.extend({width:e.width,height:e.height,modal:false,type:"html",onload:null},c.fn.ceebox.defaults,a);var f,g;if(c(b).is("a,area,input")&&(a.type=="html"||a.type=="image"||a.type==
"video")){if(f=c.data(b,"ceeboxGallery"))g=c(a.selector).eq(f.parentId).contents().andSelf().find("[href]");B[a.type].prototype=new G(b,a);e=new B[a.type];b=e.content;a.action=e.action;a.modal=e.modal;if(a.titles){a.titleHeight=c(e.titlebox).contents().contents().wrap("<div></div>").parent().attr("id","ceetitletest").css({position:"absolute",top:"-300px",width:e.width+"px"}).appendTo("body").height();c("#ceetitletest").remove();a.titleHeight=a.titleHeight>=10?a.titleHeight+20:30}else a.titleHeight=
0;a.width=e.width+2*a.padding;a.height=e.height+a.titleHeight+2*a.padding}c.fn.ceebox.overlay(a);e=z(a);e={marginLeft:e.mleft,marginTop:e.mtop,width:a.width+"px",height:a.height+"px",borderWidth:a.borderWidth};if(a.borderColor){var i=/#[1-90a-f]+/gi;i=v(a.borderColor,i);e=c.extend(e,{borderTopColor:i[0],borderRightColor:i[1],borderBottomColor:i[2],borderLeftColor:i[3]})}e=a.textColor?c.extend(e,{color:a.textColor}):e;e=a.boxColor?c.extend(e,{backgroundColor:a.boxColor}):e;c("#cee_box").animate(e,
a.animSpeed,a.easing,function(){var k=c(this).append(b).children().hide(),j=k.length;k.fadeIn(a.fadeIn,function(){if(c(this).is("iframe")){c(this).load(function(){d()});var m=true}!m&&this==k[j-1]&&d()});if(a.modal==true)c("#cee_overlay").removeClass("cee_close");else{c("<a href='#' id='cee_closeBtn' class='cee_close' title='Close'>close</a>").prependTo("#cee_box");f&&D(f,g,a);C(f,g,a.fadeOut)}})};c.fn.ceebox.closebox=function(b){b=b||400;c("#cee_box").fadeOut(b);c("#cee_overlay").fadeOut(E(b)?b*
2:"slow",function(){c("#cee_box,#cee_overlay,#cee_HideSelect,#cee_load").unbind().trigger("unload").remove()});document.onkeydown=null};function G(b,a){var d=a.type,e={image:[a.imageWidth,a.imageHeight,a.imageRatio||a.imageWidth/a.imageHeight],video:[a.videoWidth,a.videoHeight,a.videoRatio],html:[a.htmlWidth,a.htmlHeight,a.htmlRatio]},f=e[d][0],g=e[d][1],i=e[d][2];if((d=c(b).attr("rel"))&&d!=""){d=[d.match(c.fn.ceebox.relMatch.modal),d.match(c.fn.ceebox.relMatch.width),d.match(c.fn.ceebox.relMatch.height)];
if(d[0])var k=String(d[0]).match(/true|false/i);if(k=="true")this.modal=true;else if(k=="false")this.modal=false;if(d[1])f=Number(String(d[1]).match(/[0-9]+\b/));if(d[2])g=Number(String(d[2]).match(/[0-9]+\b/))}k=A(a.margin);f=r(f,k.width);g=r(g,k.height);if(i){if(!Number(i)){c.each(c.fn.ceebox.ratios,function(j,m){if(i==j){i=m;return false}});i=Number(i)||1}if(f/g>i)f=parseInt(g*i,10);if(f/g<i)g=parseInt(f/i,10)}this.modal=this.modal||a.modal;this.href=c(b).attr("href");this.title=c(b).attr("title");
this.titlebox=a.titles?"<div id='cee_title'><h2>"+this.title+"</h2></div>":"";this.width=f;this.height=g}var B={image:function(){this.content="<img id='cee_img' src='"+this.href+"' width='"+this.width+"' height='"+this.height+"' alt='"+this.title+"'/>"+this.titlebox},video:function(){var b=String(String(this.href.match(/\w+\.com/i)).match(/\w+/i));t[b]?(u.prototype=new t[b]):(u.prototype=new t.swf);b=new u(this.href);var a=b.src,d=b.prm,e=b.fvr,f=this.width,g=this.height;this.action=function(){c("#cee_vid").flash({swf:a,
params:d,flashvars:e,width:f,height:g})};this.content="<div id='cee_vid' style='width:"+this.width+"px;height:"+this.height+"px'></div>"+this.titlebox},html:function(){var b=this.href,a=this.rel;a=[b.match(/\w+\.com/i),b.match(/^http:+/),a?a.match(/^iframe/):false];if(document.domain==a[0]&&a[1]&&!a[2]||!a[1]&&!a[2]){var d=b;if(a=b.match(/#[a-z_A-Z1-9]+/)){d=b.split("#")[0];d=String(d+" "+a)}this.action=function(){c("#cee_ajax").load(d)};this.content=this.titlebox+"<div id='cee_ajax' style='width:"+
(this.width-30)+"px;height:"+(this.height-20)+"px'></div>"}else{c("#cee_iframe").remove();this.content=this.titlebox+"<iframe frameborder='0' hspace='0' src='"+b+"' id='cee_iframeContent' name='cee_iframeContent"+Math.round(Math.random()*1E3)+"'  style='width:"+this.width+"px;height:"+this.height+"px;' > </iframe>"}}},F=/youtube\.com\/watch|metacafe\.com\/watch|google\.com\/videoplay|ifilm\.com\/video|vimeo\.com|dailymotion\.com|facebook\.com\/video|\.swf$/i,t={facebook:function(){this.src=["/v/",
["v=",1,"&",0],""];this.prm={movie:this.src}},youtube:function(){this.src=["/v/",["v=",1,"&",0],"&hl=en&fs=1&autoplay=1"]},metacafe:function(){this.src=["/fplayer/",["id=",1,"&",0],"/.swf"]},google:function(){this.src=["/googleplayer.swf?docId=",["id=",1,"&",0],"&hl=en"];this.fvr={playerMode:"normal",fs:true}},ifilm:function(){this.src="/efp";this.prm=[h,"",["id=",1,"&",0],"&"]},vimeo:function(){this.src=["/moogaloop.swf?clip_id=",["/",3],"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1"]},
dailymotion:function(){this.src=["/swf/",["/",4],"&related=0&autoplay=1"]},swf:function(){this.src=false}};function u(b){this.prm=c.extend({wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"},this.prm);this.fvr=c.extend({autoplay:true},this.fvr);if(this.src){var a=this.src,d=b,e=0,f=a[1].length;do{d=d.split(a[1][e])[a[1][e+1]];e+=2}while(e<f);this.src=String(b.match(/http:\/\/[a-zA-Z\.]+\.com/))+a[0]+d+a[2]}else this.src=b}function A(b){var a=document.documentElement;b=b||100;this.width=
(window.innerWidth||self.innerWidth||a&&a.clientWidth||document.body.clientWidth)-b;this.height=(window.innerHeight||self.innerHeight||a&&a.clientHeight||document.body.clientHeight)-b;return this}function z(b){var a="fixed",d=0,e=/[0-9]+/g;e=v(b.borderWidth,e);if(!window.XMLHttpRequest){c("#cee_HideSelect")===null&&c("body").append("<iframe id='cb.HideSelect'></iframe>");a="absolute";d=parseInt(document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop,10)}this.mleft=parseInt(-1*
(b.width/2+Number(e[3])),10);this.mtop=parseInt(-1*(b.height/2+Number(e[0])),10)+d;this.position=a;return this}})(jQuery);