//ceebox
/*
 * Ceebox 1.3.4 (with minor adaptations specific for UCSF Surgery websites)
 * Requires jQuery 1.3.2 and swfobject.jquery.js plugin to work (plugin is attached to this js file because of CMS limitations)
 * Original Code hosted on GitHub (http://github.com/catcubed/CeeBox) Please visit there or http://catcubed.com/tag/ceebox/ for more information.
 * By Colin Fahrion (http://www.catcubed.com)
 * Adapted from Thickbox (http://jquery.com/demo/thickbox/) Copyright (c) 2007 Cody Lindley (http://www.codylindley.com)
 * Video pop-up code inspired by Videobox (http://videobox-lb.sourceforge.net/)
 * Copyright (c) 2009 Colin Fahrion
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/

var pathToLoadingAnim="http://surgery.ucsf.edu/media/621964/loadinganimation.gif";var htmlBaseW=false;var htmlBaseH=false;var vidBaseW=600;var vidBaseH=400;
/*!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
$(document).ready(function(){cee_init("a.ceebox, area.ceebox, input.ceebox");imgLoader=new Image();imgLoader.src=pathToLoadingAnim;if($.browser.opera){$("body").append("<span style='line-height:0px;color:rgba(0,0,0,0)' rel='lame opera hack'>-</span>")}});function cee_init(a){$(a).click(function(){var c=this.title||this.name||null;var b=this.href||this.alt;var d=this.rel||false;cee_show(c,b,d);this.blur();return false})}function cee_show(n,b,o){try{if(typeof document.body.style.maxHeight==="undefined"){$("html").css("overflow","hidden");if(document.getElementById("cee_HideSelect")===null){$("body").append("<iframe id='cee_HideSelect'></iframe><div id='cee_overlay'></div><div id='cee_box'></div>");$("#cee_overlay").click(cee_remove)}}else{if(document.getElementById("cee_overlay")===null){$("body").append("<div id='cee_overlay'></div><div id='cee_box'></div>");$("#cee_overlay").click(cee_remove)}}(cee_detectMacXFF())?$("#cee_overlay").addClass("cee_overlayMacFFBGHack"):$("#cee_overlay").addClass("cee_overlayBG");cee_closeBtn="<a href='#' id='cee_closeBtn' title='Close'>close</a>";if(n===null){n=""}$("body").append("<div id='cee_load'><img src='"+imgLoader.src+"' /></div>");$("#cee_load").show();var c=(b.indexOf("?")!==-1)?b.substr(0,b.indexOf("?")):b;var g=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.swf$|\.htm$|\.html$|\.asp$|\.aspx$/;var p=c.toLowerCase().match(g);var m=cee_getSize(o,vidBaseW,vidBaseH);var j=cee_getSize(o,htmlBaseW,htmlBaseH);var l=[[(!b.match(/^http:+/)&&(o&&!o.match("iframe")))||(o&&o.match("ajax"))||false,"ajax"],[p==".jpg"||p==".jpeg"||p==".png"||p==".gif"||p==".bmp"||false,"image"],[b.match(/youtube\.com\/watch/i)||false,"youtube"],[b.match(/metacafe\.com\/watch/i)||false,"metacafe"],[b.match(/google\.com\/videoplay/i)||false,"google"],[b.match(/ifilm\.com\/video/i)||false,"ifilm"],[b.match(/vimeo\.com/i)||false,"vimeo"],[b.match(/dailymotion\.com/i)||false,"dailymotion"],[b.match(/facebook\.com\/video/i)||false,"facebook"]];var h=l.length;var d;do{if(l[h-1][0]){var d=l[h-1][1];break}}while(--h);switch(d){case"image":cee_imagegal(b,n,o,g);break;case"facebook":var a="http://www.facebook.com/v/"+b.split("v=")[1].split("&")[0];var f={wmode:"transparent",movie:a,allowFullScreen:"true",allowScriptAccess:"always",flashvars:{autoplay:true}};cee_vidWindow(a,m,n,f);break;case"youtube":var a="http://www.youtube.com/v/"+b.split("v=")[1].split("&")[0]+"&hl=en&fs=1&autoplay=1";var f={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};cee_vidWindow(a,m,n,f);break;case"metacafe":var a="http://www.metacafe.com/fplayer/"+b.split("id=")[1].split("&")[0]+"/.swf";var f={wmode:"transparent"};cee_vidWindow(a,m,n,f);break;case"google":a="http://video.google.com/googleplayer.swf?docId="+b.split("id=")[1].split("&")[0]+"&hl=en";f={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always",flashvars:{autoplay:true,playerMode:"normal",fs:true}};cee_vidWindow(a,m,n,f);break;case"ifilm":a="http://www.ifilm.com/efp";f={wmode:"transparent",flashvars:{flvbaseclip:vidId+"&"}};cee_vidWindow(a,m,n,f);break;case"vimeo":a="http://www.vimeo.com/moogaloop.swf?clip_id="+b.split("/")[3]+"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1";f={wmode:"transparent",allowFullScreen:"true",allowScriptAccess:"always"};cee_vidWindow(a,m,n,f);break;case"dailymotion":a="http://www.dailymotion.com/swf/"+b.split("/")[4]+"&related=0&autoplay=1";f={allowFullScreen:"true",allowScriptAccess:"always"};cee_vidWindow(a,m,n,f);case"ajax":cee_ajaxWindow(b,j,n,o);break;default:cee_iframeWindow(b,j,n,o)}}catch(k){}}function cee_imagegal(a,m,n,c){if(n){var e=$("a[rel="+n+"]").get();var b=e.length;var d=b;var k="",j="";do{if(e[d-1].href==a){var h=d;break}}while(--d);var l="Image "+(d)+" of "+(b);if(h>1){var j="<a href='#' id='cee_prev'>Previous</a>"}if(h<b){var k="<a href='#' id='cee_next'>Next</a>"}}else{var l=false;var j=false;var k=false}var f=new Image();f.onload=function(){f.onload=null;var t=cee_getPageSize();var g=t[0]-150;var s=t[1]-150;var o=f.width;var r=f.height;if(o>g){o=g;r=r*(g/o)}if(r>s){o=o*(s/r);r=s}var i=o+30;cee_append("<img id='cee_img' src='"+a+"' width='"+o+"' height='"+r+"' alt='"+m+"'/><div id='cee_nav' style='width:"+i+"px;height:"+r+"px'>"+j+k+"</div><div id='cee_cap'>"+m+"<div id='cee_count'>"+l+"</div></div>"+cee_closeBtn,o+30,r+60);if(j){function q(){document.onkeydown=null;if($(document).unbind("click",q)){$(document).unbind("click",q)}$("#cee_box").remove();$("body").append("<div id='cee_box'></div>");cee_show(e[h-2].title,e[h-2].href,n);return false}$("#cee_prev").click(q)}if(k){function p(){document.onkeydown=null;$("#cee_box").remove();$("body").append("<div id='cee_box'></div>");cee_show(e[h].title,e[h].href,n);return false}$("#cee_next").click(p)}document.onkeydown=function(v){v=v||window.event;var u=v.keyCode||v.which;if(u==27){cee_remove()}else{if(u==190||u==39){if(k){p()}}else{if(u==188||u==37){if(j){q()}}}}}};f.src=a}function cee_ajaxWindow(c,d,b,a){var e=[d[0],d[1]-5];if($("#cee_box").css("display")!="block"){if(a&&a.match("modal")){$("#cee_overlay").unbind();cee_append("<div id='cee_ajax' class='cee_modal' style='width:"+e[0]+"px;height:"+e[1]+"px;'></div>",d[0]+30,d[1]+40)}else{cee_append("<div id='cee_title'><div id='cee_ajaxTitle'>"+b+"</div>"+cee_closeBtn+"</div><div id='cee_ajax' style='width:"+e[0]+"px;height:"+e[1]+"px'></div>",d[0]+30,d[1]+40)}}else{$("#cee_ajaxContent")[0].style.width=e[0]+"px";$("#cee_ajaxContent")[0].style.height=e[1]+"px";$("#cee_ajaxContent")[0].scrollTop=0;$("#cee_ajaxWindowTitle").html(b)}if(a&&a.match(/#[a-z_A-Z1-9]+/)){targetId=a.match(/#[a-z_A-Z1-9]+/);$("#cee_ajax").load(c+" "+targetId)}else{$("#cee_ajax").load(c)}cee_init("#cee_ajax a.ceebox");cee_keyEvents()}function cee_iframeWindow(d,e,c,b){var f=[e[0]+29,e[1]+12];$("#cee_iframe").remove();if(b&&b.match("modal")){$("#cee_overlay").unbind();var a="<iframe frameborder='0' hspace='0' src='"+d+"' id='cee_iframe' name='cee_iframe"+Math.round(Math.random()*1000)+"' onload='cee_showIframe()' style='width:"+f[0]+"px;height:"+f[1]+"px;'> </iframe>"}else{var a="<div id='cee_title'><div id='cee_ajaxTitle'>"+c+"</div>"+cee_closeBtn+"</div><iframe frameborder='0' hspace='0' src='"+d+"' id='cee_iframeContent' name='cee_iframeContent"+Math.round(Math.random()*1000)+"' onload='cee_showIframe()' style='width:"+f[0]+"px;height:"+f[1]+"px;' > </iframe>"}cee_append(a,e[0]+30,e[1]+40);cee_keyEvents()}function cee_showIframe(){$("#cee_load").remove();$("#cee_window").css({display:"block"})}function cee_remove(){$("#cee_imgBtn").unbind("click");$("#cee_closeBtn").unbind("click");$("#cee_box").fadeOut("fast",function(){$("#cee_box,#cee_overlay,#cee_HideSelect").unbind().trigger("unload").remove()});$("#cee_load").remove();if(typeof document.body.style.maxHeight=="undefined"){$("body","html").css({height:"auto",width:"auto"});$("html").css("overflow","")}document.onkeydown=null;document.onkeyup=null;return false}function cee_position(a,b){$("#cee_box").css({marginLeft:"-"+parseInt((a/2),10)+"px",width:a+"px"});if(!(jQuery.browser.msie&&jQuery.browser.version<7)){$("#cee_box").css({marginTop:"-"+parseInt((b/2),10)+"px"})}}function cee_getSize(a,c,e){var d=cee_getPageSize();(c)?c=c*1:c=d[0]-150;(e)?e=e*1:e=d[1]-150;var b=new Array();if(a&&a.match(/[0-9]+/g)){var b=a.match(/[0-9]+/g);b[0]=(b[0])?b[0]*1:c;b[1]=(b[1])?b[1]*1:e}else{b=[c,e]}return b}function cee_vidWindow(a,b,e,d){cee_append("<div id='cee_vid'></div><div id='cee_cap'>"+e+"</div>"+cee_closeBtn,b[0]+30,b[1]+60);cee_keyEvents();$("#cee_vid").flash({swf:a,width:b[0],height:b[1],params:d})}function cee_getPageSize(){var c=document.documentElement;var a=window.innerWidth||self.innerWidth||(c&&c.clientWidth)||document.body.clientWidth;var b=window.innerHeight||self.innerHeight||(c&&c.clientHeight)||document.body.clientHeight;arrayPageSize=[a,b];return arrayPageSize}function cee_detectMacXFF(){var a=navigator.userAgent.toLowerCase();if(a.indexOf("mac")!=-1&&a.indexOf("firefox")!=-1){return true}}function cee_keyEvents(){document.onkeyup=function(a){a=a||window.event;(a.keyCode==27||a.which==27)?cee_remove():false}}function cee_append(d,a,b){$("#cee_box").append(d);$("#cee_closeBtn").click(cee_remove);cee_position(a,b);$("#cee_load").remove();$("#cee_box").css({display:"block"})};/* swfobject jquery plugin */
(function(E,B){var C=function(G){var F,H=[];for(F in G){H.push(F+'="'+G[F]+'"')}return H.join("")},D=function(H){var F,J,I=[],G;for(F in H){if(typeof H[F]=="object"){G=[];for(J in H[F]){G.push([J,"=",encodeURIComponent(H[F][J])].join(""))}H[F]=G.join("&amp;")}I.push(['<param name="',F,'" value="',H[F],'" />'].join(""))}return I.join("")},A=false;E[B]=(function(){var F="0,0,0",G=navigator.plugins["Shockwave Flash"]||ActiveXObject;F=G.description||(function(){try{return(new G("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")}catch(H){}}());F=F.match(/^[A-Za-z\s]*?(\d+)[\.|,](\d+)(?:\s+r|,)(\d+)/);return{available:F[1]>0,activeX:!G.name,version:{major:F[1]*1,minor:F[2]*1,release:F[3]*1},hasVersion:function(I){var L=this.version,J="major",K="minor",H="release";I=(/string|number/.test(typeof I))?I.toString().split("."):I||[0,0,0];I=[I[J]||I[0]||L[J],I[K]||I[1]||L[K],I[H]||I[2]||L[H]];return(I[0]<L[J])||(I[0]==L[J]&&I[1]<L[K])||(I[0]==L[J]&&I[1]==L[K]&&I[2]<=L[H])},expressInstall:"expressInstall.swf",create:function(H){if(!E[B].available||A||!typeof H=="object"||!H.swf){return false}if(H.hasVersion&&!E[B].hasVersion(H.hasVersion)){H={swf:H.expressInstall||E[B].expressInstall,attrs:{id:"SWFObjectExprInst",height:Math.max(H.height||137),width:Math.max(H.width||214)},params:{flashvars:{MMredirectURL:location.href,MMplayerType:(E[B].activeX)?"ActiveX":"PlugIn",MMdoctitle:document.title.slice(0,47)+" - Flash Player Installation"}}};A=true}else{H=E.extend(true,{attrs:{height:H.height||180,width:H.width||320},params:{wmode:H.wmode||"opaque",flashvars:H.flashvars}},H)}return"<object "+(C(H.attrs))+(E[B].activeX?' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value="'+H.swf+'" />':' type="application/x-shockwave-flash" data="'+H.swf+'">')+(D(H.params))+"</object>"}}}());E.fn[B]=function(F){if(typeof F=="object"){this.each(function(){var G=document.createElement(B);G.innerHTML=E[B].create(F);if(G.childNodes[0]){this.appendChild(G.childNodes[0])}})}else{if(typeof F=="function"){this.find("object").andSelf().filter("object").each(function(){var H=this,G="jsInteractionTimeoutMs";H[G]=H[G]||0;if(H[G]<660){if(H.clientWidth||H.clientHeight){F.call(this)}else{setTimeout(function(){E(H)[B](F)},H[G]+66)}}})}}return this}}(jQuery,"flash"));