var selectedList;
var availableList;

//Creates selected objects and available objects
function createListObjects(){
  availableList = document.getElementById("availableOptions");
  selectedList = document.getElementById("selectedOptions");
}
//Deletes the selected values
function delAttribute(){
  var check_selected = 1;
  for (i = 0; i < selectedList.length; i++) {
    if (selectedList.options[i].selected) {
      availableList.appendChild(selectedList.options[i]);
      i-- ;
      check_selected = 0;
    }
  }
  if(check_selected) {
    alert("No item selected");
  }

  selectNone(selectedList, availableList);
}

//Adds the selected values
function addAttribute(){
  var check_selected = 1; 
  for (i = 0; i < availableList.length; i++) {
    if (availableList.options[i].selected) {
      selectedList.appendChild(availableList.options[i]);
      i-- ;
      check_selected = 0;
    }
  }
  if(check_selected) {
    alert("No Item selected");
  }

  selectNone(selectedList, availableList);
}

function setTop(top){
  document.getElementById
    ('someLayer').style.top = top;
}
function setLayerTop(lyr,top){
  lyr.style.top = top;
}

//Sets the index to -1
function selectNone(list1,list2){
  list1.selectedIndex = -1;
  list2.selectedIndex = -1;
  addIndex = -1;
  selIndex = -1;
}

//Deletes all selected values
function delAll(){
  var len = selectedList.length -1;
  var check_selected = 1;
  for(i=len; i>=0; i--){
    availableList.appendChild(selectedList.item(i));
    check_selected = 0;
  }
  if(check_selected) {
    alert("No Item available to remove.");
  }
  selectNone(selectedList,availableList);
}

// Sets the flag and adds all selected values
function addAll(){
  var len = availableList.length -1;
  var check_selected = 1;
  for(i=len; i>=0; i--){
    selectedList.appendChild(availableList.item(i));
    check_selected = 0;
  }
  if(check_selected) {
    alert("No Item available to add.");
  }
  selectNone(selectedList,availableList);
}


function CheckSelectedOption(cntrl_name,cntrl_msg) {

    oSelect = document.getElementById (cntrl_name);
    var iNumSelected = 0;
    for (var iCount=0; oSelect.options[iCount]; iCount++) {
            iNumSelected ++;
    }
    if (iNumSelected == 0) {
        Err=cntrl_msg+" should not be empty";
     alert(Err);
        return false;
    }

    return true;
}
// Check for selected locations
