Selecteddef = false;                    

function SetValue(value,Name,col){
         AddToListV(value,Name,col);
}

//添加到非列表框
function SetText(value,col){
        col.value=value;
}

//添加一个属性到列表框
function AddToList(colOption,col){
        if(multi == '1'){
			var len = col.length;
			col.options[len] = colOption;
			if(Selecteddef == true){
				col.options[len].selected = true;
			}
		}else{
			MinusAllList(col);
			col.options[0] = colOption;
			if(Selecteddef == true){
				col.options[0].selected = true;
			}
		}
}

//添加一个键值对到列表框
function AddToListV(value,name,col){
		if(multi == '1'){
			for(var i=0;i<col.length;i++){
					if(col.options[i].value == value){
							alert("已经添加过了");
							return false;
					}
			}
		}
        var colOption = new Option(name,value);
        AddToList(colOption,col);
}

//从列表中删除值为 value的选想
function MinusFromListV(value,col){
        for(var i=0;i<col.length;i++){
                if(col.options[i].value == value)
                       col.options[i] = null;
        }
		if(col.length > 0){
			 col.options[0].selected = true;
		 }
}

//删除列表况钟已经选中的值
function MinusFromList(col){
         if(col.selectedIndex>=0){
                  col.options[col.selectedIndex] = null;
         }
		 if(col.length > 0){
			 col.options[0].selected = true;
		 }
}

function MinusAllList(col){
         if(col.length>=1){
             for(var i=col.length-1;i>=0;i--){
                 col.options[0] = null;
             }
         }
}

function SelectListAll(col,winSelectClose){
         var liststr = '';
		 if(col.length < 1 ){
			 alert("对不起，您并没有选择列表数据");
			 return false;
		 }
		 if(col.length == 1 && col.options[0].value == null){
			 col.options[0].value = '';
		 }
         for(var i=col.length-1;i>=0;i--){
             liststr += col.options[i].value+':';
         }
         AddToListV(liststr,'All',col);
         col.options[col.length-1].selected = true;
         if(winSelectClose){
            //CloseSelectWin();
         }
}
//这三个function是专门为省份，景区列表实现作的。
multi = '1';
//刷新景点列表
function re_flush(upcol,distcol){
	MinusAllList(distcol);
	AddToListV(" ","请选择景区",distcol);
	for(var i=0;i<district.length;i++){
		if(district[i][2] == upcol.value){
			AddToListV(district[i][0],district[i][1],distcol);
		}
	}
	distcol.options[0].selected = true;
}
//复制到目的列表
function copy_option(src,dest) {
	for(var i=0;i<src.length;i++){
		if(src.options[i].selected == true){
			AddToListV(src.options[i].value,src.options[i].text,dest);
		}
	}
}
//初始化省份列表
function init_pro(dest){
	MinusAllList(dest);
	AddToListV("--","请选择省份",dest);
	if (province != null)
	{
		for (var i=0;i<province.length;i++ )
		{
			AddToListV(province[i][1],province[i][2],dest);
		}
	}
	//dest.options[dest.length-1].selected = true;
	return;
}
//设定目标列表值
function set_var(dist,val){
	for (var i=0;i<dist.length ;i++ )
	{
		if (dist.options[i].value == val)
		{
			dist.options[i].selected = true;
		}
	}
}