/* 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)
 */


/* code for second level GB */
var GBsm_DONE = false;
/*var GBsm_HEIGHT = 400;
var GBsm_WIDTH = 500;*/

/*This works better. document.documentElement for standard compliance mode IE. window for all other browsers. */
var de = document.documentElement || window;
function GBsm_show(caption, url, height, width) {
    jQuery.noConflict();
    GBsm_hide();
  GBsm_HEIGHT = height || 400;
  GBsm_WIDTH = width || 500;
  if(!GBsm_DONE) {
    jQuery(document.body)
      .append("<div id='GBsm_overlay'></div><div id='GBsm_window'>");
    jQuery(window).resize(GBsm_position);
    GBsm_DONE = true;
  }

  jQuery("#GBsm_frame").remove();
  jQuery("#GBsm_window").append("<iframe id='GBsm_frame' src='"+url+"' frameborder='0' scrolling='no'></iframe>");

  jQuery("#GBsm_overlay").show();
  GBsm_position();

  jQuery("#GBsm_window").show();
}

function GBsm_hide() {
    jQuery.noConflict();
   GBpan_hide();
  jQuery("#GBsm_window,#GBsm_overlay").hide();
  jQuery("#GBsm_frame").remove();

}

function GBsm_position() {
    jQuery.noConflict();
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  jQuery("#GBsm_window").css({width:GBsm_WIDTH+"px",height:GBsm_HEIGHT+"px",
    left: "0px" });
  jQuery("#GBsm_frame").css("height",GBsm_HEIGHT+"px");
}

/* code for second level panorama GB */
var GBpan_DONE = false;
var GBpan_HEIGHT = 400;
var GBpan_WIDTH = 400;

function GBpan_show(caption, url, height, width) {
    jQuery.noConflict();
  GBpan_HEIGHT = height || 400;
  GBpan_WIDTH = width || 400;
  if(!GBpan_DONE) {
    jQuery(document.body)
      .append("<div id='GBpan_overlay'></div><div id='GBpan_window'>");
    jQuery(window).resize(GBpan_position);
    GBpan_DONE = true;
  }

  jQuery("#GBpan_frame").remove();
  jQuery("#GBpan_window").append("<iframe id='GBpan_frame' src='"+url+"' frameborder='0' scrolling='no'></iframe>");

  jQuery("#GBpan_overlay").show();
  GBpan_position();

  jQuery("#GBpan_window").show();
}

function GBpan_hide() {
    jQuery.noConflict();
  jQuery("#GBpan_window,#GBpan_overlay").hide();
  jQuery("#GBpan_frame").remove();
}

function GBpan_position() {
    jQuery.noConflict();
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  jQuery("#GBpan_window").css({width:GBpan_WIDTH+"px",height:GBpan_HEIGHT+"px",
    left: "153px" });
  jQuery("#GBpan_frame").css("height",GBpan_HEIGHT - 12 +"px");
}