function allcat(){
  if ($('allcats').visible()){
    $('allcats').hide();
    $('tnpath').show()
  } else {
    $('allcats').show();
    $('tnpath').hide()
  }
  $('tnmore').toggleClassName('tnsel');
}

function Highlight(el){
  new Effect.Highlight(el, {duration: 2});
  new Effect.Highlight('cartc', {duration: 2});
}

function addtocart($qtyel, $id, $enote, $eport){
  if ($enote != ''){
    $note = $($enote).value;
  } else {
    $note = '';
  }
  if ($eport != ''){
    $port = $($eport).value;
  } else {
    $port = '';
  }
  if ($($qtyel).value == '0' || $($qtyel).value == ''){
    new Ajax.Updater('cartc', 'rpc/cart.php', {
      parameters: { 'qty': $F($qtyel), 'pid': $id, 'note':$note, 'port':$port}
    });
  } else {
    new Ajax.Updater('cartc', 'rpc/cart.php', {
      parameters: { 'qty': $F($qtyel), 'pid': $id, 'note':$note, 'port':$port},
      onComlete: Highlight($qtyel)
    });
  }
}

function addtocart2(qtyel, id, mprid){
  new Ajax.Updater('cartc', 'rpc/cart.php', {
    parameters: { 'qty': $F(qtyel), 'pid': id},
    onComlete: Highlight($qtyel)
  });
}

function sudo($uid){
  document.location.href = '?suid='+$uid;
}

function tb(t, trg){
  t = $(t);
  ul = t.parentNode.parentNode;
  childs = $(ul.id).childElements()
  childs.each(function(item){
    item.removeClassName('ptsel');
  });
  t.parentNode.addClassName('ptsel');
  tp = t.parentNode.parentNode.parentNode.parentNode;
  childs = $(tp).childElements();
  childs.each(function(item){
    if (item.hasClassName('tcnt')){
      if (item.id == trg){
        item.show();
      } else {
        item.hide();
      }
    }
  });
}
function compare(form, cont1, cont2){
  frm = $(form);
  chb = frm.getInputs('checkbox');
  new Ajax.Updater(cont2, 'rpc/comp.php', {
    parameters: frm.serialize()
  });
  $(cont2).innerHtml = '';
  $(cont1).hide();
  $(cont2).show();
}

function cback(cont1, cont2){
  $(cont1).show();
  $(cont2).hide();
}
function newmsg(frm, divid, valid){
  new Ajax.Updater(divid, 'rpc/newmsg.php', {
    parameters: $(frm).serialize()+'&ajax=1'
  });
  return false;
}
function mph(id, mpid){
  val = parseInt($(id).value);
  mp = $(mpid);
  ch = mp.immediateDescendants();
  ch.reverse();
  set = false;
  ch.each(function (item){
      fch = item.firstChild;
      if ((fch) && (fch.value) && (fch.value > 0) && (fch.type == 'hidden')){
        var iv = parseInt(fch.value);
        if ((val >= iv) && (!set)){
          item.setStyle({'font-weight':'bold'});
          set = true;
        } else {
          item.setStyle({'font-weight':'normal'});
        }
      }
    }
  )
}
