var selectedList;
var availableList;
function delAttribute(){
    var selIndex = selectedList.selectedIndex;
    if(selIndex < 0)
        return;
    availableList.appendChild(selectedList.options.item(selIndex))
    selectNone(selectedList,availableList);
    setSize(availableList,selectedList);
}
function addAttribute(){	
	availableList = document.getElementById("availableOptions");
    selectedList = document.getElementById("City[]");
    var addIndex = availableList.selectedIndex;
	if (getSize(selectedList)>=5)
	{
		alert(" You can not select more than 5 city");
		return;
	}
    if(addIndex < 0)
        return;
    selectedList.appendChild(availableList.options.item(addIndex));
    selectNone(selectedList,availableList);
    setSize(selectedList,availableList)
	//selectCity(selectedList);
}
function selectCity(list)
{
	for (var i = 0; i < list.options.length; i++) {
			list.options[i].selected = true;
		}
}
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){
    /* Mozilla ignores whitespace, IE doesn't - count the elements in the list */
    var len = list.childNodes.length;
    var nsLen = 0;
    //nodeType returns 1 for elements
    for(i=0; i<len; i++){
        if(list.childNodes.item(i).nodeType==1)
            nsLen++;
    }
    if(nsLen<2)
        return 2;
    else
        return nsLen;
}

