/* Greybox Redux
 * Required: http://jquery.com/
 * Written by: John Resig
 * Based on code by: 4mir Salihefendic (http://amix.dk)
 * License: LGPL (read more in LGPL.txt)
 */

var GB_DONE = false;
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) {
    $("#body")
      .append("<div id='GB_overlay'></div><div id='GB_window'>"
		+ "<img src='/images/gray_box/close.png' alt='Close window'/><div class='close_bg'></div><div class='top_border'><div class='bottom_border'></div></div></div>");
    $("#GB_window img").click(GB_hide);
    $("#GB_overlay").click(GB_hide);
    $(window).resize(GB_position);
    GB_DONE = true;
  }

  $("#GB_frame").remove();
  $(".bottom_border").append("<iframe id='GB_frame' onload='frameHeight()' frameBorder='0' src='"+url+"'></iframe>");
  $("#GB_overlay").show();
  GB_position();

  if(GB_ANIMATION)
    $("#GB_window").slideDown("slow");
  else
    $("#GB_window").show();
}

function GB_hide() {
  $("#GB_window,#GB_overlay").hide();
}

function GB_position() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;

}


function frameHeight() { 
	var frame = document.getElementById('GB_frame'); 
	var frameDoc = frame.contentWindow;	
	frame.style.height = frameDoc.document.body.scrollHeight+"px";
	return false; 
}



