<!--
//**************************************************************************************************
//*	function included:
//*		is_valid_email(email)
//*		open_calendar(url, name, width, height, feature)
//*		open_center_browser(url, name, width, height, feature)
//*		is_numeric(keyCode)
//*		change_image(target, image, width, height)
//**************************************************************************************************

function is_valid_email(email){
	var emailInfo = email.split("@");

	if (emailInfo.length > 2){									// @check at most one @ is exist
		return false;
	} else if (emailInfo.length < 2){
		return false;
	} else{
		var user = emailInfo[0];
		var domain = emailInfo[1];
		var userFormat = /[\s\/\\\*\+\?\|\(\)\[\]\{\}~!@#$%^&=;\'\"<>:]/;
		var domainFormat = /[\s\/\\\*\+\?\|\(\)\[\]\{\}~!@#$%^&=;\'\"<>:_]/;

		if (user.match(userFormat) != null){					// @check username haven't any illegal character
			return false;
		}

		if (domain.indexOf(".") == -1){							// @check at least the format of domain be XXXX.XXX
			return false;
		}

																// @ check the top domain at least have 1 char and not more than 4 char
		if ((domain.substring(domain.lastIndexOf(".") + 1, domain.length).length > 4) || (domain.substring(domain.lastIndexOf(".") + 1, domain.length).length < 2)){
			return false;
		}
																// @ check the top level domain MUST be English character
		if (domain.substring(domain.lastIndexOf(".") + 1, domain.length).match(/[^A-Za-z]/) != null){
			return false;
		}

		if (domain.match(domainFormat) != null){				// @ check the domain havent any illegal character
			return false;
		}
	}
	return true;
}

//--------------------------------------------------------------------------------------------------
function open_calendar(textfield_name){
	var url = "/lib/asp/commons/calendar.asp?obj=" + textfield_name;
	var width = 250, height = 175;
	var name = "calendar";
	var feature = "";
	var calendar = open_center_browser(url, name, width, height, feature);
}

//--------------------------------------------------------------------------------------------------
function open_center_browser(url, name, width, height, feature){
	var isIE	= (document.all ? true : false);				//@ is Internet Explorer
	var isNS	= (document.layer ? true : false);				//@ is Netscape Navigator 4
	var isDOM	= (document.getElementById ? true : false);		//@ is Netscape Navigator 6+ or other
	var browser				= new Object();
	var browser_attribute	= "";

	if (!browser.win || (browser.win && browser.win.closed)){
		browser.url		= url;
		browser.name	= name;
		browser.width	= width;
		browser.height	= height;

		//-- centerized the opened broswer and initial its attribute
		if (isIE || isDOM){
			browser.left	= (screen.width - browser.width) / 2;
			browser.top		= (screen.height - browser.height) / 2;
			browser_attribute = "left=" + browser.left + ",top=" + browser.top + ",resizeable=no,width=" + browser.width + ",height=" + browser.height + "," + feature;
		} else if (isNS){
			browser.left	= window.screenX + ((window.outerWidth - browser.width) / 2);
			browser.top		= window.screenY + ((window.outerHeight - browser.height) / 2);
			browser_attribute = "screenX=" + browser.left + ",screenY=" + browser.top + ",resizeable=no,width=" + browser.width + ",height=" + browser.height + "," + feature;
		}

		//-- open new browser
		browser.win = window.open (browser.url, browser.name, browser_attribute);
	}

	browser.win.focus();
	
	return;
}

//--------------------------------------------------------------------------------------------------
function is_numeric(keyCode){

	//-- between 0 - 9, 48 = 1, 57 = 0
	if (keyCode >= 48 && keyCode <= 57){
		return true;
	} else{
		return false;
	}
}

//--------------------------------------------------------------------------------------------------
function change_image(target, image, width, height){
	document.images[target].src = image;
	if (width != 0){
		document.images[target].width = width;
	}

	if (height != 0){
		document.images[target].height = height;
	}
}
//-->