  function SimpleQuery(rootLocation,lang,sect,iface,cmd)
  { this.Params=new Object();
    this.chpu=false;

    this.ClearParams=function(){ this.Params=new Object();}  // Очистка списка параметров

    this.SetParam=function(name,val) // Установка значения параметра
    { if(name)
      { if(val!=null)
          this.Params[name]=String(val);
        else
          delete this.Params[name];
        
      }
    }
    this.Post=function()  // Отправка запроса методом POST
    { var args;
      this.createForm();  // Создание формы запроса
      if(this.chpu)
        document.simpleQuery.action=encodeURI(this.RootLocation+"/"+this.lang+"/"+this.sect+"/"+this.iface+"/"+this.cmd+"/");
      else
        document.simpleQuery.action=encodeURI(this.RootLocation+"/?lang="+this.lang+"&sect="+this.sect+"&iface="+this.iface+"&cmd="+this.cmd);
      this.formInputAdd("args",this.param2str());
      document.simpleQuery.submit();
    };
    this.Get=function()  // Отправка запроса методом GET
    { var strLocation;
      if(this.chpu)
        strLocation=this.RootLocation+"/"+this.lang+"/"+this.sect+"/"+this.iface+"/"+this.cmd+"/"+this.param2str()+"/";
      else
        strLocation=this.RootLocation+"/?lang="+this.lang+"&sec="+this.sect+"&iface="+this.iface+"&cmd="+this.cmd+"&args="+this.param2str();
      window.location=strLocation;
    };
    this.GetLocation=function()
    { var strLocation;
      if(this.chpu)
        strLocation=this.RootLocation+"/"+this.lang+"/"+this.sect+"/"+this.iface+"/"+this.cmd+"/"+this.param2str()+"/";
      else
        strLocation=this.RootLocation+"/?lang="+this.lang+"&sec="+this.sect+"&iface="+this.iface+"&cmd="+this.cmd+"&args="+this.param2str();
      return(strLocation);
    };
    this.GetContent=function(id)
    { var strLocation;
      var params;
      params=this.encodeParam('id')+':'+this.encodeParam(String(id));
      strLocation=this.RootLocation+"/?lang="+this.lang+"&spec_cmd=getcontent&args="+params;
      return(strLocation);
    };
    // ----------------------------------------------------
    // ---------------- Внутренние функции ----------------
    this.param2str=function()
    { var retVal="";
      var val;
      for(i in this.Params)
      { if(retVal.length>0)
          retVal=retVal+";";
        val=this.encodeParam(String(i))+':'+this.encodeParam(String(this.Params[i]));
        retVal=retVal+val;
      } 
      return(retVal);
    }
    
    this.formInputAdd=function(elem,val)
    { if(!(elem in document.simpleQuery))
      { if(typeof(document.simpleQuery.insertAdjacentHTML) == "undefined")
        { new_input=document.createElement("input");
          new_input.type="hidden";
          new_input.name=elem;
          document.simpleQuery.appendChild(new_input);
        }
        else
        { document.simpleQuery.insertAdjacentHTML("beforeEnd","<input type=hidden name='"+elem+"' value='' />");
        }
      } 
      document.simpleQuery[elem].value=val;
    }
    
    this.encodeParam=function(str) 
    { var ret = str.replace(/\$/g, "$$$$");
      ret=ret.replace(/\*/g, "$$\*");
      ret=ret.replace(/_/g, '$$_');
      ret=ret.replace(/:/g, "\*_");
      ret=ret.replace(/;/g, "_\*");
      ret=encodeURIComponent(ret);
      return ret;
    }
    
    this.createForm=function()  // Создание формы для отправки запроса
    { var rootElem;
      if("simpleQuery" in document.forms)
      { var elem=document.forms["simpleQuery"];
        var parent=elem.parentNode;
        if(parent)
          parent.removeChild(elem);
      }
      if(!("simpleQuery" in document.forms))
      { 
        rootElem=document.getElementsByTagName("body")[0];
        if(typeof(rootElem.insertAdjacentHTML) == "undefined")
        { new_input=document.createElement("form");
          new_input.method="POST";
          new_input.name="simpleQuery";
          new_input.style.setProperty("float","left","");
          rootElem.appendChild(new_input);
        }
        else
        { rootElem.insertAdjacentHTML("beforeEnd","<form method=POST name='simpleQuery' style='float:left' />");
        }
      } 
    }

    if(rootLocation==null) this.RootLocation=window.CurQuery.rootLocation;
    else this.RootLocation=rootLocation;
    if(lang==null)this.lang=window.CurQuery.lang;
    else this.lang=lang;
    if(sect==null)this.sect=window.CurQuery.sect;
    else this.sect=sect;
    if(iface==null)this.iface=window.CurQuery.iface;
    else this.iface=iface;
    if(cmd==null)this.cmd=window.CurQuery.cmd;
    else this.cmd=cmd;
  }
