
  function showSelects(){
    if(document.selector.which.value == 'styles'){
      document.getElementById('styles1').style.display = "inline";
      document.getElementById('styles2').style.display = "inline";
      document.getElementById('brands1').style.display = "none";
      document.getElementById('brands2').style.display = "none";
      document.getElementById('brands3').style.display = "none";
      document.getElementById('brands4').style.display = "none";
    }
    else{
      document.getElementById('styles1').style.display = "none";
      document.getElementById('styles2').style.display = "none";
      document.getElementById('brands1').style.display = "inline";
      document.getElementById('brands2').style.display = "inline";
      document.getElementById('brands3').style.display = "inline";
      document.getElementById('brands4').style.display = "inline";
    }
  }
  function setId(){
    if(document.selector.which.value == 'styles'){
      document.selector.id.value = document.selector.s_id.value;
    }
    else{
      document.selector.id.value = document.selector.b_id.value;
    }
  }
  function getBrandsCallback(ajax){
    var xml = ajax.responseXML.documentElement;
    var select = document.selector.b_id;
    select.options.length = 0;
    var brands = xml.getElementsByTagName('brand');
    for(i=0;i<brands.length;i++){
      var id = brands[i].childNodes[0].firstChild.nodeValue;
      var name = html_entity_decode(brands[i].childNodes[1].firstChild.nodeValue);
      var option = new Option(name,id);
      try{
      select.add(option,null);
      }
      catch(e){
       select.add(option,-1);
      }
    }
  }
  function getBrands(id){
    var ajax = new thajax();
    ajax.onError = function (){alert(this.ajax.responseText);}
    ajax.request("?_nox_&command=getBrandsAjax&id="+id, getBrandsCallback);
  }
  
  function showOne(cigarid){
    var dm = document.selector;
    dm.command.value = "showone";
    dm.cigar.value = cigarid;
    dm.submit();
  }
  
  function html_entity_decode(str) {
    var ta=document.createElement("textarea");
    ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
    return ta.value;
  }

