function showPic(imgName,imgw,imgh) {
  var s=String(document.location);
  var p=s.lastIndexOf('/');
  var path=s.substr(0,p+1);
  imgName=path+imgName;
  w = window.open('','Demo','toolbar=no,location=no,directories=no,status=no,scrollbars=auto,resizable=yes,copyhistory=no,width='+imgw+',height='+imgh+',left='+(screen.width-imgw)/2+',top='+(screen.height-imgh-100)/2);
  w.document.write( "<html><head><title>Image</title>" );
  w.document.write( "<script language='JavaScript'>\n");
  w.document.write( "IE5=NN4=NN6=false\n");
  w.document.write( "if(document.all)IE5=true;\n");
  w.document.write( "else if(document.getElementById)NN6=true\n");
  w.document.write( "else if(document.layers)NN4=true\n");
  
  w.document.write( "function autoSize() {\n");
  w.document.write( " W=document.images[0].width;H=document.images[0].height;\n");
  w.document.write( " if (W>screen.width-100){\n");
  w.document.write( "   H=Math.round(H*(screen.width-100)/W)\n");
  w.document.write( "   W=screen.width-100;\n");
  w.document.write( " }\n");
  w.document.write( " if (H>screen.height-100){\n");
  w.document.write( "   W=Math.round(W*(screen.height-100)/H);\n");
  w.document.write( "   H=screen.height-100;\n");
  w.document.write( " }\n");
  w.document.write( " document.images[0].width=W;document.images[0].height=H;\n");
  w.document.write( " if(IE5) self.resizeTo(W+25,H+65)\n");
  w.document.write( " else if(NN6) self.resizeTo(W+25,H+65)\n");
  w.document.write( " else top.window.resizeTo(W+25,H+65)\n");
  w.document.write( " self.moveTo((screen.width-W)/2,(screen.height-H-62)/2)\n");
  w.document.write( " self.focus()\n");
  w.document.write( "}\n");
  w.document.write( "</scr");
  w.document.write( "ipt>\n");
  w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad=" );
  w.document.write( "'javascript:autoSize();'>" );
  w.document.write( "<table border='0' width='100%' height='100%'><tr><td align='center' valign='center'><img src='"+imgName+"' border=0 OnClick='window.close();'></td></tr></table>" );  
  w.document.write( "</center></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;
  }
}

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 = "CLIENT_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);
  }
}
