
var GB_WIDTH=800;var GB_HEIGHT=600;$(document).ready(function(){$('body').append('<div id="GB_overlay" style="display:none;"></div><div id="GB_window" style="display:none;"><div id="GB_topbar"><a id="GB_close" alt="Close">Close</a><div id="GB_caption"></div></div><div id="GB_frame"></div><div id="GB_notes"><div id="GB_notes_inner">&nbsp;</div></div></div>');$('#GB_close').click(GB_hide);$('#GB_overlay').click(GB_hide);});function GB_show(el,width,height,notes){if(width){GB_WIDTH=width;}
if(height){GB_HEIGHT=height;}
var caption=el.title||$(el).parent().attr('title')||$(el).text()||'';var url=$(el).attr('href')||$(el).parent().attr('href');var html='';var args=arguments;$(window).resize(function(){GB_position(0);});$(window).scroll(function(){GB_position(0);});if(url.indexOf('.jpg')>0){var imgsrc='<img src="'+url+'" alt="'+caption+'" id="GB_img" />';var $img=$(imgsrc).load(function(){var callback=args[4]&&typeof args[4]=='function'?args[4]:false;GB_change(imgsrc,caption,notes,callback);});}else{$.get(url,{},function(rsp){GB_change(rsp,caption,notes);if(args[4]&&typeof args[4]=='function'){args[4]();}});}
var thispos=$(el).offset();$('#GB_window').css({top:thispos.top+'px',left:thispos.left+'px',width:$(el).width()+'px',height:$(el).height()+'px',});}
function GB_change(html,caption,notes,callback){var frameheight=(GB_HEIGHT-4)-(parseInt($("#GB_caption").css('height'),10));$('#GB_frame').hide().html(html);if(notes!=''){$('#GB_notes').css({width:(GB_WIDTH-200)+'px'}).show();$('#GB_notes_inner').css({width:(GB_WIDTH-240)+'px'}).html(notes);}
$("#GB_topbar").hide();$("#GB_caption").html('');$('#GB_overlay').fadeIn(function(){var newpos=getPosition();$('#GB_window').animate(newpos.window,function(){$('#GB_frame').css({height:(frameheight)+'px'}).fadeIn(function(){$("#GB_caption").html(caption);$("#GB_topbar").slideDown(callback);GB_position(1);});});});}
function GB_hide(){$('#GB_window,#GB_overlay,#GB_notes').hide();}
function getPosition(){var w=$('#GB_img').width()||GB_WIDTH;var h=$('#GB_img').height()||GB_HEIGHT;var cp=$("#GB_caption").height();var wh=$(window).height();var scrolltop=$(window).scrollTop();if(h>=(GB_HEIGHT-cp)){w=w+18;}
if((h+50)>(wh-100)){h=(wh-100);}
return{overlay:{top:scrolltop+'px'},window:{width:w+'px',height:h+'px',left:(($(window).width()-w)/2)+'px',top:scrolltop+50+'px'}};}
function setFrameSize(){var h=$('#GB_img').height()||GB_HEIGHT;var wh=$(window).height();if((h+50)>(wh-100)){var frameheight=(parseInt($('#GB_window').height(),10)-4)-(parseInt($("#GB_caption").css('height'),10));$('#GB_frame').css({height:(frameheight)+'px'})}}
function GB_position(animate){var newpos=getPosition();$("#GB_overlay").css(newpos.overlay);if(animate==1){$('#GB_window').animate(newpos.window,setFrameSize);}else{$('#GB_window').css(newpos.window);setFrameSize();}}