function chkminmax(e)
{
  f=getEventSrc(e);
  while (f.tagName.toLowerCase()!="form") f=f.parentNode;
  prd_id=f.elements.namedItem("id").value;

  min=parseInt(document.getElementById('minprice_'+prd_id).firstChild.data);
  max=parseInt(document.getElementById('maxprice_'+prd_id).firstChild.data);
  myp=parseInt(f.elements.namedItem("myprice").value);
  if (myp<min || myp>max || isNaN(myp)) 
  {
    if(e.preventDefault) e.preventDefault();                                                      
    if(e.preventDefault) e.stopPropagation();                                                     
    e.returnValue=false                                                                           
    e.cancelBubble=true;                                                                          
    alert("מחיר מחוץ לטווח!");
  }
}

function click_product(e)
{
  e=getEventSrc(e);
  while (e.tagName.toLowerCase()!="li")
  {
    if(e.tagName.toLowerCase()=="input") return false;
    e=e.parentNode;
  }
  window.location="product.php?id="+e.prd_id
}

for(i=0;i<document.forms.length;++i)
{
  form=document.forms.item(i);
  if(form.className=='MinMaxForm') addEvent(form,"submit",chkminmax);
  if(form.className=='MehrazForm') addEvent(form,"submit",chkminmax);
}

if(document.getElementById('Products'))
{
products=document.getElementById('Products').childNodes
for(i=0;i<products.length;++i)
{
  prd=products.item(i);
  if (prd.nodeType==1) 
  {
    prd_id=parseInt(prd.getAttribute('id').substring(4))
    prd.prd_id=prd_id
    addEvent(prd,'click',click_product)
  }
}
}
