/* 
 */
function pjsViewAttachment(href) {
  var w = jvCalendarWindows[jvCalendarWindows.length] = window.open(href, "attachment", "width=700,height=500,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
  w.focus();
}

/* View : Open Project */
function vjsOpenProject() {
  vjsSelectTab("Attachments");
  vjsAddProject("Home", "../../project/html/home.do", "Home");
}

/* View : Close Project */
function vjsCloseProject() {
}

/*
 * General : Open Calendar Window
 *
 * @param name String
 * @param description String
 */
function jsOpenCalendarWindowDo(name, description) {
  var w = jvCalendarWindows[jvCalendarWindows.length] = window.open("calendarWindow.do?description=" + escape(description) + "&name=" + escape(name), name, "width=235,height=240,resizable=no,menubar=no,scrollbars=no,toolbar=no");
  w.focus();
}

/* Alert Empty Select */
function alertEmptySelect(selectId, message) {
  if (document.getElementById(selectId).length == 0) {
    alert(message);
  }
}

/* Adjust Select */
function adjustSelect(parentSelectId, childSelectId, replacementOptionsArray) {
  var parentSelect = document.getElementById(parentSelectId);
  var childSelect = document.getElementById(childSelectId);

  childSelect.options.length = 0;

  var replacementOptions = replacementOptionsArray[parentSelect.selectedIndex];

  for (var i = 0; i < replacementOptions.length; i++) {
    childSelect.options[childSelect.options.length] = new Option(replacementOptions[i][0], replacementOptions[i][1]);
  }
}

/*
 * General : Get Field
 *
 * @return Field
 * @param fieldName String
 * @param formName String
 */
function jsGetField(fieldName, formName) {
  switch (arguments.length) {
    case 2: {
      return document.forms[formName].elements[fieldName];
    } break;
    case 1: {
      for (f = 0; f < document.forms.length; f++) {
        for (e = 0; e < document.forms[f].elements.length; e++) {
          if (document.forms[f].elements[e].name == fieldName) {
            return document.forms[f].elements[e];
          }
        }
      }
    } break;
    default: {
      for (f = 0; f < document.forms.length; f++) {
        for(e = 0; e < document.forms[f].elements.length; e++) {
          var l = document.forms[f].elements[e];
          if ((l.type != "hidden") && (l.disabled == false) && (l.readOnly != true) && (l.readOnly != "readonly")) {
            return document.forms[f].elements[e];
          }
        }
      }
    }
  }
  return null;
}

