    function SC_Refs(frmName){
      this.options_refs = new Array();
      this.options_items = new Array();
      this.frmName=frmName;
      
      this.addRef=addRef;
      this.updateCombos=updateCombos;
      this.addOption=addOption;
      this.init=init;
    
      function addRef(source,dest){
        if (document.forms[this.frmName].elements[source] && document.forms[this.frmName].elements[dest]){
          var ref = new Array();
          ref.source=source;
          ref.dest=dest;
          this.options_refs[this.options_refs.length]=ref;
          this.options_items[source]= new Array();
        }
      }
      
      function addOption(source,val,text,grp){
        opt= new Array();
        opt.val=val;
        opt.text=text;
        opt.grp=grp;
        this.options_items[source][this.options_items[source].length]=opt;
      }
       
      function updateCombos(sel){
        var i;
        var val;
        
        if (sel.selectedIndex>=0){
          val=sel.options[sel.selectedIndex].value;
        } else {
          val=-1;
        }
      
        for (i=0;i<this.options_refs.length;i++){
          if (this.options_refs[i].dest==sel.name){
//            alert ("Treba updatovat "+this.options_refs[i].source+" Dest:"+sel.name);
            //saving options------------------
            if (this.options_items[this.options_refs[i].source].length==0){
//              alert("Treba updatovat index");
//              this.options_items[this.options_refs[i].source]=sel.form[this.options_refs[i].source].options;
              for (j=0;j<sel.form[this.options_refs[i].source].length;j++){
                var grp=sel.form[this.options_refs[i].source].options[j].className.substring(3,sel.form[this.options_refs[i].source].options[j].className.length);
                this.addOption(this.options_refs[i].source,sel.form[this.options_refs[i].source].options[j].value,sel.form[this.options_refs[i].source].options[j].text,grp);
//              sel.form[this.options_refs[i].source].remove(j);
              }
            }
            //povodna hodnota
            var orig_value=sel.form[this.options_refs[i].source].value;
            //clearing source
            var j;
            for (j=sel.form[this.options_refs[i].source].length-1;j>=0;j--){
              sel.form[this.options_refs[i].source].remove(j);
            }
            //adding currect options------------
            var opts=this.options_items[this.options_refs[i].source];
//            alert (opts.length);
            for (j=0;j<opts.length;j++){
              if ((opts[j].grp==val) | (opts[j].grp==0)){//
                var option = new Option(opts[j].text,opts[j].val);
                sel.form[this.options_refs[i].source].options[sel.form[this.options_refs[i].source].length] = option;
//                alert(opts[j].val);
              }
            }
            //setting original value if possible
            for (j=sel.form[this.options_refs[i].source].length-1;j>=0;j--){
              if(sel.form[this.options_refs[i].source][j].value==orig_value){
                sel.form[this.options_refs[i].source].selectedIndex=j;
              }
            }           
            //calling onchange
            this.updateCombos(sel.form[this.options_refs[i].source]);
//            sel.form[this.options_refs[i].source]
//            alert(this.options_refs[i].source);
          }
        }
      }

     function init(refs){
//        alert ("initialize");
        var i;
        for (i=0;i<this.options_refs.length;i++){
//          document.forms[formName][this.options_refs[i].dest].captureEvents(Event.CHANGE);
          //adding handler
          document.forms[this.frmName].elements[this.options_refs[i].dest].onchange=function(){refs.updateCombos(this);}//changeHandler;
          //onload setting
          this.updateCombos(document.forms[this.frmName].elements[this.options_refs[i].dest])
        }
      }

      
     }
