/*
 * Facebox (for jQuery)
 * version: 1.2 (05/05/2008)
 * @requires jQuery v1.2 or later
 *
 * Examples at http://famspam.com/facebox/
 *
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
 *
 * Usage:
 *  
 *  jQuery(document).ready(function() {
 *    jQuery('a[rel*=facebox]').facebox() 
 *  })
 *
 *  <a href="#terms" rel="facebox">Terms</a>
 *    Loads the #terms div in the box
 *
 *  <a href="terms.html" rel="facebox">Terms</a>
 *    Loads the terms.html page in the box
 *
 *  <a href="terms.png" rel="facebox">Terms</a>
 *    Loads the terms.png image in the box
 *
 *
 *  You can also use it programmatically:
 * 
 *    jQuery.facebox('some html')
 *
 *  The above will open a facebox with "some html" as the content.
 *    
 *    jQuery.facebox(function($) { 
 *      $.get('blah.html', function(data) { $.facebox(data) })
 *    })
 *
 *  The above will show a loading screen before the passed function is called,
 *  allowing for a better ajaxy experience.
 *
 *  The facebox function can also display an ajax page or image:
 *  
 *    jQuery.facebox({ ajax: 'remote.html' })
 *    jQuery.facebox({ image: 'dude.jpg' })
 *
 *  Want to close the facebox?  Trigger the 'close.facebox' document event:
 *
 *    jQuery(document).trigger('close.facebox')
 *
 *  Facebox also has a bunch of other hooks:
 *
 *    loading.facebox
 *    beforeReveal.facebox
 *    reveal.facebox (aliased as 'afterReveal.facebox')
 *    init.facebox
 *
 *  Simply bind a function to any of these hooks:
 *
 *   $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
 *
 */
(function($){$.facebox=function(_52,_53){$.facebox.loading();if(_52.ajax){fillFaceboxFromAjax(_52.ajax)}else{if(_52.image){fillFaceboxFromImage(_52.image)}else{if(_52.div){fillFaceboxFromHref(_52.div)}else{if($.isFunction(_52)){_52.call($)}else{$.facebox.reveal(_52,_53)}}}}};$.extend($.facebox,{settings:{opacity:0.75,overlay:true,loadingImage:"mod/socialtide/_graphics/facebox/loading.gif",closeImage:"mod/socialtide/_graphics/facebox/closelabel.gif",imageTypes:["png","jpg","jpeg","gif"],faceboxHtml:"    <div id=\"facebox\" style=\"display:none;\">       <div class=\"popup\">         <table>           <tbody>             <tr>               <td class=\"tl\"/><td class=\"b\"/><td class=\"tr\"/>             </tr>             <tr>               <td class=\"b\"/>               <td class=\"body\">                 <div class=\"content\">                 </div>                 <div class=\"footer\">                   <a href=\"#\" class=\"close\">                     <img src=\"mod/socialtide/_graphics/facebox/closelabel.gif\" title=\"close\" class=\"close_image\" />                   </a>                 </div>               </td>               <td class=\"b\"/>             </tr>             <tr>               <td class=\"bl\"/><td class=\"b\"/><td class=\"br\"/>             </tr>           </tbody>         </table>       </div>     </div>"},loading:function(){init();if($("#facebox .loading").length==1){return true}showOverlay();$("#facebox .content").empty();$("#facebox .body").children().hide().end().append("<div class=\"loading\"><img src=\""+$.facebox.settings.loadingImage+"\"/></div>");$("#facebox").css({top:getPageScroll()[1]+(getPageHeight()/10),left:385.5}).show();$(document).bind("keydown.facebox",function(e){if(e.keyCode==27){$.facebox.close()}return true});$(document).trigger("loading.facebox")},reveal:function(_55,_56){$(document).trigger("beforeReveal.facebox");if(_56){$("#facebox .content").addClass(_56)}$("#facebox .content").append(_55);$("#facebox .loading").remove();$("#facebox .body").children().fadeIn("normal");$("#facebox").css("left",$(window).width()/2-($("#facebox table").width()/2));$(document).trigger("reveal.facebox").trigger("afterReveal.facebox")},close:function(){$(document).trigger("close.facebox");return false}});$.fn.facebox=function(_57){init(_57);function clickHandler(){$.facebox.loading(true);var _58=this.rel.match(/facebox\[?\.(\w+)\]?/);if(_58){_58=_58[1]}fillFaceboxFromHref(this.href,_58);return false}return this.click(clickHandler)};function init(_59){if($.facebox.settings.inited){return true}else{$.facebox.settings.inited=true}$(document).trigger("init.facebox");makeCompatible();var _5a=$.facebox.settings.imageTypes.join("|");$.facebox.settings.imageTypesRegexp=new RegExp("."+_5a+"$","i");if(_59){$.extend($.facebox.settings,_59)}$("body").append($.facebox.settings.faceboxHtml);var _5b=[new Image(),new Image()];_5b[0].src=$.facebox.settings.closeImage;_5b[1].src=$.facebox.settings.loadingImage;$("#facebox").find(".b:first, .bl, .br, .tl, .tr").each(function(){_5b.push(new Image());_5b.slice(-1).src=$(this).css("background-image").replace(/url\((.+)\)/,"$1")});$("#facebox .close").click($.facebox.close);$("#facebox .close_image").attr("src",$.facebox.settings.closeImage)}function getPageScroll(){var _5c,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;_5c=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;_5c=document.documentElement.scrollLeft}else{if(document.body){yScroll=document.body.scrollTop;_5c=document.body.scrollLeft}}}return new Array(_5c,yScroll)}function getPageHeight(){var _5d;if(self.innerHeight){_5d=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){_5d=document.documentElement.clientHeight}else{if(document.body){_5d=document.body.clientHeight}}}return _5d}function makeCompatible(){var $s=$.facebox.settings;$s.loadingImage=$s.loading_image||$s.loadingImage;$s.closeImage=$s.close_image||$s.closeImage;$s.imageTypes=$s.image_types||$s.imageTypes;$s.faceboxHtml=$s.facebox_html||$s.faceboxHtml}function fillFaceboxFromHref(_5f,_60){if(_5f.match(/#/)){var url=window.location.href.split("#")[0];var _62=_5f.replace(url,"");$.facebox.reveal($(_62).clone().show(),_60)}else{if(_5f.match($.facebox.settings.imageTypesRegexp)){fillFaceboxFromImage(_5f,_60)}else{fillFaceboxFromAjax(_5f,_60)}}}function fillFaceboxFromImage(_63,_64){var _65=new Image();_65.onload=function(){$.facebox.reveal("<div class=\"image\"><img src=\""+_65.src+"\" /></div>",_64)};_65.src=_63}function fillFaceboxFromAjax(_66,_67){$.get(_66,function(_68){$.facebox.reveal(_68,_67)})}function skipOverlay(){return $.facebox.settings.overlay==false||$.facebox.settings.opacity===null}function showOverlay(){if(skipOverlay()){return}if($("facebox_overlay").length==0){$("body").append("<div id=\"facebox_overlay\" class=\"facebox_hide\"></div>")}$("#facebox_overlay").hide().addClass("facebox_overlayBG").css("opacity",$.facebox.settings.opacity).click(function(){$(document).trigger("close.facebox")}).fadeIn(200);return false}function hideOverlay(){if(skipOverlay()){return}$("#facebox_overlay").fadeOut(200,function(){$("#facebox_overlay").removeClass("facebox_overlayBG");$("#facebox_overlay").addClass("facebox_hide");$("#facebox_overlay").remove()});return false}$(document).bind("close.facebox",function(){$(document).unbind("keydown.facebox");$("#facebox").fadeOut(function(){$("#facebox .content").removeClass().addClass("content");hideOverlay();$("#facebox .loading").remove()})})})(jQuery);