// JavaScript Document

var gErrorMsg = "";
var gErrorAnchor = "";
function setClassByName(eleName,className) {
	if (eleName != "") {
		var ele = document.getElementsByName(eleName);
		if(ele.length > 0) {
			ele[0].className = className;
		}
	}
}
function validateInput(value, errMsg, titleName) {
	var className = "";
	if ((gErrorMsg == "") && (value=="")) {
		gErrorMsg = errMsg;
		gErrorAnchor = titleName;
		className = "errorMsg";
	}
	setClassByName(titleName,className);
}

function trim(str){
	return(str.replace(/^\s*/, "").replace(/\s*$/, ""));
}
function trimInput(inp){
	inp.value = trim(inp.value);
}
function numericInput(inp) {
	var str=inp.value;
	inp.value = str.replace(/\D*/g,"")
}
function posIntInput(inp,defaultVal) {
	var tmp = parseInt(inp.value);
	if (tmp > 0) {tmp = String(tmp);} else {tmp = String(defaultVal);}
	inp.value = tmp;
}
function floatInput(inp) {
	var tmp	= String(parseFloat(inp.value));
	if (tmp == "NaN") {tmp=0;}
	inp.value = tmp;
}
function posFloatInput(inp,defaultVal) {
	var tmp = parseFloat(inp.value);
	if (tmp > 0) {tmp = String(tmp);} else {tmp = String(defaultVal);}
	inp.value = tmp;
}
function setValueRadio(aryObjs, val) {
	var i;
	for(i=0; i<aryObjs.length; i++) {
		if (aryObjs[i].value == val) {
			aryObjs[i].checked = true;
		}
		else {
			aryObjs[i].checked = false;
		}
	}
}
function setValueSelect(aryObjs, val) {
	var i;
	for(i=0; i<aryObjs.length; i++) {
		if (aryObjs[i].value == val) {
			aryObjs[i].selected = true;
		}
		else {
			aryObjs[i].selected = false;
		}
	}
}
function setValueCheckbox(obj, val) {
	if (obj.value == val) {
		obj.checked = true;
	}
	else {
		obj.checked = false;
	}
}
function setValueText(obj, val) {
	obj.value = val;
}
function setValueTextarea(obj, val) {
	obj.value = val;
}


function getValueRadio(aryObjs) {
	var i, ret;
	for(i=0; i<aryObjs.length; i++) {
		if (aryObjs[i].checked == true) {
			ret = aryObjs[i].value;
		}
	}
	return(ret);
}
function getValueSelect(aryObjs) {
	var i, ret;
	for(i=0; i<aryObjs.length; i++) {
		if (aryObjs[i].selected == true) {
			ret = aryObjs[i].value;
		}
	}
	return(ret);
}


function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt='+alt+'>'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
