﻿var publicHoliday = new Array();
publicHoliday[0] = "20070702";    //yyyymmdd
publicHoliday[1] = "20070926";
publicHoliday[2] = "20071001";
publicHoliday[3] = "20071019";
publicHoliday[4] = "20071225";
publicHoliday[5] = "20071226";
publicHoliday[6] = "20080101";

var ImgPath;

function SetImgPath(InImgPath){	
	ImgPath = InImgPath;
}


function preloadImages() {
	if ( document.images ){
		var preload = new Array()
				
		preload[0] =  "menubtn_65_h.gif";	//common images - Top Menu
		preload[1] =  "menubtn_421_h.gif";
		preload[2] =  "menubtn_422_h.gif";
		preload[3] =  "menubtn_chi_h.gif";
		preload[4] =  "menubtn_search_h.gif";
		preload[5] =  "submenubtn_415_h.gif";		//common images - Sub Menu
		preload[6] =  "submenubtn_416_h.gif";
		preload[7] =  "submenubtn_417_h.gif";
		preload[8] =  "submenubtn_418_h.gif";
		preload[9] =  "submenubtn_419_h.gif";
		preload[10] = "submenubtn_420_h.gif";
		preload[11] = "submenubtn_415_r.gif";		//common images - Sub Menu
		preload[12] = "submenubtn_416_r.gif";
		preload[13] = "submenubtn_417_r.gif";
		preload[14] = "submenubtn_418_r.gif";
		preload[15] = "submenubtn_419_r.gif";
		preload[16] = "submenubtn_420_r.gif";
		preload[17] = "submenubtn_415_n.gif";		//common images - Sub Menu
		preload[18] = "submenubtn_416_n.gif";
		preload[19] = "submenubtn_417_n.gif";
		preload[20] = "submenubtn_418_n.gif";
		preload[21] = "submenubtn_419_n.gif";
		preload[22] = "submenubtn_420_n.gif";
		
		preload[23] = "spacer.gif";
		preload[24] = "layer_bullet.gif";
		preload[25] = "submenubtn_bg.gif";
//		preload[13] = "images/index/btn_details_h.jpg";		//for index page only
//		preload[14] = "images/index/btn_warranty_h.jpg";
//		preload[15] = "images/index/btn_service_h.jpg";
//		preload[16] = "images/index/btn_maintenance_h.jpg";
//		preload[17] = "images/index/btn_spare_h.jpg";
//		preload[18] = "images/index/btn_worldwide_h.jpg";
		preload[26] = ImgPath + "images/btn_more_h.gif";
	
		for ( var i in preload ){
			var I = new Image();
			I.src = ImgPath + "/" + preload[i];
			preload[i] = I
		}
	}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//For Demo Use
var imgNo = true;

function switchImage()
{
	if (imgNo) {document.flashImage.src = "images/index/flash2.jpg"; imgNo=false;}
	else {document.flashImage.src = "images/index/flash1.jpg"; imgNo=true;}
}

var mainTopic = "";
var subTopic = "";

function over(imgName, imgSrc) {
	var e = document[imgName];
	var imgType = e.src.substring(e.src.length - 3, e.src.length)
	//var imgType = "layer"
	var imgAni = "h";	//animated menu button
	// 	alert(imgSrc);
	if(over.arguments[2] == "layer" || mainTopic == imgName) {imgAni = "r";}	//static menu button or main topic
	if(subTopic == imgName) {imgAni = "h";}	//highlight sub menu button
	if (e && document.images) {e.src =  imgSrc + "_" + imgAni + "." + imgType;}
	if (navigator.appName != 'Netscape') {MM_showHideLayers("layer_" + imgName,'','show');}
}

function out(imgName, imgSrc) {
	var e = document[imgName];
	var imgType = e.src.substring(e.src.length - 3, e.src.length)
	//var imgType = "layer"
	var imgAni = "n";	//no highlight menu button
	// alert(imgSrc);
	if(mainTopic == imgName) {imgAni = "r";}	//main topic menu button
	if(subTopic == imgName) {imgAni = "h";}	//highlight sub menu button
	if (e && document.images) {e.src =  imgSrc + "_" + imgAni + "." + imgType;}
	if (navigator.appName != 'Netscape') {MM_showHideLayers("layer_" + imgName,'','hide');}
}

function overTarget(imgName, imgSrc) {
	var e = document[imgName];
	var imgType = e.src.substring(e.src.length - 3, e.src.length)
	var imgAni = "r";	//animated menu button
	// 	alert(imgSrc);
	if(overTarget.arguments[2] == "layer" || mainTopic == imgName) {imgAni = "r";}	//static menu button or main topic
	if(subTopic == imgName) {imgAni = "r";}	//highlight sub menu button
	if (e && document.images) {e.src =  imgSrc + "_" + imgAni + "." + imgType;}
	if (navigator.appName != 'Netscape') {MM_showHideLayers("layer_" + imgName,'','show');}
}

function outTarget(imgName, imgSrc) {
	var e = document[imgName];
	var imgType = e.src.substring(e.src.length - 3, e.src.length)
	var imgAni = "r";	//no highlight menu button
	// alert(imgSrc);
	if(mainTopic == imgName) {imgAni = "r";}	//main topic menu button
	if(subTopic == imgName) {imgAni = "r";}	//highlight sub menu button
	if (e && document.images) {e.src =  imgSrc + "_" + imgAni + "." + imgType;}
	if (navigator.appName != 'Netscape') {MM_showHideLayers("layer_" + imgName,'','hide');}
}

function DistrictSelect(d){
	for(i=0;i<document.contactForm.strDistrict.length;i++){
		if (document.contactForm.strDistrict.options[i].value==d)	{
			document.contactForm.strDistrict.options[i].selected = true	
		}
	}
}


function updateEngR(r){

	var options=document.contactForm.strDistrict.options; 
	options.length = 0;
	if(r=="Hong Kong"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
 		 document.contactForm.strDistrict.options[1] = new Option('Aberdeen','Aberdeen');
 		 document.contactForm.strDistrict.options[2] = new Option('Admiralty','Admiralty');
		 document.contactForm.strDistrict.options[3] = new Option('Ap Lei Chau','Ap Lei Chau');
		 document.contactForm.strDistrict.options[4] = new Option('Causeway Bay','Causeway Bay');
		 document.contactForm.strDistrict.options[5] = new Option('Central District','Central District');
		 document.contactForm.strDistrict.options[6] = new Option('Chai Wan','Chai Wan');
		 document.contactForm.strDistrict.options[7] = new Option('Happy Valley','Happy Valley');		 
		 document.contactForm.strDistrict.options[8] = new Option('Jardine\'s Lookout','Jardine\'s Lookout');
		 document.contactForm.strDistrict.options[9] = new Option('Kennedy Town','Kennedy Town');
		 document.contactForm.strDistrict.options[10] = new Option('Mid-Level','Mid-Level');
		 document.contactForm.strDistrict.options[11] = new Option('North Point','North Point');
		 document.contactForm.strDistrict.options[12] = new Option('Pok Fu Lam','Pok Fu Lam');
		 document.contactForm.strDistrict.options[13] = new Option('Quarry Bay','Quarry Bay');
		 document.contactForm.strDistrict.options[14] = new Option('Repulse Bay','Repulse Bay');  
		 document.contactForm.strDistrict.options[15] = new Option('Sai Wan Ho','Sai Wan Ho');
		 document.contactForm.strDistrict.options[16] = new Option('Sai Ying Pun','Sai Ying Pun');
		 document.contactForm.strDistrict.options[17] = new Option('Shau Kei Wan','Shau Kei Wan');
		 document.contactForm.strDistrict.options[18] = new Option('Shek O','Shek O');		
		 document.contactForm.strDistrict.options[19] = new Option('Sheung Wan','Sheung Wan');
		 document.contactForm.strDistrict.options[20] = new Option('Siu Sai Wan ','Siu Sai Wan');
		 document.contactForm.strDistrict.options[21] = new Option('Stanley','Stanley');
		 document.contactForm.strDistrict.options[22] = new Option('Tai Tam','Tai Tam');	
		 document.contactForm.strDistrict.options[23] = new Option('The Peak','The Peak');		
    	 document.contactForm.strDistrict.options[24] = new Option('Wah Fu','Wah Fu');	 
		 document.contactForm.strDistrict.options[25] = new Option('Wan Chai','Wan Chai');
		 document.contactForm.strDistrict.options[26] = new Option('Wong Chuk Hang','Wong Chuk Hang');
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if( r=="Kowloon"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
		 document.contactForm.strDistrict.options[1] = new Option('Cheung Sha Wan','Cheung Sha Wan');
		 document.contactForm.strDistrict.options[2] = new Option('Choi Hung','Choi Hung');
		 document.contactForm.strDistrict.options[3] = new Option('Diamond Hill','Diamond Hill');
		 document.contactForm.strDistrict.options[4] = new Option('Ho Man Tin','Ho Man Tin');
		 document.contactForm.strDistrict.options[5] = new Option('Hung Hom ','Hung Hom');
		 document.contactForm.strDistrict.options[6] = new Option('Jordan','Jordan');
		 document.contactForm.strDistrict.options[7] = new Option('Kowloon Bay','Kowloon Bay');
		 document.contactForm.strDistrict.options[8] = new Option('Kowloon City','Kowloon City');
		 document.contactForm.strDistrict.options[9] = new Option('Kowloon Tong','Kowloon Tong');
		 document.contactForm.strDistrict.options[10] = new Option('Kwun Tong','Kwun Tong');	
		 document.contactForm.strDistrict.options[11] = new Option('Lai Chi Kok','Lai Chi Kok');
		 document.contactForm.strDistrict.options[12] = new Option('Lam Tin','Lam Tin');
		 document.contactForm.strDistrict.options[13] = new Option('Mong Kok','Mong Kok');
		 document.contactForm.strDistrict.options[14] = new Option('Ngau Chi Wan','Ngau Chi Wan');
		 document.contactForm.strDistrict.options[15] = new Option('Ngau Tau Kok','Ngau Tau Kok');
		 document.contactForm.strDistrict.options[16] = new Option('San Po Kong','San Po Kong');
		 document.contactForm.strDistrict.options[17] = new Option('Sau Mau Ping','Sau Mau Ping');	
		 document.contactForm.strDistrict.options[18] = new Option('Sham Shui Po','Sham Shui Po');
		 document.contactForm.strDistrict.options[19] = new Option('Shek Kip Mei','Shek Kip Mei');
		 document.contactForm.strDistrict.options[20] = new Option('Tai Kok Tsui','Tai Kok Tsui');
		 document.contactForm.strDistrict.options[21] = new Option('To Kwan Wan','To Kwan Wan');
		 document.contactForm.strDistrict.options[22] = new Option('Tsim Sha Tsui','Tsim Sha Tsui');
		 document.contactForm.strDistrict.options[23] = new Option('Tsz Wan Shan','Tsz Wan Shan');
		 document.contactForm.strDistrict.options[24] = new Option('Wang Tau Hom','Wang Tau Hom');
		 document.contactForm.strDistrict.options[25] = new Option('Wong Tai Sin','Wong Tai Sin');
		 document.contactForm.strDistrict.options[26] = new Option('Yau Ma Tei','Yau Ma Tei');   		 
		 document.contactForm.strDistrict.options[27] = new Option('Yau Tong','Yau Tong');		 
	 	 
			 
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
		if( r=="New Territories"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
   	     document.contactForm.strDistrict.options[1] = new Option('Clear Water Bay','Clear Water Bay');
		 document.contactForm.strDistrict.options[2] = new Option('Fanling','Fanling');
		 document.contactForm.strDistrict.options[3] = new Option('Kwai Chung','Kwai Chung');
		 document.contactForm.strDistrict.options[4] = new Option('Lok Ma Chau','Lok Ma Chau');	
		 document.contactForm.strDistrict.options[5] = new Option('Ma On Shan','Ma On Shan');
		 document.contactForm.strDistrict.options[6] = new Option('Ma Wan','Ma Wan');
		 document.contactForm.strDistrict.options[7] = new Option('Sai Kung','Sai Kung');
		 document.contactForm.strDistrict.options[8] = new Option('Sha Tau Kok','Sha Tau Kok');
		 document.contactForm.strDistrict.options[9] = new Option('Sham Tseng ','Sham Tseng');
		 document.contactForm.strDistrict.options[10] = new Option('Shatin','Shatin');
		 document.contactForm.strDistrict.options[11] = new Option('Sheung Shui','Sheung Shui');
		 document.contactForm.strDistrict.options[12] = new Option('Tai Po','Tai Po');
		 document.contactForm.strDistrict.options[13] = new Option('Tin Shui Wai','Tin Shui Wai');
		 document.contactForm.strDistrict.options[14] = new Option('Tseng Kwan O','Tseng Kwan O');
		 document.contactForm.strDistrict.options[15] = new Option('Tsing Lung Tau','Tsing Lung Tau');
		 document.contactForm.strDistrict.options[16] = new Option('Tsing Yi','Tsing Yi');
		 document.contactForm.strDistrict.options[17] = new Option('Tsuen Wan','Tsuen Wan');
		 document.contactForm.strDistrict.options[18] = new Option('Tuen Mun','Tuen Mun');
		 document.contactForm.strDistrict.options[19] = new Option('Yuen Long','Yuen Long');		
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
		if( r=="Outlying Islands"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');		 
		 document.contactForm.strDistrict.options[1] = new Option('Cheung Chau','Cheung Chau');
		 document.contactForm.strDistrict.options[2] = new Option('Discovery Bay','Discovery Bay');
		 document.contactForm.strDistrict.options[3] = new Option('Lamma Island','Lamma Island');
		 document.contactForm.strDistrict.options[4] = new Option('Lantau Island','Lantau Island');			
		 document.contactForm.strDistrict.options[5] = new Option('Peng Chau','Peng Chau');		 	
		 document.contactForm.strDistrict.options[6] = new Option('Tung Chung','Tung Chung');		
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="Macau")	{
		document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
		document.contactForm.strDistrict.options[1] = new Option('Macau','Macau');
		document.contactForm.strDistrict.options[1].selected = true
		document.contactForm.strDistrict.disabled=true;
	}
	if(r=="Others")	{
		document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
		document.contactForm.strDistrict.options[1] = new Option('Sha Tau Kok','Sha Tau Kok');
		document.contactForm.strDistrict.options[2] = new Option('Lok Ma Chau','Lok Ma Chau');		
		document.contactForm.strDistrict.options[3] = new Option('Others','Others');
		document.contactForm.strDistrict.disabled=false;
	}
	if(r=="Overseas")	{
		document.contactForm.strDistrict.options[0] = new Option(' Not Applicable ',' Not Applicable ');
		document.contactForm.strDistrict.options[1] = new Option(' Not Applicable ',' Not Applicable ');
		document.contactForm.strDistrict.options[1].selected = true
		document.contactForm.strDistrict.disabled=true;
	}
	 //document.contactForm.strDistrict.options[0].selected = true
}

function updateChiR(r){
	var options=document.contactForm.strDistrict.options; 
	options.length = 0;
	if(r=="香港"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		 document.contactForm.strDistrict.options[1] = new Option('上環','上環');
		 document.contactForm.strDistrict.options[2] = new Option('大潭','大潭');
		 document.contactForm.strDistrict.options[3] = new Option('小西灣','小西灣');
		 document.contactForm.strDistrict.options[4] = new Option('山頂','山頂');
		 document.contactForm.strDistrict.options[5] = new Option('中環','中環');
		 document.contactForm.strDistrict.options[6] = new Option('北角','北角');
		 document.contactForm.strDistrict.options[7] = new Option('半山','半山');
		 document.contactForm.strDistrict.options[8] = new Option('石澳','石澳');
		 document.contactForm.strDistrict.options[9] = new Option('西灣河','西灣河');
		 document.contactForm.strDistrict.options[10] = new Option('西營盤','西營盤');
		 document.contactForm.strDistrict.options[11] = new Option('赤柱','赤柱');
		 document.contactForm.strDistrict.options[12] = new Option('金鐘','金鐘');
		 document.contactForm.strDistrict.options[13] = new Option('香港仔','香港仔');
		 document.contactForm.strDistrict.options[14] = new Option('柴灣','柴灣');
		 document.contactForm.strDistrict.options[15] = new Option('堅尼地城','堅尼地城');
		 document.contactForm.strDistrict.options[16] = new Option('淺水灣','淺水灣');
		 document.contactForm.strDistrict.options[17] = new Option('渣甸山','渣甸山');
		 document.contactForm.strDistrict.options[18] = new Option('華富','華富');
		 document.contactForm.strDistrict.options[19] = new Option('跑馬地','跑馬地');
		 document.contactForm.strDistrict.options[20] = new Option('黃竹坑','黃竹坑');
		 document.contactForm.strDistrict.options[21] = new Option('筲箕灣','筲箕灣');
		 document.contactForm.strDistrict.options[22] = new Option('銅鑼灣','銅鑼灣');
		 document.contactForm.strDistrict.options[23] = new Option('鴨脷洲','鴨脷洲');
		 document.contactForm.strDistrict.options[24] = new Option('薄扶林','薄扶林');		 
		 document.contactForm.strDistrict.options[25] = new Option('灣仔','灣仔');
		 document.contactForm.strDistrict.options[26] = new Option('鰂魚涌','鰂魚涌');		 
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="九龍"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		 document.contactForm.strDistrict.options[1] = new Option('九龍城','九龍城');
		 document.contactForm.strDistrict.options[2] = new Option('九龍塘','九龍塘');
		 document.contactForm.strDistrict.options[3] = new Option('九龍灣','九龍灣');
		 document.contactForm.strDistrict.options[4] = new Option('土瓜灣','土瓜灣');
		 document.contactForm.strDistrict.options[5] = new Option('大角嘴','大角嘴');
		 document.contactForm.strDistrict.options[6] = new Option('牛池灣','牛池灣');
		 document.contactForm.strDistrict.options[7] = new Option('牛頭角','牛頭角');
		 document.contactForm.strDistrict.options[8] = new Option('石硤尾','石硤尾');
		 document.contactForm.strDistrict.options[9] = new Option('尖沙嘴','尖沙嘴');
		 document.contactForm.strDistrict.options[10] = new Option('何文田','何文田');
		 document.contactForm.strDistrict.options[11] = new Option('佐敦','佐敦');
		 document.contactForm.strDistrict.options[12] = new Option('秀茂坪','秀茂坪');
		 document.contactForm.strDistrict.options[13] = new Option('旺角','旺角');
		 document.contactForm.strDistrict.options[14] = new Option('油麻地','油麻地');
		 document.contactForm.strDistrict.options[15] = new Option('油塘','油塘');
		 document.contactForm.strDistrict.options[16] = new Option('長沙灣','長沙灣');
		 document.contactForm.strDistrict.options[17] = new Option('紅磡','紅磡');
		 document.contactForm.strDistrict.options[18] = new Option('荔枝角','荔枝角');
		 document.contactForm.strDistrict.options[19] = new Option('彩虹','彩虹');
		 document.contactForm.strDistrict.options[20] = new Option('深水埗','深水埗');
	     document.contactForm.strDistrict.options[21] = new Option('黃大仙','黃大仙');		 
		 document.contactForm.strDistrict.options[22] = new Option('慈雲山','慈雲山');
 		 document.contactForm.strDistrict.options[23] = new Option('新蒲崗','新蒲崗');
		 document.contactForm.strDistrict.options[24] = new Option('橫頭磡','橫頭磡');	
		 document.contactForm.strDistrict.options[25] = new Option('藍田','藍田');
		 document.contactForm.strDistrict.options[26] = new Option('觀塘','觀塘');		 
	 	 document.contactForm.strDistrict.options[27] = new Option('鑽石山','鑽石山');		 
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
		if(r=="新界"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		 document.contactForm.strDistrict.options[1] = new Option('上水','上水');
		 document.contactForm.strDistrict.options[2] = new Option('大埔','大埔');
		 document.contactForm.strDistrict.options[3] = new Option('元朗','元朗');
		 document.contactForm.strDistrict.options[4] = new Option('天水圍','天水圍');
		 document.contactForm.strDistrict.options[5] = new Option('屯門','屯門');
		 document.contactForm.strDistrict.options[6] = new Option('西貢','西貢');
		 document.contactForm.strDistrict.options[7] = new Option('沙田','沙田');
	 	 document.contactForm.strDistrict.options[8] = new Option('沙頭角','沙頭角');
		 document.contactForm.strDistrict.options[9] = new Option('青衣','青衣');
		 document.contactForm.strDistrict.options[10] = new Option('青龍頭','青龍頭');
		 document.contactForm.strDistrict.options[11] = new Option('粉嶺','粉嶺');
		 document.contactForm.strDistrict.options[12] = new Option('荃灣','荃灣');
		 document.contactForm.strDistrict.options[13] = new Option('馬鞍山','馬鞍山');
		 document.contactForm.strDistrict.options[14] = new Option('馬灣','馬灣');
		 document.contactForm.strDistrict.options[15] = new Option('落馬洲','落馬洲');
		 document.contactForm.strDistrict.options[16] = new Option('將軍澳','將軍澳');
		 document.contactForm.strDistrict.options[17] = new Option('清水灣','清水灣');
		 document.contactForm.strDistrict.options[18] = new Option('深井','深井');
		 document.contactForm.strDistrict.options[19] = new Option('葵涌','葵涌');
		
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="離島"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		 document.contactForm.strDistrict.options[1] = new Option('大嶼山','大嶼山'); 
		 document.contactForm.strDistrict.options[2] = new Option('坪洲','坪洲');
		 document.contactForm.strDistrict.options[3] = new Option('東涌','東涌');
		 document.contactForm.strDistrict.options[4] = new Option('長洲','長洲');
		 document.contactForm.strDistrict.options[5] = new Option('南丫島','南丫島');
		 document.contactForm.strDistrict.options[6] = new Option('愉景灣','愉景灣');
		
		
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="澳門")	{
		document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		document.contactForm.strDistrict.options[1] = new Option('澳門','澳門');
		document.contactForm.strDistrict.options[1].selected = true
		document.contactForm.strDistrict.disabled=true;
	}
	if(r=="其他"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');		  
		 document.contactForm.strDistrict.options[1] = new Option('沙頭角','沙頭角');
		 document.contactForm.strDistrict.options[2] = new Option('落馬洲','落馬洲');
		 document.contactForm.strDistrict.options[3] = new Option('其他','其他');
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="海外")	{
		document.contactForm.strDistrict.options[0] = new Option(' 不適用 ',' 不適用 ');
		document.contactForm.strDistrict.options[0].selected = true
		document.contactForm.strDistrict.disabled=true;
	}
	 //document.contactForm.strDistrict.options[0].selected = true
}



//For Conatct Us Form 
function updateContactEngR(r){

	var options=document.contactForm.strDistrict.options; 
	options.length = 0;
	if(r=="Hong Kong"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
 		 document.contactForm.strDistrict.options[1] = new Option('Aberdeen','Aberdeen');
 		 document.contactForm.strDistrict.options[2] = new Option('Admiralty','Admiralty');
		 document.contactForm.strDistrict.options[3] = new Option('Ap Lei Chau','Ap Lei Chau');
		 document.contactForm.strDistrict.options[4] = new Option('Causeway Bay','Causeway Bay');
		 document.contactForm.strDistrict.options[5] = new Option('Central District','Central District');
		 document.contactForm.strDistrict.options[6] = new Option('Chai Wan','Chai Wan');
		 document.contactForm.strDistrict.options[7] = new Option('Happy Valley','Happy Valley');		 
		 document.contactForm.strDistrict.options[8] = new Option('Jardine\'s Lookout','Jardine\'s Lookout');
		 document.contactForm.strDistrict.options[9] = new Option('Kennedy Town','Kennedy Town');
		 document.contactForm.strDistrict.options[10] = new Option('Mid-Level','Mid-Level');
		 document.contactForm.strDistrict.options[11] = new Option('North Point','North Point');
		 document.contactForm.strDistrict.options[12] = new Option('Pok Fu Lam','Pok Fu Lam');
		 document.contactForm.strDistrict.options[13] = new Option('Quarry Bay','Quarry Bay');
		 document.contactForm.strDistrict.options[14] = new Option('Repulse Bay','Repulse Bay');  
		 document.contactForm.strDistrict.options[15] = new Option('Sai Wan Ho','Sai Wan Ho');
		 document.contactForm.strDistrict.options[16] = new Option('Sai Ying Pun','Sai Ying Pun');
		 document.contactForm.strDistrict.options[17] = new Option('Shau Kei Wan','Shau Kei Wan');
		 document.contactForm.strDistrict.options[18] = new Option('Shek O','Shek O');		
		 document.contactForm.strDistrict.options[19] = new Option('Sheung Wan','Sheung Wan');
		 document.contactForm.strDistrict.options[20] = new Option('Siu Sai Wan ','Siu Sai Wan');
		 document.contactForm.strDistrict.options[21] = new Option('Stanley','Stanley');
		 document.contactForm.strDistrict.options[22] = new Option('Tai Tam','Tai Tam');	
		 document.contactForm.strDistrict.options[23] = new Option('The Peak','The Peak');		
    	 document.contactForm.strDistrict.options[24] = new Option('Wah Fu','Wah Fu');	 
		 document.contactForm.strDistrict.options[25] = new Option('Wan Chai','Wan Chai');
		 document.contactForm.strDistrict.options[26] = new Option('Wong Chuk Hang','Wong Chuk Hang');
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if( r=="Kowloon"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
		 document.contactForm.strDistrict.options[1] = new Option('Cheung Sha Wan','Cheung Sha Wan');
		 document.contactForm.strDistrict.options[2] = new Option('Choi Hung','Choi Hung');
		 document.contactForm.strDistrict.options[3] = new Option('Diamond Hill','Diamond Hill');
		 document.contactForm.strDistrict.options[4] = new Option('Ho Man Tin','Ho Man Tin');
		 document.contactForm.strDistrict.options[5] = new Option('Hung Hom ','Hung Hom');
		 document.contactForm.strDistrict.options[6] = new Option('Jordan','Jordan');
		 document.contactForm.strDistrict.options[7] = new Option('Kowloon Bay','Kowloon Bay');
		 document.contactForm.strDistrict.options[8] = new Option('Kowloon City','Kowloon City');
		 document.contactForm.strDistrict.options[9] = new Option('Kowloon Tong','Kowloon Tong');
		 document.contactForm.strDistrict.options[10] = new Option('Kwun Tong','Kwun Tong');	
		 document.contactForm.strDistrict.options[11] = new Option('Lai Chi Kok','Lai Chi Kok');
		 document.contactForm.strDistrict.options[12] = new Option('Lam Tin','Lam Tin');
		 document.contactForm.strDistrict.options[13] = new Option('Mong Kok','Mong Kok');
		 document.contactForm.strDistrict.options[14] = new Option('Ngau Chi Wan','Ngau Chi Wan');
		 document.contactForm.strDistrict.options[15] = new Option('Ngau Tau Kok','Ngau Tau Kok');
		 document.contactForm.strDistrict.options[16] = new Option('San Po Kong','San Po Kong');
		 document.contactForm.strDistrict.options[17] = new Option('Sau Mau Ping','Sau Mau Ping');	
		 document.contactForm.strDistrict.options[18] = new Option('Sham Shui Po','Sham Shui Po');
		 document.contactForm.strDistrict.options[19] = new Option('Shek Kip Mei','Shek Kip Mei');
		 document.contactForm.strDistrict.options[20] = new Option('Tai Kok Tsui','Tai Kok Tsui');
		 document.contactForm.strDistrict.options[21] = new Option('To Kwan Wan','To Kwan Wan');
		 document.contactForm.strDistrict.options[22] = new Option('Tsim Sha Tsui','Tsim Sha Tsui');
		 document.contactForm.strDistrict.options[23] = new Option('Tsz Wan Shan','Tsz Wan Shan');
		 document.contactForm.strDistrict.options[24] = new Option('Wang Tau Hom','Wang Tau Hom');
		 document.contactForm.strDistrict.options[25] = new Option('Wong Tai Sin','Wong Tai Sin');
		 document.contactForm.strDistrict.options[26] = new Option('Yau Ma Tei','Yau Ma Tei');   		 
		 document.contactForm.strDistrict.options[27] = new Option('Yau Tong','Yau Tong');		 
	 	 
			 
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
		if( r=="New Territories"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
   	     document.contactForm.strDistrict.options[1] = new Option('Clear Water Bay','Clear Water Bay');
		 document.contactForm.strDistrict.options[2] = new Option('Fanling','Fanling');
		 document.contactForm.strDistrict.options[3] = new Option('Kwai Chung','Kwai Chung');
		 document.contactForm.strDistrict.options[4] = new Option('Ma On Shan','Ma On Shan');
		 document.contactForm.strDistrict.options[5] = new Option('Ma Wan','Ma Wan');
		 document.contactForm.strDistrict.options[6] = new Option('Sai Kung','Sai Kung');		
		 document.contactForm.strDistrict.options[7] = new Option('Sham Tseng ','Sham Tseng');
		 document.contactForm.strDistrict.options[8] = new Option('Shatin','Shatin');
		 document.contactForm.strDistrict.options[9] = new Option('Sheung Shui','Sheung Shui');
		 document.contactForm.strDistrict.options[10] = new Option('Tai Po','Tai Po');
		 document.contactForm.strDistrict.options[11] = new Option('Tin Shui Wai','Tin Shui Wai');
		 document.contactForm.strDistrict.options[12] = new Option('Tseng Kwan O','Tseng Kwan O');
		 document.contactForm.strDistrict.options[13] = new Option('Tsing Lung Tau','Tsing Lung Tau');
		 document.contactForm.strDistrict.options[14] = new Option('Tsing Yi','Tsing Yi');
		 document.contactForm.strDistrict.options[15] = new Option('Tsuen Wan','Tsuen Wan');
		 document.contactForm.strDistrict.options[16] = new Option('Tuen Mun','Tuen Mun');
		 document.contactForm.strDistrict.options[17] = new Option('Yuen Long','Yuen Long');		
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
		if( r=="Outlying Islands"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');		 
		 document.contactForm.strDistrict.options[1] = new Option('Cheung Chau','Cheung Chau');
		 document.contactForm.strDistrict.options[2] = new Option('Discovery Bay','Discovery Bay');
		 document.contactForm.strDistrict.options[3] = new Option('Lamma Island','Lamma Island');
		 document.contactForm.strDistrict.options[4] = new Option('Lantau Island','Lantau Island');			
		 document.contactForm.strDistrict.options[5] = new Option('Peng Chau','Peng Chau');		 	
		 document.contactForm.strDistrict.options[6] = new Option('Tung Chung','Tung Chung');		
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="Macau")	{
		document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
		document.contactForm.strDistrict.options[1] = new Option('Macau','Macau');
		document.contactForm.strDistrict.options[1].selected = true
		document.contactForm.strDistrict.disabled=true;
	}
	if(r=="Others")	{
		document.contactForm.strDistrict.options[0] = new Option(' -- Select --','');
		document.contactForm.strDistrict.options[1] = new Option('Sha Tau Kok','Sha Tau Kok');
		document.contactForm.strDistrict.options[2] = new Option('Lok Ma Chau','Lok Ma Chau');		
		document.contactForm.strDistrict.options[3] = new Option('Others','Others');
		document.contactForm.strDistrict.disabled=false;
	}
	if(r=="Overseas")	{
		document.contactForm.strDistrict.options[0] = new Option(' Not Applicable ',' Not Applicable ');
		document.contactForm.strDistrict.options[1] = new Option(' Not Applicable ',' Not Applicable ');
		document.contactForm.strDistrict.options[1].selected = true
		document.contactForm.strDistrict.disabled=true;
	}
	 //document.contactForm.strDistrict.options[0].selected = true
}

function updateContactChiR(r){
	var options=document.contactForm.strDistrict.options; 
	options.length = 0;
	if(r=="香港"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		 document.contactForm.strDistrict.options[1] = new Option('上環','上環');
		 document.contactForm.strDistrict.options[2] = new Option('大潭','大潭');
		 document.contactForm.strDistrict.options[3] = new Option('小西灣','小西灣');
		 document.contactForm.strDistrict.options[4] = new Option('山頂','山頂');
		 document.contactForm.strDistrict.options[5] = new Option('中環','中環');
		 document.contactForm.strDistrict.options[6] = new Option('北角','北角');
		 document.contactForm.strDistrict.options[7] = new Option('半山','半山');
		 document.contactForm.strDistrict.options[8] = new Option('石澳','石澳');
		 document.contactForm.strDistrict.options[9] = new Option('西灣河','西灣河');
		 document.contactForm.strDistrict.options[10] = new Option('西營盤','西營盤');
		 document.contactForm.strDistrict.options[11] = new Option('赤柱','赤柱');
		 document.contactForm.strDistrict.options[12] = new Option('金鐘','金鐘');
		 document.contactForm.strDistrict.options[13] = new Option('香港仔','香港仔');
		 document.contactForm.strDistrict.options[14] = new Option('柴灣','柴灣');
		 document.contactForm.strDistrict.options[15] = new Option('堅尼地城','堅尼地城');
		 document.contactForm.strDistrict.options[16] = new Option('淺水灣','淺水灣');
		 document.contactForm.strDistrict.options[17] = new Option('渣甸山','渣甸山');
		 document.contactForm.strDistrict.options[18] = new Option('華富','華富');
		 document.contactForm.strDistrict.options[19] = new Option('跑馬地','跑馬地');
		 document.contactForm.strDistrict.options[20] = new Option('黃竹坑','黃竹坑');
		 document.contactForm.strDistrict.options[21] = new Option('筲箕灣','筲箕灣');
		 document.contactForm.strDistrict.options[22] = new Option('銅鑼灣','銅鑼灣');
		 document.contactForm.strDistrict.options[23] = new Option('鴨脷洲','鴨脷洲');
		 document.contactForm.strDistrict.options[24] = new Option('薄扶林','薄扶林');		 
		 document.contactForm.strDistrict.options[25] = new Option('灣仔','灣仔');
		 document.contactForm.strDistrict.options[26] = new Option('鰂魚涌','鰂魚涌');		 
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="九龍"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		 document.contactForm.strDistrict.options[1] = new Option('九龍城','九龍城');
		 document.contactForm.strDistrict.options[2] = new Option('九龍塘','九龍塘');
		 document.contactForm.strDistrict.options[3] = new Option('九龍灣','九龍灣');
		 document.contactForm.strDistrict.options[4] = new Option('土瓜灣','土瓜灣');
		 document.contactForm.strDistrict.options[5] = new Option('大角嘴','大角嘴');
		 document.contactForm.strDistrict.options[6] = new Option('牛池灣','牛池灣');
		 document.contactForm.strDistrict.options[7] = new Option('牛頭角','牛頭角');
		 document.contactForm.strDistrict.options[8] = new Option('石硤尾','石硤尾');
		 document.contactForm.strDistrict.options[9] = new Option('尖沙嘴','尖沙嘴');
		 document.contactForm.strDistrict.options[10] = new Option('何文田','何文田');
		 document.contactForm.strDistrict.options[11] = new Option('佐敦','佐敦');
		 document.contactForm.strDistrict.options[12] = new Option('秀茂坪','秀茂坪');
		 document.contactForm.strDistrict.options[13] = new Option('旺角','旺角');
		 document.contactForm.strDistrict.options[14] = new Option('油麻地','油麻地');
		 document.contactForm.strDistrict.options[15] = new Option('油塘','油塘');
		 document.contactForm.strDistrict.options[16] = new Option('長沙灣','長沙灣');
		 document.contactForm.strDistrict.options[17] = new Option('紅磡','紅磡');
		 document.contactForm.strDistrict.options[18] = new Option('荔枝角','荔枝角');
		 document.contactForm.strDistrict.options[19] = new Option('彩虹','彩虹');
		 document.contactForm.strDistrict.options[20] = new Option('深水埗','深水埗');
	     document.contactForm.strDistrict.options[21] = new Option('黃大仙','黃大仙');		 
		 document.contactForm.strDistrict.options[22] = new Option('慈雲山','慈雲山');
 		 document.contactForm.strDistrict.options[23] = new Option('新蒲崗','新蒲崗');
		 document.contactForm.strDistrict.options[24] = new Option('橫頭磡','橫頭磡');	
		 document.contactForm.strDistrict.options[25] = new Option('藍田','藍田');
		 document.contactForm.strDistrict.options[26] = new Option('觀塘','觀塘');		 
	 	 document.contactForm.strDistrict.options[27] = new Option('鑽石山','鑽石山');		 
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
		if(r=="新界"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		 document.contactForm.strDistrict.options[1] = new Option('上水','上水');
		 document.contactForm.strDistrict.options[2] = new Option('大埔','大埔');
		 document.contactForm.strDistrict.options[3] = new Option('元朗','元朗');
		 document.contactForm.strDistrict.options[4] = new Option('天水圍','天水圍');
		 document.contactForm.strDistrict.options[5] = new Option('屯門','屯門');
		 document.contactForm.strDistrict.options[6] = new Option('西貢','西貢');
		 document.contactForm.strDistrict.options[7] = new Option('沙田','沙田'); 
		 document.contactForm.strDistrict.options[8] = new Option('青衣','青衣');
		 document.contactForm.strDistrict.options[9] = new Option('青龍頭','青龍頭');
		 document.contactForm.strDistrict.options[10] = new Option('粉嶺','粉嶺');
		 document.contactForm.strDistrict.options[11] = new Option('荃灣','荃灣');
		 document.contactForm.strDistrict.options[12] = new Option('馬鞍山','馬鞍山');
		 document.contactForm.strDistrict.options[13] = new Option('馬灣','馬灣'); 
		 document.contactForm.strDistrict.options[14] = new Option('將軍澳','將軍澳');
		 document.contactForm.strDistrict.options[15] = new Option('清水灣','清水灣');
		 document.contactForm.strDistrict.options[16] = new Option('深井','深井');
		 document.contactForm.strDistrict.options[17] = new Option('葵涌','葵涌');
		
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="離島"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		 document.contactForm.strDistrict.options[1] = new Option('大嶼山','大嶼山'); 
		 document.contactForm.strDistrict.options[2] = new Option('坪洲','坪洲');
		 document.contactForm.strDistrict.options[3] = new Option('東涌','東涌');
		 document.contactForm.strDistrict.options[4] = new Option('長洲','長洲');
		 document.contactForm.strDistrict.options[5] = new Option('南丫島','南丫島');
		 document.contactForm.strDistrict.options[6] = new Option('愉景灣','愉景灣');
		
		
		// document.contactForm.strDistrict.options[0].selected = true
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="澳門")	{
		document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');
		document.contactForm.strDistrict.options[1] = new Option('澳門','澳門');
		document.contactForm.strDistrict.options[1].selected = true
		document.contactForm.strDistrict.disabled=true;
	}
	if(r=="其他"){ 
		 document.contactForm.strDistrict.options[0] = new Option(' -- 請選擇 --','');		  
		 document.contactForm.strDistrict.options[1] = new Option('沙頭角','沙頭角');
		 document.contactForm.strDistrict.options[2] = new Option('落馬洲','落馬洲');
		 document.contactForm.strDistrict.options[3] = new Option('其他','其他');
		 document.contactForm.strDistrict.disabled=false;
	}
	if(r=="海外")	{
		document.contactForm.strDistrict.options[0] = new Option(' 不適用 ',' 不適用 ');
		document.contactForm.strDistrict.options[0].selected = true
		document.contactForm.strDistrict.disabled=true;
	}
	 //document.contactForm.strDistrict.options[0].selected = true
}

 
function searchSubmit(field,language,name)
{	
	function checkForm()
	{
		if ((field.value.length == 0) || (field.value.length == 1))
		{
			alert(alertMessage[language].input.replace(/FIELDNAME/g,name));
			field.focus();
			return false;
		}
		return true;					
	}

	if (checkForm())
	{		
		document.searchBox.submit();
	}
}

 
function isEmpty(field){
	if(field==null)return true;
	if(field.value.trim()=="" || field.value.trim()==null)return true;
	return false;
}

function layoutContentEncode(content){
		if(content){
			var temp="";
			var pos=0;
			while(pos<content.length){
				var currentChar=content.charAt(pos);
				switch(currentChar){
					case "<":
						for(;pos<content.length && content.charAt(pos)!=">";pos++)temp+=content.charAt(pos);
						temp+=content.charAt(pos);
						break;
					case "@":
						temp+="[@]";
						break;
					default:
						temp+=currentChar;
					
				}
				pos++;					
			}
			return temp;
		}
}
	
function layoutContentDecode(content){
	return content.replace(/\[@\]/g,"@");
}

function isNumber(field){
	if(field==null)return false;
	if(field.value=="")return false;
	if(field.value.match(/[^0-9\/]/))return false;
	return !isNaN(field.value);
}


function isDate(field){
	if(field==null){
		return false;
	}
	var checkDate=field.value.trim();
	if(checkDate=="")return false;
	var d=new Date(checkDate);
	if(isNaN(d))return false;
	if(checkDate.match(/[^0-9\/]/))return false;
	var isPass=true;
	var datePart=checkDate.split("/");
	if(datePart.length!=3)return false;
	var d=datePart[1];
	var m=datePart[0];
	var y=datePart[2];
	if(m < 1 || m >12 || isNaN(m))return false;
	if(d < 1 || d >31 || isNaN(d))return false;
	if(y<0 || y > 3000 || isNaN(y))return false;
	return true;
}

function checkDate2(day1,month1,year1,day2,month2,year2)
{
	var date1;
    var date2;

	date1 = year1 * 10000 + month1 * 100 + day1;
    date2 = year2 * 10000 + month2 * 100 + day2;
 
	return date1 <= date2;
}

function isValidDate(field){
	if(field==null){
		return false;
	}
	var checkDate=field;
	if(checkDate=="")return false;
	var d=new Date(checkDate);
	if(isNaN(d))return false;
	if(checkDate.match(/[^0-9\/]/))return false;
	var isPass=true;
	var datePart=checkDate.split("/");
	if(datePart.length!=3)return false;
	var d=datePart[1];
	var m=datePart[0];
	var y=datePart[2];
	if(m < 1 || m >12 || isNaN(m))return false;
	if(d < 1 || d >31 || isNaN(d))return false;
	if(y<0 || y > 3000 || isNaN(y))return false;
	
	var today = new Date();
	var t_y = today.getFullYear();
	var t_m = today.getMonth()+1;
	var t_d = today.getDate();
	
	if (t_m == 12){
		t_m = t_m -12;
		t_y = t_y + 1 ;
	}
	
	//if (!checkDate2(parseInt(d),parseInt(m),parseInt(y),t_d,t_m,t_y)) return false; 
	
	return true;
}

function isLimitValidDate(field){
	if(field==null){
		return false;
	}
	var checkDate=field;
	if(checkDate=="")return false;
	var d=new Date(checkDate);
	if(isNaN(d))return false;
	if(checkDate.match(/[^0-9\/]/))return false;
	var isPass=true;
	var datePart=checkDate.split("/");
	if(datePart.length!=3)return false;
	var d=datePart[1];
	var m=datePart[0];
	var y=datePart[2];
	if(m < 1 || m >12 || isNaN(m))return false;
	if(d < 1 || d >31 || isNaN(d))return false;
	if(y<0 || y > 3000 || isNaN(y))return false;
	
	var today = new Date();
	var t_y = today.getFullYear();
	var t_m = today.getMonth()+1;
	var t_d = today.getDate();
	
	if (t_m == 12){
		t_m = t_m -12;
		t_y = t_y + 1 ;
	}
	
	//if (!checkDate2(t_d,t_m,(t_y-5), parseInt(d),parseInt(m),parseInt(y))) return false; 
	
	return true;
}


function isValidDate2(field){
	if(field==null){
		return false;
	}
	var checkDate=field;
	if(checkDate=="")return false;
	var d=new Date(checkDate);
	if(isNaN(d))return false;
	if(checkDate.match(/[^0-9\/]/))return false;
	var isPass=true;
	var datePart=checkDate.split("/");
	if(datePart.length!=3)return false;
	var d=datePart[1];
	var m=datePart[0];
	var y=datePart[2];
	if(m < 1 || m >12 || isNaN(m))return false;
	if(d < 1 || d >31 || isNaN(d))return false;
	if(y<0 || y > 3000 || isNaN(y))return false;
	
	var today = new Date();
	var t_y = today.getFullYear();
	var t_m = today.getMonth()+1;
	var t_d = today.getDate(); 
	 
	
	return true;
}

function isValidChoiceDate(field) {
	if (!isValidDate2(field)) {
		return false;
	}
	
	var d=(new Date() );
	d.setDate(d.getDate() - 1);
	
	if ( d > (new Date(field)) ) {
		return false;
	}
	
	return true; 
}
 
 
function isLimitValidChoiceDate(field) {
	if(field==null){
		return false;
	}
	var checkDate=field;
	if(checkDate=="")return false;
	var d=new Date(checkDate);
	if(isNaN(d))return false;
	if(checkDate.match(/[^0-9\/]/))return false;
	var isPass=true;
	var datePart=checkDate.split("/");
	if(datePart.length!=3)return false;
	var d=datePart[1];
	var m=datePart[0];
	var y=datePart[2];
	if(m < 1 || m >12 || isNaN(m))return false;
	if(d < 1 || d >31 || isNaN(d))return false;
	if(y<0 || y > 3000 || isNaN(y))return false;
	
	var today = new Date();
	var t_y = today.getFullYear();
	var t_m = today.getMonth()+1;
	var t_d = today.getDate()-1;
	
	if (t_m == 12){
		t_m = t_m -12;
		t_y = t_y + 1 ;
	}
	
	if (!checkDate2(parseInt(d),parseInt(m),parseInt(y), (t_d),(t_m+1),t_y)) return false; 
	
	return true;
}
  
 

function isEscape(field){
	if(field==null)return true;
	var value=field.value.trim();
	return value.match(/[^a-zA-Z0-9\.]/);
}

function isOverLength(field,length){
	if(field==null)return true;
	var value=field.value.trim();
	return value.length >length;
}

function isSelected(field,index){
	if(field==null)return false;
	if(field.selectedIndex==index)return true;
	return false;
}

function isSelectedRadio(field){
	if(getRadioValue(field)!=null)return true;
	else return false;
}

function getRadioValue(field){
	for(var i=0;i<field.length;i++){
		if(field[i].checked){
			return field[i].value;
		}
	}
	return null;
}

function isChecked(field,total){
	var temp=0;
	if(field==null)return false;
	if(field.length){
		for(var i=0;i<field.length;i++){
			if(field[i].checked)temp++;
		}
	}else{
		temp=field.checked?1:0;
	}
	return temp>=total;
}


String.prototype.trim = function()
{
    // Use a regular expression to replace leading and trailing 
    // spaces with the empty string
    return this.replace(/(^\s*)|(\s*$)/g, "");
}


function checkSelect(field,name,language){
	if(isSelected(field,0)){
		alert(alertMessage[language].select.replace(/FIELDNAME/g,name));
		return false;
	}else{
		return true;
	}
}

function checkRadio(field,name,language){
	if(!isSelectedRadio(field)){
		alert(alertMessage[language].select.replace(/FIELDNAME/g,name));
		return false;
	}else{
		return true;
	}
}

function checkString(field,name,language,length){
	if(isEmpty(field)){
		alert(alertMessage[language].input.replace(/FIELDNAME/g,name));
		field.focus();
		return false;
	}else if(length>0 && length<field.value.length){
		msg=alertMessage[language].maxLength.replace(/FIELDNAME/g,name);
		msg=msg.replace(/LENGTH/g,length)
		alert(msg);
		field.focus();
		return false;
	}else{
		return true;
	}
}

function checkLimitString(field,name,language,length){
	if(isEmpty(field)){
		alert(alertMessage[language].input.replace(/FIELDNAME/g,name));
		field.focus();
		return false;
	}else if(length>0 && length>field.value.length){
		msg=alertMessage[language].minLength.replace(/FIELDNAME/g,name);
		msg=msg.replace(/LENGTH/g,length)
		alert(msg);
		field.focus();
		return false;
	}else{
		return true;
	}
}

function checkInt(field,name,language,length){
	if(!isNumber(field)){
		alert(alertMessage[language].number.replace(/FIELDNAME/g,name));
		field.focus();
		return false;
	}else if(length>0 && length<field.value){
		msg=alertMessage[language].maxValue.replace(/FIELDNAME/g,name);
		msg=msg.replace(/VALUE/g,length)
		alert(msg);
		field.focus();
		return false;
	}else{
		return true;
	}
}

function checkWarrantyNo(field)
{
	if(field==null) {
		return true;
	}
	if(field.value=="") {
		return true;
	}
	if(field.value.length>6 && field.value.length<11)
	{
		if(field.value.match(/[0-9]/) || field.value.indexOf("A")!=-1 || field.value.indexOf("B")!=-1 || field.value.indexOf("C")!=-1 || field.value.indexOf("J")!=-1 || field.value.indexOf("a")!=-1 || field.value.indexOf("b")!=-1 || field.value.indexOf("c")!=-1 || field.value.indexOf("j")!=-1)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	return false;
}

function checkEMail(field,name,language)
{
	if (field==null) {
		alert(alertMessage[language].email.replace(/FIELDNAME/g,name));
		field.focus();
		return false;
	}
	if (field.value == "") {
		alert(alertMessage[language].email.replace(/FIELDNAME/g,name));
		field.focus();
		return false;
	}
	if (field.value.indexOf("@") < 1) {
		alert(alertMessage[language].email.replace(/FIELDNAME/g,name));
		field.focus();
		return false;
	}
	/*
	if (field.value.indexOf(".") < 3) {
		alert(alertMessage[language].email.replace(/FIELDNAME/g,name));
		field.focus();
		return false;
	}*/
	return true;	
}

var alertMessage=new Array();
alertMessage["en"]=new Object();
alertMessage["en"].input="Please input FIELDNAME.";
alertMessage["en"].select="Please select FIELDNAME.";
alertMessage["en"].maxLength="The FIELDNAME field cannot be over LENGTH characters.";
alertMessage["en"].minLength="The FIELDNAME shall not be less than LENGTH digits.";
alertMessage["en"].invalidDate="The FIELDNAME is invalid date.";
alertMessage["en"].number="The FIELDNAME field shall be entered with numbers only.";
alertMessage["en"].maxValue="The FIELDNAME field cannot over VALUE.";
alertMessage["en"].email="The FIELDNAME is invalid.";

alertMessage["tc"]=new Object();
alertMessage["tc"].input="請輸入FIELDNAME.";
alertMessage["tc"].select="請選擇FIELDNAME.";
alertMessage["tc"].maxLength="FIELDNAME不能超出LENGTH個字.";
alertMessage["tc"].minLength="FIELDNAME不能少於LENGTH個字.";
alertMessage["tc"].invalidDate="FIELDNAME不是正確日期.";
alertMessage["tc"].number="FIELDNAME欄只可輸入數字.";
alertMessage["tc"].maxValue="FIELDNAME不能超出VALUE.";
alertMessage["tc"].email="FIELDNAME不正確.";

function dateSelector(yyyy,mm,dd){
	str = "";
	D = new Date()
	if((yyyy+mm+dd).length != 6){
		
	}
	D.setDate(D.getDate()+2); 
	for( x = 0 ; x< 31 ; x++){
		if((D.getDay()>0)&&(!isHoliday(D.getFullYear(),D.getMonth()*1+1,D.getDate()))){
			str += "<option value='"+D.getFullYear()+","+(D.getMonth()*1+1)+","+D.getDate()+"'";
			if((D.getFullYear() == yyyy) &&(D.getMonth() == mm) &&(D.getDate() == dd) ) {
				str += " selected";		
			}
			str += ">";
			str += D.getFullYear()+"/"+(D.getMonth()*1+1)+"/"+D.getDate() + "</option>\n";
		}
		D.setDate(D.getDate()+1);
	}
	return str;
}

function isHoliday(yyyy,mm,dd){
		isH = false;
		yyyy = ""+yyyy;
		mm = ""+mm;
		dd = ""+dd;
		for (y = 0;y<publicHoliday.length ; y++)
		{
			if(mm.length==1) {
				mm = "0"+mm ;
			}
			if(dd.length==1){
				dd = "0"+dd;
			}

			if(yyyy+""+mm+""+dd==publicHoliday[y]){
			return true;
			}
		}
		return isH;
}

function haveSpecialChar(str){
	//var specialStr = "\^&<>@!$\"'+";
	var specialStr = "\^&<>@!$\"'+,";
	var countx = 0;
	for (countx = 0; countx < specialStr.length; countx++){
		if(str.indexOf(specialStr.charAt(countx))>=0){
			return true;
		}
	}
	return false;
}