function addAttribute() {
	var availableList = document.getElementById('ctl00_CP_AvailableListBox');
	var selectedList = document.getElementById('ctl00_CP_SelectedListBox');
	var addIndex = availableList.selectedIndex;
	var len = availableList.length - 1;
	for (i = len; i >= 0; i--) {
		if (availableList.options(i).selected) {
			selectedList.appendChild(availableList.options.item(i));
		}
	}
	SetSelectedHiddenId();
	selectNone(selectedList, availableList);
	setSize(selectedList, availableList);
}
function delAttribute() {
	var availableList = document.getElementById('ctl00_CP_AvailableListBox');
	var selectedList = document.getElementById('ctl00_CP_SelectedListBox');
	var selIndex = selectedList.selectedIndex;
	var len = selectedList.length - 1;
	for (i = len; i >= 0; i--) {
		if (selectedList.options(i).selected) {
			availableList.appendChild(selectedList.options.item(i))
		}
	}
	SetSelectedHiddenId();
	selectNone(selectedList, availableList);
	setSize(availableList, selectedList);
}
function SetSelectedHiddenId() {
	var availableList = document.getElementById('ctl00_CP_AvailableListBox');
	var selectedList = document.getElementById('ctl00_CP_SelectedListBox');
	var SelectedIDHiddenField = document.getElementById('ctl00_CP_SelectedIDHiddenField');
	SelectedIDHiddenField.value = '';
	for (i = selectedList.length - 1; i >= 0; i--) {
		if (SelectedIDHiddenField.value == '') {
			if (selectedList.length == 0) {
				SelectedIDHiddenField.value = '';
			}
			else {
				SelectedIDHiddenField.value = (selectedList.options.item(i).value) + '|' + (selectedList.options.item(i).text);
			}
		}
		else {
			if (selectedList.length == 0) {
				SelectedIDHiddenField.value = '';
			}
			else {
				SelectedIDHiddenField.value = SelectedIDHiddenField.value + ',' + (selectedList.options.item(i).value) + '|' + (selectedList.options.item(i).text);
			}
		}
	}
}

function selectNone(list1, list2) {
	list1.selectedIndex = -1;
	list2.selectedIndex = -1;
	addIndex = -1;
	selIndex = -1;
}
function setSize(list1, list2) {
	list1.size = getSize(list1);
	list2.size = getSize(list2);
}
function getSize(list) {        
	var len = list.childNodes.length;
	var nsLen = 0;          
	for (i = 0; i < len; i++) {
		if (list.childNodes.item(i).nodeType == 1)
			nsLen++;
	}
	if (nsLen < 2)
		return 2;
	else
		return nsLen;
} 