//ceebox
/*
 * Ceebox 1.4.1 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.1"};a.fn.ceebox=function(e){e=jQuery.extend({vidWidth:false,vidHeight:false,htmlWidth:false,htmlHeight:false},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(w,s,m){a("body").append("<div id='cee_load'></div>");a("#cee_load").show();var n=(s.indexOf("?")!==-1)?s.substr(0,s.indexOf("?")):s;urlString=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.swf$|\.htm$|\.html$|\.asp$|\.aspx$/;var y=n.toLowerCase().match(urlString);var v=(!e.vidWidth||!e.vidHeight)?c(m):[e.vidWidth,e.vidHeight];var u=(!e.htmlWidth||!e.htmlHeight)?c(m):[e.htmlWidth,e.htmlHeight];var x=[[(!s.match(/^http:+/)&&(m&&!m.match("iframe")))||(m&&m.match("ajax"))||false,"ajax"],[y==".jpg"||y==".jpeg"||y==".png"||y==".gif"||y==".bmp"||false,"image"],[s.match(/youtube\.com\/watch/i)||false,"youtube"],[s.match(/metacafe\.com\/watch/i)||false,"metacafe"],[s.match(/google\.com\/videoplay/i)||false,"google"],[s.match(/ifilm\.com\/video/i)||false,"ifilm"],[s.match(/vimeo\.com/i)||false,"vimeo"],[s.match(/dailymotion\.com/i)||false,"dailymotion"],[s.match(/facebook\.com\/video/i)||false,"facebook"]];var q=x.length;var o;do{if(x[q-1][0]){var o=x[q-1][1];break}}while(--q);switch(o){case"image":f(w,s,m);break;case"facebook":var l="http://www.facebook.com/v/"+s.split("v=")[1].split("&")[0];var p={wmode:"transparent",movie:l,allowFullScreen:"true",allowScriptAccess:"always",flashvars:{autoplay:true}};k(l,v,w,p,m);break;case"youtube":var l="http://www.youtube.com/v/"+s.split("v=")[1].split("&")[0]+"&hl=en&fs=1&autoplay=1";var p={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};k(l,v,w,p,m);break;case"metacafe":var l="http://www.metacafe.com/fplayer/"+s.split("id=")[1].split("&")[0]+"/.swf";var p={wmode:"transparent"};k(l,v,w,p,m);break;case"google":l="http://video.google.com/googleplayer.swf?docId="+s.split("id=")[1].split("&")[0]+"&hl=en";p={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always",flashvars:{autoplay:true,playerMode:"normal",fs:true}};k(l,v,w,p,m);break;case"ifilm":l="http://www.ifilm.com/efp";p={wmode:"transparent",flashvars:{flvbaseclip:s.split("id=")[1].split("&")[0]+"&"}};k(l,v,w,p,m);break;case"vimeo":l="http://www.vimeo.com/moogaloop.swf?clip_id="+s.split("/")[3]+"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1";p={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};k(l,v,w,p,m);break;case"dailymotion":l="http://www.dailymotion.com/swf/"+s.split("/")[4]+"&related=0&autoplay=1";p={allowFullScreen:"true",allowScriptAccess:"always"};k(l,v,w,p,m);case"ajax":h(w,s,m,u);break;default:g(w,s,m,u)}};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 f(x,o,l){if(l){var p=a("a[rel="+l+"]").get();var m=p.length;var n=m;var v="",u="";do{if(p[n-1].href==o){var s=n;break}}while(--n);var w="Image "+(n)+" of "+(m);if(s>1){var u="<a href='#' id='cee_prev'>Previous</a>"}if(s<m){var v="<a href='#' id='cee_next'>Next</a>"}}else{var w="";var u="";var v=""}var q=new Image();q.onload=function(){q.onload=null;var E=d();var r=E[0]-150;var D=E[1]-150;var z=q.width;var C=q.height;if(z>r){z=r;C=C*(r/z)}if(C>D){z=z*(D/C);C=D}var t=z+30;j("<img id='cee_img' src='"+o+"' width='"+z+"' height='"+C+"' alt='"+x+"'/><div id='cee_title'><div id='cee_nav' style='width:"+t+"px;height:"+C+"px'>"+u+v+"</div><h2>"+x+"</h2><div id='cee_count'>"+w+"</div></div>",z+30,C+60,"cee_img");if(u!=""){function B(){document.onkeydown=null;if(a(document).unbind("click",B)){a(document).unbind("click",B)}a("#cee_box").remove();a.ceebox.show(p[s-2].title,p[s-2].href,l);return false}a("#cee_prev").click(B)}if(v!=""){function A(){document.onkeydown=null;a("#cee_box").remove();a.ceebox.show(p[s].title,p[s].href,l);return false}a("#cee_next").click(A)}document.onkeydown=function(F){F=F||window.event;var y=F.keyCode||F.which;if(y==27){b()}else{if(y==190||y==39){if(v!=""){A()}}else{if(y==188||y==37){if(u!=""){B()}}}}}};q.src=o}function k(l,n,m,q,o){j("<div id='cee_vid'></div><div id='cee_title'><h2>"+m+"</h2></div>",n[0]+30,n[1]+60,"cee_vid");i();a("#cee_vid").flash({swf:l,width:n[0],height:n[1],params:q})}function h(l,n,o,m){var p=[m[0],m[1]-5];if(a("#cee_box").css("display")!="block"){j("<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();i()}function g(m,o,p,n){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)+"' onload='$.ceebox.showIframe()' style='width:"+q[0]+"px;height:"+q[1]+"px;' > </iframe>";j(l,n[0]+30,n[1]+40,p,"cee_iframe");i()}a.ceebox.showIframe=function(){a("#cee_load").remove();a("#cee_window").css({display:"block"})};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 i(){document.onkeyup=function(l){l=l||window.event;(l.keyCode==27||l.which==27)?b():false}}function j(u,l,n,o,m){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 s="absolute";var q=document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop;var p=parseInt(-1*(n/2-q),10)+"px"}else{var s="fixed";var p=parseInt(-1*(n/2),10)+"px"}$overlay=a("<div></div>");$box=a("<div></div>");$overlay.attr("id","cee_overlay").css({opacity:0.8,position:"absolute",top:0,left:0,"background-color":"#000",width:"100%",height:a(document).height(),"z-index":100});$box.attr({id:"cee_box","class":m}).css({position:s,"z-index":102,display:"none",top:"50%",left:"50%","margin-left":parseInt(-1*(l/2),10)+"px","margin-top":p,width:l+"px"});if(a("#cee_overlay").size()==0){$overlay.appendTo(a("body"))}$box.appendTo("body").append(u);if(o&&o.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").remove();a("#cee_box").show()}}})(jQuery);
