//ceebox
/*
* CeeBox 2.1.5.1 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(a){function u(c,b,d){m.vidRegex=function(){var f="";a.each(a.fn.ceebox.videos,function(e,i){if(i.siteRgx!==null&&typeof i.siteRgx!=="string"){var g=String(i.siteRgx);f=f+g.slice(1,g.length-2)+"|"}});return RegExp(f+"\\.swf$","i")}();m.userAgent=navigator.userAgent;a(".cee_close").die().live("click",function(){a.fn.ceebox.closebox();return false});d!=false&&a(c).each(function(f){A(this,f,b,d)});a(c).live("click",function(f){var e=a(f.target).closest("[href]"),i=e.data("ceebox");if(i){var g=
i.opts?a.extend({},b,i.opts):b;a.fn.ceebox.overlay(g);if(i.type=="image"){var h=new Image;h.onload=function(){var l=h.width,k=h.height;g.imageWidth=l&&l<a.fn.ceebox.defaults.imageWidth||!a.fn.ceebox.defaults.imageWidth?l:a.fn.ceebox.defaults.imageWidth;g.imageHeight=k&&k<a.fn.ceebox.defaults.imageHeight||!a.fn.ceebox.defaults.imageHeight?k:a.fn.ceebox.defaults.imageHeight;g.imageRatio=l/k;a.fn.ceebox.popup(e,a.extend(g,{type:i.type},{gallery:i.gallery}))};h.src=a(e).attr("href")}else a.fn.ceebox.popup(e,
a.extend(g,{type:i.type},{gallery:i.gallery}));return false}})}function v(c){var b=document.documentElement;c=c||100;this.width=(window.innerWidth||self.innerWidth||b&&b.clientWidth||document.body.clientWidth)-c;this.height=(window.innerHeight||self.innerHeight||b&&b.clientHeight||document.body.clientHeight)-c;return this}function w(c){var b="fixed",d=0,f=y(c.borderWidth,/[0-9]+/g);if(!window.XMLHttpRequest){a("#cee_HideSelect")===null&&a("body").append("<iframe id='cee_HideSelect'></iframe>");b=
"absolute";d=parseInt(document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop,10)}this.mleft=parseInt(-1*(c.width/2+Number(f[3])),10);this.mtop=parseInt(-1*(c.height/2+Number(f[0])),10)+d;this.position=b;return this}function y(c,b){var d=c.match(b),f=[],e=d.length;if(e>1){f[0]=d[0];f[1]=d[1];f[2]=e==2?d[0]:d[2];f[3]=e==4?d[3]:d[1]}else f=[d,d,d,d];return f}function B(){document.onkeydown=function(c){c=c||window.event;switch(c.keyCode||c.which){case 13:return false;case 27:a.fn.ceebox.closebox();
document.onkeydown=null;break;case 188:case 37:a("#cee_prev").trigger("click");break;case 190:case 39:a("#cee_next").trigger("click")}return true}}function C(c,b,d){function f(l,k){var j,o=h[d.type].bgtop,n=o-2E3;l=="prev"?j=[{left:0},"left"]:j=[{right:0},x="right"];var p=function(r){return a.extend({zIndex:105,width:h[d.type].w+"px",height:h[d.type].h+"px",position:"absolute",top:h[d.type].top,backgroundPosition:j[1]+" "+r+"px"},j[0])};a("<a href='#'></a>").text(l).attr({id:"cee_"+l}).css(p(n)).hover(function(){a(this).css(p(o))},
function(){a(this).css(p(n))}).one("click",function(r){r.preventDefault();(function(D,E,F){a("#cee_prev,#cee_next").unbind().click(function(){return false});document.onkeydown=null;var t=a("#cee_box").children(),G=t.length;t.fadeOut(F,function(){a(this).remove();this==t[G-1]&&D.eq(E).trigger("click")})})(b,k,d.fadeOut)}).appendTo("#cee_box")}var e=d.height,i=d.titleHeight,g=d.padding,h={image:{w:parseInt(d.width/2,10),h:e-i-2*g,top:g,bgtop:(e-i-2*g)/2},video:{w:60,h:80,top:parseInt((e-i-10-2*g)/2,
10),bgtop:24}};h.html=h.video;c.prevId>=0&&f("prev",c.prevId);c.nextId&&f("next",c.nextId);a("#cee_title").append("<div id='cee_count'>Item "+(c.gNum+1)+" of "+c.gLen+"</div>")}function s(c){return typeof c=="function"}function q(c){var b=c.length;return b>1?c[b-1]:c}a.ceebox={version:"2.1.5.1"};a.fn.ceebox=function(c){c=a.extend({selector:a(this).selector},a.fn.ceebox.defaults,c);var b=this,d=a(this).selector;c.videoJSON?a.getJSON(c.videoJSON,function(f){a.extend(a.fn.ceebox.videos,f);u(b,c,d)}):
u(b,c,d);return this};a.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,unload:null,videoJSON:null,
iPhoneRedirect:true};a.fn.ceebox.ratios={"4:3":1.333,"3:2":1.5,"16:9":1.778,"1:1":1,square:1};a.fn.ceebox.relMatch={width:/(?:width:)([0-9]+)/i,height:/(?:height:)([0-9]+)/i,ratio:/(?:ratio:)([0-9\.:]+)/i,modal:/modal:true/i,nonmodal:/modal:false/i,videoSrc:/(?:videoSrc:)(http:[\/\-\._0-9a-zA-Z:]+)/i,videoId:/(?:videoId:)([\-\._0-9a-zA-Z:]+)/i,start:/(?:start:)([0-9]+)/i};a.fn.ceebox.loader="<div id='cee_load' style='z-index:105;top:50%;left:50%;position:fixed'></div>";a.fn.ceebox.videos={base:{param:{wmode:"transparent",
allowFullScreen:"true",allowScriptAccess:"always"},flashvars:{autoplay:true}},facebook:{siteRgx:/facebook\.com\/video/i,idRgx:/(?:v=)([a-zA-Z0-9_]+)/i,src:"http://www.facebook.com/v/[id]"},youtube:{siteRgx:/youtube\.com\/watch/i,idRgx:/(?:v=)([a-zA-Z0-9_\-]+)/i,src:"http://www.youtube.com/v/[id]&hl=en&fs=1&autoplay=1"},metacafe:{siteRgx:/metacafe\.com\/watch/i,idRgx:/(?:watch\/)([a-zA-Z0-9_]+)/i,src:"http://www.metacafe.com/fplayer/[id]/.swf"},google:{siteRgx:/google\.com\/videoplay/i,idRgx:/(?:id=)([a-zA-Z0-9_\-]+)/i,
src:"http://video.google.com/googleplayer.swf?docId=[id]&hl=en&fs=true",flashvars:{playerMode:"normal",fs:true}},spike:{siteRgx:/spike\.com\/video|ifilm\.com\/video/i,idRgx:/(?:\/)([0-9]+)/i,src:"http://www.spike.com/efp",flashvars:{flvbaseclip:"[id]"}},vimeo:{siteRgx:/vimeo\.com\/[0-9]+/i,idRgx:/(?:\.com\/)([a-zA-Z0-9_]+)/i,src:"http://www.vimeo.com/moogaloop.swf?clip_id=[id]&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1"},dailymotion:{siteRgx:/dailymotion\.com\/video/i,
idRgx:/(?:video\/)([a-zA-Z0-9_]+)/i,src:"http://www.dailymotion.com/swf/[id]&related=0&autoplay=1"},cnn:{siteRgx:/cnn\.com\/video/i,idRgx:/(?:\?\/video\/)([a-zA-Z0-9_\/\.]+)/i,src:"http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=[id]",width:416,height:374}};a.fn.ceebox.overlay=function(c){c=a.extend({width:60,height:30,type:"html"},a.fn.ceebox.defaults,c);a("#cee_overlay").size()===0&&a("<div id='cee_overlay'></div>").css({opacity:c.overlayOpacity,
position:"absolute",top:0,left:0,backgroundColor:c.overlayColor,width:"100%",height:a(document).height(),zIndex:100}).appendTo(a("body"));if(a("#cee_box").size()===0){var b=w(c);b={position:b.position,zIndex:102,top:"50%",left:"50%",height:c.height+"px",width:c.width+"px",marginLeft:b.mleft+"px",marginTop:b.mtop+"px",opacity:0,borderWidth:c.borderWidth,borderColor:c.borderColor,backgroundColor:c.boxColor,color:c.textColor};a("<div id='cee_box'></div>").css(b).appendTo("body").animate({opacity:1},
c.animSpeed,function(){a("#cee_overlay").addClass("cee_close")})}a("#cee_box").removeClass().addClass("cee_"+c.type);a("#cee_load").size()===0&&a(a.fn.ceebox.loader).appendTo("body");a("#cee_load").show("fast").animate({opacity:1},"fast")};a.fn.ceebox.popup=function(c,b){var d=v(b.margin);b=a.extend({width:d.width,height:d.height,modal:false,type:"html",onload:null},a.fn.ceebox.defaults,b);var f;if(a(c).is("a,area,input")&&(b.type=="html"||b.type=="image"||b.type=="video")){if(b.gallery)f=a(b.selector).eq(b.gallery.parentId).find("a[href],area[href],input[href]");
z[b.type].prototype=new H(c,b);d=new z[b.type];c=d.content;b.action=d.action;b.modal=d.modal;if(b.titles){b.titleHeight=a(d.titlebox).contents().contents().wrap("<div></div>").parent().attr("id","ceetitletest").css({position:"absolute",top:"-300px",width:d.width+"px"}).appendTo("body").height();a("#ceetitletest").remove();b.titleHeight=b.titleHeight>=10?b.titleHeight+20:30}else b.titleHeight=0;b.width=d.width+2*b.padding;b.height=d.height+b.titleHeight+2*b.padding}a.fn.ceebox.overlay(b);m.action=
b.action;m.onload=b.onload;m.unload=b.unload;d=w(b);d={marginLeft:d.mleft,marginTop:d.mtop,width:b.width+"px",height:b.height+"px",borderWidth:b.borderWidth};if(b.borderColor){var e=y(b.borderColor,/#[1-90a-f]+/gi);d=a.extend(d,{borderTopColor:e[0],borderRightColor:e[1],borderBottomColor:e[2],borderLeftColor:e[3]})}d=b.textColor?a.extend(d,{color:b.textColor}):d;d=b.boxColor?a.extend(d,{backgroundColor:b.boxColor}):d;a("#cee_box").animate(d,b.animSpeed,b.easing,function(){var i=a(this).append(c).children().hide(),
g=i.length,h=true;i.fadeIn(b.fadeIn,function(){if(a(this).is("#cee_iframeContent"))h=false;h&&this==i[g-1]&&a.fn.ceebox.onload()});if(b.modal===true)a("#cee_overlay").removeClass("cee_close");else{a("<a href='#' id='cee_closeBtn' class='cee_close' title='Close'>close</a>").prependTo("#cee_box");b.gallery&&C(b.gallery,f,b);B(void 0,f,b.fadeOut)}})};a.fn.ceebox.closebox=function(c,b){c=c||400;a("#cee_box").fadeOut(c);a("#cee_overlay").fadeOut(typeof c=="number"?c*2:"slow",function(){a("#cee_box,#cee_overlay,#cee_HideSelect,#cee_load").unbind().trigger("unload").remove();
if(s(b))b();else s(m.unload)&&m.unload();m.unload=null});document.onkeydown=null};a.fn.ceebox.onload=function(){a("#cee_load").hide(300).fadeOut(600,function(){a(this).remove()});if(s(m.action)){m.action();m.action=null}if(s(m.onload)){m.onload();m.onload=null}};var m={},A=function(c,b,d){var f,e=[],i=[],g=0;a(c).is("[href]")?f=a(c):f=a(c).find("[href]");var h={image:function(k,j){return j&&j.match(/\bimage\b/i)?true:k.match(/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/i)||false},video:function(k,j){return j&&
j.match(/\bvideo\b/i)?true:k.match(m.vidRegex)||false},html:function(){return true}};f.each(function(k){var j=this,o=a.metadata?a(j).metadata():false,n=o?a.extend({},d,o):d;a.each(h,function(p){if(h[p](a(j).attr("href"),a(j).attr("rel"))&&n[p]){var r=false;if(n[p+"Gallery"]===true){i[i.length]=k;r=true}e[e.length]={linkObj:j,type:p,gallery:r,linkOpts:n};return false}})});var l=i.length;a.each(e,function(k){if(e[k].gallery){var j={parentId:b,gNum:g,gLen:l};if(g>0)j.prevId=i[g-1];if(g<l-1)j.nextId=
i[g+1];g++}!a.support.opacity&&a(c).is("map")&&a(e[k].linkObj).click(function(o){o.preventDefault()});a.data(e[k].linkObj,"ceebox",{type:e[k].type,opts:e[k].linkOpts,gallery:j})})},H=function(c,b){var d=b[b.type+"Width"],f=b[b.type+"Height"],e=b[b.type+"Ratio"]||d/f,i=a(c).attr("rel");if(i&&i!==""){var g={};a.each(a.fn.ceebox.relMatch,function(l,k){g[l]=k.exec(i)});if(g.modal)b.modal=true;if(g.nonmodal)b.modal=false;if(g.width)d=Number(q(g.width));if(g.height)f=Number(q(g.height));if(g.ratio){e=q(g.ratio);
e=Number(e)?Number(e):String(e)}if(g.videoSrc)this.videoSrc=String(q(g.videoSrc));if(g.videoId)this.videoId=String(q(g.videoId));if(g.start)this.startTime=Number(q(g.start))}var h=v(b.margin);d=d&&d<h.width||!h.width?d:h.width;f=f&&f<h.height||!h.height?f:h.height;if(e){Number(e)||(e=a.fn.ceebox.ratios[e]?Number(a.fn.ceebox.ratios[e]):1);if(d/f>e)d=parseInt(f*e,10);if(d/f<e)f=parseInt(d/e,10)}this.modal=b.modal;this.href=a(c).attr("href");this.title=a(c).attr("title")||c.t||"";this.titlebox=b.titles?
"<div id='cee_title'><h2>"+this.title+"</h2></div>":"";this.width=d;this.height=f;this.rel=i;this.iPhoneRedirect=b.iPhoneRedirect},z={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 c="",b=this,d=function(){var e=this,i=b.videoId;e.flashvars=e.param={};e.src=b.videoSrc||b.href;e.width=b.width;e.height=b.height;a.each(a.fn.ceebox.videos,function(g,h){if(h.siteRgx&&typeof h.siteRgx!=
"string"&&h.siteRgx.test(b.href)){if(h.idRgx){h.idRgx=RegExp(h.idRgx);i=String(q(h.idRgx.exec(b.href)))}e.src=h.src?h.src.replace("[id]",i):e.src;var l=RegExp(/(?:t=)*([0-9]+)s/i),k=RegExp(/(?:t=)*([0-9]+)m/i).exec(b.href);l=l.exec(b.href);var j=0;if(k)j=Number(k[1])*60;if(l)j+=Number(l[1]);h.flashvars&&a.each(h.flashvars,function(o,n){if(typeof n=="string")e.flashvars[o]=n.replace("[id]",i)});h.param&&a.each(h.param,function(o,n){if(typeof n=="string")e.param[o]=n.replace("[id]",i)});if(b.startTime||
j)e.param.start=j||b.startTime;e.width=h.width||e.width;e.height=h.height||e.height;e.site=g}});return e}();if(a.flash.hasVersion(8)){this.width=d.width;this.height=d.height;this.action=function(){a("#cee_vid").flash({swf:d.src,params:a.extend(a.fn.ceebox.videos.base.param,d.param),flashvars:a.extend(a.fn.ceebox.videos.base.flashvars,d.flashvars),width:d.width,height:d.height})}}else{this.width=400;this.height=200;if(m.userAgent.match(/iPhone/i)&&this.iPhoneRedirect||m.userAgent.match(/iPod/i)&&this.iPhoneRedirect){var f=
this.href;this.action=function(){a.fn.ceebox.closebox(400,function(){window.location=f})}}else{d.site=d.site||"SWF file";c="<p style='margin:20px'>Adobe Flash 8 or higher is required to view this movie. You can either:</p><ul><li>Follow link to <a href='"+this.href+"'>"+d.site+" </a></li><li>or <a href='http://www.adobe.com/products/flashplayer/'>Install Flash</a></li><li> or <a href='#' class='cee_close'>Close This Popup</a></li></ul>"}}this.content="<div id='cee_vid' style='width:"+this.width+"px;height:"+
this.height+"px;'>"+c+"</div>"+this.titlebox},html:function(){var c=this.href,b=this.rel;b=[c.match(/[a-zA-Z0-9_\.]+\.[a-zA-Z]{2,4}/i),c.match(/^http:+/),b?b.match(/^iframe/):false];if(document.domain==b[0]&&b[1]&&!b[2]||!b[1]&&!b[2]){var d,f=(d=c.match(/#[a-zA-Z0-9_\-]+/))?String(c.split("#")[0]+" "+d):c;this.action=function(){a("#cee_ajax").load(f)};this.content=this.titlebox+"<div id='cee_ajax' style='width:"+(this.width-30)+"px;height:"+(this.height-20)+"px'></div>"}else{a("#cee_iframe").remove();
this.content=this.titlebox+"<iframe frameborder='0' hspace='0' src='"+c+"' id='cee_iframeContent' name='cee_iframeContent"+Math.round(Math.random()*1E3)+"' onload='jQuery.fn.ceebox.onload()' style='width:"+this.width+"px;height:"+this.height+"px;' > </iframe>"}}}})(jQuery);
