
// Show/hide elements

function toggleVisibility(id,action) {

  if (action == "show") { var state = "block"; }
  if (action == "hide") { var state = "none"; }

  //safe function to show an element with a specified id
		  
  if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById(id).style.display = state;
  }
  else {
    if (document.layers) { // Netscape 4
      document.id.display = state;
    }
    else { // IE 4
      document.all.id.style.display = state;
    }
  }
}

// Hide containers after a delay

function fnHide(){
  if (document.getElementById("message") != null) window.setTimeout("fnHide2()",5000);
}

function fnHide2(){
  document.getElementById("message").style.display = "none";
}


// Checkboxes - select all

function setCheckboxesByType(do_check) {
    var elts = document.getElementsByTagName("input");
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;
 if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            if ((elts[i].type == "checkbox") && (elts[i].disabled != true)) {
                elts[i].checked = do_check;
            }
        } 
    } else {
        if (elts.type == "checkbox") {
            elts.checked = do_check;
        }
    }
}


// Highlight selected table rows

function highlight(checkbox) {
   if (document.getElementById) {
      var tr = eval("document.getElementById(\"TR" + checkbox.value + "\")");
   } else {
      return;
   }
   if (tr.style) {
      if (checkbox.checked) {
         tr.style.backgroundColor = "#c9fe56";
      } else {
         tr.style.backgroundColor = "#f3f5f7";
      }
   }
}



// Open new window

function open_newwindow(filenam, w, h) { 
  newwindow = window.open(""+filenam+"", "newwindow", "width="+w+",height="+h+",toolbar=no, location=no,directories=no, status=yes,menubar=no,resizable=yes,scrollbars=yes,top");
  newwindow.focus()
}