var BIDArray=new Array();//大类ID
var BNameArray=new Array();//大类名字
var BTypeFlag=new Array();//是否有子类

function addBType(BID,BName,Flag){
//BID,大类ID    BName,大类名字    Flag,是否含子类
	BIDArray[BIDArray.length]=BID;
	BNameArray[BNameArray.length]=BName;
	BTypeFlag[BTypeFlag.length]=Flag;
}

var MIDArray=new Array();//中类ID
var MNameArray=new Array();//中类名字
var MBelongto=new Array();//中类属于哪个大类
var MTypeFlag=new Array();//中类是否有小类

function addMType(MID,MName,BID,Flag){
//MID,中类ID    MName,中类名字     BID,所属大类ID      Flag,是否含子类
	MIDArray[MIDArray.length]=MID;
	MNameArray[MNameArray.length]=MName;
	MBelongto[MBelongto.length]=BID;
	MTypeFlag[MTypeFlag.length]=Flag;
}

var SIDArray=new Array();//小类ID
var SNameArray=new Array();//小类名字
var SBelongto=new Array();//小类属于哪个中类

function addSType(SID,SName,MID){
//SID,小类ID    SName,小类名字    MID,所属中类
	SIDArray[SIDArray.length]=SID;
	SNameArray[SNameArray.length]=SName;
	SBelongto[SBelongto.length]=MID;
}

var PIDArray=new Array();//产品ID
var PNameArray=new Array();//产品名字
var _Belongto=new Array();//产品属于哪个类

function addPType(PID,PName,_ID){
//PID,产品ID    PName,产品名字    _ID,所属类id
	PIDArray[PIDArray.length]=PID;
	PNameArray[PNameArray.length]=PName;
	_Belongto[_Belongto.length]=_ID;
}

/**************************以下是两个LIST框移来移去的函数，稍有不同，因为第一项是标题，不要移************************/
function tAdd_onclick(objsou,objtar) {
	MoveList(objsou,objtar);
}

function tRemove_onclick(objsou,objtar) {
	MoveList(objtar,objsou);
}

function tAddAll_onclick(objsou,objtar) {
	MoveAll(objsou,objtar);
}
function tRemoveAll_onclick(objsou,objtar) {
	MoveAll(objtar,objsou);
}

function tsltSource_ondblclick(objsou,objtar) {
	MoveList(objsou,objtar);
}

function tsltTarget_ondblclick(objsou,objtar) {
	MoveList(objtar,objsou);
}

function MoveList(SourceList,TargetList){
	var oOption;
	if(SourceList.id=="sel_PType"){
		for (i=1;i<SourceList.options.length; i++){
			if(SourceList.options(i).selected){
				oOption = document.createElement("OPTION");
				oOption.text=SourceList.options(i).text;
				oOption.value=SourceList.options(i).value;
				
				TargetList.add(oOption,TargetList.length);
			}
		}
		for (i=SourceList.options.length-1;i>0; i--)
		if(SourceList.options(i).selected)
		SourceList.remove(i);
	}else{
		for (i=0;i<SourceList.options.length; i++){
			if(SourceList.options(i).selected){
				oOption = document.createElement("OPTION");
				oOption.text=SourceList.options(i).text;
				oOption.value=SourceList.options(i).value;
				
				TargetList.add(oOption,TargetList.length);
			}
		}
		for (i=SourceList.options.length-1;i>=0; i--)
		if(SourceList.options(i).selected)
		SourceList.remove(i);
	}
	if(SourceList.options.length==1 && SourceList.id=="sel_PType") SourceList.disabled=true;
	if(TargetList.options.length>1 && TargetList.id=="sel_PType") TargetList.disabled=false;
}

function MoveAll(SourceList,TargetList){
	var oOption;
	if(SourceList.id=="sel_PType"){
		for (i=1;i<SourceList.options.length; i++){
			oOption = document.createElement("OPTION");
			oOption.text=SourceList.options(i).text;
			oOption.value=SourceList.options(i).value;
			TargetList.add(oOption,TargetList.length);
		}
		for (i=SourceList.options.length-1;i>=1; i--)
		SourceList.remove(i);
		SourceList.disabled=true;
	}else{
		for (i=0;i<SourceList.options.length; i++){
			oOption = document.createElement("OPTION");
			oOption.text=SourceList.options(i).text;
			oOption.value=SourceList.options(i).value;
			TargetList.add(oOption,TargetList.length);
		}
		for (i=SourceList.options.length-1;i>=0; i--)
		SourceList.remove(i);
		TargetList.disabled=false;
	}
}
/******************************************************************************************/