var ignoredIds = new Array();
document.getElementById('hiddenId').value = "";

function showHelper(text,onOff){
   if(text.length == 0 && onOff == 1){
      $('helper').show();
      $('band_list').hide();
   }else {
      $('helper').hide();
   }
}
function updateHiddenli(li)
{
    //Run on add
    id = li.id.replace("f_","");
    var hiddenField =  document.getElementById('hiddenId');
    hiddenField.value = hiddenField.value + id + ', ';
    ignoredIds.push(id);
}
function removeSelected(id){
   //Run on remove
   var removeId = id.replace("ff_","");
   $(id).hide();
   $('hiddenId').value = $('hiddenId').value.gsub('' + removeId + ', ', '');
   ignoredIds = removeArrValue(ignoredIds,removeId);
}
function removeArrValue(arr,value){
  for(var i=0;i<arr.length;i++){
    if (arr[i]===value){
      arr.splice(i,1);
      return arr;
    }
  }
}
function modifyQuery(str){
   var returnStr = 'q=' + str.value + '&ignore=' + ignoredIds;
   return returnStr
}
function updateField(li){
   value = Element.collectTextNodesIgnoreClass(li, 'informal');
   var uniqueId = 'f' + li.id;
   $('bands_from_the_70s').value = '';
    new Insertion.Before($('main_field'), '<li id="'+uniqueId+'" class="bit-box" onmouseover="$(\''+uniqueId+'\').addClassName(\'bit-hover\')"  onmouseout="$(\''+uniqueId+'\').removeClassName(\'bit-hover\')">'+value+'<a class="closebutton" href="#" onclick="removeSelected(\''+uniqueId+'\');"></a></li>')
    $('bands_from_the_70s').focus();
    //Run on add
    updateHiddenli(li);
}
