var calendarWindow = null;
var calendarColors = new Array();
var calendarFormat = 'm/d/y';
var calendarStartMonday = false;

calendarColors['bgColor'] = '#BDC5D0';
calendarColors['borderColor'] = '#333366';
calendarColors['headerBgColor'] = '#143464';
calendarColors['headerColor'] = '#FFFFFF';
calendarColors['dateBgColor'] = '#8493A8';
calendarColors['dateColor'] = '#004080';
calendarColors['dateHoverBgColor'] = '#FFFFFF';
calendarColors['dateHoverColor'] = '#8493A8';

function getCalendar(formField) 
{
  if (formField.disabled)
    return false;
    
  var cal_width = 220;  //415;
  var cal_height = 190; //310;

  // IE needs less space to make this thing
  
//  if ((document.all) && (navigator.userAgent.indexOf("Konqueror") == -1))
//    cal_width = 220;//410;

  calendarTarget = formField;
//  calendarWindow = window.open('calendar/calendar.html', 'dateSelectorPopup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=0,dependent=no,width='+cal_width+',height='+cal_height);
  calendarWindow = openWindow("calendar/calendar.html", cal_width, cal_height);

  return false;
}

function getCalendarByID(formFieldID)
{
  return getCalendar(document.getElementById(formFieldID));
}

function killCalendar() 
{
  if (calendarWindow && !calendarWindow.closed)
    calendarWindow.close();
}

function openWindow(url, width, height)
{
  var top = Math.round((window.screen.availHeight - height) / 2);
  var left = Math.round((window.screen.availWidth - width) / 2);
  
  return window.open(url, "_blank", "directories=no, height=" + height + ", left=" + left + ", location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no, top=" + top + ", width=" + width);
}
