var GB_DONE = false;
var GB_ANIMATION = true;
var GB_HEIGHT = 400;
var GB_WIDTH = 400;
function GB_show(caption, url, height, width) {
  GB_HEIGHT = height || 400;
  GB_WIDTH = width || 400;
  if(!GB_DONE) {
    jQuery(document.body)
      .append("<div id='GB_overlay'></div><div id='GB_window'><div id='GB_caption'></div>"
        + "<img src='close.gif' alt='Close window'/></div>");
    jQuery("#GB_window img").click(GB_hide);
  //  jQuery("#GB_overlay").click(GB_hide);
    jQuery(window).resize(GB_position);
    GB_DONE = true;
  }
  jQuery("#GB_frame").remove();
  jQuery("#GB_window").append("<iframe id='GB_frame' src='"+url+"'></iframe>");
  jQuery("#GB_caption").html(caption);
  jQuery("#GB_overlay").show();
  GB_position();
  if(GB_ANIMATION)
    jQuery("#GB_window").slideDown("slow");
  else
    jQuery("#GB_window").show();
}
function GB_hide() {
  jQuery("#GB_window,#GB_overlay").hide();
 // window.location.reload();
}
function getPageSizeWithScroll(){
		if (window.innerHeight && window.scrollMaxY) {// Firefox
			yWithScroll = window.innerHeight + window.scrollMaxY;
			xWithScroll = window.innerWidth + window.scrollMaxX;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			yWithScroll = document.body.scrollHeight;
			xWithScroll = document.body.scrollWidth;
		} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
			yWithScroll = document.body.offsetHeight;
			xWithScroll = document.body.offsetWidth;
		  }
		arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
		//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
		return yWithScroll;
	}
function GB_position() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  var pheight=getPageSizeWithScroll();
//  /  alert("H:"+pheight);
  
  jQuery("#GB_window").css({width:GB_WIDTH+"px",height:GB_HEIGHT+"px",    left: ((w - GB_WIDTH)/10)+"px" });
//  /jQuery("#GB_frame").css("height",GB_HEIGHT - 32 +"px");
  jQuery("#GB_frame").css("height",GB_HEIGHT - 32 +"px");
  jQuery("#GB_overlay").css("height",pheight+"px");
}

function GB_resize(width, height, caption){
    var de = document.documentElement;
    var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
    jQuery("#GB_caption").html(caption);
    jQuery("#GB_window").css({width:width+"px",height:height+"px", left: ((w - width)/10)+"px" });
    jQuery("#GB_frame").css("height",height - 32 +"px");
}