/* field handle example : document.forms[0].MyField */
function getFieldValue(field) {
	switch(field.type) {
		case "text" :
		case "textarea" :
		case "password" :
		case "hidden" :
			return field.value;
		case "select-one" :
			var i = field.selectedIndex;
			if (i == -1) return "";
			else return (field.options[i].value == "") ? field.options[i].text : field.options[i].value;
		case "select-multiple" :
			var allChecked = new Array();
			for(i = 0; i < field.options.length; i++)
				if(field.options[i].selected)
					allChecked[allChecked.length] = (field.options[i].value == "") ? field.options[i].text : field.options[i].value;
			return allChecked;
		case "button" :
		case "reset" :
		case "submit" :
			return "";
		case "radio" :
		case "checkbox" :
			if (field.checked) { return field.value; } else { return ""; }
		default :
			if(field[0].type == "radio") {
				for (i = 0; i < field.length; i++)
					if (field[i].checked)
						return field[i].value;
				return "";
			}
			else if(field[0].type == "checkbox") {
				var allChecked = new Array();
				for(i = 0; i < field.length; i++)
					if(field[i].checked)
						allChecked[allChecked.length] = field[i].value;
				return allChecked;
			}
			break;
	}
	return "";
}

function go(url, param, value) {
	var sep = "?";
	if (url.indexOf("?") >= 0) sep = "&";
	var newurl = url + sep + param + "=" + value;
	location.href = newurl;
}

function popup(url, target, width, height) {
	day		= new Date();
	id		= day.getTime();
	var w	= screen.width;
	var h	= screen.height;
	var settings = "directories=0,toolbar=0,scrollbars=1,location=0,status=0,menubar=0,hotkeys=0,resizable=1";
	if (width >= 0 && height >= 0) {
		width	= (width > w || width == 0 ? w : width);
		height	= (height > h || height == 0 ? h : height);
		var l	= ((w - width) / 2);
		var t	= ((h - height) / 2);
		settings += ",width=" + width + ",height=" + height + ",top=" + t + ",left=" + l;
	}
	else {
		var l	= w  * 0.05;
		var t	= h  * 0.05;
		settings += ",top=" + t + ",left=" + l;
	}
	targ = (target == null ? id : target);
	eval("page" + id + "=window.open(url,'" + targ + "','" + settings + "');");
}

function screenSizeUrl(url, param, curSize) {
	var w = (screen.width > 800 ? 1024 : 800);
	if (w != curSize) {
		var sep = "?";
		if (url.indexOf("?") >= 0) sep = "&";
		var newurl = url + sep + param + "=" + w;
		location.replace(newurl);
	}
}

