
function check4other(selObj){
  //state_or_province_other_text
  var name = selObj.id.replace(/^vendor_/,'')+'_other_span';
  if(selObj.value == 'Other'){Element.show(name);}
  else{Element.hide(name);}
}


function toggle_checkboxes(chkObj){
  if(chkObj.checked){Element.show(chkObj.value+'_options');var all = $(chkObj.value+'_all');all.checked = true;select_all(all);}
  else{Element.hide(chkObj.value+'_options');}
}

function select_all(chkObj){
 var name = 'vendor['+chkObj.id.split(/_/)[0]+'][]';
 var el = chkObj.form.elements;
 for(var i=0;i<el.length;i++){if(el[i].name == name){el[i].checked = false;}}
 var other = el['vendor['+chkObj.id.split(/_/)[0]+'_other]'];
 if(other != undefined){other.value = '';}
}

function select_some(chkObj){ // make sure the 'all' checkbox is clear
  $(chkObj.name.split(/\[|\]/)[1]+'_all').checked = false;
}

function select_other(txtObj){
  var other_chk = $(txtObj.id.replace(/_text$/,''));
  if(txtObj.value.length){
    other_chk.checked = true;
    select_some(other_chk);
  }else{
    other_chk.checked = false;
  }
  return true;
}

