  /** 
   * Converts the passed date to a unix timestamp
   */
  function getUnixTimestampUTC(year, month, day, hour, minute, second) {
    var date = new Date(Date.UTC(year, month - 1, day, hour, minute, second));
    return (date.getTime() / 1000.0);
  }

  function padZeroes(numberString, maxLength) {
    var i;
    for(i = numberString.length; i < maxLength; i ++) {
      numberString = '0' + numberString;
    }

    return numberString;
  }

  function renderOptionNumberRange(start, length, selected) {
    var i;
    for(i = start; i < length; i ++) {
      document.write('<option' + (selected == i ? ' selected ' : ' ') + 'value="' + i + '">' + i + '</option>');
    }
    return false;
  }

  function renderOptionArray(optionsArray, selectedValue) {
    var i;
    var value;
    var pretty;

    for(i = 0; i < optionsArray.length; i += 2) {
      value = optionsArray[i];
      pretty = optionsArray[i + 1];
      document.write('<option' + (selectedValue == value ? ' selected ' : ' ') + 'value="' + value + '">' + pretty + '</option>');
    }
    return false;
  }

  function getObjById(id) {
    if(document.getElementById) {
      return document.getElementById(id);
    } else if(document.all) {
      return document.all[id];
    } else {
      return null;
    }
  }

  function changeHtml(text,id) {
    if(document.getElementById) {
      element = document.getElementById(id);
      element.innerHTML = '';
      element.innerHTML = text;
    } else if(document.all) {
      element = document.all[id];
      element.innerHTML = text;
    } else if (document.layers) {
      // Pretty much obsolete but...
      element = document.layers[id];
      element.document.open();
      element.document.write(text);
      element.document.close();
    }
    return false;
  }

  function showPopup(url, width, height) {
    newWindow = window.open(url, 'popup', config='width=' + width + ',height=' + height + ',dependent=yes');
    if(window.focus) {
      newWindow.focus();
    }
    return newWindow;
  }

  function showCalendar(todayDate, numMonths, startMonthYear, parentFormName, targetMonthYearName, targetDayName) {
    return showPopup('calendar.php?today=' + todayDate + '&parentForm=' + parentFormName + '&targetMonthYearName=' + targetMonthYearName + '&startDateTimeMonthYear=' + startMonthYear + '&targetDayName=' + targetDayName + '&numMonths=' + numMonths + '&monthYear=' + startMonthYear, 300, 240);
  }
