//ceebox
/*
 * Ceebox 1.4.3 jQuery Plugin - Minimized via YUI compressor
 * 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){a.ceebox={version:"1.4.3"};a.fn.ceebox=function(e){e=jQuery.extend({vidWidth:false,vidHeight:false,htmlWidth:false,htmlHeight:false,animSpeed:"normal",overlayColor:"#000",overlayOpacity:0.8},e);a(this).each(function(){if(a(this).is("a")||a(this).is("area")||a(this).is("input")){a(this).bind("click",function(l){l.preventDefault();a.ceebox.show(this.title||this.name||this.t||"",this.href||this.alt,this.rel||false);a(this).blur()})}return this});a.ceebox.show=function(n,o,p){var m=[{url:true,act:function(){a.ceebox.iframe(n,o,p)}},{url:(!o.match(/^http:+/)&&(p&&!p.match("iframe")))||(p&&p.match("ajax"))||false,act:function(){a.ceebox.ajax(n,o,p)}},{url:o.match(g)||false,act:function(){a.ceebox.video(n,o,p)}},{url:o.match(/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/i)||false,act:function(){a.ceebox.image(n,o,p)}}];var l=m.length;do{if(m[l-1]["url"]){m[l-1].act();break}}while(--l)};a.ceebox.iframe=function(m,o,p){var n=f(p);var q=[n[0]+29,n[1]+12];a("#cee_iframe").remove();var l="<div id='cee_title'><h2>"+m+"</h2></div><iframe frameborder='0' hspace='0' src='"+o+"' id='cee_iframeContent' name='cee_iframeContent"+Math.round(Math.random()*1000)+"'  style='width:"+q[0]+"px;height:"+q[1]+"px;' > </iframe>";a.ceebox.append(l,n[0]+30,n[1]+40,p,"cee_iframe")};a.ceebox.ajax=function(l,n,o){var m=f(o);var p=[m[0],m[1]-5];if(a("#cee_box").css("display")!="block"){a.ceebox.append("<div id='cee_title'><h2>"+l+"</h2></div><div id='cee_ajax' style='width:"+p[0]+"px;height:"+p[1]+"px'></div>",m[0]+30,m[1]+40,o,"cee_ajax")}else{a("#cee_ajaxContent")[0].style.width=p[0]+"px";a("#cee_ajaxContent")[0].style.height=p[1]+"px";a("#cee_ajaxContent")[0].scrollTop=0;a("#cee_ajaxWindowTitle").html(caption)}if(o&&o.match(/#[a-z_A-Z1-9]+/)){targetId=o.match(/#[a-z_A-Z1-9]+/);a("#cee_ajax").load(n+" "+targetId)}else{a("#cee_ajax").load(n)}a("#cee_ajax a.ceebox").ceebox()};a.ceebox.video=function(l,m,n){var p=j(l,m,n);var o=(!e.vidWidth||!e.vidHeight)?c(n):[e.vidWidth,e.vidHeight];a.ceebox.append("<div id='cee_vid'></div><div id='cee_title'><h2>"+l+"</h2></div>",o[0]+30,o[1]+60,n,"cee_vid");a("#cee_vid").flash({swf:p.src,params:p.params,width:o[0],height:o[1]})};var g=/youtube\.com\/watch|metacafe\.com\/watch|google\.com\/videoplay|ifilm\.com\/video|vimeo\.com|dailymotion\.com|facebook\.com\/video|\.swf$/i;function j(l,n,q){var u=String(n.match(/\w+\.com/i));var o="http://www."+u;var m,v;switch(u){case"facebook.com":m=o+"/v/"+n.split("v=")[1].split("&")[0];v={wmode:"transparent",movie:m,allowFullScreen:"true",allowScriptAccess:"always",flashvars:{autoplay:true}};break;case"youtube.com":m=o+"/v/"+n.split("v=")[1].split("&")[0]+"&hl=en&fs=1&autoplay=1";v={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};break;case"metacafe.com":m=o+"/fplayer/"+n.split("id=")[1].split("&")[0]+"/.swf";v={wmode:"transparent"};break;case"google.com":m="http://video.google.com/googleplayer.swf?docId="+n.split("id=")[1].split("&")[0]+"&hl=en";v={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always",flashvars:{autoplay:true,playerMode:"normal",fs:true}};break;case"ifilm.com":m=o+"/efp";v={wmode:"transparent",flashvars:{flvbaseclip:n.split("id=")[1].split("&")[0]+"&"}};break;case"vimeo.com":m=o+"/moogaloop.swf?clip_id="+n.split("/")[3]+"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1";v={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};break;case"dailymotion.com":m=o+"/swf/"+n.split("/")[4]+"&related=0&autoplay=1";v={allowFullScreen:"true",allowScriptAccess:"always"};break;default:m=n;v={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};break}return{src:m,params:v}}a.ceebox.image=function(m,n,o){var l=new Image();l.onload=function(){l.onload=null;var t=d();var p=t[0]-150;var s=t[1]-150;var q=l.width;var r=l.height;if(q>p){q=p;r=r*(p/q)}if(r>s){q=q*(s/r);r=s}a.ceebox.append("<img id='cee_img' src='"+n+"' width='"+q+"' height='"+r+"' alt='"+m+"'/><div id='cee_title'><h2>"+m+"</h2></div>",q+30,r+60,o,"cee_img");if(o){i(m,n,o,q,r)}};l.src=n};function k(l,m,n){document.onkeydown=null;a("#cee_box").empty();a.ceebox.image(l,m,n);return false}function i(y,p,l,v,n){var q=a("a[rel="+l+"]").get();var m=q.length;if(m>1){var s=v+30;var w=a("<div id='cee_nav'></div>").css({width:s,height:n});var o=m;do{if(q[o-1].href==p){var u=o;break}}while(--o);var x="<div id='cee_count'>Image "+(o)+" of "+(m)+"</div>";if(u>1){$ceePrev=a("<a href='#' id='cee_prev'>Previous</a>");$ceePrev.t=q[u-2].title;$ceePrev.bind("click",function(r){r.preventDefault();k($ceePrev.t,$ceePrev.attr("href"),l)}).appendTo(w).attr({href:q[u-2].href})}if(u<m){$ceeNext=a("<a href='#' id='cee_next'>Next</a>");$ceeNext.t=q[u].title;$ceeNext.bind("click",function(r){r.preventDefault();k($ceeNext.t,$ceeNext.attr("href"),l)}).appendTo(w).attr({href:q[u].href})}}a("#cee_title").prepend(w).append(x)}a.ceebox.append=function(s,n,u,l,t){a("<div id='cee_load'></div>").appendTo("body").show;if(a.browser.opera){a("body").append("<span style='line-height:0px;color:rgba(0,0,0,0)' rel='lame opera hack'>-</span>")}if(typeof document.body.style.maxHeight==="undefined"){if(a("#cee_HideSelect")===null){a("body").append("<iframe id='cee_HideSelect'></iframe>")}var q="absolute";var o=document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop;var m=parseInt(-1*(u/2-o),10)+"px"}else{var q="fixed";var m=parseInt(-1*(u/2),10)+"px"}var p=parseInt(-1*(n/2),10)+"px";if(a("#cee_overlay").size()==0){a("<div id='cee_overlay'></div>").css({opacity:e.overlayOpacity,position:"absolute",top:0,left:0,backgroundColor:e.overlayColor,width:"100%",height:a(document).height(),zIndex:100}).appendTo(a("body"))}if(a("#cee_box").size()==0){a("<div id='cee_box'></div>").addClass(t).css({position:q,zIndex:102,top:"50%",left:"50%"}).appendTo("body")}a("#cee_box").animate({marginLeft:p,marginTop:m,height:u+"px",width:n+"px"},e.animSpeed,function(){a("#cee_box").children().fadeIn("fast")}).append(s).children().hide();if(l&&l.match("modal")){a("#cee_overlay").unbind()}else{a("#cee_title").prepend("<a href='#' id='cee_closeBtn' title='Close'>close</a>");a("#cee_closeBtn").click(b);a("#cee_overlay").click(b)}a(".cee_close").live("click",function(r){r.preventDefault();b()});a("#cee_load").hide();h(l)};function f(l){return(!e.htmlWidth||!e.htmlHeight)?c(l):[e.htmlWidth,e.htmlHeight]}function c(o){var p=d();var l=p[0]-150;var n=p[1]-150;var m=new Array();if(o&&o.match(/[0-9]+/g)){var m=o.match(/[0-9]+/g);m[0]=(m[0])?m[0]*1:l;m[1]=(m[1])?m[1]*1:n}else{m=[l,n]}return m}function d(){var o=document.documentElement;var l=window.innerWidth||self.innerWidth||(o&&o.clientWidth)||document.body.clientWidth;var m=window.innerHeight||self.innerHeight||(o&&o.clientHeight)||document.body.clientHeight;var n=[l,m];return n}function b(){a("#cee_closeBtn").unbind("click");a("#cee_box").fadeOut("fast",function(){a("#cee_box,#cee_overlay,#cee_HideSelect").unbind().trigger("unload").remove()});a("#cee_load").remove();document.onkeydown=null;document.onkeyup=null;return false}function h(l){document.onkeydown=function(n){n=n||window.event;var m=n.keyCode||n.which;switch(m){case 27:b();break;case 188:case 37:if(a("#cee_prev").size()!=0){k($ceePrev.t,$ceePrev.attr("href"),l)}break;case 190:case 39:if(a("#cee_next").size()!=0){k($ceeNext.t,$ceeNext.attr("href"),l)}break}}}}})(jQuery);
