    function fnviewcatalog(){
      var f = document.forms['selectcatalog'];
      var body = document.getElementById('mainbody');
      var req = new JsHttpRequest();
      // Code automatically called on load finishing.
       if(f.elements['company'].value=="-1" && f.elements['category'].value=="-1"){
           alert("Выберите фирму или категорию!");
       }
       else{
      req.onreadystatechange = function(){
        if (req.readyState == 4) {
          if(req.responseJS.State == 'ok'){
            body.style.minHeight="auto";
            body.style.height="auto";
            body.innerHTML=req.responseText;
          }	
        }
      }
      fnshowStatus(body,'Подождите, идет загрузка...');
      req.open("POST",'/phpsrc/viewcatalog.php',true);
      // Send data to backend.
      req.send(fnwrapForm(f));
      }
    }   

   function showCollection(colid){
      window.location="/collections/name/"+colid;
   }

   function fnsomesearch(){
      var f = document.forms['fastsearch'];
      var body = document.getElementById('mainbody');
      var req = new JsHttpRequest();
      // Code automatically called on load finishing.
      req.onreadystatechange = function(){
        if (req.readyState == 4) {
          if(req.responseJS.State == 'ok'){
            body.style.minHeight="auto";
            body.style.height="auto";
            body.innerHTML=req.responseText;
          }	
        }
      }
      fnshowStatus(body,'Подождите, идет загрузка...');
      req.open("POST",'/phpsrc/viewsearch.php',true);
      // Send data to backend.
      req.send(fnwrapForm(f));
   }
   

   function fnshowcart(){
      var path = '/cart/showbascket.php';
      var infoemp = window.open(path, 'basket','width=820,height=400,resizable=yes,scrollbars=yes,titlebar=no,innerWidth=560,innerHeight=550');
      infoemp.w = window;
   }


   function fnaddtocart(){
      var bstate = document.getElementById('cart'), f,cnt=0,sum=0;
      var req = new JsHttpRequest();
      // Code automatically called on load finishing.
      req.onreadystatechange = function(){
        if (req.readyState == 4) {
          if(req.responseJS.State == 'ok'){
            cnt = req.responseJS.c;
            sum = req.responseJS.p;
            bstate.innerHTML = +cnt+' шт./'+sum+' руб.';	     	    	
          }	
        }
      }
      req.open("POST",'/cart/addtobasket.php',true);
      // Send data to backend.
      req.send(null); 
     	
   }
  	 
  
   function fncheckcart(){
     var bstate = document.getElementById('cart'), f,cnt=0,sum=0;
     var req = new JsHttpRequest();
     // Code automatically called on load finishing.
     req.onreadystatechange = function(){
       if (req.readyState == 4) {
         if(req.responseJS.State == 'ok'){
           cnt = req.responseJS.c;
           sum = req.responseJS.p;
           bstate.innerHTML = (cnt==0 && sum==0)? '0 шт./0 руб.' : +cnt+' шт./'+sum+' руб.';	     	    	
         }	
       }
     }
     req.open("POST",'/cart/addtobasket.php',true);
     // Send data to backend.
     req.send(null); 
   }
   
  
   function fnloadpage(parid, scrname, maspar){
      var parnt = document.getElementById(parid);
      var req = new JsHttpRequest();
      // Code automatically called on load finishing.

      req.onreadystatechange = function(){
        if(req.readyState == 4) {
          if(req.responseJS.State == 'ok'){
            var bool = parnt.hasChildNodes();
            if(bool==1){ 
              // если да, то удаляем
              for(var i=parnt.childNodes.length; i!=0; i--){
                parnt.removeChild(parnt.firstChild);
              }
            }
            if(req.responseJS.h!=250){
              parnt.style.height= req.responseJS.h;
            }
            parnt.innerHTML = req.responseText;
          }	
        }
      
      }
      fnshowStatus(parnt,'Подождите, идет загрузка...');
      req.open("POST",'/phpsrc/'+scrname+'.php',true);
      // Send data to backend.
      req.send(maspar);
   }

      function fncomeinto(){
        var felems = document.forms['income'].elements;
        var req = new JsHttpRequest();
        req.onreadystatechange = function(){
          if(req.readyState==4){
            if(req.responseJS.State=='ok'){
              window.location.reload();
            }
            if(req.responseJS.State=='pswderror'){
              window.location="/errorpg.php";
            }
          }
        }
        req.open("POST",'/phpsrc/income.php',true);
        req.send({'l':felems['my.email'].value,'p':felems['password'].value});
      }

      function fnlogout(){
        var req = new JsHttpRequest();
        req.onreadystatechange = function(){
          if(req.readyState==4){
            if(req.responseJS.State=='ok'){
              window.location='/';
            }
          }
        }
        req.open("POST",'/phpsrc/logout.php',true);
        req.send(null );
      }

       function fnshoworder(obj){
         var t = document.getElementById(obj.id+'p');
         t.style.display=(t.style.display=="none")?"":"none";
      }

      function checkemail(str){
        var f=2;
        if(str.match(/^[a-zA-Z0-9\.]+[@][a-z0-9\.]+[\.][a-z]+/)) { f=0; }
        return f;
      }
      function checkpassword(){
        var p=document.getElementById('passwd'),f=3;
        var cp=document.getElementById('passwdc');
        if(p.value==cp.value){ f=0; }
       return f;
      }
     function regme(){
         var msg = ['<h3>У Вас не правильно заполнена форма!!!</h3>','<h3>У Вас не все поля заполнены!!!</h3>','<h3>У Вас не правильно указан E-mail!!!</h3>','<h3>Указанный пароль не совпадает!!!</h3>'];
     	 var freg = document.getElementById('registr');
     	 var mas = {}, tmas,i,dd,gg1=0,fg=0;
     	 var chke,ncl=0,chkp=checkpassword();

     	 tmas = document.forms[freg.name].elements;
     	 for(i=0;i<tmas.length; i++){
     	    if(tmas[i].type!='button'){
     	         if(tmas[i].type=='radio' && tmas[i].checked==true){
     	           mas[tmas[i].name] = tmas[i].value; fg=1;
     	         }
     	         else if(tmas[i].type!='radio'){
     	 	   mas[tmas[i].name] = tmas[i].value;
     	 	 }
     	     if(tmas[i].value==""){
     	        gg1=1;
     	     }
     	   }
     	 }
     	chke=checkemail(mas['email']);
     	if(0==chke && gg1==0 && chkp==0){
         dd = document.getElementById('status');
     	 dd.style.display = "none";
     	 var req = new JsHttpRequest();
         // Code automatically called on load finishing.
         req.onreadystatechange = function(){
         	if (req.readyState == 4) {
         	    if(req.responseJS.State == 'ok'){
         	      //alert(req.responseText);
                      window.location='/step2.php';
         	    }	
           }
         }
        req.open("POST",'/cart/registration.php',true);
         // Send data to backend.
        req.send(mas);
       }
       else{
         dd = document.getElementById('status');
     	 dd.style.display = "";
     	 if(gg1==0 && chke==0 && chkp!=0){ gg1=chkp;}
         if(chkp==0 && chke==0 && gg1!=0){ gg1=gg1;}
         if(chkp==0 && gg1==0 && chke!=0){ gg1=chke;}         
         if(chkp!=0 && chke!=0 && gg1!=0){ gg1=0;}         
         ncl = 1;
     	 dd.innerHTML = msg[gg1];
       }
       //return ncl;
     }

      function fnshowenter(){
         var d = document.getElementById('comeinform');
         d.style.display="";
      }
     function fncloseenterform(){
         var d = document.getElementById('comeinform');
         d.style.display="none";
     }
     
     function detail(id){
       var page = "/phpsrc/unit.php?id=" + id;
       var aDim = browser_switch(450, 287);
       var w = window.open(page, "detail","width=" + aDim[0] + ",height=" + aDim[1] + ",status=0,scrollbars=no,scrolling=0,resizable=no");
       w.focus();
     }

     function fnsetfirmbycat(selcat){
        var req = new JsHttpRequest();
        var i=0,kf;
        var sfrm = document.getElementById('company');
        var sfrm_c = sfrm.childNodes;
        var sfrm_c_l = sfrm_c.length;
        var firms={};
        req.onreadystatechange = function(){
          if(req.readyState==4){
            if(req.responseJS.State=='ok'){
              firms = req.responseJS.fff;
              sfrm.innerHTML='';
              var no = document.createElement('OPTION');
              no.setAttribute('value','-1');
              no.innerHTML='Фирма';
              no.slected=true;
              sfrm.appendChild(no);
              if(req.responseJS.cnt>1){
                no = document.createElement('OPTION');
                no.setAttribute('value','0');
                no.innerHTML='Все';
                sfrm.appendChild(no);
              }
              for(f in firms){
                no = new Option(firms[f]['t'],f);
                no = document.createElement('OPTION');
                no.setAttribute('value',f);
                no.innerHTML=firms[f]['t'];
                sfrm.appendChild(no);
              }
            }
          }
        }
        req.open("POST",'/phpsrc/firmbycat.php',true);
        req.send({'catid':selcat.options[selcat.selectedIndex].value});
     }
function showpicture(picstr, w, h, pos, sw, sh){
}
