function setDropDowns(mode) {
  var dropdowns = document.getElementsByTagName('select');

  for(index in dropdowns) {
    var dropdown = dropdowns[index];

    if(typeof(dropdown) == 'object') dropdown.style.display = mode;
  }
}

function hideDropDowns() {
  setDropDowns('none');
}

function showDropDowns() {
  setDropDowns('');
}

function modalHandler(e) {
  var html   = document.getElementsByTagName('html')[0];
  var modal  = document.getElementById('pp-modal');
  var new_id = null;

  // Toggle modal visibility
  if(html.id == 'pp-modal-open') {
    modal.style.display = 'none';
    if($().isIE6()) showDropDowns();
  } else {
    new_id = 'pp-modal-open';
    modal.style.display = 'block';
    if($().isIE6()) hideDropDowns();
  }

  html.setAttribute('id', new_id);

  return false;
}

$(document).ready(function() {
	window.SetupModalHandlers(document);
});

window.SetupModalHandlers = function(rootNode){
	$(rootNode).find('.pp-modal').click(modalHandler);
	$(rootNode).find('#close-modal').click(modalHandler);
}
