﻿/*******************************************************************************************************************
* 函數名稱: replaceAll(str, key, keyReplace)											                           *	
* 功能說明: 取代全部						   									   					               *
* 傳入參數: : str:文字		  		                                           		   		                       *
*		      key:關鍵字                                                                                	       *
*             keyReplace:取代字                                                                                    *
* 範   例: replaceAll('testittegfe', "t", "a")			                                                           *								
* 傳 回 值: 全部取代後的值										                                                   *
* 更新日期: 2010/07/12	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function replaceAll(str, key, keyReplace)
{
    var index = 0;
    while (str.indexOf(key, index) != -1)
    {
        str = str.replace(key, keyReplace);
        index = str.indexOf(key, index);
    }
    return str;
}

/*******************************************************************************************************************
* 函數名稱: wordCount(str, key)											                                       	   *	
* 功能說明: 計算某關鍵字出現次數						   									   					   *
* 傳入參數: : str:文字		  		                                           		   		                       *
*		      key:關鍵字                                                                                	       *
* 範   例: wordCount("abcjdkajkdjskiisjajij","a")			                                                       *								
* 傳 回 值: 出現次數										                                                       *
* 更新日期: 2010/07/12	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function wordCount(str, key)
{
    return str.split(key).length - 1
}


/*******************************************************************************************************************
* 函數名稱: jsonArray(str)											                                       	       *	
* 功能說明: 把陣列資料物件化						   									   					       *
* 傳入參數: str: json字串格式                                                                                	   *
* 範   例: *jsonArray({index:1,title:商品目錄1標題1,que:1,memo:111},{index:1,title:商品目錄1標題2,que:2,memo:222},{index:3,title:商品目錄3標題1,que:5,memo:333},{index:3,title:商品目錄3標題2,que:3,memo:444})                                                         							   *								
* 傳 回 值: 陣列建立失敗回傳  false  成功回傳陣列										                           *
* 更新日期: 2010/04/12	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function jsonArray(str)
{
	if(str!="")
	{
		var returnArray = new Array();
		var strArray = str.split("},");
		for(i=0;i<strArray.length;i++)
		{
			var Obj = new Object();
			var arry = new Array();
			var stringTemp = strArray[i];
			if(i<(strArray.length-1))
			{
				stringTemp = stringTemp.substring(1);
			}
			else
			{
				stringTemp = stringTemp.substring(1);
				stringTemp = stringTemp.substring(0,(stringTemp.length-1));
			}
			
			var stringTemp2 = stringTemp.split(",");
			for(j=0;j<stringTemp2.length;j++)
			{
				stringTemp3 = stringTemp2[j];
				stringTemp4 = stringTemp3.split(":");
				arry[stringTemp4[0]] = stringTemp4[1];
			}
			Obj = arry;
			returnArray.push(Obj);
		}
		return 	returnArray;
	}
	else
	{
		return false;
	}
}

/********************************************************************************************************************
* 函數名稱: alertUI
* 前置作業: 需載入<script src="/js/jquery.blockUI.js" type="text/javascript" charset="utf-8"></script>				*																									*	
* 功能說明: 進階alert jquery視窗，使用後可自動結束alert，其他動作還是可以執行									*
* 傳入參數: instatus:顯示圖(1:成功 2:失敗 3:警告)預設為成功																				
*			val1:標題																								*
*			val2:內容																								*
*			timeout:幾秒後消失　預設：２０００秒																	*
*			bgcolorui:背景		預設：黑（#000）																	*
*			topui:距離上邊界　　預設：中																			*
*			leftui:距離左邊界　　預設：中																			*
* 使用方式: alertUI(1,"wewe","dfdf",5000,"#fff000",0,0)																*
* 更新日期: 2010/02/01	 																                       		*
* 更新人員: 林意文																	                            	*
********************************************************************************************************************/
function alertUI(instatus, va1, va2, timeout, bgcolorui, topui, leftui) {
    if (instatus == undefined || instatus == '') { instatus = 1 };
    if (instatus == 1) {
        statusimg = '/images/uiok.gif'
    } else if (instatus == 2) {
        statusimg = '/images/uierror.gif'
    } else if (instatus == 3) {
        statusimg = '/images/uialert.gif'
    }
    if (timeout == undefined || timeout == '') { timeout = 2000 };
    if (timeout == undefined || timeout == '') { timeout = 2000 };
    if (bgcolorui == undefined || bgcolorui == '') { bgcolorui = '#000' };
    if (topui == undefined || topui == '0' || topui == '') { topui = 200 };
    if (leftui == undefined || leftui == '') { leftui = 0 };
    $.growlUI(va1, va2);
    $.blockUI({
        message: $('div.growlUI'),
        fadeIn: 700,
        fadeOut: 700,
        showOverlay: false,
        centerY: false,
        css: {
            width: '350px',
            top: (($(window).height() - 500) / 2) + topui + 'px',
            left: ($(window).width() - 500) / 2 + leftui + 'px',
            border: 'none',
            padding: '5px',
            backgroundColor: bgcolorui,
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            opacity: .8,
            color: '#fff'
        }
    });
    setTimeout($.unblockUI, timeout);
    $("div.growlUI").css("background", "url(" + statusimg + ") no-repeat 10px 10px");
    $("div.growlUI h1, div.growlUI h2").css("color", "white").css("padding", "5px 5px 5px 75px").css("text-align", "left");
    $("h2").css("font-size", "12px");
}
function alertUIW(instatus, va1, va2, timeout, bgcolorui, topui, leftui,rwidth) {
    if (instatus == undefined || instatus == '') { instatus = 1 };
    if (instatus == 1) {
        statusimg = '/images/uiok.gif'
    } else if (instatus == 2) {
        statusimg = '/images/uierror.gif'
    } else if (instatus == 3) {
        statusimg = '/images/uialert.gif'
    }
    if (timeout == undefined || timeout == '') { timeout = 2000 };
    if (timeout == undefined || timeout == '') { timeout = 2000 };
    if (bgcolorui == undefined || bgcolorui == '') { bgcolorui = '#000' };
    if (topui == undefined || topui == '0' || topui == '') { topui = 200 };
    if (leftui == undefined || leftui == '') { leftui = 0 };
    $.growlUI(va1, va2);
    $.blockUI({
        message: $('div.growlUI'),
        fadeIn: 700,
        fadeOut: 700,
        showOverlay: false,
        centerY: false,
        css: {
            width: rwidth,
            top: (($(window).height() - 500) / 2) + topui + 'px',
            left: ($(window).width() - 500) / 2 + leftui + 'px',
            border: 'none',
            padding: '5px',
            backgroundColor: bgcolorui,
            '-webkit-border-radius': '10px',
            '-moz-border-radius': '10px',
            opacity: .8,
            color: '#fff'
        }
    });
    setTimeout($.unblockUI, timeout);
    $("div.growlUI").css("background", "url(" + statusimg + ") no-repeat 10px 10px");
    $("div.growlUI h1, div.growlUI h2").css("color", "white").css("padding", "5px 5px 5px 75px").css("text-align", "left");
    $("h2").css("font-size", "12px");
}
/*******************************************************************************************************************
* 函數名稱: checkBoxSet(sId,str)											                                       	   *	
* 功能說明: checkBox 值相同勾選起來						   									   						   *
* 傳入參數: : sId:checkBox清單控制項名稱		  		                                           		   			   *
*		   str:比對checkBox的值                                                                                	   *
* 範   例: checkBoxSet("awardCity","高雄")			                                                               *								
* 傳 回 值: 無										                                                               *
* 更新日期: 2010/02/11	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function checkBoxSet(sId,str)
{
	var i;
	var checkBox = document.getElementsByName(sId);
	var num = checkBox.length;
	for(i=0;i<num;i++)
	{
		
		if(checkBox[i].value==str)
		{
			checkBox[i].checked = true;	
		}
	}
	
}

/*******************************************************************************************************************
* 函數名稱: newCheckImage(sObj,swidth,sheight)																   		   *	
* 功能說明: 檢查圖片長寬是否符合標準						   													   *
* 傳入參數: sobj:File物件																						   *
*		   sheight:長																							   *
*		   swidth:寬																							   *
* 更新日期: 2010/01/12	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function newCheckImage(sObj,swidth,sheight)
{
	var w,h;
	var Browser = navigator.userAgent ;
	var msgErrors = function()
	{
		var sAlert = "此照片格式限定為:【寬"+swidth+"】【長"+sheight+"】\n";
		sAlert = sAlert + "你的照片格式為:【寬"+w+"】【長"+h+"】\n";
		sAlert = sAlert + "格式不符合，請重新選擇檔案";
		sObj.outerHTML = sObj.outerHTML;
		alert(sAlert);	
	}	
	if(Browser.indexOf("MSIE") > -1)
	{
		/*IE專用開始*/
		var re = /\.(jpg)$/i;
		sObj.select();      
		var imgSrc = document.selection.createRange().text;
		if (!re.test(imgSrc))
		{
			sObj.outerHTML = sObj.outerHTML;
			alert("只允許上傳JPG檔");
			return false;
		}
		var jsElementDiv = document.createElement('div');
		jsElementDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image)";
		jsElementDiv.style.width =  "1px";
		jsElementDiv.style.height = "1px";
		document.body.appendChild(jsElementDiv);
		jsElementDiv.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;	
		w = jsElementDiv.offsetWidth;
		h = jsElementDiv.offsetHeight;
		document.body.removeChild(jsElementDiv);
		if(parseInt(w)>parseInt(swidth)||parseInt(h)>parseInt(sheight))
		{
			msgErrors();
		}
		/*IE專用開始*/
	}
	else
	{
		/*fireFox專用開始*/ 
		var imgSrc =  sObj.files[0].getAsDataURL();
		if(imgSrc.indexOf('image/jpeg')==-1)
		{
			sObj.outerHTML = sObj.outerHTML;
			alert("只允許上傳JPG檔");
			return false;
		}	
		var img = new Image(); 
		img.onload = function()
		{
	       	w = img.width;
			h = img.height;
			if(parseInt(this.width)>parseInt(swidth)||parseInt(this.height)>parseInt(sheight))
			{
				firefoxOuterHTML();//firefox沒有OuterHTML 呼叫他後就可以正常使用
				msgErrors();		
			}
		}
		img.src = sObj.files[0].getAsDataURL(); 
		/*fireFox專用結束*/ 
	}
}

/********************************************************************************************************************
* 函數名稱: firefoxOuterHTML																							*	
* 功能說明: firefoxOuter沒有OuterHTML的東西，所以呼叫這個函數後就可以正常使用OuterHTML										*
* 更新日期: 2010/01/12	 																                       		*
* 更新人員: 蘇耀坤																	                            	*
********************************************************************************************************************/
function firefoxOuterHTML()
{
	if(typeof(HTMLElement)!="undefined" && !window.opera) 
	{ 
		HTMLElement.prototype.__defineGetter__("outerHTML",function() 
		{ 
			var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++) 
			if(a[i].specified) 
				str+=" "+a[i].name+'="'+a[i].value+'"'; 
			if(!this.canHaveChildren) 
				return str+" />"; 
			return str+">"+this.innerHTML+"</"+this.tagName+">"; 
		}); 
		HTMLElement.prototype.__defineSetter__("outerHTML",function(s) 
		{ 
			var r = this.ownerDocument.createRange(); 
			r.setStartBefore(this); 
			var df = r.createContextualFragment(s); 
			this.parentNode.replaceChild(df, this); 
			return s; 
		}); 
		HTMLElement.prototype.__defineGetter__("canHaveChildren",function() 
		{ 
			return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase()); 
		}); 
	}
}

/*******************************************************************************************************************
* 函數名稱: selectSet(sId,str)																				       *	
* 功能說明: 送出非同步連結取回回傳值														   					   		   *
* 傳入參數: sId:清單控制項名稱		  		                                           		   						   *
*		   str:設定值為預設的值																       				   *
* 範    例: selectSet('area','鳥松鄉')						   													   *
* 更新日期: 2010/01/11	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function selectSet(sId,str)
{
	var getid = document.getElementById(sId);
	for(i=0;i<getid.length;i++)
	{
		if(getid.options[i].value==str)	
		{
			getid.options[i].selected = "selected";	
			break;
		}
	}
}

/*******************************************************************************************************************
* 函數名稱: Xajax(url,mode,fun)																					   *	
* 功能說明: 送出非同步連結取回回傳值														   					   		   *
* 傳入參數: url:網址和參數 (不需要在escape 已經處理過了)		  		                                           		   *
*			mode:txt 傳回是文字 mode:xml 傳回是XML																       *
*			fun:指定回傳值要回到到哪個function																	       *
* 傳 回 值: AJAX接收的值 																                       	       *
* 範    例: Xajax('test.asp?act=123','txt','demo')這樣他會把回傳值傳到demo function的第一個參數上						   *
* 更新日期: 2010/01/08	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/

function Xajax(url,mode,fun)
{
	var len = url.indexOf("?",0);
	var postUrl;
	var postUrlAct;
	var temp;
	var notread ;
	if(len == -1) 
	{
		postUrl = url;	
		postUrlAct = "";
	}
	else//表示有參數
	{
		postUrl = url.substr(0,len);
		postUrlAct = url.substr((len+1));
		var postUrlActArray1 = postUrlAct.split("&");
		postUrlAct = "";
		for(i=0;i<postUrlActArray1.length;i++)
		{
			temp = postUrlActArray1[i];
			var postUrlActArray2 = temp.split("=");
			temp2 = "";
			if(i==postUrlActArray1.length-1)
				temp2="";
			else
			{
				temp2="&";
			}		
			postUrlAct = postUrlAct + postUrlActArray2[0] + "=" + escape(postUrlActArray2[1]) + temp2;
		}
	}
	if(postUrlAct=="")
		postUrl	= postUrl + "?" + "notread=" + new Date().getTime();
	else
	{
		postUrl	= postUrl + "?" + postUrlAct + "&notread=" + new Date().getTime();
	}	
	var xmlhttp = Ajax();
	xmlhttp.open("GET",postUrl,true);
	xmlhttp.send();
	xmlhttp.onreadystatechange = function()
	{
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			var memo = "";
			if(mode=="txt"){memo = xmlhttp.responseText;}
			if(mode=="xml"){memo = xmlhttp.responseXML;}
			eval(fun+'('+"'"+memo+"'"+')');				
		}
	}
}

/*******************************************************************************************************************
* 函數名稱: MoneyRCheck(startmoney,endmoney)											                               *	
* 功能說明: 檢查輸入金額是否正確					   												       			   *
* 傳入參數: startmoney:開始金額																					   *
*		   endmoney:結束金額																					       *
* 範   例:  MoneyRCheck(getid(money1),getid(money2))				       											   *								
* 傳 回 值: 如果開始金額小於結束金額:true  如果開始金額大於結束金額:false										           *
* 更新日期: 2010/01/07 																                               *
* 更新人員: 林意文																                                   *
********************************************************************************************************************/
function MoneyRCheck(startmoney,endmoney)
{
	var startmoney=parseFloat(startmoney);
	var endmoney=parseFloat(endmoney);
	if(startmoney!= "" && endmoney!="")
	{
		if( startmoney < endmoney)
		{
			return true;
		}
		else
		{
			return false;
		}
	}	
}
/********************************************************************************************************************
* 函數名稱: getid(sId)																								*	
* 功能說明: 取getElementById的值																		   				*
* 傳入參數: sId:控制項名稱																								*
*		   act:o 代表要回傳物件 act空白的話就回傳值																		*
* 傳 回 值: getElementById的值  																                		*
* 更新日期: 2010/01/07	 																                       		*
* 更新人員: 蘇耀坤																	                            	*
********************************************************************************************************************/
function getid(sId,act)
{
	if(act==undefined)
	{
		return document.getElementById(sId).value;//回傳值	
	}
	else
	{
		if(act=="o")
		return document.getElementById(sId);//回傳物件
	}	
	
}

/********************************************************************************************************************
* 函數名稱: alerts(sId,msg)																							*	
* 功能說明: 在指定控制項後面加上訊息																		   				*
* 傳入參數: sId:控制項名稱																								*
*		   msg:訊息																									*
* 更新日期: 2010/01/07	 																                       		*
* 更新人員: 蘇耀坤																	                            	*
********************************************************************************************************************/
function alerts(sId,msg)
{
	var offsetParent,x,y,xx,spaces,i;
	x=0;
	y=0;
	i=0;
	offsetParent = document.getElementById(sId);
	while(offsetParent!=null && offsetParent.tagName.toUpperCase()!="BODY")
	{
		x+=offsetParent.offsetLeft;
		y+=offsetParent.offsetTop;
		if(i==0)
		{
			xx = offsetParent.offsetWidth;
			i= i +1;
		}	
		offsetParent=offsetParent.offsetParent;
	}
	x = x + xx ;
	var jsElementSpan = document.createElement('span');
	jsElementSpan.style.position = "absolute";
	jsElementSpan.setAttribute("id",sId+"ShowSpan");
	jsElementSpan.setAttribute("name",sId+"ShowSpan");
	jsElementSpan.style.left = x + "px";
	jsElementSpan.style.top = y + "px";
	jsElementSpan.style.fontSize = "12px";
	jsElementSpan.style.color = "#ff6701";
	document.body.appendChild(jsElementSpan);
	document.getElementById(sId+"ShowSpan").innerHTML = "　"+msg;
}

/********************************************************************************************************************
* 函數名稱: checkCompanyIdText(str)																					*	
* 功能說明: 檢查是否為正確的公司統一編號																		   			*
* 傳入參數: str:統一編號	  		       																				*
* 傳 回 值: True:正確  OR 錯誤訊息 																                	*
* 更新日期: 2010/01/06	 																                       		*
* 更新人員: 蘇耀坤																	                            	*
********************************************************************************************************************/
function checkCompanyIdText(str)
{
	var alls;
	var ck = false;
	var num = new Array();
	var numArray = new Array("2","4","6","7");
	
	var msg ="不是正確的統一編號";
	if(str!="")
	{
		if(str.length!==8){return msg;}
		
		var re = new RegExp("[^0-9]+","i"); 
		var result = re.exec(str);		
		if (result != null){return msg;}
		
		for(i=1;i<=8;i++)
		{
			num[i] = Number(str.substr(i-1,1));	
			if(i==7&&num[i]==7){ck=true;}
		}	
		
		alls = num[1] + num[3] + num[5] + num[8];
		
		/*計算加權開始*/
		for(i=0;i<numArray.length;i++)
		{
			if(numArray[i]==7)
			{
				num[numArray[i]] = num[numArray[i]] * 4;
			}
			else
			{
				num[numArray[i]] = num[numArray[i]] * 2;
			}
			num[numArray[i]] = parseInt(num[numArray[i]]/10) + num[numArray[i]] % 10 ;
			
		}
		alls = alls + num[2] + num[4] + num[6] + num[7];
		/*計算加權結束*/
		if(alls%10==0)
		{
			return true;
		}
		else
		{
			if(ck)
			{
				alls = alls - num[7] + parseInt(num[7]/10)//重新計算加權數
				if(alls&10==0)
				{
					return true;
				}
				else
				{
					return msg;
				}
			}
			else
			{
				return msg;
			}
		} 
	}
	else
	{
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckNumb	Text																					       *	
* 功能說明: 檢查 所輸入之值是否為數值字串																		   		   *
* 傳入參數: 1.str:型態為 字串	；如str 為空白，則不做任何動作	  		       											   *
* 傳 回 值:   True  OR  錯誤訊息 																                       *
* 更新日期:   2010/01/06	 																                       	   *
* 更新人員:   蘇耀坤																	                               *
********************************************************************************************************************/
function CheckNumbText(str)
{
	var re = new RegExp("[^0-9]+","i"); 
	var result;
	result = re.exec(str);
	if (result != null)
	{ 
		return "不可輸入數字以外的資料";
	}
	else
	{
		return true;
	}
}

/********************************************************************************************************************
* 函數名稱: CheckStrText(str)																						    *	
* 功能說明: 檢查 所輸入之值是否為數值、英文字母及"/"															   			*
* 傳入參數: 1. str: 型態為 字串；如str 為空白，則不做任何動作	  		       												*
* 傳 回 值:   True  OR 錯誤訊息 																                       	*
* 更新日期:   2010/01/06	 																                       		*
* 更新人員:   蘇耀坤																	                           		*
********************************************************************************************************************/
function CheckStrText(str)
{
	var re = new RegExp("[^a-zA-Z0-9\/\]+","i"); 
	var result;
	result = re.exec(str);
	if (result != null)
	{ 
		return "不可輸入數字、英文字母以外的資料";
	}
	else
	{
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckTelText																						       *	
* 功能說明: 檢查 所輸入之電話號碼																	               	   *
* 傳入參數: 1. str: 型態為 字串；如str 為空白，則不做任何動作	  		       											   *
* 傳 回 值:   True  OR  錯誤訊息 																                   	   *
* 更新日期:   2010/01/05	 																                       	   *
* 更新人員:   蘇耀坤																	                           	   *
********************************************************************************************************************/
function CheckTelText(str)
{
	var re = new RegExp("[^0-9\-\#\+:]+","i"); 
	var result;
	result = re.exec(str);
	if (result != null)
	{ 
		return "含有不允許的符號";
	}
	else
	{
		return true;
	}
}

/********************************************************************************************************************
* 函數名稱: CheckEmailText																						    *	
* 功能說明: 檢查 email格式是否正確																		           		*
* 傳入參數: 1. str: 型態為 字串；如str 為空白，則不做任何動作	  		       												*
* 傳 回 值:   True or 錯誤訊息																						*
* 更新日期:   2010/01/05	 																                       		*
* 更新人員:   蘇耀坤																	                           		*
********************************************************************************************************************/
function CheckEmailText(str)
{
	var re = new RegExp("[\?\/\*\+\?\(\)\[!#$^&;',<>\}\{\"\~]+","i");
	var result;
	result = re.exec(str);
	if (str!='')
	{
		if (result != null)
		{ 
			return "你所輸入的E-Mail格式錯誤";
		}
		else if (str.indexOf("@")<=0)
		{
			return "你所輸入的E-Mail格式錯誤";
		} 
		else if (parseInt(str.length)  == parseInt(str.lastIndexOf("@")+1) )
		{
			return "你所輸入的E-Mail格式錯誤";
		}
		else if (str.indexOf("@") != str.lastIndexOf("@"))
		{
			return "你所輸入的E-Mail格式錯誤";
		}	
	}
	else if (str.indexOf(".",parseInt(str.indexOf("@"))) <= 0)
	{
		return "你所輸入的E-Mail格式錯誤";
	}
	else if (parseInt(str.length)  == parseInt(str.lastIndexOf(".")+1) )
	{
		return "你所輸入的E-Mail格式錯誤";
	}
	else
	{
		return true;
	}
	return true;
}

/*******************************************************************************************************************
* 函數名稱: checkBoxAll(obj,name)											                                           *	
* 功能說明: 可以讓同群組的checkBox全部勾選和取消選取						   											   *
* 傳入參數: obj:全選自己本身的物件                                                                                     *
*		   name:群組名稱	                                                                                           *
* 範   例: checkBoxAll(this,'ab')			                                                                       *								
* 傳 回 值: 無										                                                               *
* 更新日期: 2009/11/26	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function checkBoxAll(obj,name)
{
	var checkBox = document.getElementsByName(name);
	var num = checkBox.length;
	if(obj.checked==true)
	{
		for(i=0;i<num;i<i++)
		{
			checkBox[i].checked = "checked";
		}	
	}
	else
	{
		for(i=0;i<num;i<i++)
		{
			checkBox[i].checked = "";
		}
	}
}

/*******************************************************************************************************************
* 函數名稱: exFileName(src)											                                               *	
* 功能說明: 取出路徑的副檔名						   												                   *
* 傳入參數: src:路徑字串																							   *
* 範   例: exFileName("aaa.jpeg")			                                                                       *								
* 傳 回 值: 解析出來:副檔名  解析不出來:false										                                   *
* 更新日期: 2009/11/13	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function exFileName(src)
{
	if(src!="")
	{
		src = src.split(".");
		if(src.length>=2)
		{
			return src[src.length-1];	
		}
		else//沒有副檔名
		{
			return false;	
		}
	}
}

/*******************************************************************************************************************
* 函數名稱: fileSrc(obj)											                                                   *	
* 功能說明: 取出File物件的檔案路經						   												               *
* 傳入參數: obj:檔案物件																							   *
* 範   例: fileSrc(this)			                                                                                   *								
* 傳 回 值: 檔案真實完整路徑										                                                   *
* 更新日期: 2010/04/08	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function fileSrc(obj)
{
	var Browser = navigator.userAgent ;
	var imgSrc;
	if(Browser.indexOf("MSIE") > -1)
	{
		obj.select();      
    	imgSrc = document.selection.createRange().text;
	}
	else
	{
		if(obj.files[0]==undefined)
		{
			imgSrc = "";
		}
		else
		{
			imgSrc = obj.files[0].getAsDataURL();
		}	
	}
	return 	imgSrc;
}

/*******************************************************************************************************************
* 函數名稱: endDateCheck(startdate,enddate)											                               *	
* 功能說明: 檢查起始日期是不是大於結束日期						   												       *
* 傳入參數: startdate:起始日期																					       *
*		    enddate:結束日期																					       *
* 範   例:  bigdate(document.getElementById("start").value,document.getElementById("end").value)				       *								
* 傳 回 值: 如果起始日期大於結束日期:true  如果結束日期大於起始日期:false										           *
* 更新日期: 2009/11/10	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function endDateCheck(startdate,enddate)
{
	if(startdate != "" && enddate!="")
	{
		var start_date = new Date(startdate);
		var end_date = new Date(enddate);
		if( start_date > end_date)
		{
			return true;
		}
		else
		{
			return false;
		}
	}	
}

/*******************************************************************************************************************
* 函數名稱: trim(str)											                                                       *	
* 功能說明: 過濾前後空白						   													                   *
* 傳入參數: str:要過濾的字串																					       *
* 範   例: trim(' 測試 ')								                                                               *
* 更新日期: 2009/11/06	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function trim(str)
{
	if (str!="")
	{
		var strTrim = new String();
		strTrim = str ;
		strTrim = strTrim.replace(/(^\s*)/g, "");
		strTrim = strTrim.replace(/(\s*$)/g, "");
		return strTrim;
	}	
}

/*******************************************************************************************************************
* 函數名稱: div_view_image2(sObj,sValue,sheight,swidth)支援IE6 IE7 IE8											   *	
* 功能說明: 利用濾鏡預覽圖片						   													               *
* 傳入參數: sobj:Image物件(IDV)																					   *
*		    sobj2:Image物件																				           *
*			sheight:長																							   *
*			swidth:寬																							   *
* 範   例: div_view_image(document.getElementById('pic1'),this,200,400)									           *
* 更新日期: 2009/10/26	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function div_view_image2(sObj,sObj2,swidth,sheight)
{ 
	sObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
	sObj.style.width = swidth + "px";
	sObj.style.height = sheight + "px";
	sObj2.select();      
    	var imgSrc = document.selection.createRange().text;
	sObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;	
}

/*******************************************************************************************************************
* 函數名稱: divPicShow(obj,url,w,h)																                   *	
* 功能說明: 移動到小圖會動態產生大圖在右邊顯示						   												   *
* 傳入參數: obj:img物件																							   *
*		   url:	img圖片路徑																						   *
*		   w:大圖的寬																								   *
*		   h:大圖的高																						   		   *
*		   xx:大圖追加X軸																						   	   *
*		   yy:大圖追加Y軸																						   	   *
* 更新日期: 2009/10/16	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function divPicShow(obj,url,w,h,xx,yy)
{
	var url = url ;
	var offsetParent,x,y;
	offsetParent = obj;
	x=0;
	y=0;
	while(offsetParent!=null && offsetParent.tagName.toUpperCase()!="BODY") {
		x+=offsetParent.offsetLeft;
		y+=offsetParent.offsetTop;
		offsetParent=offsetParent.offsetParent;
		}
	var jsElementDiv = document.createElement("div");
	var jsElementImg = document.createElement("img");
	jsElementImg.src = url;
	jsElementImg.width = w;
	jsElementImg.height = h;
	jsElementDiv.setAttribute("id",obj.id+"A");
	jsElementDiv.setAttribute("name",obj.name+"A");
	jsElementDiv.style.width = w+"px";
	jsElementDiv.style.height = h+"px";
	jsElementDiv.style.position = "absolute";
	jsElementDiv.style.left = (x+xx)+"px";
	jsElementDiv.style.top = (y+yy)+"px";
	jsElementDiv.style.zIndex = "99";
	document.body.appendChild(jsElementDiv);
	document.getElementById(obj.id+"A").appendChild(jsElementImg);
	obj.onmouseout = function()
	{
		document.body.removeChild(jsElementDiv);
	};
}

/*******************************************************************************************************************
* 函數名稱: noEsc()																                                   *	
* 功能說明: 禁止按Esc						   													                       *
* 傳入參數: 無																						   			   *
* 更新日期: 2009/08/13	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function noEsc()
{
	document.onkeydown = function()
	{
		if(event.keyCode==27)
		{
			event.returnValue = false;  
		} 		
	}
}

/*******************************************************************************************************************
* 函數名稱: div_view_image(sObj,sObj2,swidth,sheight)支援IE6 IE7 IE8 Firefox									       *	
* 功能說明: 利用濾鏡預覽圖片						   													               *
* 傳入參數: sobj:Image物件(IDV)																					   *
*		    sobj2:file物件 或 圖片的位置																			   *
*			sheight:長																							   *
*			swidth:寬																							   *
* 範   例: div_view_image(document.getElementById('pic1'),this,200,400)									           *
* 更新日期: 2010/01/27	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function div_view_image(sObj,sObj2,swidth,sheight)
{
	var Browser = navigator.userAgent ;
	if(Browser.indexOf("MSIE") > -1)
	{
		/*IE專用開始*/
		sObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
		sObj.style.width = swidth + "px";
		sObj.style.height = sheight + "px";
		if(typeof(sObj2)=="object")
		{
			sObj2.select();      
    		var imgSrc = document.selection.createRange().text;
		}
		else
		{
			var imgSrc = sObj2;
		}
		sObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;	
		/*IE專用開始*/
	}
	else
	{
		/*fireFox專用開始*/ 
		var firefoxObj;
		var getName = sObj.name;
		var getId = sObj.id;
		sObj.style.width = swidth + "px";
		sObj.style.height = sheight + "px";
		firefoxObj = document.getElementById(getId + "TempImage");
		if(firefoxObj==null)
		{
			var jsElementImg = document.createElement('img');
			jsElementImg.style.width = swidth + "px";
			jsElementImg.style.height = sheight + "px";
			jsElementImg.id = getId + "TempImage";
			jsElementImg.name = getName + "TempImage";
			sObj.appendChild(jsElementImg);
			firefoxObj = document.getElementById(jsElementImg.id);	
		}
	
		if(typeof(sObj2)=="object")
		{
			firefoxObj.src = sObj2.files[0].getAsDataURL();    
		}
		else
		{
			firefoxObj.src = sObj2; 	
		}
		/*fireFox專用結束*/ 
	}	
}

/*******************************************************************************************************************
* 函數名稱: view_image(sObj,sValue)																                   *	
* 功能說明: 預覽圖片						   													                       *
* 傳入參數: sobj:Image物件																						   *
*		   sValue:File物件的value																				   *
* 範   例: view_image(document.getElementById('pc1'),this.value)													   *
* 更新日期: 2009/08/13	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function view_image(sObj,sValue)
{
	if(sValue!="")
	{
		try
		{
    		for(i=1;i<=20;i++){sValue = sValue.replace("\\","/");}
			sValue = "file://127.0.0.1/" + sValue.replace(":","$"); 
			sObj.src = sValue;
    	} 
		catch (e)
		{
			
		} 
	}
}

/*******************************************************************************************************************
* 函數名稱: checkImage(sObj,sheight,swidth,sfilesize)																   *	
* 功能說明: 檢查圖片長寬是否符合標準						   													           *
* 傳入參數: sobj:File物件																							   *
*		   sheight:長																							   *
*		   swidth:寬																								   *
*		   sfilesize:檔案大小(單位 bytes)		   																	   *
* 更新日期: 2009/08/13	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function checkImage(sObj,sheight,swidth,sfilesize)
{
	try{
		flag = true;
		sImage_temp = sObj.value;
		var re = /\.(jpg)$/i;
		if (re.test(sImage_temp))
		{
			if(flag)
			{
				for(i=1;i<=20;i++){sImage_temp = sImage_temp.replace("\\","/");}
				sImage_temp = "file://127.0.0.1/" + sImage_temp.replace(":","$"); 
				var img = new Image(); 
				img.onload = function(){
					if(parseInt(this.fileSize) > parseInt(sfilesize))
					{
						sAlert = "此照片檔案大小限制為:"+(parseInt(sfilesize/1024))+"K\n";
						sAlert = sAlert + "你的照片檔案大小為:"+(parseInt(this.fileSize/1024))+"K\n";
						sAlert = sAlert + "檔案大小不符合，請重新選擇檔案";
						sObj.outerHTML = sObj.outerHTML;
						alert(sAlert);
					}
					
					if(parseInt(this.width)>parseInt(swidth)||parseInt(this.height)>parseInt(sheight))
					{
						sAlert = "此照片格式限定為:【長"+sheight+"】【寬"+swidth+"】\n";
						sAlert = sAlert + "你的照片格式為:【長"+this.height+"】【寬"+this.width+"】\n";
						sAlert = sAlert + "格式不符合，請重新選擇檔案";
						sObj.outerHTML = sObj.outerHTML;
						alert(sAlert);
					}
					flag = false;
				}
			}
			img.src = sImage_temp;
		}
		else
		{
			sObj.outerHTML = sObj.outerHTML;
			alert("只允許上傳JPG檔");
		}	
	}
	catch (e)
	{	
	}
}

/*******************************************************************************************************************
* 函數名稱:image_size																						           *	
* 功能說明: 動態調整視窗為圖片大小						   													           *
* 傳入參數: sobj 為image物件	               									                                       *					
* 更新日期: 2009/07/31	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function image_size(sobj)
{
	moveTo(0,0);
	var img = new Image(); 
	img.onload = function(){
		resizeTo(this.width,(this.height+75));
	}	
	img.src = sobj.src;
}

/*******************************************************************************************************************
* 函數名稱: Check_space																						       *	
* 功能說明: 檢查文字欄位是否有輸入資料						   													   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；	               									   *
* 傳 回 值: ture 表示有輸入資料 false 表示沒有輸入資料		   													   *								
* 開發部門: 資訊部																	                               *
* 更新日期: 2009/06/13	 																                           *
* 更新人員: 蘇耀坤																                                   *
*																						                           *
*																						                           *
********************************************************************************************************************/
function Check_space(sTextObj)
{
	re = /^[ ]+|[ ]+$/g;//過濾半行空白
	re2 = /^[　]+|[　]+$/g;//過濾全行空白	
	var String_temp = sTextObj.value ;
	String_temp = String_temp.replace(re2, "");
	String_temp = String_temp.replace(re, "");
	if(String_temp=="")
	{
		return false;
	}
	else
	{
		return true ;
	}
}
/*******************************************************************************************************************
* 函數名稱: GetFormValue																						   *	
* 功能說明: 取出表單內所有欄位值(文字欄位、文字區域、核取方塊、選項按鈕、選單、隱藏欄位) 						   *
* 傳入參數: 1. Form 為 表單的名稱 ； 型態為 字串	                                                               *
* 傳 回 值: 表單內所有欄位值 例如: ?sLoadtype=C10AaAD&nNeli_used=1&nIspl_serno=2 or 沒有欄位值則傳回 false		   *								
* 開發部門: 資訊部																	                               *
* 更新日期: 2009/06/03	 																                           *
* 更新人員: 蘇耀坤																                                   *
*																						                           *
*																						                           *
********************************************************************************************************************/
function GetFormValue(Form)
{
	Form = document.all(Form) ;
	var str = "" ;
	for(var i = 0 ; i < Form.elements.length ; i++)
    {
    	var e = Form.elements[i];
		switch(e.type)
		{
			case "text" : if(e.value != ""){str = str + "&" + e.name + "=" + e.value ;};break;
			case "textarea" : if(e.value != ""){str = str + "&" + e.name + "=" + e.value ;};break;
			case "checkbox" : if(e.checked){str = str + "&" + e.name + "=" + e.value ;};break;
			case "radio" : if(e.checked){str = str + "&" + e.name + "=" + e.value ;};break;
			case "select-one" : if(e.value != ""){str = str + "&" + e.name + "=" + e.value ;};break;
			case "hidden" : if(e.value != ""){str = str + "&" + e.name + "=" + e.value ;};break;
		}
    }
	if(str!="")
	{
		return "?" + str.substring(1,str.length);
	}
	else
	{
		return false ;
	}
}

function img_ad(sObj,sImgurl,nIndex)
{
	var sImg_ad = sImgurl.split(",");
	var nMax = sImg_ad.length;
	var Browser = navigator.userAgent ;

	if(Browser.indexOf("MSIE") > -1)
	{
		if(nIndex>=nMax)
		{
			nIndex=0;
			document.getElementById(sObj).filters[0].Apply();
			document.getElementById(sObj).src = sImg_ad[nIndex];
			document.getElementById(sObj).filters[0].Play();
		}
		else
		{
			document.getElementById(sObj).filters[0].Apply();
			document.getElementById(sObj).src = sImg_ad[nIndex];
			document.getElementById(sObj).filters[0].Play();
			nIndex = nIndex+1;
		}	
	}
	else
	{
		if(nIndex>=nMax)
		{
			nIndex=0;
			document.getElementById(sObj).src = sImg_ad[nIndex];
		}
		else
		{
			
			document.getElementById(sObj).src = sImg_ad[nIndex];
			nIndex = nIndex+1;
		}
	}		
	sImgurl_temp = sImgurl;
	nIndex_temp = nIndex;
	sObj_temp = sObj;
	setTimeout("img_ad(sObj_temp,sImgurl_temp,nIndex_temp)",6000);
}

/*******************************************************************************************************************
* 函數名稱: CityAddress(sObj,sCity,sZip)																			   *	
* 功能說明: 城市區域連動選單 																	                       *
* 傳入參數: 1.sObj 為選單名稱物件 ； 型態為 物件                                                                        *
*          2.sCity 為城市名稱 ; 型態為 字串                                                                           *
*		   3.sZip Y:區域+區域號碼   N:區域不加區域號碼                                                                 *  
*		   範例:Mrt(表單.選單名稱,"高雄市","Y")                                                                       *
* 傳 回 值: 無									                                                                   *																
* 更新日期: 2009/06/11	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function CityAddress(sObj,sCity,sZip)
{
	var sValue_text = new Array();
	var sValue_zip = new Array();
	sCity_temp = ["台北市","基隆市","台北縣","宜蘭縣","新竹縣市","桃園縣","苗栗縣","台中市","台中縣","彰化縣","南投縣","嘉義縣市","雲林縣","台南市","台南縣","高雄市","高雄縣","澎湖縣","屏東縣","台東縣","花蓮縣","金門縣","連江縣"];
	/*台北市*/
	sValue_text[0] = ["中正區","大同區","中山區","松山區","大安區","萬華區","信義區","士林區","北投區","內湖區","南港區","文山區"];
	sValue_zip[0] = ["100","103","104","105","106","108","110","111","112","114","115","116"]; 
	/*基隆市*/  
	sValue_text[1] = ["仁愛區","信義區","中正區","中山區","安樂區","暖暖區","七堵區"];
	sValue_zip[1] = ["200","201","202","203","204","205","206"];
	/*台北縣*/  
	sValue_text[2] = ["萬里鄉","金山鄉","板橋市","汐止市","深坑鄉","石碇鄉","瑞芳鎮","平溪鄉","雙溪鄉","貢寮鄉","新店市","坪林鄉","烏來鄉","永和市","中和市","土城市","三峽鎮","樹林市","鶯歌鎮","三重市","新莊市","泰山鄉","林口鄉","蘆洲市","五股鄉","八里鄉","淡水鎮","三芝鄉","石門鄉"];
	sValue_zip[2] = ["207","208","220","221","222","223","224","226","227","228","231","232","233","235","236","237","238","239","241","242","243","244","247","248","248","249","251","252","253"];
	/*宜蘭縣*/
	sValue_text[3] = ["宜蘭市","頭城鎮","礁溪鄉","壯圍鄉","員山鄉","羅東鎮","三星鄉","大同鄉","五結鄉","冬山鄉","蘇澳鎮","南澳鄉"];
	sValue_zip[3] = ["260","261","262","263","264","265","266","267","268","269","270","272"];
	/*新竹縣市*/
	sValue_text[4] = ["新竹市","竹北市","湖口鄉","新豐鄉","新埔鎮","關西鎮","芎林鄉","寶山鄉","竹東鎮","五峰鄉","橫山鄉","尖石鄉","北埔鄉","峨眉鄉"];
	sValue_zip[4] = ["300","302","303","304","305","306","307","308","310","311","312","313","314","315"];
	/*桃園縣*/
	sValue_text[5] = ["中壢市","平鎮市","龍潭鄉","楊梅鎮","新屋鄉","觀音鄉","桃園市","龜山鄉","八德市","大溪鎮","復興鄉","大園鄉","蘆竹鄉"];
	sValue_zip[5] = ["320","324","325","326","327","328","330","333","334","335","336","337","338"];
	/*苗栗縣*/
	sValue_text[6] = ["竹南鎮","頭份鎮","三灣鄉","南庄鄉","獅潭鄉","後龍鎮","通霄鎮","苑裡鎮","苗栗市","造橋鄉","頭屋鄉","公館鄉","大湖鄉","泰安鄉","銅鑼鄉","三義鄉","西湖鄉","卓蘭鎮"] ;
	sValue_zip[6] = ["350","351","352","353","354","356","357","358","360","361","362","363","364","365","366","367","368","369"] ;
	/*台中市*/ 
	sValue_text[7] = ["中區","東區","南區","西區","北區","北屯區","西屯區","南屯區"];
	sValue_zip[7] = ["400","401","402","403","404","406","407","408"];
	/*台中縣*/
	sValue_text[8] = ["太平市","大里市","霧峰鄉","烏日鄉","豐原市","后里鄉","石岡鄉","東勢鎮","和平鄉","新社鄉","潭子鄉","大雅鄉","神岡鄉","大肚鄉","沙鹿鎮","龍井鄉","梧棲鎮","清水鎮","大甲鎮","外埔鄉","大安鄉"];
	sValue_zip[8] = ["411","412","413","414","420","421","422","423","424","426","427","428","429","432","433","434","435","436","437","438","439"];
	/*彰化縣*/ 
	sValue_text[9] = ["彰化市","芬園鄉","花壇鄉","秀水鄉","鹿港鎮","福興鄉","線西鄉","和美鎮","伸港鄉","員林鎮","社頭鄉","永靖鄉","埔心鄉","溪湖鎮","大村鄉","埔鹽鄉","田中鎮","北斗鎮","田尾鄉","埤頭鄉","溪州鄉","竹塘鄉","二林鎮","大城鄉","芳苑鄉","二水鄉"];
	sValue_zip[9] = ["500","502","503","504","505","506","507","508","509","510","511","512","513","514","515","516","520","521","522","523","524","525","526","527","528","530"];
	/*南投縣*/
	sValue_text[10] = ["南投市","中寮鄉","草屯鎮","國姓鄉","埔里鎮","仁愛鄉","名間鄉","集集鎮","水里鄉","魚池鄉","信義鄉","竹山鎮","鹿谷鄉"];
	sValue_zip[10] = ["540","541","542","544","545","546","551","552","553","555","556","557","558"];
	/*嘉義縣市*/
	sValue_text[11] = ["嘉義市","番路鄉","梅山鄉","竹崎鄉","阿里山","中埔鄉","大埔鄉","水上鄉","鹿草鄉","太保市","朴子市","東石鄉","六腳鄉","新港鄉","民雄鄉","大林鎮","溪口鄉","義竹鄉","布袋鎮"];
	sValue_zip[11] = ["600","602","603","604","605","606","607","608","611","612","613","614","615","616","621","622","623","624","625"];
	/*雲林縣*/
	sValue_text[12] = ["斗南鎮","大埤鄉","虎尾鎮","土庫鎮","褒忠鄉","東勢鄉","台西鄉","崙背鄉","麥寮鄉","斗六市","林內鄉","古坑鄉","莿桐鄉","西螺鎮","二崙鄉","北港鎮","水林鄉","口湖鄉","四湖鄉","元長鄉"];
	sValue_zip[12] = ["630","631","632","633","634","635","636","637","638","640","643","646","647","648","649","651","652","653","654","655"];
	/*台南市*/
	sValue_text[13] = ["中西區","東區","南區","北區","安平區","安南區"];
	sValue_zip[13] = ["700","701","702","704","708","709"];
	/*台南縣*/
	sValue_text[14] = ["永康市","歸仁鄉","新化鎮","左鎮鄉","玉井鄉","楠西鄉","南化鄉","仁德鄉","關廟鄉","龍崎鄉","官田鄉","麻豆鎮","佳里鎮","西港鄉","七股鄉","將軍鄉","學甲鎮","北門鄉","新營市","後壁鄉","白河鎮","東山鄉","六甲鄉","下營鄉","柳營鄉","鹽水鎮","善化鎮","大內鄉","山上鄉","新市鄉","安定鄉"];
	sValue_zip[14] = ["710","711","712","713","714","715","716","717","718","719","720","721","722","723","724","725","726","727","730","731","732","733","734","735","736","737","741","742","743","744","745"];
	/*高雄市*/
	sValue_text[15] = ["新興區","前金區","苓雅區","鹽埕區","鼓山區","旗津區","前鎮區","三民區","楠梓區","小港區","左營區"];
	sValue_zip[15] = ["800","801","802","803","804","805","806","807","811","812","813"];
	/*高雄縣*/
	sValue_text[16] = ["仁武鄉","大社鄉","岡山鎮","路竹鄉","阿蓮鄉","田寮鄉","燕巢鄉","橋頭鄉","梓官鄉","彌陀鄉","永安鄉","湖內鄉","鳳山市","大寮鄉","林園鄉","鳥松鄉","大樹鄉","旗山鎮","美濃鎮","六龜鄉","內門鄉","杉林鄉","甲仙鄉","桃源鄉","三民鄉","茂林鄉","茄萣鄉"];
	sValue_zip[16] = ["814","815","820","821","822","823","824","825","826","827","828","829","830","831","832","833","840","842","843","844","845","846","847","848","849","851","852"];
	/*澎湖縣*/
	sValue_text[17] = ["馬公市","西嶼鄉","望安鄉","七美鄉","白沙鄉","湖西鄉"];
	sValue_zip[17] = ["880","881","882","883","884","885"];
	/*屏東縣*/
	sValue_text[18] = ["屏東市","三地門","霧台鄉","瑪家鄉","九如鄉","里港鄉","高樹鄉","鹽埔鄉","長治鄉","麟洛鄉","竹田鄉","內埔鄉","萬丹鄉","潮州鎮","泰武鄉","來義鄉","萬巒鄉","崁頂鄉","新埤鄉","南州鄉","林邊鄉","東港鎮","琉球鄉","佳冬鄉","新園鄉","枋寮鄉","枋山鄉","春日鄉","獅子鄉","車城鄉","牡丹鄉","恆春鎮","滿州鄉"];
	sValue_zip[18] = ["900","901","902","903","904","905","906","907","908","909","911","912","913","920","921","922","923","924","925","926","927","928","929","931","932","940","941","942","943","944","945","946","947"];
	/*台東縣*/
	sValue_text[19] = ["台東市","綠島鄉","蘭嶼鄉","延平鄉","卑南鄉","鹿野鄉","關山鎮","海端鄉","池上鄉","東河鄉","成功鎮","長濱鄉","太麻里","金峰鄉","大武鄉","達仁鄉"];
	sValue_zip[19] = ["950","951","952","953","954","955","956","957","958","959","961","962","963","964","965","966"];
	/*花蓮縣*/
	sValue_text[20] = ["花蓮市","新城鄉","秀林鄉","吉安鄉","壽豐鄉","鳳林鎮","光復鄉","豐濱鄉","瑞穗鄉","萬榮鄉","玉里鎮","卓溪鄉","富里鄉"];
	sValue_zip[20] = ["970","971","972","973","974","975","976","977","978","979","981","982","983"];
	/*金門縣*/
	sValue_text[21] = ["金沙鎮","金湖鎮","金寧鄉","金城鎮","烈嶼鄉","烏坵鄉"];
	sValue_zip[21] = ["890","891","892","892","894","896"];
	/*連江縣*/
	sValue_text[22] = ["南竿鄉","北竿鄉","莒光鄉","東引鄉"];
	sValue_zip[22] = ["209","210","211","212"];
	sObj.options.length =0;//先清除控制項
	sObj.options[0] = new Option("請選擇","000000");
	for(i=0;i<sCity_temp.length;i++)
	{
		if(sCity_temp[i]==sCity)
		{
			for(j=0;j<sValue_text[i].length;j++)
			{
				if(sZip=="y"||sZip=="Y")
					sObj.options[j+1] = new Option(sValue_text[i][j],sValue_text[i][j]+sValue_zip[i][j]);
				else
					sObj.options[j+1] = new Option(sValue_text[i][j],sValue_text[i][j]);
			}	
		}
	}
}

/*******************************************************************************************************************
* 函數名稱: Mrt()																					                   *	
* 功能說明: 產捷運選單 																	                           *
* 傳入參數: 1.sObj 為選單名稱物件 ； 型態為 物件                                                                        *
*          2.sCity 為城市名稱 ; 型態為 字串                                                                           *  
*		   範例:Mrt(表單.選單名稱,"高雄市")                                                                           *
* 傳 回 值: 無									                                                                   *																
* 更新日期: 2009/06/11	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function Mrt(sObj,sCity,snull)
{
	//捷運資料設定檔
	sCity_temp = ["高雄縣","高雄市","台北縣","台北市"];
	//高雄縣
	var sValue_text = new Array();
	var sValue_value = new Array();
	sValue_text[0] = ["R3小港","R4高雄國際機場","R4A草衙","R5前鎮國中","R6凱旋","R21都會公園","R22青埔","R22A橋頭糖廠","R23橋頭火車站","R24南岡山","O10衛武營","O11鳳山西站","O12鳳山站","O13大東","O14鳳山國中","OT1大寮"];
	//高雄市
	sValue_text[1] = ["R3小港","R4高雄國際機場","R4A草衙","R5前鎮國中","R6凱旋","R7獅甲","R8三多商圈","R9中央公園","R10美麗島","R11高雄車站","R12後驛","R13凹子底","R14巨蛋","R15生態園區","R16左營","R17世運","R18油廠國小","R19楠梓加工區","R20後勁","R21都會公園","R22青埔","R22A橋頭糖廠","O1西子灣","O2鹽埕埔","O4市議會","O5美麗島","O6信義國小","O7文化中心","O8五塊厝","O9技擊館","O10衛武營"];
	//台北縣
	sValue_text[2] = ["淡水","紅樹林","竹圍","江子翠","新埔","板橋","府中","亞東醫院","海山","土城","永寧","頂溪","永安市場","景安","南勢角","大坪林","七張","新店市公所","新店"];
	//台北市
	sValue_text[3] = ["關渡","忠義","復興崗","新北投","北投","奇岩","唭哩岸","石牌","明德","芝山","士林","劍潭","圓山","民權西路","雙連","中山","台北車站","台大醫院","中正紀念堂","昆陽","後山碑","永春","國父紀念館","忠孝敦化","忠孝復興","忠孝新生","善導寺","台北車站","西門","龍山寺","中山國中","南京東路","忠孝復興","大安","科技大樓","六張犁","麟光","辛亥","萬芳醫院","萬芳社區","木柵","動物園","小南門","古亭","台電大樓","公館","萬隆","景美"];
	sValue_value[3] = ["(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(紅)","(藍)","(藍)","(藍)","(藍)","(藍)","(藍)","(藍)","(藍)","(藍)","(藍)","(藍)","(棕)","(棕)","(棕)","(棕)","(棕)","(棕)","(棕)","(棕)","(棕)","(棕)","(棕)","(棕)","(綠)","(綠)","(綠)","(綠)","(綠)","(綠)"];
	//捷運資料設定檔
	sObj.options.length =0;//先清除控制項
	if (snull=="y"||snull=="Y")
	sObj.options[0] = new Option("不限","");
	else
	sObj.options[0] = new Option("無","0");
	for(i=0;i<sCity_temp.length;i++)
	{
		if(sCity_temp[i]==sCity)
		{
			for(j=0;j<sValue_text[i].length;j++)
			{
				if(sCity_temp[i]=="台北市")
					sObj.options[j+1] = new Option(sValue_text[i][j],sValue_text[i][j]+sValue_value[i][j]);
				else
					sObj.options[j+1] = new Option(sValue_text[i][j],sValue_text[i][j]);
			}	
		}
	}
	sObj.options[0].selectedIndex=0;
}

/*******************************************************************************************************************
* 函數名稱: get_sorce																						       *	
* 功能說明: 動態載入Css或Js 																	                   *
* 傳入參數: 1. url 為 Css或Js路徑 ； 型態為 字串                                                                   *
*           2. sorce 為 要載入的類型 字串為 css 將動態載入 css ，字串為js 將動態載入 js                            *
			範例：get_sorce('Css.css','css') 表示載入                                                              *
* 傳 回 值: 無									                                                                   *																
* 更新日期: 2009/06/01	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function get_sorce(url,sorce)
{
	nCheck = false;
	var js_css = document.getElementsByTagName('head')[0];
	if(sorce=="css")
	{
		js_css_temp = document.createElement("link");
		js_css_temp.setAttribute("type","text/css");
		js_css_temp.setAttribute("rel","stylesheet");
		js_css_temp.setAttribute("href",url);
		nCheck = true;
	}
	if(sorce=="js")
	{
		js_css_temp = document.createElement("script");
		js_css_temp.setAttribute("type","text/javascript");
		js_css_temp.setAttribute("src",url);
		nCheck = true;
	}
	if(nCheck)
	{
		js_css.appendChild(js_css_temp);
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckBrowser																						   *	
* 功能說明: 檢查目前所使用的瀏覽器是什麼瀏覽器 																	   *
* 傳入參數: 無                                                                                                     *
* 傳 回 值: 1.Safari ==> Safari瀏覽器																			   *
*           2.Opera ==> Opera瀏覽器																			       *
*			3.Firefox ==> Firefox瀏覽器																			   *														
*			4.Netscape/Mozilla ==> Gecko瀏覽器																	   *
*			5.Inter Explorer ==> IE瀏覽器																		   *
*			6.Netscape ==> Mozilla瀏覽器																		   *
*			7.false ==>無法判別瀏覽器																			   *
* 更新日期: 2009/06/01	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function CheckBrowser()
{
	var Browser = navigator.userAgent ;
	if(Browser.indexOf("Safari") > -1) return "Safari";
	if(Browser.indexOf("Opera") > -1) return "Opera";
	if(Browser.indexOf("Firefox") > -1) return "Firefox";
	if(Browser.indexOf("Gecko") > -1) return "Netscape/Mozilla";
	if(Browser.indexOf("MSIE") > -1) return "Inter Explorer";
	if(Browser.indexOf("Mozilla") > -1) return "Netscape";
	return false;
}

/*******************************************************************************************************************
* 函數名稱: CheckIPv4																						       *	
* 功能說明: 檢查 所輸入之IP是否符合格式																	           *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																                               *
********************************************************************************************************************/

function CheckIPv4(sTextobj,sMsgTxt)
{
	var temp = sTextobj.value ;
	var result;
	var re = new RegExp("[^0-9\.]+","i");
	sck = /^[ ]+|[ ]+$/g;//過濾半行空白
	sck2 = /^[　]+|[　]+$/g;//過濾全行空白
	temp = temp.replace(sck2, "");
	temp = temp.replace(sck, "");
	if(temp!="")
	{
		var Ip_temp = temp.split(".");
		if((Ip_temp.length-1)!=3)
		{
			alert ("『" + sMsgTxt + "』 " + "輸入錯誤");
			sTextobj.value="";
			sTextobj.select();
			return false;
		}
		for(i=0;i<=3;i++)
		{
			if(Ip_temp[i]=="")
			{
				alert ("『" + sMsgTxt + "』 " + "輸入不完整");
				sTextobj.value="";
				sTextobj.select();
				return false;	
			}
			result = re.exec(Ip_temp[i]);
			if(result != null)
			{ 
				alert ("『" + sMsgTxt + "』 " + "不可輸入數字以外的資料");
				sTextobj.value="";
				sTextobj.select();
				return false;
			} 
			if(parseInt(Ip_temp[i]) > 255)
			{
				alert ("『" + sMsgTxt + "』 " + "每個值不得大於255");
				sTextobj.value="";
				sTextobj.select();
				return false;
			}
		}
	}
}


/*******************************************************************************************************************
* 函數名稱: CheckMac																					       	   *	
* 功能說明: 檢查 所輸入之Mac Address是否符合格式														           *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息	  			   *
*                                                                                                                  *
* 傳 回 值: True  OR  False 																                       *
* 更新日期: 2009/06/01	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/
function CheckMac(sTextobj,sMsgTxt)
{
	nCheck = true ;
	var temp = sTextobj.value ;
	if (temp != "")
	{
		temp = temp.toUpperCase();//轉換大寫
		if(temp.length==12)
		{
			for(i=0;i<temp.length;i++)
			{	
				sCheck = temp.charCodeAt(i);//使用charCodeAt判別編碼，來得知目前是輸入哪一個字元
				if((sCheck>=48&&sCheck<=57)||(sCheck>=65&&sCheck<=70))//因為Mac是16進位
				{
				}
				else
				{
					alert("『" + sMsgTxt + "』 "+ "第" + (i+1) +"碼輸入格式錯誤");	
					nCheck = false ;
					sTextobj.select();
					return false;
				}
			}
		}
		else
		{
			alert("『" + sMsgTxt + "』 "+ "請輸入錯誤");	
			nCheck = false ;
			sTextobj.select();
			return false;
		}
		if(nCheck==true)
		{
			sTextobj.value = temp;
			return true ;
		}
	}	
}

/*******************************************************************************************************************
* 函數名稱: Ajax																					       		   *	
* 功能說明: 建立AJAX的使用元件，可以使用AJAX任何屬性和方法														   *
* 傳入參數: 無		  		                                           											   *
* 傳 回 值: 回傳物件 																                       		   *
* 更新日期: 2009/06/01	 																                           *
* 更新人員: 蘇耀坤																                                   *
********************************************************************************************************************/

function Ajax()
{
	var XmlHttpArray = new Array(8);
	XmlHttpArray[0] = "MSXML2.XMLHTTP.6.0";
	XmlHttpArray[1] = "Msxml2.XMLHTTP.5.0";
	XmlHttpArray[2] = "Msxml2.XMLHTTP.4.0";
	XmlHttpArray[3] = "Msxml2.XMLHTTP.3.0";
	XmlHttpArray[4] = "Msxml2.XMLHTTP.2.6";
	XmlHttpArray[5] = "Msxml2.XMLHTTP.1.0";
	XmlHttpArray[6] = "Microsoft.XMLHTTP.1";
	XmlHttpArray[7] = "Microsoft.XMLHTTP";
	if (window.XMLHttpRequest)
	{ 
    	return new XMLHttpRequest();   
    } 
	else if (window.ActiveXObject)
	{
		for(i=0 ; i <= XmlHttpArray.length ; i++)
		{
			var ck = "true" ;
			try
			{
    			return new ActiveXObject(XmlHttpArray[i]);
    		} 
			catch (e)
			{
				ck = "false" ;
			} 
			if(ck=="true") //表示找到可以使用的物件
			{
				break;
			}
		}
    }
}

/*******************************************************************************************************************
* 函數名稱: CheckIP																						           *	
* 功能說明: 檢查 所輸入之IP是否符合格式																	           *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 開發部門:   資訊部																	                           *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																                               *
********************************************************************************************************************/

	function CheckIP(sTextobj,sMsgTxt){
		var sx = sTextobj.value ;
		var re = new RegExp("[^0-9\.]+","i");
		var check = 1;
		var result;

		if (sx != ""){
			result = re.exec(sx);
			if (result != null) { 
				alert ("『" + sMsgTxt + "』 " + "不可輸入數字以外的資料");
				sTextobj.value="";
				sTextobj.select();
				check = 0;
				return false;
			} 
			var ip = sx.split(".");
			if (ip.length != 4){
				alert ("『" + sMsgTxt + "』 " + "輸入錯誤");
				sTextobj.value="";
				sTextobj.select();
				check = 0;
				return false;
			}
			for (var i=0 ; i<4 ; i++){
				if (eval(ip[i]) > 255){
					alert ("『" + sMsgTxt + "』 " + "每個值不得大於255");
					sTextobj.value="";
					sTextobj.select();
					check = 0;
					return false;
				}
			}
		}
		if (check ==1){
			return true;
		}
	}

/*******************************************************************************************************************
* 函數名稱: CheckNumbChar																						   *	
* 功能說明: 檢查 所輸入之姓名是否輸入文字及數字以外之其它資料，如有，則將以訊息告知使用者並將游標移至此欄位		   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/

function CheckNumbChar(sTextObj,sMsgTxt){
	var sx = sTextObj.value ;
	var re = new RegExp("[\?\/\.\*\+\?\|\(\)\[@!#$%^&';:,<>\}\{\"\~`]+","i");
	var result;
	result = re.exec(sx);
	if (result != null) { 
		alert ("『" + sMsgTxt + "』 " +"不可輸入數字、中英文字母以外的資料");
		sTextObj.select();
		return false;
	} else {
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckStr																						       *	
* 功能說明: 檢查 所輸入之值是否為數值、英文字母及"/"															   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/

function CheckStr(sTextobj,sMsgTxt){
	var sx = sTextobj.value ;
	var re = new RegExp("[^a-zA-Z0-9\/\]+","i"); 
	var result;
	result = re.exec(sx);
	if (result != null) { 
		alert ("『" + sMsgTxt + "』 " + "不可輸入數字、英文字母以外的資料");
//		sTextobj.value="";
		sTextobj.select();
		return false;
	} else {
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckNumE																						       *	
* 功能說明: 檢查 所輸入之值是否為數值字串																		   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/

function CheckNumE(sTextobj,sMsgTxt){
	var sx = sTextobj.value ;
	var re = new RegExp("[^a-zA-Z0-9]+","i"); 
	var result;
	result = re.exec(sx);
	if (result != null) { 
		alert ("『" + sMsgTxt + "』 " + "不可輸入數字、英文字母以外的資料");
		sTextobj.value="";
		sTextobj.select();
		return false;
	} else {
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckNumEMax																						   *	
* 功能說明: 檢查 所輸入之值是否為大寫英文字母																	   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/

function CheckNumEMax(sTextobj,sMsgTxt){
	var sx = sTextobj.value ;
	var re = new RegExp("[^A-Z]+","i"); 
	var result;
	result = re.exec(sx);
	if (result != null) { 
		alert ("『" + sMsgTxt + "』 " + "不可輸入英文字母大寫以外的資料");
		sTextobj.value="";
		sTextobj.select();
		return false;
	} else {
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckNumb																						       *	
* 功能說明: 檢查 所輸入之值是否為數值字串																		   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/

function CheckNumb(sTextobj,sMsgTxt){
	var sx = sTextobj.value ;
	var re = new RegExp("[^0-9]+","i"); 
	var result;
	result = re.exec(sx);
	if (result != null) { 
		alert ("『" + sMsgTxt + "』 " + "不可輸入數字以外的資料");
		sTextobj.value="";
		sTextobj.select();
		return false;
	} else {
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckTel																						       *	
* 功能說明: 檢查 所輸入之電話號碼																	               *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
*			2. sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *   
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/

function CheckTel(sTextobj,sMsgTxt){
	var sx = sTextobj.value ;
	var re = new RegExp("[^0-9\-\#\+:]+","i"); 
	var result;
	result = re.exec(sx);
	if (result != null) { 
		alert ('『' + sMsgTxt + '』' + '含有不允許的符號');
		sTextobj.value="";
		sTextobj.select();
		return false;
	} else {
		return true;
	}
}


/*******************************************************************************************************************
* 函數名稱: CheckTime																						       *	
* 功能說明: 檢查 輸入之時間是否正確																	               *
* 傳入參數: 1. sObj 為 TEXT 元件 的名稱 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		           *
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/
function CheckTime(sObj){
	if (sObj.value!="")
	 {
		var vStr = sObj.value;
		if(isNaN(vStr.substring(0,2))){
			alert("開始時間的前兩碼要輸入數值型態");
			sObj.focus();
			return false ;
		}
		if(vStr.substring(2,3) !=":"){
			alert("開始時間的中間要輸入':'");
			sObj.focus();
			return false ;
		}
		if(vStr.substring(2,3) =="："){
			alert("『:』需要輸入半型");
			sObj.focus();
			return false ;
		}

		if(vStr.substring(3)==""){
			alert("請輸入開始時間的後兩碼");
			sObj.focus();
			return false ;
		}
		else
		{
			if(vStr.substring(4)==""){
				alert("請輸入開始時間的後一碼");
				sObj.focus();
				return false ;
			}
			if(isNaN(vStr.substring(3))){
				alert("開始時間的後兩碼要輸入數值型態");
				sObj.focus();
				return false ;
			}
		}
	 }		
}

/*******************************************************************************************************************
* 函數名稱: CheckTextNum																					       *	
* 功能說明: 檢查 金額欄是否為空白時，如是則傳回０，否，則不變													   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 														  		       *   
* 傳 回 值:   0 																                                   *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/
function CheckTextNum(sTextobj){
	if (sTextobj.value =="")
	{
		sTextobj.value = "0";
		return true;
	}
}

/*******************************************************************************************************************
* 函數名稱: CheckTextZero																					       *	
* 功能說明: 檢查 欄位是否為空白or零時																			   *
* 傳入參數: 1. sTextObj 為 TEXT 元件 的名稱 														  		       *   
* 傳 回 值:   True  OR  False																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/
function CheckTextZero(sTextobj,sMsgTxt){
	var sx = sTextobj.value ;
	
	if (sx == "" || sx == "0")
	{
		alert ("『" + sMsgTxt + "』 " + "不可輸入空白或者是零");
		sTextobj.value="";
		sTextobj.select();
		return false;
	} else {
		return true;
	}
}


/*******************************************************************************************************************
* 函數名稱: MM_openBrWindow																						　 *	
* 功能說明: 開始新視窗 																							   *
* 傳入參數:																							  		       *
* 傳 回 值:					 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}

/*******************************************************************************************************************
* 函數名稱: CheckID																						           *	
* 功能說明: 檢查 所輸入之身份證字號是否正確																		   *
* 傳入參數: 1. sId 為 text 欄位值			； 型態為 字串	；如sTextName 為空白，則不做任何動作	  		       *
* 傳 回 值:   True  OR  False 																                       *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/

function CheckID(sId) {
  var sIdLoad = ''+ sId.value.toUpperCase()
  
  if (sIdLoad !="") {
	  if (sIdLoad.length != 10)
		{
			alert('身分證號碼錯誤!\r\n字數不足!')
			//sId.select();
			return false;
		}
	
	  //建立一個 ID_Input 陣列
	  var ID_Input    = new Array(10)
	  //將 sIdLoad 字串一個字元接著一個字元放入 ID_Input 陣列內
	  for (var i=0; i<10; i++) { ID_Input[i] = sIdLoad.charAt(i) }
	  //====以下測試 ID_Input[0] 是否為英文字母===
	  var EngString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	  ID_Input[0]   = EngString.indexOf(ID_Input[0])
	  if (ID_Input[0] == -1)
		{
			alert('身分證號碼錯誤!\r\n無開頭的字母!')
			//sId.select();
			return false;
		}
	  if (ID_Input[1] !=1 && ID_Input[1] !=2)
		{
			alert('身分證號碼錯誤!\r\n無法辨識性別!')
			//sId.select();
			return false;
		}
		  var NumArray  = new Array(26)
		  NumArray[0]   = 1 ; NumArray[1]  = 10; NumArray[2]  = 19;
		  NumArray[3]   = 28; NumArray[4]  = 37; NumArray[5]  = 46;
		  NumArray[6]   = 55; NumArray[7]  = 64; NumArray[8]  = 39;
		  NumArray[9]   = 73; NumArray[10] = 82; NumArray[11] = 2 ;
		  NumArray[12]  = 11; NumArray[13] = 20; NumArray[14] = 48;
		  NumArray[15]  = 29; NumArray[16] = 38; NumArray[17] = 47;
		  NumArray[18]  = 56; NumArray[19] = 65; NumArray[20] = 74;
		  NumArray[21]  = 83; NumArray[22] = 21; NumArray[23] = 3 ;
		  NumArray[24]  = 12; NumArray[25] = 30;

	  var result = NumArray[ID_Input[0]]
	  for (var i=1; i<10; i++)
		{
		var NumString = '0123456789'
		ID_Input[i] = NumString.indexOf(ID_Input[i])
		if (ID_Input[i] == -1)
		  {
			  alert('身分證號碼錯誤!\r\n數字檢查錯誤!')
			  //sId.select();
			  return false;
		  }
		else
		  { result += ID_Input[i] * (9-i) }
		}
	
	  result += 1 * ID_Input[9]
	  if (result % 10 != 0)
		{
			alert('身分證號碼錯誤!\r\n加總檢查錯誤!')
			//sId.select();
			return false;
		}
	  return true;
 	} 
 }

/*******************************************************************************************************************
* 函數名稱: CheckEmail																						       *	
* 功能說明: 檢查 email格式是否正確																		           *
* 傳入參數: 1. sTextObj 為 text 欄位值； 型態為 字串	；如sTextName 為空白，則不做任何動作	  				   *
* 傳 回 值:   True or False																						   *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/

function CheckEmail(sTextObj){
	var x =	sTextObj.value ;
	var re = new RegExp("[\?\/\*\+\?\(\)\[!#$^&;',<>\}\{\"\~]+","i");
	var result;

	result = re.exec(x);

if (sTextObj.value!='') {
	
	if (result != null) { 

		alert ("你所輸入的E-Mail格式錯誤");

		sTextObj.select();

		return false;

	} else if (sTextObj.value.indexOf("@")<=0) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
		
	} else if (parseInt(sTextObj.value.length)  == parseInt(sTextObj.value.lastIndexOf("@")+1) ) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
		
	} else if (sTextObj.value.indexOf("@") != sTextObj.value.lastIndexOf("@")) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else if (sTextObj.value.indexOf(".",parseInt(sTextObj.value.indexOf("@"))) <= 0) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else if (parseInt(sTextObj.value.length)  == parseInt(sTextObj.value.lastIndexOf(".")+1) ) {
		alert ("你所輸入的E-Mail格式錯誤");
		sTextObj.select();

		return false;
	} else {
	
		return true;
	}

		return true;
  }
	
}
/*******************************************************************************************************************
* 函數名稱: CheckDate																						       *	
* 功能說明: 檢查 日期格式是否正常																		           *
* 傳入參數: 1. oObjName 為 text 名稱		 ； 型態為 字串	；如sTextName 為空白，則不做任何動作	  			   *
*			2.	sMsgTxt 為 TEXT 欄位名稱     ； 型態為 字串	；如有錯誤，則將此變數之內容帶入訊息				   *																			
* 傳 回 值:   True or False																						   *
* 更新日期:   2009/06/01	 																                       *
* 更新人員:   蘇耀坤																	                           *
********************************************************************************************************************/
function CheckDate(oObjName,sMsgText){
	var lIs_ok;
	lIs_ok = true;   
	
	if (oObjName.value != "") { 
		
		sArry_date = oObjName.value.split("/") ;
		
		if (lIs_ok == true && sArry_date.length != 3) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』格式不正確");		
		} else {		
			sTemp_year = sArry_date[0] ;
			sTemp_month = sArry_date[1] ;
			sTemp_day = sArry_date[2] ;
		}
		
		//檢查是否輸入非數字的資料或數字格式不正確
		if (lIs_ok == true && (isNaN(sTemp_year) == true || sTemp_year.length != 4 || sTemp_year.indexOf(".",0) != -1 ) ) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』，年份格式不正確");		
		}
		
		
		if (lIs_ok == true && (isNaN(sTemp_month) == true || sTemp_month.indexOf(".",0) != -1 || (parseFloat(sTemp_month) < 1 || parseFloat(sTemp_month) > 12) ) ) { 
			lIs_ok = false ;
			alert("對不起，你所輸入的『" + sMsgText + "』，月份格式不正確");		
		}	
		
		if (lIs_ok == true) {
			
			switch (parseFloat(sTemp_month)) {
				
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12 :
					
					//alert(parseFloat(sTemp_day));
					if (lIs_ok == true && (isNaN(sTemp_day) == true || sTemp_day.indexOf(".",0) != -1 || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 31) ) ) { 
						lIs_ok = false ;
						alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
					}
					
					break;
				
				case 4:
				case 6:
				case 9:
				case 11 :
					if (lIs_ok == true && (isNaN(sTemp_day) == true || sTemp_day.indexOf(".",0) != -1 || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 30) ) ) { 
						lIs_ok = false ;
						alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
					}
					
					break;
				
				case 2 :
					
					if (parseFloat(sTemp_year) % 4 == 0 && parseFloat(sTemp_year) % 100 != 0 || parseFloat(sTemp_year) % 400 == 0) {
						
						if (lIs_ok == true && (isNaN(sTemp_day) == true || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 29) ) ) { 
							lIs_ok = false ;
							alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
						}
						
						break;
						
					} else {
						
						if (lIs_ok == true && (isNaN(sTemp_day) == true || (parseFloat(sTemp_day) < 1 || parseFloat(sTemp_day) > 28) ) ) { 
							lIs_ok = false ;
							alert("對不起，你所輸入的『" + sMsgText + "』，天數格式不正確");		
						}
						
						break;
					
					}
			}
		}		
	}

	if (lIs_ok == true) { 
		if (oObjName.value!= "") {
			if (sTemp_month.length<2)
			{
				sTemp_month = "0" + sTemp_month;
			}
			if (sTemp_day.length <2)
			{
				sTemp_day = "0" + sTemp_day;
			}

			oObjName.value=sTemp_year + "/" + sTemp_month + "/" + sTemp_day;
			return true;
		}
	} else {
		oObjName.value = "";
		oObjName.focus();
		return false;
	}	
}

/*******************************************************************************************************************
* 函數名稱: setType 																						       *
* 功能說明: 租售房屋"用途"選單  																		           *
* 傳入參數: 1. sobj 為 為選單名稱物件 ； 型態為 物件                                            	  			   *
*			2.	sMsgTxt 為 租或售     ； 型態為 字串(售:"sale" or 租:"rent")		                    		   *
* 傳 回 值:   無																		        				   *
* 更新日期:   2009/07/10	 																                       *
* 更新人員:   黃承璿																	                           *
********************************************************************************************************************/
function setType(sobj,stype) {
    var saletypes=new Array();
    var renttypes=new Array();
    saletypes[0]=["A", "K", "B", "C", "D", "E", "F", "G", "H", "I", "O"];
    saletypes[1]=["住家(公寓 . 大樓)", "住家(獨棟 . 透天)", "店面(公寓 . 大樓)", "店面(獨棟 . 透天)", "別墅(無店面)", "套房", "農地", "土地.廠房", "辦公大樓", "停車位", "其他"];
    renttypes[0]=["A", "K","B", "C", "D", "E", "F", "G", "H", "I", "O"];
    renttypes[1]=["住家(公寓.大樓)", "住家(獨棟 . 透天)", "店面(公寓.大樓)", "店面(獨棟.透天)", "別墅(無店面)", "套房(大樓獨立門戶)", "雅房(分租)", "土地.農地.廠房", "辦公大樓", "停車位", "其他"];
	sobj.options.length =0;//先清除控制項
	sobj.options[0] = new Option("不限","");
    if (stype=="sale") {
	    for(i=0;i<saletypes[0].length;i++)
	    { sobj.options[i+1] = new Option(saletypes[1][i],saletypes[0][i]); }
    }else{
	    for(i=0;i<renttypes[0].length;i++)
	    { sobj.options[i+1] = new Option(renttypes[1][i],renttypes[0][i]); }
    }
}