/**
 * Hides and displays appropriate sections of the contact us form or the guest
 * comment form based on the message type the user has selected.
 * 
 * @param select
 * @param firstDivId
 * @param secondDivId
 * @param guestCommentDivId
 * @return
 */
function showFields(select, firstDivId, secondDivId, guestCommentDivId) {
  var selection = select.options[select.selectedIndex].text;
  var firstDiv = document.getElementById(firstDivId);
  var secondDiv = document.getElementById(secondDivId);
  var guestCommentDiv = document.getElementById(guestCommentDivId);

  if (selection == "Guest Comment") {
    firstDiv.className = "display_none";
    secondDiv.className = "display_none";
    guestCommentDiv.className = "display_block";
    
    // Sizing hack for content div (related to inc_footer.jsp resize)
    var content = document.getElementById("content");
    var contentWrapper = document.getElementById("contentwrapper");
    content.style.height = guestCommentDiv.offsetHeight + 110 + "px";
    contentWrapper.style.backgroundColor = "transparent";
    
  } else {
    firstDiv.className = "display_block";
    secondDiv.className = "display_block";
    guestCommentDiv.className = "display_none";

    // Sizing hack for content div (related to inc_footer.jsp resize)
	var linkh = document.getElementById('links').offsetHeight;
	var contenth = document.getElementById('content').offsetHeight;
	document.getElementById('content').style.height = linkh + 'px';
  }

}

/**
 * When a form error occurs on the guest comment form, this piece of javascript
 * reselects "Guest Comment" from the message type drop down, which resides
 * in another form.
 * 
 * @param selectId
 * @return
 */
function reselectGuestComment(selectId) {
  var select = document.getElementById(selectId);
  
  for (var i = 0; i < select.options.length; i++) {
    if (select.options[i].value == "txt_guest_comment") {
      select.options[i].selected = true;
    }
  }
  
}

