/*
 * Thickbox 3 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/

/*
 * This is a HEAVILY customized version of Thickbox3
 * + window is a fixed width
 * + window is anchored to the top of the viewport
 * + window height is flexible
 * + window is height-aware, and resizes if neccessary
 * + window is styled with top & bottom background images
 * -- bbuchs 08/09/07
 */

var tb_pathToImage = "../images/loadingAnimation.gif";

$(document).ready(function(){tb_init('a.thickbox');imgLoader=new Image();imgLoader.src=tb_pathToImage});function tb_init(domChunk){$(domChunk).click(function(){var t=this.title||this.name||null;var a=this.href||this.alt;var g=this.rel||false;tb_show(t,a,g);this.blur();return false})}function tb_show(caption,url,imageGroup){try{if(typeof document.body.style.maxHeight==="undefined"){$("body","html").css({height:"100%",width:"100%"});$("html").css("overflow","hidden");if(document.getElementById("TB_HideSelect")===null){$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");$("#TB_overlay").click(tb_remove)}}else{if(document.getElementById("TB_overlay")===null){$("body").append("<div id='TB_overlay'></div><div id='TB_window'>");$("#TB_overlay").click(tb_remove)}}$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");$('#TB_load').show();if($("#TB_window").css("display")!="block"){$("#TB_window").append("<div id='TB_title'><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a></div></div><div id='TB_windowWrapper'><div id='TB_ajaxContent'></div></div>")}else{$("#TB_ajaxContent")[0].scrollTop=0;$("#TB_ajaxContent").css({height:'auto'})}$("#TB_closeWindowButton").click(tb_remove);$("#TB_ajaxContent").load(url+="?random="+(new Date().getTime()),function(){$("#TB_window").css({marginLeft:'-300px',width:'600px'});$("#TB_load").remove();tb_init("#TB_ajaxContent a.thickbox");$("#TB_window").css({display:"block"});var availableHeight=parseInt($(window).height()-70);var tbHeight=parseInt($("#TB_ajaxContent").height());if(tbHeight>availableHeight){$("#TB_ajaxContent").height(availableHeight)}});document.onkeyup=function(e){if(e==null){keycode=event.keyCode}else{keycode=e.which}if(keycode==27){tb_remove()}}}catch(e){}}function tb_remove(){$("#TB_imageOff").unbind("click");$("#TB_overlay").unbind("click");$("#TB_closeWindowButton").unbind("click");$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').remove()});$("#TB_load").remove();if(typeof document.body.style.maxHeight=="undefined"){$("body","html").css({height:"auto",width:"auto"});$("html").css("overflow","")}document.onkeydown="";return false}