function showPic(imgName,imgw,imgh) {
  w = window.open('','Image','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width='+(parseInt(imgw)+30)+',height='+(parseInt(imgh)+30)+',left='+Math.round((screen.width-parseInt(imgw))/2)+',top='+Math.round((screen.height-parseInt(imgh))/2));
  w.document.write( "<html><head><title>Image</title>" );
  w.document.write( "<scr" );
  w.document.write( "ipt language='javascript'>" );
  w.document.write( "if (window.focus){" );
  //w.document.write( "self.resizeTo("+(parseInt(imgw)+30)+","+(parseInt(imgh)+30)+");" );
  w.document.write( "self.focus();" );
  w.document.write( "}" );
  w.document.write( "</script>" );
  w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 >" );
  w.document.write( "<table border='0' width='100%' height='100%'><tr><td align='center' valign='center'><img src='upload.img/"+imgName+".jpg' border=0 width='"+imgw+"' height='"+imgh+"' OnClick='window.close();'></td></tr></table>" );
  w.document.write( "</body></html>" );
  w.document.close();
}


function jsReplace(inString, find, replace) {
  var outString = "";
  if (!inString)return "";
  if (inString.indexOf(find) != -1){
    t = inString.split(find);
    return (t.join(replace));
  }else{
    return inString;
  }
}

var reEmail=/^.+\@.+\..+$/


function szubmit(action,aname,aid) {
  form=document.forms.mainform;
  for (i=0; i<form.length; i++) {
    if (form[i].name=="action")   form[i].value=action;
    if (form[i].name==aname) form[i].value=aid;
  }
  form.submit();
}


function checkname(name,ln){
  var sw=0;
  carray=name.split(" ");
  sw=0;
  for(i=0;i<carray.length;i++)
    if (carray[i].length!=0)
      sw+=carray[i].length;
  if (sw<ln){
    return false;
  }else{
    return true;
  }
}

function set_menu_cookie(div_nr,status){
  var today = new Date();
  var expire = new Date();
  expire.setTime(today.getTime() + 3600000*24*100);
  document.cookie = "MENU_TREE_"+div_nr+"="+status+ ";expires="+expire.toGMTString();
}

function show_hide_menu_divs(div_nr){
  form=document.forms.mainform;
  d=eval("document.getElementById('menu_div_"+div_nr+"');");
  i=eval("document.getElementById('menu_img_"+div_nr+"');");
  
  if (d.style.display=='block'){
    d.style.display='none';
    i.src='images/pl.jpg';
    set_menu_cookie(div_nr,0);
  }else{
    d.style.display='block';
    i.src='images/minus.jpg';
    set_menu_cookie(div_nr,1);
  }
}

function handleEnter(function_name) {
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if (keyCode == 13){
    alert(function_name);
    return false;
  }
}

function searchprod(){
  document.location='prod.php?search='+escape(document.forms.mainform.search.value);
}

