function alterVisible(element) {
  if (document.all) {
    var e = document.all[element];
  } else {
    var e = document.getElementById(element);
  }
  if (e.style.display=='none') e.style.display='block';
  else e.style.display='none';
}

var alterClassNow = true;

function alterClassTimeout(el, className) {
  if (alterClassNow) {
    alterClass(el, className);
    alterClassNow = false;
    setTimeout("alterClassNow = true", 10);
  }
}

function alterClass(el, className) {
  el.className=className;
}

function checkAll(form) {
  var check = true;
  for(var i = 0; i < form.elements.length; i++) {
    if (form.elements[i].type == "checkbox") check = check & form.elements[i].checked;
  }
  check = !check;
  for(var i = 0; i < form.elements.length; i++) {
    if (form.elements[i].type == "checkbox") form.elements[i].checked = check;
  }
}

function openPic(image) {
   var win = window.open('browsepic.html?image='+image, 'gallery', 'width=450, height=320');
   win.focus();
}

// ---------------------------------

function findroot(tree, childName) {
  var i;
  for(i in tree) {
    if (tree[i][0] == childName) return tree[i][1];
    var found = findroot(tree[i][1], childName);
    if (found) return found;
  }
}

function popnote(title,note) {
  var win = window.open('', '_blank', 'width=400,height=200,scrollbars=yes,resizable=no');
  var doc = win.document;
  doc.write('<html><head><title>' + title + '</title></head><body><b>' + title + '</b><br/><br/>' + note + '</body></html>');
  doc.close();
  win.focus();
}

function popup(url, width, height) {
  if (!width) width = 600;
  if (!height) height = 500;
  var win = window.open(url, '_blank', 'width='+width+',height='+height+',scrollbars=yes,resizable=no');
  win.focus();
}

var htmlEditField;

function pasteHtml(formField) {
  var win = window.open('pastehtml.html', 'pasteHtml', 'width=760,height=500,scrollbars=yes,resizable=no');
  win.focus();
  win.opener = this;
  htmlEditField = formField;
}


 var preloadImages = new Array();

 function preload(name, state, src) {
   if (preloadImages[name+state]) return;
   preloadImages[name+state] = new Image();
   preloadImages[name+state].src = src;
 }

 function alter(name, state, src) {
   document.images[name].src = preloadImages[name+state].src;
 }

 function alterClass(el, className) {
   el.className=className;
 }

function flash(swf, width, height) {
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" height="'+height+'" width="'+width+'"><param name="movie" value="'+swf+'" border="0"><param name=scale value="noscale"><param name="menu" value="false"> <param name="quality" value="high"><param name="wmode" value="transparent"><embed scale="noscale" src="'+swf+'" wmode="transparent" quality="high" menu="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" height="'+height+'" width="'+width+'"></object>');
 }

/*function clickIE() { if (event.button==2){ return false; } }
function clickNS(e){ if (document.layers||document.getElementById&&!document.all) { if (e.which==2||e.which==3){ return false; } } }
if (document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS; } else if (document.all&&!document.getElementById) { document.onmousedown=clickIE; }
document.oncontextmenu=new Function("return false");
*/


var calendarDateForm;
var calendarDateField;

function calendar(dateForm, dateField) {
  var calWin = window.open("calendar.html", "_calendar", "width=200,height=200,status=no,toolbar=no,menubar=no,location=no,top=400,left=250");
  calWin.screenX = 400;
  calWin.screenY = 250;
  calWin.opener = this;
  calendarDateForm = dateForm;
  calendarDateField = dateField;
}
