// JavaScript Document
function space_only(s) {
	return (/^\s*$/).exec(s);
}

function time_format(time){
	return (/^[0-9]{2,2}:[0-9]{2,2}$/).exec(time);
	var $s = time.split(':');
	if ($s[0] > 24 || $s[0] < 1) return false;
	if ($s[1] > 59 || $s[1] < 1) return false;
	return true;
}


function hk_phone_format(data){
	return (/^[1-9]{1,1}[0-9]{7,7}$/).exec(data);
}

function check_safe_input($obj){
	var pattern = /^([a-zA-Z0-9_\-\.@])*$/;
	return pattern.exec($obj);
}

function date_format(date){
	if ((/^[0-9]{4,4}\-[0-9]{1,2}\-[0-9]{1,2}$/).exec(date) == null) return false;
	var s = date.split('-');
	if (s[1] > 12 || s[1] < 1) return false;
	
	var end_day;
	switch (s[1]){
		case '1': case '3': case '5': case '7':
		case '8': case '10': case '12':
			end_day = 31;
			break;
		case '4': case '6': case '9': case '11':
			end_day = 30;
			break;
		case '2':
			if (s[0] % 4 == 0 && (s[0] % 100 != 0 || s[0] % 400 == 0))
				end_day = 29;
			else
				end_day = 28;
			break;
	}
	
	if (s[2] > end_day || s[2] < 1) return false;
	return true;
}

function email_format(email){
  	return (/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/).exec(email);
}
  
function HKID_format(s){
	return (/^[A-Z]{1,2}[0-9]{7,7}$/).exec(s);
}

function kodsun_username(obj){
	return (/^([a-zA-Z])([a-zA-Z0-9_\.-])+$/).test(obj);
}