var CapsState = 0;
function CheckCapsState(e) {
	var ShiftKey, EventKey;
	if (document.all) { EventKey = e.keyCode; ShiftKey = e.shiftKey; } 
	else {  EventKey = e.which; ShiftKey = (EventKey == 16 ) ? true : false; }
	if (   ( (EventKey >= 65 && EventKey <= 90) && !ShiftKey ) 
	    || ( (EventKey >= 97 && EventKey <= 122) && ShiftKey ) ) {
		CapsState++;
		if (CapsState == 1) { 
			document.getElementById("PwdErr").style.display = "";
		}
	} else if (CapsState > 0 &&
	            ( (EventKey >= 65 && EventKey <= 90)
	           || (EventKey >= 97 && EventKey <= 122) ) ) {
		document.getElementById("PwdErr").style.display = "none";
		CapsState = 0;
	}
}
function eval_button(e, frm, func) {
	// e = event, to grab keypressed
	// frm = form object, to submit form
	// func = name of function to call before submitting.  Must return true or false
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if (code == 13) {
		if (e.target) { objtype = e.target.type; }
		else { objtype = e.srcElement.type; }
		if (objtype != "textarea") {
			var tosubmit = true;
			if (func) { tosubmit = func(); }
			if (tosubmit) { frm.submit(); }
		}
	}
}

// CALENDAR FUNCTIONS
function display_tcal(form,col,HTMLvalue,URLvalue) {
	document.write("<div id=\"cal"+col+"\" style=\"display:none; position:absolute;\"><iframe name=\"IFtcal"+col+"\" width=\"150\" height=\"225\" frameborder=\"0\" scrolling=\"no\" src=\"/common/calendar.asp?form="+form+"&col="+col+"&dt="+URLvalue+"\"></iframe></div>");
	document.write("<a href=\"javascript:toggle_cal('"+col+"');\"><img border=\"0\" src=\"/images/calendar_icon.gif\"></a>");
}
function toggle_cal(col) {
	var objref = document.getElementById("cal"+col);
	if (objref.style.display == "") {
		objref.style.display = "none";
	} else {
		var caltop, clientHeight;
		var calleft, clientWidth;
		clientWidth = document.body.clientWidth;
		clientHeight = document.body.clientHeight;
		objref.style.display = "";
		if (objref.offsetTop + 225 > clientHeight) {
			caltop = clientHeight - 225 - 10 + document.body.scrollTop;
			if (caltop < document.body.scrollTop) { caltop = document.body.scrollTop; }
			objref.style.top = caltop;
		}
		if (objref.offsetLeft + 150 > clientWidth) {
			calleft = clientWidth - 150 - 10 + document.body.scrollLeft;
			if (calleft < document.body.scrollLeft) { calleft = document.body.scrollLeft; }
			objref.style.left = calleft;
		}
	}
}
function toggle_mbutton(objref, state) {
	if (state == "off") {
		objref.style.borderBottom = "#000 2px solid";
		objref.style.borderRight = "#000 2px solid";
		objref.style.borderTop = "#FFF 2px solid";
		objref.style.borderLeft = "#FFF 2px solid";
	} else {
		objref.style.borderBottom = "#FFF 2px solid";
		objref.style.borderRight = "#FFF 2px solid";
		objref.style.borderTop = "#000 2px solid";
		objref.style.borderLeft = "#000 2px solid";
	}
}

// HELP FUNCTION
function show_help(url, width, height) { 
  if (width == undefined) { width = 400; }
  if (height == undefined) { height = 400; }
  window.open(url,"_blank","width="+width+",height="+height+",left="+parseInt(screen.availWidth-410)+",top=0,resizable,scrollbars"); return false; }

// MAP FUNCTIONS
function show_map(url) {
	window.open(url,"memmap","width=800,height=600,scrollbars,resizable");
	return false;
}
function show_map_build(streetaddress, city, state, zip) {
	var url = "http://maps.google.com/maps?f=q&amp;hl=en&amp;q="+streetaddress+",+"+city+",+"+state+",+"+zip;
	return show_map(url);
}