function Trim(str)
{
	return str.replace(/^[\s\u3000]+|[\s\u3000]+$/g, '');
}

function ValidEmail(emailStr)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(emailStr) == false) {
		return false;
	}
	return true;
}

function ValidPhone(phoneStr)
{
	var reg = new RegExp(/[A-Za-z]/);
	if ( reg.test(phoneStr) ) {
		return false;
	}
	return true;
}

function ValidPassword(passwordStr)
{
	var reg = new RegExp(/[`~!@#\$%^&*()\-\_=+\[{\]}|;:'",<.>]/);
	if ( reg.test(passwordStr) )
	{
		return false;
	}
	return true;
}

function bottom(rel)
{
	var dt = new Date();

	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr>');
	document.write('<td height="30" background="'+rel+'images/general/bg_footer.jpg">&nbsp;</td>');
	document.write('<td width="1000" background="'+rel+'images/general/bg_footer.jpg">');
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr>');
	document.write('<td class="main_btm_footer">Copyright &copy; '+dt.getFullYear()+' SCMP Hearst Publications Ltd. All rights reserved.</td>');
	document.write('<td class="main_btm_footer"><div align="right">l <a class="main_btm_footerlink" href="'+rel+'contactus/contactus.jsp">Contact us</a> l <a class="main_btm_footerlink" href="'+rel+'privacypolicy.jsp">Privacy Policy</a> l </div></td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('<td background="'+rel+'images/general/bg_footer.jpg">&nbsp;</td>');
	document.write('</tr>');
	document.write('</table>');
}

function doSearch()
{
	if ( Trim(document.forms['searchform'].elements['keyword'].value) == "" )
	{
		alert("Please enter keywork for search.");
		document.forms['searchform'].elements['keyword'].focus();
		return false;
	}
	
	var encodedKeyword = document.forms['searchform'].elements['keyword'].value.replace(/\\/g, "\\\\").replace(/:/g, "\\:").replace(/"/g, "\\\"");
	document.forms['searchform'].elements['q'].value = encodedKeyword;
}

function reloadimage()
{
	document.getElementById('verimage').src = document.getElementById('verimage').src + '?' + (new Date()).getTime();
}