/*******************************************************************************
 - 另開新視窗
*******************************************************************************/
	function display(
	program, 
	toolbar, 
	location, 
	directories, 
	status, 
	menuBar, 
	scrollbars, 
	resizable, 
	width, 
	height){
		// ex: display("servlet",0,0,0,0,1,1,1,800,600);
		features = "toolbar = " + toolbar + ", " +
		           "location = " + location + ", " +
		           "directories = " + directories + ", " +
		           "status = " + status + ", " +
		           "menuBar = " + menuBar + ", " +
		           "scrollbars = " + scrollbars + ", " +
		           "resizable = " + resizable + ", " +
		           "width = " + width + ", " +
		           "height = " + height;
		var o = window.open("/travel/blank.html", "", features);
		//alert("screen.width="+screen.width+"\nscreen.height="+screen.height);
		//alert("width="+width+"\nheight="+height+"\n(screen.height - height) / 2="+((screen.height - height) / 2));
		o.moveTo((screen.width - width) / 2, (screen.height - height - 50) / 2);
		o.location.href = program;
	}

/*******************************************************************************
 - 判斷字串長度
*******************************************************************************/
	function stringLength(input){
		var str = input.value;
		var i,cnt=0;
		for(i=0; i<str.length;i++){
			if(escape(str.charAt(i)).length >= 4)
				cnt += 2;
			else
				cnt++;
		}
		return cnt;
	}
/*******************************************************************************
 - 判斷一個input中有無 "(quote) 或 '(apos)
*******************************************************************************/
	function isQuoteApos(input){
		var str = input.value;
		if(str.indexOf("'",0) != -1 || str.indexOf("\"",0) != -1){
			alert("不可輸入 \" (雙引號) 或 ' (單引號)");
			input.focus();
			return;
		}
	}
/*******************************************************************************
 - 限制input輸入的長度
*******************************************************************************/
	function isMax(input,len){
		var inputLength = stringLength(input);
		if(len < inputLength){
			alert("最大的字串長度是" + len + "，你輸入的字數是" + inputLength);
			input.focus();
			return;
		}
	}
/*******************************************************************************
 - 判斷是否為一數字
*******************************************************************************/
	function isNumber(input) { 
		var id = input.value;
		if(id == ""){
			id = "0";
			return true;
		}
		if (isNaN(id)) {
			alert("請填入數字");
			input.focus();
			return false;
		}else{
			id = eval(id);
			if(id%1 == 0){
				if(id > 2147483647){
					alert("最大數字不可超過 2,147,483,647 !!");
					input.focus();
					return false;
				}else{
					return true;
				}
			}else{
				alert("請填入整數");
				input.focus();
				return false;
			}
		}
	}
/*******************************************************************************
 - 隱藏和顯現某一HTML原素
*******************************************************************************/
	function exp(strTag ,strAttribute){
		var elem = document.getElementsByTagName(strTag);
		for (var i =0;i<elem.length;i++){
			if(elem[i].getAttribute(strAttribute)=="yes"){
				elem[i].style.display=='none'? elem[i].style.display='block':elem[i].style.display='none';
			}
		}
	}
