/* 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_ANIMATIONT = false;
var GB_DONET = false;
var GB_HEIGHTT = 400;
var GB_WIDTHT = 400;

function GB_showt(caption, url, height, width) {
  GB_HEIGHTT = height || 400;
  GB_WIDTHT = width || 400;
  if(!GB_DONET) {
    $(document.body)
      .append("<div id='GB_overlay2'></div><div id='GB_window2'><div id='GB_caption2'></div>"
        + "<img src='/public/js/greybox/close.gif' alt='Close window' title='Close Window'/></div>");
    $("#GB_window2 img").click(GB_hidet);
    $("#GB_overlay2").click(GB_hidet);
    $(window).resize(GB_positiont);
    GB_DONET = true;
  }

  $("#GB_frame2").remove();
  $("#GB_window2").append("<iframe id='GB_frame2' src='"+url+"'></iframe>");

  $("#GB_overlay2").show();
  GB_positiont();
  $("#GB_window2").append('<a id="close_me" style="cursor:pointer;font-weight:bold" href="#">Отказ<a/>');
  $("#close_me").click(GB_hidet);
  if(GB_ANIMATIONT)
    $("#GB_window2").slideDown("slow");
  else
    $("#GB_window2").show();
}

function GB_hidet() {
  $("#GB_window2,#GB_overlay2").hide();
}

function GB_positiont() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  $("#GB_window2").css({width:GB_WIDTHT+"px",height:GB_HEIGHTT+"px",
    left: ((w - GB_WIDTHT)/2)+"px" });
  $("#GB_frame2").css("height",GB_HEIGHTT +"px");
}

