var TOs = new Array();

function lsl(sname)
{
 var i;
 while(document.forms['edit'].elements[sname].options.length > 0)
 {
  document.forms['edit'].elements[sname].options[document.forms['edit'].elements[sname].options.length - 1] = null;
 }
 var sel = window.frames['lsel'].document.forms['edit'].elements['page'];
 var tsel = document.forms['edit'].elements[sname];
 for (i = 0; i < sel.options.length; i++)
 {
  var opt = new Option(sel.options[i].innerHTML, sel.options[i].value);
  tsel.options[i] = opt;
  if (document.forms['edit'].elements['op'].value == sel.options[i].value)
   tsel.options[i].selected = 1;
 }
}

function loadpage(urla,fram){
 window.frames[fram].document.location = urla;
}

function order(id)
{
 //document.location.href = 'index.php?chp=order&id='+id;
 window.frames['orderfr'].document.location.href = 'index.php?nw=1&chp=order&id='+id;
}

function updatePriceGroupsList()
{
 var chp = document.forms['edit'].elements['chp'];
 var chpval = chp.options[chp.selectedIndex].value;
 var prgid = document.forms['edit'].elements['price_group_id'];
 prgid.disabled = !(chpval == 'price');
}

function shMenu(status, id)
{
 if (status == 0)
 {
  TOs[id] = setTimeout('realShMenu(0, "' + id + '")', 300);
 }
 else
 {
  clearTimeout(TOs[id]);
  realShMenu(status, id);
 }
 // realShMenu(status, id);
}

function realShMenu(status, id)
{
 var smenu = document.getElementById('smenu'+id);
 if (smenu)
  smenu.style.display = (status == 0)?'none':'block';
 var td = document.getElementById('td'+id);
 if (td)
  td.style.backgroundImage = (status==0)?'url(img/upmenu-bg.gif)':'none';
  //td.style.backgroundPosition = (status == 0) ? "left 0px" : 'left -23px';
 var coll = td.getElementsByTagName('a');
 //alert('l = ' + coll.length + '; last = ' + coll[coll.length-1].id);
 coll[coll.length - 1 ].style.color = status ? '#00539F' : '#ffffff';
}

function update_cart(sum, cart)
{
 
}

function filterfunc(i, val)
{
 document.forms['filter'].elements['field_'+i].value = val;
 document.forms['filter'].submit();
}

function reset_filter(maxf)
{
 var i;
 for (i = 0; i < maxf; i++)
 {
  var inp = document.forms['filter'].elements['field_'+i];
  if (inp)
   inp.value = '';
 }
 document.forms['filter'].submit();
}