var _isFF,_isIE,_isIE6,_isOpera = false;
if(navigator.userAgent.indexOf("MSIE")!=-1) {
    _isIE=true;
    if(navigator.userAgent.indexOf("6.0")) isIE6:true;
}
else if(navigator.userAgent.indexOf("Opera")!=-1) _isOpera=true;
else _isFF=true;

function convertStringToBoolean(inputString){
    if(typeof (inputString)== "string") inputString=inputString.toLowerCase();
    switch (inputString){
        case "1":
        case "true":
        case "yes":
        case "y":
        case 1:
        case undefined:
        case true:
            return true;
            break;
        default:
            return false;
    }
}

function dhtmlxEvent(el, event, handler){
    if(_isIE) el.attachEvent("on"+event, handler)
    else      el.addEventListener(event, handler, false);
}
function dhtmlXCombo(parent,name,width){
    parent=(typeof(parent)=="string")?document.getElementById(parent):parent;
    this.dhx_Event();
    this._optionObject = dhtmlXCombo_defaultOption;
    this._disabled = false;
    this.rtl=(parent.style.direction == "rtl")?true:false;
    if (!window.dhx_combos){
        window.dhx_combos=new Array();
        window.dhx_openedSelect=null;
        window.dhx_SelectId=1;
        dhtmlxEvent(document.body,"click",this.closeAll);
        dhtmlxEvent(document.body,"keydown",function(e){
            try {
                if ((e||event).keyCode==9)  window.dhx_combos[0].closeAll();
            } catch(e) {}
            return true;
        });
        dhtmlxEvent(window,"resize",this.closeAll);
        dhtmlxEvent(window,"load",function(){
            for(var i in window.dhx_combos){
                var oNode=window.dhx_combos[i].DOMParent.parentNode;
                while (oNode!=undefined){
                    if(oNode.tagName=='DIV' || oNode==document.body){
                        dhtmlxEvent(oNode,"scroll",function(){
                            window.dhx_combos[i].closeAll();
                        });
                    }
                    oNode=oNode.parentNode;
                }
            }
        });
    }
    this._createSelf(parent,name,width);
    dhx_combos.push(this);
}
dhtmlXCombo.prototype.disable = function(mode){
    mode=convertStringToBoolean(mode);

    if(this._disabled && mode) return;
    var className=this.DOMelem_button.className;
    var class_disable=(this.rtl)?' _combo_rtl_disabled':' _combo_disabled';
    if(mode)
        this.DOMelem_button.className=className+class_disable;
    else
        this.DOMelem_button.className=className.replace(class_disable,"","g");
    this.DOMelem_input.disabled=this._disabled=mode;
}

dhtmlXCombo.prototype.readonly = function(mode){
    
    mode=convertStringToBoolean(mode);
    this.DOMelem_input.readOnly=mode;
    this.getValueByIndex();
}

dhtmlXCombo.prototype.getValueByIndex = function(index){
    if(index==undefined) index=0;
    this.setComboValue(this.optionsArr[index].value,false);
}

dhtmlXCombo.prototype.getOption = function(value){
    for(var i=0; i<this.optionsArr.length; i++)
        if(this.optionsArr[i].value==value)
            return this.optionsArr[i];
    return null;
}

dhtmlXCombo.prototype.stripHTML=function(oldString){
    return  oldString.replace(/(<([^>]+)>)/ig,"");
}

dhtmlXCombo.prototype.getOptionByLabel = function(value){
    for(var i=0; i<this.optionsArr.length; i++)
        if(this.stripHTML(this.optionsArr[i].text)==value)
            return this.optionsArr[i];
    return null;
}

dhtmlXCombo.prototype.getOptionByIndex = function(ind){
    return this.optionsArr[ind];
}

dhtmlXCombo.prototype.clearAll = function(mode){
    this.optionsArr=new Array();
    this.redrawOptions();
    if(mode){
        this.setComboText("");
        this._confirmSelection()
    }
}

dhtmlXCombo.prototype.clearData = function(data){
    if(data==undefined) data="";
    this.DOMelem_input.value=data;
    this.DOMelem_hidden_input.value="";
    this._lasttext=null;
    this.is_data_change=false;
    this.clearAll();
}

dhtmlXCombo.prototype.deleteOption = function(value){
    var index=this.getIndexByValue(value);
    if(index<0) return;
    if (this.optionsArr[index]==this._selOption) this._selOption=null;
    this.optionsArr.splice(index, 1);
    this.redrawOptions();
}

dhtmlXCombo.prototype.render=function(mode){
    this._skiprender=(!convertStringToBoolean(mode));
    this.redrawOptions();
}

dhtmlXCombo.prototype.addOption = function(options){
    this.render(false);
    for (var i=0; i<options.length; i++) {
        var attr=options[i];
        if(attr.length>0){
            attr.value = attr[0];
            attr.text = attr[1];
        }
        this._addOption(attr);
    }
    this.render(true);
}

dhtmlXCombo.prototype._addOption = function(attr){
    dOpt = new this._optionObject();
    this.optionsArr.push(dOpt);
    dOpt.setValue.apply(dOpt,[attr]);
    this.redrawOptions();
}

dhtmlXCombo.prototype.getIndexByValue = function(val){
    for(var i=0; i<this.optionsArr.length; i++)
        if(this.optionsArr[i].value == val) return i;
    return -1;
}

dhtmlXCombo.prototype.getSelectedValue = function(){
    return (this._selOption?this._selOption.value:null);
}

dhtmlXCombo.prototype.getComboText = function(){
    return this.DOMelem_input.value;
}

dhtmlXCombo.prototype.getTxtByValue = function(val){
    for(var i=0;i<this.optionsArr.length;i++){
        if(this.optionsArr[i].value.match(val))
            return this.stripHTML(this.optionsArr[i].text);
    }
    return null;
}

dhtmlXCombo.prototype.valid=function(mode){
    mode=convertStringToBoolean(mode);
    var className=this.DOMelem_button.className;
    var class_valid=(this.rtl)?' _combo_valid_rtl':' _combo_valid';
    var classList="dhx_combo_list";
    if(mode){
        this.DOMelem_hidden_input.className='valid';
        this.DOMelem_button.className=className+class_valid;
        this.DOMlist.className=classList+" dhx_list_valid";
    }
    else{
        this.DOMelem_hidden_input.className='';
        this.DOMelem_button.className=className.replace(class_valid,"","g");
        this.DOMlist.className=classList;
    }
};
dhtmlXCombo.prototype.setComboTitle=function(text){
    this.DOMelem_hidden_input.title=text
};

dhtmlXCombo.prototype.setComboText = function(text){
    this.DOMelem_input.value=text;
}

dhtmlXCombo.prototype.setComboValue = function(value,isEvent){
    if(isEvent==undefined) isEvent=true;
    for(var i=0; i<this.optionsArr.length; i++){
        if (this.optionsArr[i].data()[0]==value){
            return this.selectOption(i,true,isEvent);
        }
    }
    this.DOMelem_hidden_input.value="";
    this.DOMelem_input.value="";
    this._lasttext="";
    return null;
}

dhtmlXCombo.prototype.setComboValueText = function(value,text){
    if(value!=undefined){
        if(this._url) this.clearData();
        if(!this.getTxtByValue(value))
            this.addOption([[value,text]]);
        this.setComboValue(value,false);
    }
}

dhtmlXCombo.prototype.getActualValue = function(){
    return this.DOMelem_hidden_input.value;
}

dhtmlXCombo.prototype.getSelectedText = function(){
    return this.stripHTML((this._selOption?this._selOption.text:""));
}

dhtmlXCombo.prototype.getSelectedIndex = function(){
    for(var i=0; i<this.optionsArr.length; i++)
        if(this.optionsArr[i] == this._selOption)
            return i;
    return -1;
}

dhtmlXCombo.prototype.show = function(mode){
    this.DOMelem.style.display =convertStringToBoolean(mode)?"block":"none";
}

dhtmlXCombo.prototype.setListWidth = function(width){
    this.DOMlist.style.width=width+"px";
}

dhtmlXCombo.prototype._createSelf = function(selParent, name, width){
    this.DOMParent = selParent;
    this.DOMParent.className="dhx_combo_container";
    this._inID = null;
    this.name = name;
    this._selOption = null; //selectdhx_combo_buttoned option object pointer
    this.optionsArr = Array();
    this.ajax_condition     = Array();
    this.ajax_request=null;
    this.key_pressed=null;
    this.key_timer=null;
    this.is_data_change=false;
    this._lasttext=null;
    this.debug      = false;
    var opt = new this._optionObject();
    opt.DrawHeader(this,name, width);
    this.DOMlist = document.createElement("DIV");
    this.DOMlist.className = 'dhx_combo_list';
    this.DOMlist.style.width=width+"px";
    this.DOMlist.style.display = "none";
    this.DOMlist.style.height="100px";
    document.body.insertBefore(this.DOMlist,document.body.firstChild);
    this.DOMlist.combo=this.DOMelem.combo=this;
    var that=this.combo;
    //this.DOMelem_input.onfocus =this._onFocus;
    this.DOMelem_input.onkeydown = this._onKey;
    this.DOMelem_input.onkeypress = this._onKeyF;
    this.DOMelem_input.onblur = this._onBlur;
    this.DOMelem.onclick =this._toggleSelect;
    this.DOMlist.onclick = this._selectOption;
    this.DOMlist.onkeydown = function(e){
        that.combo.DOMelem_input.focus();
        (e||event).cancelBubble=true;
        that.combo.DOMelem_input.onkeydown(e)
    }
    this.DOMlist.onmouseover = this._listOver;
    

   
}

dhtmlXCombo.prototype._listOver = function(e)
{
    e = e||event;
    e.cancelBubble = true;
    var node = (_isIE?event.srcElement:e.target);
    var that = this.combo;
    if ( node.parentNode == that.DOMlist ) {
        if(that._selOption) that._selOption.deselection();
        

        var i=0;
        for (i; i<that.DOMlist.childNodes.length; i++) {
            if (that.DOMlist.childNodes[i]==node) break;
        }
        var z=that.optionsArr[i];
        that._selOption=z;
        that._selOption.selection();
    }
}

dhtmlXCombo.prototype._positList = function()
{
    if(this.rtl){
        var right=Math.round(this.DOMelem_input.getBoundingClientRect().right);
        right+=3;
        this.DOMlist.style.right=(this._getClientWidth()-right)+"px";
    }
    else{
        var left =Math.round(this.DOMelem.getBoundingClientRect().left);
        if(_isIE) left-=4;
        else if(_isOpera) left+=14;
        this.DOMlist.style.left = left+"px";
    }
    var scroll_top=0;
    if (document.documentElement.scrollTop)
        scroll_top+=document.documentElement.scrollTop;
    else if(document.body.scrollTop)
        scroll_top+=document.body.scrollTop;

    var top  =this.DOMelem.getBoundingClientRect().top+scroll_top;
    var height=parseInt(this.DOMlist.style.height)+2;
    var bottom =this._getClientHeight() - top - height;
    
    if((bottom < height)&&(top > height))
        this.DOMlist.style.top = top-height+"px";
    else
        this.DOMlist.style.top = top+this.DOMelem.offsetHeight+"px";
}

dhtmlXCombo.prototype.selectNext = function(step){
    var z=this.getSelectedIndex()+step;
    while (this.optionsArr[z]){
        if (!this.optionsArr[z].isHidden())
            return this.selectOption(z,false);
        z+=step;
    }
    return 0;
}

//dhtmlXCombo.prototype._onFocus = function(){
//    var that=this.parentNode.combo;
//    if(that._url){
//        if(that._lasttext!=that.getComboText())
//            that.request(that._url);
//    }
//}


dhtmlXCombo.prototype._onKeyF = function(e){
    var that=this.parentNode.combo;

    var ev=e||event;
    ev.cancelBubble=true;
    if (ev.keyCode=="13" || ev.keyCode=="9" ){
        that._confirmSelection();
        that.closeAll();
    } else
    if (ev.keyCode=="27" ){
        that._resetSelection();
        that.closeAll();
    }
    if (ev.keyCode=="13" || ev.keyCode=="27" ){ //enter
        that.callEvent("onKeyPressed",[ev.keyCode]);
        return false;
    }
    return true;
}

dhtmlXCombo.prototype._onKey = function(e){
    var that=this.parentNode.combo;
    (e||event).cancelBubble=true;
    var ev=(e||event).keyCode;
    if (ev>15 && ev<19) return true; //shift,alt,ctrl
    if (ev==27) return;
    if ((that.DOMlist.style.display!="block")&&(ev!="13")&&(ev!="9")&&((!that._filter)||(that._filterAny)))
        that.DOMelem.onclick(e||event);

    if ((ev!="13")&&(ev!="9")){
        window.setTimeout(function(){
            that._onKeyB(ev);
        },1);
        if (ev=="40" || ev=="38")
            return false;
    }
    else if (ev==9){
        that.closeAll();
        (e||event).cancelBubble=false;
    }
    return null;
}

dhtmlXCombo.prototype._onKeyB = function(ev)
{
    if (ev=="40"){  //down
        this.selectNext(1);
    }else if (ev=="38"){ //up
        this.selectNext(-1);
    } else{
        if(this._url!=undefined && this._url){
            if(this.ajax_request!=null)
                this.ajax_request.abort();
            clearTimeout(this.key_timer);
            var that=this;
            this.key_timer=setTimeout(function(){
                that.callEvent("onKeyPressed",[ev])
                if (that._filter) return that.filterSelf((ev==8)||(ev==46));
            },1);
        }
        else{
            this.callEvent("onKeyPressed",[ev])
            if (this._filter) return this.filterSelf((ev==8)||(ev==46));
        }
    }
    if((ev=="40" || ev=="38") && this.DOMlist.style.display!="block")
        this.openSelect();
    
    return true;
}

dhtmlXCombo.prototype._onBlur = function()
{
    var self = this.parentNode._self;
    // to enable bluring
    window.setTimeout(function(){
        if(self.getActualValue()){
            self._confirmSelection();
            if(self.is_data_change){
                self.callEvent("onBlur",[]);
                self.is_data_change=false;
            }
        }
    }
    ,1);
}

dhtmlXCombo.prototype.redrawOptions = function(){
    if (this._skiprender) return;
    for(var i=this.DOMlist.childNodes.length-1; i>=0; i--)
        this.DOMlist.removeChild(this.DOMlist.childNodes[i]);
    for(i=0; i<this.optionsArr.length; i++)
        this.DOMlist.appendChild(this.optionsArr[i].render());
}

dhtmlXCombo.prototype.unSelectOption = function(){
    if (this._selOption)
        this._selOption.deselection();
    this._selOption=null;
}

dhtmlXCombo.prototype._confirmSelection = function(data,status,isEvent){

    if(typeof(isEvent) == 'undefined' || isEvent)
        isEvent = true;

    if(arguments.length==0){
        var z=this.getOptionByLabel(this.DOMelem_input.value);
        data = z?z.value:this.DOMelem_input.value;
        status = (z==null);
        
        if (data==this.getActualValue()) return;
    }
    
    this.DOMelem_hidden_input.value=data;
    if(status) this.DOMelem_hidden_input.value='';

    this.DOMelem_hidden_input2.value = (status?"true":"false");
    
    if(isEvent && this.is_data_change)
        this.callEvent("onChange",[]);
}

dhtmlXCombo.prototype._resetSelection = function(data,status){
    var z=this.getOption(this.DOMelem_hidden_input.value);
    this.setComboValue(z?z.data()[0]:this.DOMelem_hidden_input.value)
    this.setComboText(z?z.data()[1]:this.DOMelem_hidden_input.value)
}

dhtmlXCombo.prototype.selectOption = function(ind,conf,isEvent){
    if (arguments.length<3) conf=true;
    this.unSelectOption();
    var z=this.optionsArr[ind];
    if (!z)  return;
    this._selOption=z;
    this._selOption.selection();
    var corr=this._selOption.content.offsetTop+this._selOption.content.offsetHeight-this.DOMlist.scrollTop-this.DOMlist.offsetHeight;
    if(this.DOMlist.clientWidth!=this.DOMlist.scrollWidth){
        corr=corr+20;

    }

    if (corr>0) this.DOMlist.scrollTop+=corr;
    corr=this.DOMlist.scrollTop-this._selOption.content.offsetTop;
    if (corr>0) this.DOMlist.scrollTop-=corr;
    /**/
    if(this.getActualValue()!=this.getSelectedValue()){
        this.is_data_change=true;
        this._lasttext=this.getSelectedText();
    }
    else
        this.is_data_change=false;

    /**/
    var data=this._selOption.data();
    if(conf){
        this.setComboText(data[1]);
        this._confirmSelection(data[0],false,isEvent);
    }
    
    
    this.callEvent("onSelectionChange",[]);
}

dhtmlXCombo.prototype._selectOption = function(e){
    (e||event).cancelBubble = true;
    var node=(_isIE?event.srcElement:e.target);
    var that=this.combo;
    while (!node._self) {
        node = node.parentNode;
        if (!node)
            return;
    }

    var i=0;
    for (i; i<that.DOMlist.childNodes.length; i++) {
        if (that.DOMlist.childNodes[i]==node) break;
    }
   
    that.selectOption(i,true);
    that.closeAll();
    if(that.is_data_change){
        that.is_data_change=false;
        that.callEvent("onBlur",[]);
    }
}

dhtmlXCombo.prototype.openSelect = function(){
    if (this._disabled) return;
    this.closeAll();
    this._positList();
    this.DOMlist.style.display="block";
    this.callEvent("onOpen",[]);
    if(this._selOption){
        this._selOption.selection();
        var corr=this._selOption.content.offsetTop+this._selOption.content.offsetHeight-this.DOMlist.scrollTop-this.DOMlist.offsetHeight;
        if (corr>0) this.DOMlist.scrollTop+=corr;
        corr=this.DOMlist.scrollTop-this._selOption.content.offsetTop;
        if (corr>0) this.DOMlist.scrollTop-=corr;
    }
    this.DOMelem_input.focus();
    if(this._filter) this.filterSelf();
}

dhtmlXCombo.prototype._toggleSelect = function(e){
    var that=this.combo;
    if(that.DOMlist.style.display == "block") that.closeAll();
    else {
        that.openSelect();
        that.DOMelem_input.select();
    }
    (e||event).cancelBubble = true;
}

dhtmlXCombo.prototype.enableFilteringMode = function(mode,url){
    this._filter=convertStringToBoolean(mode);
    if(url!=undefined) this._url=url;
}

dhtmlXCombo.prototype.addCondition=function(key,value){
    if(value!=undefined) this.ajax_condition[key]=value;
}

dhtmlXCombo.prototype.getCondition=function(){
    var extend_url='';
    var condition='';
    for(var key in this.ajax_condition){
        try{
            condition=eval(this.ajax_condition[key]);
        }
        catch(err){
            condition=this.ajax_condition[key];
        }
        if(condition !=undefined)
            extend_url+='&'+key+'='+encodeURIComponent(condition);
    }
    return extend_url;
}

dhtmlXCombo.prototype._fetchOptions=function(text){
    var url =this._url+"&"+this.DOMelem_input.name+"="+encodeURIComponent(text);
    url+=this.getCondition();
    
    if(this.debug) alert(url);
    if(this._lasttext!=text){
        this.request(url);
        this._lasttext=text;
        this.is_data_change=true;
    }
}

dhtmlXCombo.prototype.filterSelf = function(mode){
    
    if(this.DOMelem_input.readOnly) return false;
    var text=this.getComboText();
    var filter_text=text.toLowerCase();
    var filter;
    if (this._url)  this._fetchOptions(text);
    else{
        if(mode==undefined)  filter_text='';
        try{
            filter=new RegExp(filter_text);
        } catch (err){
            filter=new RegExp("^"+filter_text.replace(/([\[\]\{\}\(\)\+\*\\])/g,"\\$1"));
        }

        this.filterAny=false;
        for(var i=0; i<this.optionsArr.length; i++){
            var z=filter.test(this.optionsArr[i].text.toLowerCase());
            this.filterAny|=z;
            this.optionsArr[i].hide(!z,text);
        }

        if(!this.filterAny) 
            this.closeAll();
        else if (this.DOMlist.style.display!="block")
            this.openSelect();
        
    }
    return null;
}

dhtmlXCombo.prototype.closeAll = function(){
    if(window.dhx_combos)
        for (var i=0; i<dhx_combos.length; i++){
            if (dhx_combos[i].DOMlist.style.display=="block") {
                dhx_combos[i].DOMlist.style.display = "none";
            }
        }
       
}

dhtmlXCombo_defaultOption = function(){
    this.init();
}

dhtmlXCombo_defaultOption.prototype.init = function(){
    this.value = null;
    this.text = "";
    this.selected = false;
}
 
dhtmlXCombo_defaultOption.prototype.selection = function(){
    if (this.content)
        this.content.className="dhx_selected_option";
    
}

dhtmlXCombo_defaultOption.prototype.hide = function(mode,text){
    if(mode){
        this.render().style.display="none";
    }
    else{
        var highlight=this.render().innerHTML.replace(/(<em>)|(<\/em>)/g,'');
        if(text.length>0) highlight=highlight.replace(text,"<em>"+text+"</em>","g");
        this.render().innerHTML=highlight;
        this.render().style.display="block";
    }
}

dhtmlXCombo_defaultOption.prototype.isHidden = function(){
    return (this.render().style.display=="none");
}

dhtmlXCombo_defaultOption.prototype.deselection = function(){
    if (this.content) this.render();
    this.content.className="";
}

dhtmlXCombo_defaultOption.prototype.setValue = function(attr){
    this.value = attr.value||"";
    this.text = attr.text||"";
    this.content=null;
}

dhtmlXCombo_defaultOption.prototype.render = function(){
    if (!this.content){
        this.content=document.createElement("DIV");
        this.content._self = this;
        this.content.innerHTML=this.text;
        this._ctext=_isIE?this.content.innerText:this.content.textContent;
    }
    return this.content;
}

dhtmlXCombo_defaultOption.prototype.data = function(){
    if (this.content)
        return [this.value,this._ctext ? this._ctext : this.text];
    return null;
}

dhtmlXCombo_defaultOption.prototype.DrawHeader = function(self, name, width){
    var z=document.createElement("DIV");
    z.style.width = width+"px";
    z.className = 'dhx_combo_box';
    z._self = self;
    self.DOMelem = z;
    this._DrawHeaderInput(self, name, width);
    this._DrawHeaderButton(self);
    self.DOMParent.appendChild(self.DOMelem);

    
}

dhtmlXCombo_defaultOption.prototype._DrawHeaderInput = function(self, name, width){
    var z;

    z=document.createElement('input');
    z.setAttribute("autocomplete","off");
    z.type = 'text';

    var className ="dhx_combo_input";
    className+=(self.rtl)?" dhx_r_float":" dhx_l_float";
    z.className = className;
    z.name = name+"_mask";
    width-=_isIE6?30:22;
    z.style.width=width+'px';
    self.DOMelem.appendChild(z);
    self.DOMelem_input = z;

    z = document.createElement('input');
    z.type = 'hidden';
    z.name = name;
    self.DOMelem.appendChild(z);
    self.DOMelem_hidden_input = z;

    z = document.createElement('input');
    z.type = 'hidden';
    z.name = name+"_status";
    z.value="true";
    self.DOMelem.appendChild(z);
    self.DOMelem_hidden_input2 = z;
}

dhtmlXCombo_defaultOption.prototype._DrawHeaderButton = function(self){
    var z=document.createElement('div');
    var className ="dhx_combo_button";
    className+=(self.rtl)?" dhx_l_float":" dhx_r_float";
    className+=(self.rtl)?" _combo_rtl":" _combo";
    z.className = className;
    self.DOMelem.appendChild(z);
    self.DOMelem_button=z;
    z=document.createElement('div');
    z.className ="dhx_clear";
    self.DOMelem.appendChild(z);
}


dhtmlXCombo.prototype.dhx_Event=function(){
    this.dhx_SeverCatcherPath="";

    this.attachEvent = function(original, catcher, CallObj)
    {
        CallObj = CallObj||this;
        original = 'ev_'+original;
        if ( ( !this[original] ) || ( !this[original].addEvent ) ) {
            var z = new this.eventCatcher(CallObj);
            z.addEvent( this[original] );
            this[original] = z;
        }
        return ( original + ':' + this[original].addEvent(catcher) );   //return ID (event name & event ID)
    }
    this.callEvent=function(name,arg0){
        if (this["ev_"+name]) {
            return this["ev_"+name].apply(this,arg0);
        }
        return true;
    }
    this.checkEvent=function(name){
        if (this["ev_"+name]) return true;
        return false;
    }

    this.eventCatcher = function(obj)
    {
        var dhx_catch = new Array();
        var m_obj = obj;
        var z = function()
        {
            
            if (dhx_catch)
                var res=true;
            for (var i=0; i<dhx_catch.length; i++) {
                if (dhx_catch[i] != null) {
                    var zr = dhx_catch[i].apply( m_obj, arguments );
                    res = res && zr;
                }
            }
            return res;
        }

        
        z.addEvent = function(ev)
        {
            ev = eval(ev);
            if (ev)
                return dhx_catch.push( ev ) - 1;
            return false;
        }
        z.removeEvent = function(id)
        {
            dhx_catch[id] = null;
        }
        return z;
    }

    this.detachEvent = function(id)
    {
        if (id != false) {
            var list = id.split(':');            //get EventName and ID
            this[ list[0] ].removeEvent( list[1] );   //remove event
        }
    }
}
dhtmlXCombo.prototype.setOptionHeight = function(height){
    if(height!=undefined){
        this.DOMlist.style.height = height+"px";
        this._positList()
    }
};

dhtmlXCombo.prototype._getClientHeight = function(){
    return ((document.compatMode=='CSS1Compat') &&(!window.opera))?document.documentElement.clientHeight:document.body.clientHeight
};

dhtmlXCombo.prototype._getClientWidth = function(){
    return ((document.compatMode=='CSS1Compat') &&(!window.opera))?document.documentElement.clientWidth:document.body.clientWidth
};

dhtmlXCombo.prototype.request=function(url){
    var that=this;
    var className=that.DOMelem_button.className;
    
    that.closeAll();
    /**/
    that.DOMelem_input.onblur=function(){};

    that._disabled=true;
    
    /**/
    if(window.XMLHttpRequest) that.ajax_request = new XMLHttpRequest();
    else if(window.ActiveXObject) that.ajax_request = new ActiveXObject("Microsoft.XMLHTTP");
    if(that.ajax_request==null) return; // Failed to create the request
    that.ajax_request.onreadystatechange = function()
    {
        switch(that.ajax_request.readyState){
            case 1:
                that.DOMelem_button.className=className+" _combo_request";
                break;
            case 4:
                that.DOMelem_button.className=className.replace(" _combo_request","","g");
                if(that.debug) alert(that.ajax_request.responseText);
                else {
                    that.clearAll();
                    that._disabled=false;
                    eval('that'+that.ajax_request.responseText);
                    var l_length=that.optionsArr.length;
                    if(l_length>0){
                        that.openSelect();
                        /**/
                        that.DOMelem_input.onblur =that._onBlur;
                    }
                }
                break;
        }
    };
    that.ajax_request.open('GET', url,true);
    that.ajax_request.send(null);
}
