/*!
 * Thickbox 3.1 - 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
 *
 * Modifications made to allow for declaration of windows in percentage terms
 * Most of the credit for this belongs to Dave Miller (Dave-Miller.com) - thanks Dave!
 */

var tb_pathToImage=EE.PATH_CP_GBL_IMG+"loadingAnimation.gif",TB_ajaxCache=[],TB_WIDTH=0,TB_HEIGHT=0,TB_WIDTH_PARAM=0,TB_HEIGHT_PARAM=0,TB_PAGESIZE=[0,0],TB_SCROLL=[0,0],TB_HTML_OVERFLOW="auto",TB_BODY_OVERFLOW="auto",TB_MARGIN_LEFT=0,TB_MARGIN_TOP=0;$(document).ready(function(){tb_init("a.thickbox, area.thickbox, input.thickbox");imgLoader=new Image;imgLoader.src=tb_pathToImage});
function tb_init(a){$(a).click(function(){tb_show(this.title||this.name||null,this.href||this.alt,this.rel||!1);this.blur();return!1})}
function tb_show(a,b,d){try{typeof document.body.style.maxHeight==="undefined"?($("body","html").css({height:"100%",width:"100%"}),$("html").css("overflow","hidden"),document.getElementById("TB_HideSelect")===null&&($("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>"),$("#TB_overlay").fadeIn("slow"),$("#TB_overlay").click(tb_remove))):document.getElementById("TB_overlay")===null&&($("body").fadeIn("slow"),$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>"),
$("#TB_overlay").fadeIn("slow").click(tb_remove));tb_detectMacXFF()?$("#TB_overlay").addClass("TB_overlayMacFFBGHack"):$("#TB_overlay").addClass("TB_overlayBG");a===null&&(a="");$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");$("#TB_load").show("1000");var c=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/,e=(b.indexOf("?")!==-1?b.substr(0,b.indexOf("?")):b).toLowerCase().match(c);if(e==".jpg"||e==".jpeg"||e==".png"||e==".gif"||e==".bmp"){TB_imageCount=TB_NextHTML=TB_NextURL=TB_NextCaption=
TB_PrevHTML=TB_PrevURL=TB_PrevCaption="";TB_FoundURL=!1;if(d){TB_TempArray=$("a[rel="+d+"]").get();for(TB_Counter=0;TB_Counter<TB_TempArray.length&&TB_NextHTML==="";TB_Counter++)TB_TempArray[TB_Counter].href.toLowerCase().match(c),TB_TempArray[TB_Counter].href!=b?TB_FoundURL?(TB_NextCaption=TB_TempArray[TB_Counter].title,TB_NextURL=TB_TempArray[TB_Counter].href,TB_NextHTML="<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>"):(TB_PrevCaption=TB_TempArray[TB_Counter].title,TB_PrevURL=
TB_TempArray[TB_Counter].href,TB_PrevHTML="<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>"):(TB_FoundURL=!0,TB_imageCount="Image "+(TB_Counter+1)+" of "+TB_TempArray.length)}imgPreloader=new Image;imgPreloader.onload=function(){imgPreloader.onload=null;var h=tb_getPageSize(),c=h[0]-150,h=h[1]-150,f=imgPreloader.width,g=imgPreloader.height;f>c?(g*=c/f,f=c,g>h&&(f*=h/g,g=h)):g>h&&(f*=h/g,g=h,f>c&&(g*=c/f,f=c));TB_WIDTH=f+30;TB_HEIGHT=g+60;TB_WIDTH_PARAM=TB_WIDTH;TB_HEIGHT_PARAM=TB_HEIGHT;
$("#TB_window").fadeIn("slow");$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+b+"' width='"+f+"' height='"+g+"' alt='"+a+"'/></a><div id='TB_caption'>"+a+"<div id='TB_secondLine'>"+TB_imageCount+TB_PrevHTML+TB_NextHTML+"</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>");$(".TB_closeWindowButton").click(tb_remove);if(TB_PrevHTML!==""){var e=function(){$(document).unbind("click",e)&&$(document).unbind("click",
e);$("#TB_window").remove();$("body").append("<div id='TB_window'></div>");tb_show(TB_PrevCaption,TB_PrevURL,d);return!1};$("#TB_prev").click(e)}if(TB_NextHTML!==""){var i=function(){$("#TB_window").remove();$("body").append("<div id='TB_window'></div>");tb_show(TB_NextCaption,TB_NextURL,d);return!1};$("#TB_next").click(i)}document.onkeydown=function(a){keycode=a==null?event.keyCode:a.which;if(keycode==27)tb_remove();else if(keycode==190){if(TB_NextHTML!="")document.onkeydown="",i()}else if(keycode==
188&&TB_PrevHTML!="")document.onkeydown="",e()};tb_position();$("#TB_load").remove();$("#TB_ImageOff").click(tb_remove);$("#TB_window").css({display:"block"})};imgPreloader.src=b}else{var k=b.replace(/^[^\?]+\??/,""),i=tb_parseQuery(k);TB_WIDTH_PARAM=i.width;TB_HEIGHT_PARAM=i.height;TB_WIDTH=tb_calculateSize(TB_WIDTH_PARAM,0);TB_HEIGHT=tb_calculateSize(TB_HEIGHT_PARAM,1);ajaxContentW=TB_WIDTH-30;ajaxContentH=TB_HEIGHT-45;b.indexOf("TB_iframe")!=-1?(urlNoQuery=b.split("TB_"),$("#TB_iframeContent").remove(),
i.modal!="true"?$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+a+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1E3)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW+29)+"px;height:"+(ajaxContentH+17)+"px;' > </iframe>"):($("#TB_overlay").unbind(),$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+
urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1E3)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW+29)+"px;height:"+(ajaxContentH+17)+"px;'> </iframe>"))):$("#TB_window").css("display")!="block"?i.modal!="true"?$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+a+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+
ajaxContentH+"px'></div>"):($("#TB_overlay").unbind(),$("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>")):($("#TB_ajaxContent")[0].style.width=ajaxContentW+"px",$("#TB_ajaxContent")[0].style.height=ajaxContentH+"px",$("#TB_ajaxContent")[0].scrollTop=0,$("#TB_ajaxWindowTitle").html(a));$(".TB_closeWindowButton").click(tb_remove);if(b.indexOf("TB_inline")!=-1)$("#TB_ajaxContent").append($("#"+i.inlineId).children()),
$("#TB_window").unload(function(){$("#"+i.inlineId).append($("#TB_ajaxContent").children())}),tb_position(),$("#TB_load").remove(),$("#TB_window").css({display:"block"});else if(b.indexOf("TB_iframe")!=-1)tb_position(),$.browser.safari&&($("#TB_load").remove(),$("#TB_window").css({display:"block"}));else{var j=b.indexOf("TB_cache")!=-1;j&&TB_ajaxCache[b]?($("#TB_ajaxContent").html(TB_ajaxCache[b]),tb_position(),$("#TB_load").remove(),$("#TB_window").css({display:"block"})):$("#TB_ajaxContent").load(b,
function(){tb_position();$("#TB_load").remove();$("#TB_window").css({display:"block"});j&&(tb_ajaxCache[b]=$("#TB_ajaxContent").html())})}}TB_PAGESIZE=tb_getPageSize();$(window).resize(tb_resize);document.onkeyup=function(a){keycode=a==null?event.keyCode:a.which;keycode==27&&tb_remove()}}catch(l){alert(l)}}function tb_showIframe(){$("#TB_load").remove();$("#TB_window").css({display:"block"})}
function tb_remove(){$("#TB_imageOff").unbind("click");$(".TB_closeWindowButton").unbind("click");$("#TB_window").fadeOut("slow",function(){$("#TB_window,#TB_overlay,#TB_HideSelect").trigger("unload").unbind().remove()});$("#TB_load").remove();typeof document.body.style.maxHeight=="undefined"&&($("body","html").css({height:"auto",width:"auto"}),$("html").css("overflow",""));document.onkeydown="";document.onkeyup="";return!1}
function tb_position(){$("#TB_window").css({marginLeft:"-"+parseInt(TB_WIDTH/2,10)+"px",width:TB_WIDTH+"px"});jQuery.browser.msie&&jQuery.browser.version<7||$("#TB_window").css({marginTop:"-"+parseInt(TB_HEIGHT/2,10)+"px"})}function tb_parseQuery(a){var b={};if(!a)return b;a.indexOf("?")!=-1&&(a=a.substring(a.indexOf("?")+1));for(var a=a.split(/[;&]/),d=0;d<a.length;d++){var c=a[d].split("=");if(c&&c.length==2){var e=unescape(c[0]),c=unescape(c[1]),c=c.replace(/\+/g," ");b[e]=c}}return b}
function tb_getPageSize(){var a=document.documentElement;return arrayPageSize=[window.innerWidth||self.innerWidth||a&&a.clientWidth||document.body.clientWidth,window.innerHeight||self.innerHeight||a&&a.clientHeight||document.body.clientHeight]}function tb_detectMacXFF(){var a=navigator.userAgent.toLowerCase();if(a.indexOf("mac")!=-1&&a.indexOf("firefox")!=-1)return!0}
function tb_calculateSize(a,b){a=a.toString();if(a.substring(a.length-1)=="%"){var a=a.substring(0,a.length-1),d=tb_getPageSize();return d[b]*a/100-16}else return a<0?(d=tb_getPageSize(),d[b]+a*1-16):a*1+(b==1?40:30)}
function tb_resize(){TB_NEW_PAGESIZE=tb_getPageSize();TB_WIDTH=tb_calculateSize(TB_WIDTH_PARAM,0);TB_HEIGHT=tb_calculateSize(TB_HEIGHT_PARAM,1);ajaxContentW=TB_WIDTH-30;ajaxContentH=TB_HEIGHT-45;TB_NEW_PAGESIZE[0]==TB_PAGESIZE[0]&&TB_NEW_PAGESIZE[1]==TB_PAGESIZE[1]||(TB_NEW_PAGESIZE[0]==TB_PAGESIZE[0]&&TB_NEW_PAGESIZE[1]==TB_PAGESIZE[1]+1?TB_PAGESIZE=TB_NEW_PAGESIZE:(TB_PAGESIZE=TB_NEW_PAGESIZE,$("#TB_iframeContent").css({width:ajaxContentW+29+"px",height:ajaxContentH+17+"px"}),$("#TB_ajaxContent").css({width:ajaxContentW+
"px",height:ajaxContentH+"px"}),tb_position()))};
