/* Copyright (c) 2003-2008 PeopleCube. All Rights Reserved */

var wWasOpened = false;
var pwin;

function killPopups()
{
  if (!wWasOpened) return;
   wWasOpened = false;

  if (pwin && !pwin.closed)
  {
    pwin.close();
  }
}

function doit() {}

var SCROLL = true;
var RESIZABLE = true;

function popup(url, w, h, x, y, scroll, resizable)
{
  var optionString = '';
  if (is.ie)
    optionString = 'width='+w+', height='+h+', left='+x+', top='+y;
  else
    optionString = 'width='+w+',height='+h+',screenX='+x+',screenY='+y;
  if (scroll)
  {
    optionString += ',scrollbars=yes';
    if (resizable)
      optionString += ',resizable=yes';
  }
  pwin = window.open(url, 'POPUP', optionString);
  wWasOpened = true;
  pwin.focus();

}

function popup_print()
{
  var frm = false;

  if (document.forms['printMeForm'])
    frm = document.forms['printMeForm'];
  else if (document.forms['theForm'])
    frm = document.forms['theForm'];

  var newPopup = false;


  if (frm)
  {
    if (frm.printWYSIWYG)
    {
      window.print();
      return;
    }
    if (frm.display) newPopup = true;
  }
// alert(newPopup);

  if (newPopup)
  {
    pwin = window.open('', 'POPUP', 'menubar, width=600, height=500, left=50, top=50');
    wWasOpened = true;
    pwin.focus();
    frm.display.value = 'print';
    frm.popup.value = '1';
    frm.target = 'POPUP';
    frm.submit();
    frm.target = '';
    frm.display.value = 'crt';
    frm.popup.value = '0';
    window.status = "print mode 0";
    return;
  }

  if (frm)
  {
    if (frm.submitPrint)
    {
      frm.display.value = 'print';
      frm.popup.value = '1';
      frm.target = 'POPUP';
      frm.submit();
      frm.display.value = 'crt';
      frm.popup.value = '0';
      return;
    }
  }

window.status = "print mode 1";
    var url = location.href;
  if (url.indexOf('?') < 1) url += '?';
  else url += ';';
  url += "display=print;popup=1";

// alert(url);

  if (is.ie)
    pwin = window.open(url, 'POPUP', 'menubar, width=600, height=500, left=50, top=50');
  else
    pwin = window.open(url, 'POPUP', 'menubar, width=600, height=500, left=50, top=50');
  wWasOpened = true;
  pwin.focus();
}

function popupHelp(cmd)
{
  var helpURL = "help/hlp_"+cmd+".html";
  if (helpURL.length < 16) helpURL = "help/Calendar_Basics.html";
  popup(helpURL, 400, 500, 50, 50, SCROLL);
}


function popupFull(url)
{
  pwin = window.open(url, 'POPUP');
  wWasOpened = true;
  pwin.focus();
}

