var LANGUAGE = 'CN';
function addOption(objSource,objTarget,intMaxCount)
{
	intMaxCount=(intMaxCount)?intMaxCount:3;
	//alert(objSource.selectedIndex);
	if(objSource.selectedIndex>=0)
	{
		if (objTarget.options.length >= intMaxCount)
		{
			alert((LANGUAGE=='EN')?'No more than '+intMaxCount+' items':'不能超过'+intMaxCount+'个!');
			return false;
		}
		for (var i=0;i<objTarget.options.length;i++)
		{
			if (objTarget.options[i].value == objSource.options[objSource.selectedIndex].value)
			{
				alert((LANGUAGE=='EN')?'Duplicated iter is not allowed':'您不能重复加入!');
				return false;
			}
		}

	   objTarget.options.add(new Option(objSource.options[objSource.selectedIndex].text,objSource.options[objSource.selectedIndex].value));
	}
}
function removeOption(objTarget)
{
	for (var i = objTarget.length - 1; i>=0; i--)
	{
		if (objTarget.options[i].selected)
		{
		  objTarget.remove(i);
		}
	}
}
function changeOption(objSource,objTarget)
{
	var str=objSource.options[objSource.selectedIndex].getAttribute("txt");
	if(str)
	{
		objTarget.options.length=0;
		str=str.replace(/(\[)/g,'')
		arr=str.split("]");
		for (var i=0;i<arr.length-1 ;i++ )
		{
			objTarget.options.add(new Option(arr[i].split(",")[1],arr[i].split(",")[0]));
		}
	}
	else
	{
		objTarget.options.length=0;
	}

}
function selectAllOption(objSource)
{
	for(var i=0;i<objSource.options.length;i++)
	{		
		objSource.options[i].selected=true;
	}
}
