 /*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	return _isEmpty;
}

function isMatch(formElement, matchVal, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == matchVal) {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	return _isEmpty;
}

/*
	Set one value in combo box as the selected value
*/
function setSelect(listElement, listValue)
{
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue)	{
			listElement.selectedIndex = i;
		}
	}	
}
function wind(url,wind_width,wind_height,scrols){
var width = 680;
var height = 450;
var w = screen.width;
if( w >= 1024 ){
width = 720;
height = 600;
}
var l = ( screen.width - width )/2;
var t = ( screen.height - height )/2 - 20;
window.open( url, "_blank", "toolbar=0,menubar=1,scrollbars="+scrols+",resizable=0,left="+l+",top="+t+",width="+wind_width+",height="+wind_height );
	
return false;
}


