 function popup_window(strURL, size_width, size_height, has_scrollbars, has_resize, windowname) {
   if (!windowname) windowname = "popwindow";
        window_options = 'toolbar=0,width=' + size_width + ',' + 'height=' + size_height + ',center,directories=0,status=1,resizable=' + has_resize + ',scrollbars=' + has_scrollbars + ',menubar=0,left=175,top=100';
        newWindow=window.open(strURL, windowname, window_options);
        newWindow.resizeTo(size_width + 25, size_height + 100);
        newWindow.focus();
        } 

function ToggleFormOnSelect(SelectID, BlockID, ToggleOnValue) {
  var dropmenu = document.getElementById(SelectID);
  var selectvalue = dropmenu.options[dropmenu.selectedIndex].value;
  var block = document.getElementById(BlockID);

  if (selectvalue == ToggleOnValue) {
	block.style.display = "block";
	}
  else {
	block.style.display = "none";  
	}
  }
  
 function ToggleFormOnCheckBox(SelectID, BlockID, ToggleOnValue) {
   
   var thisCheckBox = document.getElementById(SelectID);
   var block = document.getElementById(BlockID);

   if (thisCheckBox.checked) {
	 block.style.display = "block";
	 }
   else {
	 block.style.display = "none";  
	 }	 
   }	  
  
function ToggleDivOnSelect(ToggleBlockID, CurrentStateID) {
  var ToggleBlockDiv = document.getElementById(ToggleBlockID);
  var CurrentState = document.getElementById(CurrentStateID);
  
  if (CurrentState.value == 'on') {
	ToggleBlockDiv.style.display = "block";
	CurrentState.value = 'off';
	}
  else {
	ToggleBlockDiv.style.display = "none";
	CurrentState.value = 'on';
	}
  }  

function disableForm(theform) {
  if (document.all || document.getElementById) {
    for (i = 0; i < theform.length; i++) {
      var tempobj = theform.elements[i];
      if (tempobj.type.toLowerCase() == "submit") {
        tempobj.disabled = true;
        }
	  }
	}
  }
		
function update_word_count(targetbox, updatebox, maxcount) {

	// get current elements...
	var data		= document.getElementById(targetbox).value;
	var count_box	= document.getElementById(updatebox);

	var tmparray = data.split("\n");
	data = tmparray.join(" ");
	
	// strip all begining and trailing whitespace...
	data = data.replace(/\s+$/gi, "");
	data = data.replace(/^\s+/gi, "");
	data = data.replace(/^\n/gi, "");
	data = data.replace(/\n$/gi, "");

	// convert multiple spaces and tabs to single spaces...
	data = data.replace(/\s+/g, " ");
	data = data.replace(/\t+/gi, " ");
	data = data.replace(/\n+/gi, "");

	if (data.length > 0) {
	  var extract = data.split(" ");
	  var out = extract.length;
	  }
	else {
	  var out = 0;
	  }
	
	// update count display
	count_box.value = out;
	
	// adjust count_box styles according to count
	if (out > maxcount) {
	  count_box.style.backgroundColor = '#FF3118';
	  count_box.style.color = '#ffffcc';
	  count_box.style.fontWeight = 'bold';
	  }
	else if (out > (maxcount - 5)){
	  count_box.style.backgroundColor = 'yellow';
	  count_box.style.color = 'black';
	  count_box.style.fontWeight = 'bold';	  
	  }
 	else {
	  count_box.style.backgroundColor = '#94D639';
	  count_box.style.color = 'black';
	  count_box.style.fontWeight = 'bold';
	  }
}

function CompareElements (id1, id2, errormsg) {
  var str1 = document.getElementById(id1);
  var str2 = document.getElementById(id2);
 
  if (str1.value != str2.value) {
  	alert(errormsg);
	return false;
	}
  else {
  	return true;
	}
  }

function ConfirmURL (strMessage, url) {
	if (confirm(strMessage)) {
		location.href = url;
		}
	}  

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);	