
function select_val(field, value) {
	//eval("document.myform."+field+" = '"+value+"'");
	document.getElementById(field).value = value;
}

function show_hide(imgid, blockid) {
	var image, input;
	image = document.getElementById(imgid);
	input = document.getElementById(blockid);
	if (input.style.display == "none") {
		input.style.display = "";
		if (imgid != '') { image.src = "images/darrow.gif"; }
	} else {
		input.style.display = "none";
		if (imgid != '') { image.src = "images/rarrow.gif"; }
	}
}

// returns true if string is in m/d/y format
function checkDate(str) {
	var slash = 0;
	var digit = 0;
	for (var i = 0; i<str.length; i++) {
		var s = str.charAt(i);
		if (s < '0' || s > '9') {
			if (s == '/' && digit > 0 && digit <= 2 && slash < 2) {
				digit = 0;
				slash++;
			} else
				return false;
		} else
			digit++;
	}
	if (slash < 2 || digit == 0 || digit > 4)
		return false;
	else
		return true;
}

function verifyDate(field) {
	if (checkDate(field.value)) {
		return true;
	} else {
		alert("This date format is not recognized. Please enter a date in the format mm/dd/yyyy.");
		return false;
	}
}

function checknull(oField) {
	if (oField.value == "") {
		alert("This is a required field.");
		oField.select();
		oField.focus();
		return false;
	} else {
		return true;
	}
}

function new_window(href, w, h) {
	var child = window.open(href, '', 'status=yes,scrollbars=yes,resizable=yes,width='+w+',height='+h);
	child.creator = self;
	return child;
}

function new_window2(href, w, h, opts) {
	var child = window.open(href, '', opts+',status=yes,scrollbars=yes,resizable=yes,width='+w+',height='+h);
	child.creator = self;
	return child;
}

function hide_warning() {
	document.getElementById("warning").style.display = "none";
}

///////////////////////
// Menu functions
///////////////////////

function init() {
	startLeft = (document.body.clientWidth-780)/2; // 111;
	startLeft = startLeft>0?startLeft:0;
	isIE = navigator.appName.indexOf('Microsoft') >= 0;
}

function show_menu(num) {
	for (var i = 0; i<Menu.length; i++) {
		document.getElementById(i).style.background = background;
		if (Menu[i].length>5 && i != num) {
			hide_menu(i);
		}
	}
	document.getElementById(num).style.background = backgroundHigh;
	if (Menu[num].length>5) {
		document.getElementById(Menu[num][0]).style.display = 'block';
	}
}

function hide_menu(num) {
	document.getElementById(num).style.background = background;
	if (Menu[num].length>5) {
		document.getElementById(Menu[num][0]).style.display = 'none';
		for (var k = 5; k<Menu[num].length; k++) {
			if (Menu[num][k][1] != "") {
				document.getElementById(num.toString()+k).style.background = background;
			}
		}
	}
}

function highlight(i, j) {
	for (var k = 5; k<Menu[i].length; k++) {
		if (Menu[i][k][1] != "") {
			document.getElementById(i+k).style.background = background;
		}
	}
	document.getElementById(i+j).style.background = backgroundHigh;
}

function lowlight(id) {
	document.getElementById(id).style.background = background;
}

function load_menu() {
	var i, j, disp, left = 0, text, w, h;
	if (isIE) {
		h = height+2;
	} else {
		h = height;
	}
	document.writeln('<div style="cursor: default; border: '+menuBorder+'; background: '+background+
						'; position: absolute; left: '+startLeft+'px; top: '+startTop+'px; width: '+width+
						'px; height: '+h+'px; z-index: 2;">');
	for (i = 0; i<Menu.length; i++) {
		if (Menu[i][1] != "") {
			text = '<a href="'+Menu[i][1]+'" class="plain">'+Menu[i][0]+'</a>';
		} else {
			text = Menu[i][0];
		}
		document.writeln('<span style="position: absolute; left: '+left+'px;" onMouseOver="show_menu('+i+')" onMouseOut="hide_menu('+i+')">');
		if (isIE) {
			w = Menu[i][3];
		} else {
			w = Menu[i][3]-paddingLeft;
		}
		document.writeln('<div id="'+i+'" style="border: '+itemBorder+'; background: '+background+'; width: '+w+'px; padding-left: '+paddingLeft+'px; font: '+font+'; color: '+textColor+';">'+
						   text+'</div>');
		if (Menu[i].length>5) {
			document.writeln('<div id="'+Menu[i][0]+'" style="position: absolute; left: 0px; top: '+(height-1)+'px; ');
			document.writeln('	display: none; border: '+menuBorder+'; background: '+background+'; width: '+Menu[i][5][3]+';">');
			for (j = 5; j<Menu[i].length; j++) {
	//alert("abc");
				if (Menu[i][j][1] != "") {
					text = ' background: '+background+'; color: '+textColor+';" onMouseOver="javascript:highlight(\''+i+
							'\',\''+j+'\')" onMouseOut="javascript:lowlight(\''+i+j+'\')" id="'+i+j+'">'+
							'<a href="'+Menu[i][j][1]+'" class="plain">'+Menu[i][j][0]+'</a>';
				} else {
					text = ' background: '+backgroundOff+'; color: '+textColor+';">'+Menu[i][j][0];
				}
				document.writeln('<div style="border: '+itemBorder+'; padding-left: '+paddingLeft+
								'px; font: '+font+';'+text+'</div>');
			}
			document.writeln('</div>');
		}
		document.writeln('</span>');
		left += Menu[i][3];
	}
	document.writeln('</div>');
}

