<!------- hide the script from old browsers
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

function open_window (file,width,height,toolbar) { // generic pop=up window
	// note: toolbar = yes to allow printing of pop-up window
	if (!toolbar) { toolbar = "yes"; }  
	winopt = "toolbar=" + toolbar + ",location=no,directories=no,menubar=yes,";
	winopt += "resizable=no,scrollbars=yes";
	if (width && height) { winopt += ",width=" + width + ",height=" + height; }
	newWin=window.open(file,"dummy",winopt);
}

function image_window(what,alt,h,w,caption,title) { // for images
	var html, winopt;
 
	html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n";
	html += "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\n";
	html += "<HTML LANG=\"EN-US\">\n";
	html += "<HEAD>\n";
	html += "<TITLE>" + title + "<\/TITLE>\n";
	html += "<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" ";
	html += "HREF=\"http://www.mdsg.umd.edu/CQ/cq_ezine.css\">\n";
	html += "<STYLE TYPE=\"text/css\"> \nbody { background-image:none; }\n</STYLE>\n";
	html += "<\/HEAD>\n";
	html += "<BODY BGCOLOR=\"#FFFFFF\" onblur=window.close()>\n";
	html += "<DIV ALIGN=\"CENTER\">\n";
	html += "<IMG SRC=\"" + what + "\" ALT=\"" + alt + "\" ";
	html += "height=" + h + " width=" + w + ">\n";
	html += "<\/DIV>\n";
	if (caption) { html += "<P ALIGN=\"center\">\n" + caption + "\n<P>\n"; }
	html += "<P CLASS=\"FOOTER\" ALIGN=RIGHT>\n";
	html += "<A HREF=\"javascript:window.close()\">close window<\/A>\n";
	html += "<\/P>\n";
	html += "<\/BODY>\n";
	html += "<\/HTML>\n";
	h = h*1 + 50;
	if (caption) { h += 100; }
	//if (h > 500) { h = 500; }
	w = w*1 + 30;
	//if (w > 500) { w = 500; }
	winopt = "toolbar=no,location=no,directories=no,menubar=yes,resizable=no";
	winopt = "scrollbars=yes,width=" + w + ",height=" + h + "," + winopt;   
	newWin=window.open("","dummy",winopt);
	newWin.document.write(html);
	newWin.document.close();
	return;
} 

function checkValue(form,name,numtype,value,max)  {  
	// check if positive number or integer
	// name - name of the field
	// input - value to check
	// numtype - no or int (default no - positive number, int - integer)
	// value - original (default) value of the field (optional) 
	// max - maximum value for the field (optional)
	if (!numtype) { numtype = "no"; }
	if (!value) { value = ""; }
	var oneDecimal = false;
	var commaFlag = false;
	var spaceFlag = false;
	var msg = "This must be a positive number.";
	var goodNumber = true;
	if (numtype != "no") { 
		oneDecimal = true; 
		msg = "This must be a positive whole number.";
	}
	var thisObj = eval('document.' + form + '.' + name);
	var str = thisObj.value; // input value
	if (!str || !goodNumber) { 
		return false; 
	} 
	for (var i = 0; i < str.length; i++) {
		var ch = str.substring(i, i + 1)
		if (ch < "0" || "9" < ch) { 
			if (ch == "." && !oneDecimal) {
			  oneDecimal = true;
			}
			else { 
			  goodNumber = false; 
			  if (ch == ",") { commaFlag = true; }
			  if (ch == " ") { spaceFlag = true; }
			}
		}
	}
	if (!goodNumber) { 
		msg += "\nDo not include non-numeric characters";
		
		if (commaFlag || spaceFlag) { msg += " such as"; }
		if (commaFlag) { 
			msg += " commas(,)"; 
			if (spaceFlag) { msg += " or"; }
		}
		if (spaceFlag) { msg += " spaces ( )"; }
		msg += ".";
		alert(msg + "\n\nPlease correct the entry.");
		thisObj.focus();
		thisObj.select();
		//thisObj.value = "";
		thisObj.value = value;
		return false;
	}
	if (max) { // check if more than maximum amount
		var vv = str * 1; // convert to numeric
		if (vv > max) {
			msg = "This number must be no more than " + max + ".";
			alert(msg);
			thisObj.focus();
			thisObj.select();
			//thisObj.value = "";
			thisObj.value = value; 
			return false;
		}
	}
	if (numtype == "no") { // decimal to 2 places
		thisObj.value = parseFloat(thisObj.value).toFixed(2);
	}
}

//close off comment to hide this script from old browsers----------->

