/* 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_show1(caption, url, height, width) {
    GB_HEIGHT = height || 400;
  GB_WIDTH = width || 400;
  
  
  if(!GB_DONE) {
	$(document.body)
      .append("<div id='GB_overlay'></div><img src='/static/img/knyga.png' id='foto1' /><div id='GB_window1'>"
        + "<img src='/static/img/close.jpg'  alt='C'/></div>");
    $("#GB_window1 img").click(GB_hide1);
    $("#GB_overlay").click(GB_hide1);
	//$("#isjunk").click(GB_hide);
	
    $(window).resize(GB_position1);
    GB_DONE = true;
  }
  

  $("#GB_frame1").remove();
  $("#GB_window1").append("<iframe id='GB_frame' src='"+url+"'></iframe>");

  $("#GB_caption").html(caption);
  $("#GB_overlay").show();
  
  GB_position1();

  if(GB_ANIMATION)
    $("#GB_window1").slideDown("slow");
  else
    $("#GB_window1").show();
	
	$("#foto").show();
}

function GB_show(caption, url, height, width) {
  GB_HEIGHT = height || 400;
  GB_WIDTH = width || 400;
  
  
  if(!GB_DONE) {
	$(document.body)
      .append("<div id='GB_overlay'></div><img src='/static/img/knyga.png' id='foto' /><div id='GB_window'>"
        + "<img src='/static/img/close.jpg'  alt='C'/></div>");
    $("#GB_window img").click(GB_hide);
    $("#GB_overlay").click(GB_hide);
	//$("#isjunk").click(GB_hide);
	
    $(window).resize(GB_position);
    GB_DONE = true;
  }
  

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

  $("#GB_caption").html(caption);
  $("#GB_overlay").show();
  
  GB_position();

  if(GB_ANIMATION)
    $("#GB_window").slideDown("slow");
  else
    $("#GB_window").show();
	
	$("#foto").show();
}

function GB_hide() {
  $("#GB_window,#GB_overlay,#foto").hide();
}

function GB_position() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  $("#GB_window").css({width:GB_WIDTH+"px",height:GB_HEIGHT+"px",
    left: ((w - GB_WIDTH)/2)+"px" });
  $("#GB_frame").css("height",GB_HEIGHT - 4 +"px");
  		 $('#GB_frame').css({
                  width:'100%'
					
                });
				//$('#GB_frame').css('background', 'url(/static/img/popup1.jpg)');
		 $('#foto').css({
                  left: ((w - (GB_WIDTH-35))/2)+"px"
					
                });

  
}



function GB_hide1() {
  $("#GB_window1,#GB_overlay,#foto1").hide();
}

function GB_position1() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  $("#GB_window1").css({width:GB_WIDTH+"px",height:GB_HEIGHT+"px",
    left: ((w - GB_WIDTH)/2)+"px" });
  $("#GB_frame").css("height",GB_HEIGHT - 4 +"px");
  		 $('#GB_frame').css({
                  width:'100%'
					
                });
		 $('#foto1').css({
                  left: ((w - (GB_WIDTH-55))/2)+"px"
					
                });

  
}


