

/*
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);
}

/*
	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;
}

/*
	Make sure that textBox has proper email address
*/
function isNotEmail(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isNotEmail = false;
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(formElement.value)==null){
		_isNotEmail = true;
		alert(message);
		formElement.focus();
	}
	
	return _isNotEmail;
}

function open_new(url,w,h){
	open_new(url,w,h,'yes');
}
function open_new(url,w,h,s) { 
nPopUp = window.self.open("","_blank","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no, width="+w+",height="+h);
ndoc = nPopUp.document;
ndoc.close();
ndoc.open();
atrs = '<HTML><HEAD><TITLE>EDCON </TITLE></HEAD>';
atrs+= '<BODY BGCOLOR="#ffffff" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>';
atrs+= "<div align='center'><A HREF='javascript:self.close()'><IMG SRC='"+url+"' BORDER=0></A></div>";
atrs+= "<div align='center' style='font-family:arial;font-size:11px;'><A HREF='javascript:self.close()'>Close</A></div>";
atrs+= "</BODY></HTML>";
ndoc.write(atrs);
ndoc.close();
}

