/* Put global javascript functions in here */
function globalSetTextOfDiv(id, text){
 if(document.getElementById){
   var theDiv = document.getElementById(id);
   theDiv.innerHTML = text;
 }
}
function globalGetTextOfDiv(id){
 if(document.getElementById){
   var theDiv = document.getElementById(id);
   if(theDiv){
     return theDiv.innerHTML;
   }else{
     return '';
   }
 }else{
   return '';
 }
}
function globalGetTextOfTextbox(id){
 if(document.getElementById){
   var theBox = document.getElementById(id);
   if(theBox){
     return theBox.value;
   }else{
     return '';
   }
 }else{
   return '';
 }
}
function globalSetTextOfTextbox(id, theText){
 if(document.getElementById){
   var theBox = document.getElementById(id);
   if(theBox){
     theBox.value = theText;
   }
 }
}
function globalGetSelectedText(sDropdownId){
  //returns the selected item in a dropdown menu's text.
  var dropdown;
  if(document.getElementById){
    dropdown = document.getElementById(sDropdownId);
    if(dropdown){
      return dropdown.options[dropdown.selectedIndex].text;
    }else{
      return '';
    }
  }else{
    return '';
  }
}
function submitSearch(){
  var searchForm;
   if(document.getElementById){
    searchForm = document.getElementById('searchForm');
    if(searchForm){
      searchForm.submit();
    }
  }
}
function global_toggleVisibility(psDivId, pnAction) {
  if(document.getElementById){
   var oCollapsibleRegion = window.document.getElementById(psDivId);
   
      if (oCollapsibleRegion) {
        if (pnAction == 1) {
          // force open 
          oCollapsibleRegion.style.display = "";
        } else if (pnAction == -1) {
          // force close
          oCollapsibleRegion.style.display = "none";
        } else if (oCollapsibleRegion && oCollapsibleRegion.style.display == "none") {
          // toggle open
          oCollapsibleRegion.style.display = "";
        } else if (oCollapsibleRegion) {
          // toggle close
          oCollapsibleRegion.style.display = "none";
        }
      } // if (oCollapsibleRegion) {
  }
}
function global_toggleVisibilityCheckbox(psChkId, psDivId) {
  if(document.getElementById){
   var oCollapsibleRegion = document.getElementById(psDivId);
   var oCheckbox = document.getElementById(psChkId);
   
      if (oCollapsibleRegion && oCheckbox) {
        if (oCheckbox.checked == true) {
          // force open 
          
          oCollapsibleRegion.style.display = "";
        } else {
          // force close
          oCollapsibleRegion.style.display = "none";
        } 
      } // if (oCollapsibleRegion) {
  }
}
function globalCollapsibleRegion_toggleVisibility(psParentImage, pnAction) {
  /* jchaplin 4/10/2006
   * jwiliams - 4/15/2006
   * dmaloney - 5/30/06
   * 
   *   This procedure changes the state of a collapsible
   *   region.  In order for this to work, you must have
   *   a parent image (that you pass to this procedure),
   *   and the child object (collapsible region) must be
   *   named the same as your parent object with the suffix
   *   _detail appended to the name.
   *
   *   NOTE: This function has been changed to accept a string representing the parent image, instead of the image itself
   * 
   * Example:
   *   <a href="#editStudentSectionDisbursementHistory" onclick="globalCollapsibleRegion_toggleVisibility('editStudentSectionDisbursementHistory',0)">
   *     <img name="editStudentSectionDisbursementHistory" id="editStudentSectionDisbursementHistory" src="images/collapsebar_close.gif" alt="" border="0" height="15" width="15" />
   *      Disbursement History
   *   </a>
   *   <table class="globalTableDetail" id="editStudentSectionDisbursementHistory_detail">
   *     <tr class="globalRowOdd"><td>University of New Hampshire</td><td align=right>$500&nbsp;</td></tr>
   *     <tr><td>University of New Hampshire</td><td align=right><span class="refund">($500)</span></td></tr>
   *     <tr class="globalRowOdd"><td>Plymouth State College</td><td align=right>$500&nbsp;</td></tr>
   *     <tr><td>Plymouth State College</td><td align=right>$500&nbsp;</td></tr>
   *     <tr class="globalRowOdd"><td>Plymouth State College</td><td align=right>$500&nbsp;</td></tr>
   *     <tr><td>Plymouth State College</td><td align=right>$500&nbsp;</td></tr>
   *   </table>
   *
   * Passed:
   *   poParentImage - image object
   *   pnAction - one of the following actions:
   *                 1 = display detail
   *                -1 = hide detail
   *                 0 = toggle collapse / expand
   * Returns:
   *   nothing
   */
    var oParentImage = document.getElementById(psParentImage);
   
    if (oParentImage) {
      var oCollapsibleRegion = window.document.getElementById(psParentImage+"_detail");
      if (oCollapsibleRegion) {
        if (pnAction == 1) {
          // force open 
          oCollapsibleRegion.style.display = "";
          oParentImage.src = "images/collapsebar_close.gif";
        } else if (pnAction == -1) {
          // force close
          oCollapsibleRegion.style.display = "none";
          oParentImage.src = "images/collapsebar_open.gif";
        } else if (oCollapsibleRegion && oCollapsibleRegion.style.display == "none") {
          // toggle open
          oCollapsibleRegion.style.display = "";
          oParentImage.src = "images/collapsebar_close.gif";
        } else if (oCollapsibleRegion) {
          // toggle close
          oCollapsibleRegion.style.display = "none";
          oParentImage.src = "images/collapsebar_open.gif";
        }
      } // if (oCollapsibleRegion) {
    } // if (poParentImage) {
  } // function globalCollapsibleRegion_toggleVisibility(poParentImage, pnAction) {
  function globalButtonEnable(psId, state){
    if(document.getElementById){
      var btn;
      btn = document.getElementById(psId);
      
      if(btn){
        if(state == -1){
          btn.disabled = true;
          btn.style.color = "#c7c7c7";
        }else{
          btn.disabled = false;
          btn.style.color = "white";
        }
      } 
    }
  }
 function openFeedback(){
   var thisPage;
   thisPage = window.location.href;
   thisPage = thisPage.substring(thisPage.lastIndexOf('/') + 1);
   if(thisPage.indexOf("#") > -1){
     thisPage = thisPage.substring(0, thisPage.indexOf("#"));
   }
   if(thisPage.indexOf("?") > -1){
     thisPage = thisPage.substring(0, thisPage.indexOf("?"));
   }
   //alert(thisPage);
   window.open("feedback.aspx?page=" + thisPage, "feedbackWindow", "width=800,height=440,resizable=1,scrollbars=1");
 }