/* $Id: popup.js,v 1.6 2009-08-29 09:03:28 jfroux Exp $ */

function popup_main(url, width, height) {
   var pHeight;
   var pWidth;
   var posY;
   var posX;

   if (popup_use_layers == 0) {
      popup_window(url, 'popup_main', width, height);
      return;
   }

   pWidth = (document.body.clientWidth);
   pHeight = (document.body.clientHeight); 
   posY = (pHeight/2)-(height/2);
   posX = (pWidth/2)-(width/2);
   //alert(posY + " " + pHeight);

   document.getElementById('i_popup_main').src=url;
   document.getElementById('i_popup_main').width = width - 6 +"px";
   document.getElementById('i_popup_main').height = height - 26 +"px";
   document.getElementById('i_popup_main').contentWindow.focus();

   document.getElementById('t_popup_main').style.width=width+"px";
   document.getElementById('t_popup_main').style.height=height+"px";
   document.getElementById('t_popup_main').style.top=posY+"px";
   document.getElementById('t_popup_main').style.left=posX+"px";

   document.getElementById('t_popup_back').style.visibility="visible";
   document.getElementById('t_popup_main').style.visibility="visible";

   document.body.style.overflow = 'hidden';
}

function close_main() {
   document.getElementById('i_popup_main').src='layers/empty.html';

   document.getElementById('t_popup_main').style.visibility="hidden";
   document.getElementById('t_popup_back').style.visibility="hidden";

   document.getElementById('t_popup_main').style.width="0px";
   document.getElementById('t_popup_main').style.height="0px";
   document.getElementById('t_popup_main').style.top="0px";
   document.getElementById('t_popup_main').style.left="0px";

   document.body.style.overflow = 'auto';
   //document.location.reload();
}

function postit_show(index, url, x, y, width, height, nof) {
   var id = "p_postit_"+index;
   var iframeid = "i_postit_main_"+index;

   if (popup_use_layers == 0) {
      popup_window(url, id, width, height);
      return;
   }

   document.getElementById(iframeid).src=url;
   document.getElementById(iframeid).width=width -6 + "px";
   document.getElementById(iframeid).height=height -20 + "px";
   document.getElementById(iframeid).contentWindow.focus();

   document.getElementById(id).style.width=width+"px";
   document.getElementById(id).style.height=height+"px";
   document.getElementById(id).style.bottom=y+"px";
   document.getElementById(id).style.left=x+"px";
   document.getElementById(id).style.visibility="visible";

   postit_to_top(index, nof);
}

function postit_to_top(index, nof) {
   var i;
   for(i=0; i<nof ; i++) {
      var id = "p_postit_"+i;
      if (i == index) {
         if (document.getElementById(id) != null)
            document.getElementById(id).style.zIndex="21";         
      }else{
         if (document.getElementById(id) != null)
            document.getElementById(id).style.zIndex="20";         
      }
   }
}

function postit_hide(index) {
   var id = 'p_postit_' + index;
   var iframeid = 'i_postit_main' + index;

   document.getElementById(id).style.visibility="hidden";
   document.getElementById(id).style.width="0px";
   document.getElementById(id).style.height="0px";
   document.getElementById(id).style.bottom="0px";
   document.getElementById(id).style.left="0px";
}


