function trim(theString){
	while(theString.substr(0,1)==" ")
		theString=theString.substr(1);

	while(theString.substr(theString.length-1,1)==" ")
		theString=theString.substr(0,theString.length-1);

	return theString;
}


function chkAll(theForm){

	var msg="";
	var j=0;
	var memnumregexp=/^[a-zA-Z]{1}\d{9}$/;
	var alpharegexp=/[a-zA-Z]+/;
	var intregexp=/\d+/;

	var catid=theForm.CategoryId.value;
	var expid=theForm.ExpertId.value;

	msg+=catid==""?(++j)+". 請選擇類別\n":"";
	//msg+=expid==""?(++j)+". 請選擇民物名稱\n":"";

	if(msg!=""){
		alert("請檢查以下項目\n\n"+msg);
		return false;
	}

}

function rptErr(theReq){
	alert("Error occured !");
	//document.write(theReq.responseText);
}


function getProductName(theCatID){
	var url="../include/asp/getProductName.asp";
	var pars="catid="+theCatID;
	var myAjax=new Ajax.Request(
			url, 
			{
				method: "post", 
				parameters: pars,
				onComplete: setDistrict,
				onFailure: rptErr
			});
}


function setDistrict(theReq){
	var objDist=$("_DISTRICT");
	var currDist=$F("CURR_Expert_ID");
	var dist=eval(theReq.responseText);
	objDist.length=0;
	for(i=0;i<dist.length;i++){
		objDist.options[i]=new Option(dist[i].text,dist[i].value);
		objDist.options[i].selected=currDist==dist[i].value;
	}
}


getProductName($F("CategoryId"))

