<!------- 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,zoom,zw,zh) { // for images
	var html, winopt;
 	var base = "http://www.mdsg.umd.edu";
	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="' + base + "/CQ/cq_ezine.css\">\n";
	html += "<STYLE TYPE=\"text/css\"> \nbody { background-image:none; }\n</STYLE>\n";
	if (zoom) {
		html += '<script type="text/javascript" src="' + base + "/includes/js/mojozoom/mojozoom.js\"></script>\n";
		html += '<link type="text/css" href="' + base + "/includes/js/mojozoom/mmojozoom.css\" rel=\"stylesheet\" />\n"; 
	}
	html += "<\/HEAD>\n";
	html += "<BODY BGCOLOR=\"#FFFFFF\" onblur=window.close()>\n";
	html += "<DIV ALIGN=\"CENTER\">\n";
	html += "<IMG SRC=\"" + what + "\" ALT=\"" + alt + "\" ";
	if (zoom) {
	 html += 'data-zoomsrc="' + base + zoom + '" data-zoomalwaysshow="false" id="myimage" style="padding:0px;border:0px;" ';  
	}
	html += "height='" + h + "' width='" + w + "'>\n";
	html += "<\/DIV>\n";
	h = h*1 + 50;
	if (caption) { 
		var l = caption.length/w * 90;
		h += l;
		// h += 120; 
	}
	//if (h > 500) { h = 500; }
	w = w*1 + 30;
	//if (w > 500) { w = 500; }
	var zt = "Move your mouse over the image to zoom in.";
	if (zoom) {
		if (caption) { 
			h += 100; 
			caption += "<BR>" + zt;
		}
		else {
			caption = zt;
		}
	}
	if (caption) {
		var aa = "";
		//if (caption.length < 100) { aa = ' align="center"'; } 
		html += "<div" + aa + " style=\"margin:5px 5px 5px 5px;\">\n" + caption + "\n<\/div>\n"; 
	}
	html += "<div CLASS=\"FOOTER\" ALIGN=\"RIGHT\">\n";
	html += "<A HREF=\"javascript:window.close()\">close window<\/A>\n";
	html += "<\/div>\n";
	if (zoom) {
		if (!zw) { zw = 250; }
		if (!zh) { zh = 250; }
		var z = parseInt(w/2 - zw/2); // 1/2 image - 1/2 zoom width
		html += '<div id="myimage_zoom" style="position:relative;width:' + zw; 
		html += "px;height:" + zh + 'px;float:right;border:1px solid black;right:' + z
		html += 'px;"><\/div>' + "\n";  
		h += 0.5 * zh;
	}
	html += "<\/BODY>\n";
	html += "<\/HTML>\n";
	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----------->


