function getCategory(form,CategoryOpt,SeriesPK,CategoryPK,ProdOpt){
	if(!CategoryPK){CategoryPK = 0;}
        if(SeriesPK == ''){
        	form.currentSeriesPK.value = 0;     //設定目前選擇的系列索引值
        	form.currentCategoryPK.value = 0;     //設定目前選擇的類別索引值
        	if(ProdOpt){form.currentProdPK.value = 0;}     //設定目前選擇的產品索引值
        	CategoryOpt.length = 0;
        	CategoryOpt.options[0] = new Option('-- No Preference --','');
        	if(ProdOpt){
                	ProdOpt.length = 0;
                	ProdOpt.options[0] = new Option('-- No Preference --','');
        	}  
        	return false;
        }
        form.currentSeriesPK.value = SeriesPK;

	var xml = makeCategoryXML(SeriesPK);

        var xh = new ActiveXObject("Microsoft.XMLHTTP");
        xh.open("POST","xh_getCategory.asp",false);
        xh.setRequestHeader("Content-Type","text/xml");
        xh.send(xml);

        var rxml = (xh.responseXML.xml);
        var xd = new ActiveXObject("Microsoft.XMLDOM");
        xd.async = false;
        var state = xd.readyState;
        xd.loadXML(rxml);

        var nodeCustomer;
        nodeCustomer = xd.selectSingleNode("//PK");
        var PK = (nodeCustomer.firstChild.nodeValue).split(',');
        nodeCustomer = xd.selectSingleNode("//Name");
        var Name = nodeCustomer.firstChild.nodeValue.split(',');

        if(PK[0] == 'Y'){
        	insCategoryOpt(form,CategoryOpt,PK,Name,CategoryPK);
        	if(ProdOpt){
                	ProdOpt.length = 0;
                	ProdOpt.options[0] = new Option('-- No Preference --','');
        	}
        }else{
                CategoryOpt.length = 0;
                CategoryOpt.options[0] = new Option('-- No Preference --','');
        }
        if(ProdOpt){form.currentProdPK.value = 0;}     //設定目前選擇的產品索引值
}
function makeCategoryXML(SeriesPK){
        var xml;
        xml = '<?xml version="1.0"?>';
        xml = xml + '<formlist>';
        xml = xml + '<formelement>';
        xml = xml + '<SeriesPK>'+ SeriesPK +'</SeriesPK>';
        xml = xml + '</formelement>';
        xml = xml + '</formlist>';
        return xml;
}
function insCategoryOpt(form,CategoryOpt,PK,Name,CategoryPK){
	CategoryOpt.length = 0;
	CategoryOpt.options[0] = new Option('-- No Preference --','');
	for(i=1;i<PK.length;i++){
        	CategoryOpt.options[i] = new Option(Name[i],PK[i]);
       		if(PK[i] == CategoryPK){
       			CategoryOpt.options[i].selected = true;
       			putCategoryPK(form,CategoryPK);
       		}
	}
}
function putCategoryPK(form,CategoryPK){
	form.currentCategoryPK.value = CategoryPK;
}
