function NewWindow(mypage, myname, w, h, scroll, resize) {
      var winl = (screen.width - w) / 2;
      var wint = (screen.height - h) / 2;
     winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize+',toolbar=no,location=no,status=no,menubar=no,dependent=no'
        win = window.open(mypage, myname, winprops)
     if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
 }


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		nav_01_over = newImage("/images/site/nav_01-over.gif");
		nav_02_over = newImage("/images/site/nav_02-over.gif");
		nav_03_over = newImage("/images/site/nav_03-over.gif");
		nav_04_over = newImage("/images/site/nav_04-over.gif");
		nav_05_over = newImage("/images/site/nav_05-over.gif");
		nav_06_over = newImage("/images/site/nav_06-over.gif");
		preloadFlag = true;
	}
}


/**
 *
 * Changes sizes of Text Areas
 *
 */

function increaseNotesHeight(thisTextarea, add) {
	if (thisTextarea) {
		newHeight = parseInt(thisTextarea.style.height) + add;
		thisTextarea.style.height = newHeight + "px";
	}
	if (document.getElementById('notes_height')) {
		document.getElementById('notes_height').value = newHeight;
	}
}

function decreaseNotesHeight(thisTextarea, subtract) {
	if (thisTextarea) {
		if ((parseInt(thisTextarea.style.height) - subtract) > 30) {
			newHeight = parseInt(thisTextarea.style.height) - subtract;
			thisTextarea.style.height = newHeight + "px";
		}
		else {
			newHeight = 30;
			thisTextarea.style.height = "30px";
		}			
	}
	if (document.getElementById('notes_height')) {
		document.getElementById('notes_height').value = newHeight;
	}
}

// makes sure the category browse form in the header submits to 
// the correct category view so that the pulldown states will
// persist until the page is changed using a control that is
// not part of the form
function categoryBrowseSubmitCtl(_this) {
  for(var i = 0; i < _this.elements.length; i++) {
    if(_this.elements[i].name.substr(0, 8) == 'category') {
      if(_this.elements[i].value != '') {
        var _category = _this.elements[i].value;
      } else {
        return false;
      }
    }
  }

  _this.action = '/category/' + _category;

  return true;
}

// flushes child category settings before submit of the
// category browse form in the header in order to keep
// subsections from showing up orphaned on the next
// page load
function categoryBrowseChangeCtl(_this) {
  var _thisnum = parseInt(_this.name.substr(8));
  var _thisform = _this.parentNode;

  while(_thisform.nodeName != 'FORM') {
    _thisform = _thisform.parentNode;
  }

  while(_thisform.elements['category'+(_thisnum+1)]) {
    _thisform.elements['category'+(_thisnum+1)].selectedIndex = 0;
    _thisnum++;
  }

  _thisform.submit();
}
