function lazyJS(input, object){
  return new selector(input, object);
}

if(typeof $$=="undefined"){
  window.$$=lazyJS;
}

function trim(str){
  return str.replace(/(^\s+)|(\s+$)/g, "");
}
function selector(input, object){

  this.output=new Array();
  this.length=0;

  var input=trim(input);
  var seps=new Array();
  var sep=new Array('#', '.', ':', ' > ', ' + ', ' ~ ', '[', ']', ',', ' ');
  var emp_out=new Array();
  var temp_out=new Array();
  var temp=new Array();
  var parent=new Array();
  if(!object){object=document;}
  
  if(input){
    var j=0;
    var step=0;
    while(j<input.length){
      var plus=0;
      for(var k=0;k<sep.length;k++){
        if(input.substring(j, j+sep[k].length)==sep[k] && sep[k]!=']'){
          seps[step]={"sep":sep[k], "start":j};
          if(step){
            seps[step-1]["end"]=j;
            seps[step-1]["value"]=input.substring(seps[step-1]["start"]+seps[step-1]['sep'].length, j);
          }
          j=j+sep[k].length;
          step++;
          plus=1;
        }
      }
      if(!plus){
        j++;
      }
    }
  }
  if(!seps.length){
    if(object.getElementById(input)){
      this.output[0]=object.getElementById(input);
    }else{
      tag=object.getElementsByTagName(input);
      for(var i=0;i<tag.length;i++){
        this.output[i]=tag[i];
      }
    }
  }else{
    seps[seps.length-1]["end"]=input.length;
    seps[seps.length-1]["value"]=input.substring(seps[seps.length-1]["start"]+seps[seps.length-1]["sep"].length);
    
    step=0;
    
    /*
    for(var x in seps){
      console.log(x+' {sep:'+seps[x]['sep']+' start:'+seps[x]['start']+' end:'+seps[x]['end']+' value:'+seps[x]['value']);
    }
    */
    
    for(var x in seps){
      var prev=0;
      if(seps[x-1]){
        prev=seps[x-1];
      }
      if(!step && ((!prev && seps[x]["start"]) || (seps[x]['sep']==' '))){
        var temptag=object.getElementsByTagName(input.substring(0,seps[x]['start']));
        for(var i=0;i<temptag.length;i++){
          temp_out[temp_out.length]=temptag[i];
        }
        step=1;
      }else if(!step && !temp_out.length){
        temp_out=[object];
      }
      if(!step){
        switch(seps[x]['sep']){
          case '.':
          case '[':
          case '#':{
            if(seps.length==1 && seps[x]['sep']=='#'){
              temp_out.length=1;
              temp_out[0]=object.getElementById(seps[x]['value']);
              
            }else{
              temp_out=nodeRun(seps[x]['sep'], seps[x]['value'], temp_out);
            }
            break;
          }
        }
        if(temp_out.length){
          step=1;
        }
      }else{
        switch(seps[x]['sep']){
          case ' ':{
            if(!seps[x]['value']){
              step=0;
            }else if(seps[x]['value']){
              var tagname=seps[x]['value'];
              var temp=temp_out;
              temp_out=new Array();
              for(var i=0;i<temp.length;i++){
                var templen2=temp[i].getElementsByTagName(tagname).length;
                for(var j=0;j<templen2;j++){
                  var temptag=temp[i].getElementsByTagName(tagname)[j];
                  if((seps[x-1] && seps[x-1]['sep']!=' ') || (temp[i].tagName!=temptag.tagName || temptag.parentNode==temp[i])){
                    temp_out[temp_out.length]=temptag;
                  }
                }
              }
            }
            break;
          }
          case ',':{
            this.output=this.output.concat(temp_out);
            temp_out=0;
            step=0;
            break;
          }
          case ' > ':{
            var temp=temp_out;
            temp_out=new Array();
            for(var i=0;i<temp.length;i++){
              for(var j=0;j<temp[i].childNodes.length;j++){
                if(temp[i].childNodes[j].nodeType==1 && temp[i].childNodes[j].tagName.toLowerCase()==seps[x]['value']){
                  temp_out[temp_out.length]=temp[i].childNodes[j];
                }
              }
            }
            break;
          }
          case '#':
          case '.':
          case '[':{
            temp=temp_out;
            temp_out=new Array();
            for(var i=0, j=temp.length;i<j;i++){
              if(trueSelector(temp[i], seps[x]['sep'], seps[x]['value'])){
                temp_out[temp_out.length]=temp[i];
              }
            }
            break;
          }
          case ':':{
            var temp=temp_out;
            temp_out=new Array();
            switch(seps[x]['value']){
              case 'first-child':{
                for(var i=0, j=temp.length;i<j;i++){
                  if(temp[i].childNodes && temp[i].childNodes.length){
                    for(var k=0, l=temp[i].childNodes.length;k<l;k++){
                      if(temp[i].childNodes[k].nodeType==1){
                        temp_out[temp_out.length]=temp[i].childNodes[k];
                        l=0;
                      }
                    }
                  }
                }
                break;
              }
              case 'last-child':{
                for(var i=0, j=temp.length;i<j;i++){
                  if(temp[i].childNodes && temp[i].childNodes.length){
                    for(var k=temp[i].childNodes.length;k>0;k--){
                      if(temp[i].childNodes[k-1].nodeType==1){
                        temp_out[temp_out.length]=temp[i].childNodes[k-1];
                        k=-1;
                      }
                    }
                  }
                }
                break;
              }
              case 'first-of-type':{
                temp_out[temp_out.length]=temp[0];
                break;
              }
              case 'last-of-type':{
                temp_out[temp_out.length]=temp[temp.length-1];
                break;
              }
              case 'only-child':{
                var kol;
                for(var i=0, j=temp.length;i<j;i++){
                  kol=0;
                  if(temp[i].childNodes && temp[i].childNodes.length){
                    for(var k=temp[i].childNodes.length;k>0;k--){
                      if(temp[i].childNodes[k-1].nodeType==1){
                        kol++;
                        if(kol>1){
                          k=-1;
                          kol=0;
                        }
                      }
                    }
                    if(kol){
                      temp_out[temp_out.length]=temp[i];
                    }
                  }
                }
                break;
              }
              case 'only-of-type':{
                var kol;
                for(var i=0, j=temp.length;i<j;i++){
                  kol=0;
                  if(temp[i].childNodes && temp[i].childNodes.length){
                    for(var k=temp[i].childNodes.length;k>0;k--){
                      if(temp[i].childNodes[k-1].nodeType==1 && temp[i].childNodes[k-1].tagName==temp[i].tagName){
                        kol++;
                        if(kol>1){
                          k=-1;
                          kol=0;
                        }
                      }
                    }
                    if(kol){
                      temp_out[temp_out.length]=temp[i];
                    }
                  }
                }
                break;
              }
              case 'empty':{
                var kol;
                for(var i=0, j=temp.length;i<j;i++){
                  kol=0;
                  if(temp[i].childNodes && temp[i].childNodes.length){
                    for(var k=temp[i].childNodes.length;k>0;k--){
                      if(temp[i].childNodes[k-1].nodeType==1 && temp[i].childNodes[k-1].tagName==temp[i].tagName){
                        kol++;
                        if(kol>0){
                          k=-1;
                        }
                      }
                    }
                    if(!kol){
                      temp_out[temp_out.length]=temp[i];
                    }
                  }
                }
                break;
              }
              case 'enabled':{
                for(var i=0, j=temp.length;i<j;i++){
                  if(!temp[i].disabled){
                    temp_out[temp_out.length]=temp[i];
                  }
                }
                break;
              }
              case 'disabled':{
                for(var i=0, j=temp.length;i<j;i++){
                  if(temp[i].disabled){
                    temp_out[temp_out.length]=temp[i];
                  }
                }
                break;
              }
              case 'checked':{
                for(var i=0, j=temp.length;i<j;i++){
                  if(!temp[i].checked){
                    temp_out[temp_out.length]=temp[i];
                  }
                }
                break;
              }
              default:{
                var inner='';
                if(seps[x]['value'].indexOf('(')!==false){inner=seps[x]['value'].substring(seps[x]['value'].indexOf('(')+1, seps[x]['value'].indexOf(')'));}
                if(seps[x]['value'].substring(0, 9)=='nth-child' || seps[x]['value'].substring(0, 14)=='nth-last-child' || seps[x]['value'].substring(0, 11)=='nth-of-type' || seps[x]['value'].substring(0, 16)=='nth-last-of-type'){
                  var type='';
                  if(seps[x]['value'].substring(0, 9)=='nth-child'){
                    type='nth-child';
                  }else if(seps[x]['value'].substring(0, 14)=='nth-last-child'){
                    type='nth-last-child';
                  }else if(seps[x]['value'].substring(0, 11)=='nth-of-type'){
                    type='nth-of-type';
                  }else if(seps[x]['value'].substring(0, 16)=='nth-last-of-type'){
                    type='nth-last-of-type';
                  }
                  var formula='';
                  switch(inner){
                    case 'odd':{
                      formula='2*n+1';
                      break;
                    }
                    case 'even':{
                      formula='2*n';
                      break;
                    }
                    default:{
                      formula=inner;
                      if(formula.indexOf('n') && parseInt(formula.substring(formula.indexOf('n')-1, formula.indexOf('n')))==formula.substring(formula.indexOf('n')-1, formula.indexOf('n'))){
                        formula=formula.substring(0, formula.indexOf('n'))+'*'+formula.substring(formula.indexOf('n'), formula.length)
                      }
                      break;
                    }
                  }
                  
                  var num=new Array();
                  if(parseInt(formula)!=formula){
                    for(var m=0, n=0;!m;n++){
                      if(eval(formula)>0){
                        if(eval(formula)<=document.all.length){
                          num.push(eval(formula));
                        }else{
                          m=1;
                        }
                      }else{
                        if(!temp_num){var temp_num=eval(formula);}else if(eval(formula)<temp_num){
                          m=1;
                        }
                      }
                    }
                  }
                  
                  switch(type){
                    case 'nth-child':{
                      for(var i=0, j=temp.length;i<j;i++){
                        if(temp[i].childNodes && temp[i].childNodes.length){
                          n=0;
                          for(var k=0, l=temp[i].childNodes.length;k<l;k++){
                            if(temp[i].childNodes[k].nodeType==1){
                              n++;
                              if(parseInt(formula)!=formula){
                                for(var m=0;m<num.length;m++){
                                  if(n==num[m]){
                                    temp_out[temp_out.length]=temp[i].childNodes[k];
                                  }
                                }
                              }else if(n==formula){
                                temp_out[temp_out.length]=temp[i].childNodes[k];
                              }
                            }
                          }
                        }
                      }
                      break;
                    }
                    case 'nth-last-child':{
                      for(var i=0, j=temp.length;i<j;i++){
                        if(temp[i].childNodes && temp[i].childNodes.length){
                          n=0;
                          for(var k=temp[i].childNodes.length-1, l=0;k>l;k--){
                            if(temp[i].childNodes[k].nodeType==1){
                              n++;
                              if(parseInt(formula)!=formula){
                                for(var m=0;m<num.length;m++){
                                  if(n==num[m]){
                                    temp_out[temp_out.length]=temp[i].childNodes[k];
                                  }
                                }
                              }else if(n==formula){
                                temp_out[temp_out.length]=temp[i].childNodes[k];
                              }
                            }
                          }
                        }
                      }
                      break;
                    }
                    case 'nth-of-type':{
                      parent=new Array();
                      for(var i=0, j=temp.length;i<j;i++){
                        if(temp[i].parentNode){
                          var check=0;
                          for(x in parent){
                            if(temp[i].parentNode==parent[x]){
                              check=1;
                            }
                          }
                          if(!check){
                            parent.push(temp[i].parentNode);
                          }
                        }
                      }
                      for(var i=0, j=parent.length;i<j;i++){
                        if(parent[i].childNodes && parent[i].childNodes.length){
                          n=0;
                          for(var k=0, l=parent[i].childNodes.length;k<l;k++){
                            if(parent[i].childNodes[k].nodeType==1){
                              n++;
                              if(parseInt(formula)!=formula){
                                for(var m=0;m<num.length;m++){
                                  if(n==num[m] && parent[i].childNodes[k].tagName==parent[i].tagName){
                                    temp_out[temp_out.length]=parent[i].childNodes[k];
                                  }
                                }
                              }else if(n==formula && parent[i].childNodes[k].tagName==parent[i].tagName){
                                temp_out[temp_out.length]=parent[i].childNodes[k];
                              }
                            }
                          }
                        }
                      }
                      break;
                    }
                    case 'nth-last-of-type':{
                      parent=new Array();
                      for(var i=0, j=temp.length;i<j;i++){
                        if(temp[i].parentNode){
                          var check=0;
                          for(x in parent){
                            if(temp[i].parentNode==parent[x]){
                              check=1;
                            }
                          }
                          if(!check){
                            parent.push(temp[i].parentNode);
                          }
                        }
                      }
                      for(var i=0, j=parent.length;i<j;i++){
                        if(parent[i].childNodes && parent[i].childNodes.length){
                          n=0;
                          for(var k=parent[i].childNodes.length-1, l=0;k>l;k--){
                            if(parent[i].childNodes[k].nodeType==1){
                              n++;
                              if(parseInt(formula)!=formula){
                                for(var m=0;m<num.length;m++){
                                  if(n==num[m] && parent[i].childNodes[k].tagName==parent[i].tagName){
                                    temp_out[temp_out.length]=parent[i].childNodes[k];
                                  }
                                }
                              }else if(n==formula && parent[i].childNodes[k].tagName==parent[i].tagName){
                                temp_out[temp_out.length]=parent[i].childNodes[k];
                              }
                            }
                          }
                        }
                      }
                      break;
                    }
                  }
                }
              }
            }
            break;
          }
        }
      } 
    }
  }
  function isSelector(str){
    for(var x in sep){
      if(sep[x]==str){
        return 1;
      }
    }
    return 0;
  }
  function nodeRun(sep, value, node, out){
    if(!out){var out=new Array();}
    if(!isArray(node)){node=new Array(node);}
    for(var x in node){
      if(node[x].nodeType==1){
        var children=node[x].childNodes;
        var childlen=children.length;
        for(var i=0;i<childlen;i++){
          if(children[i].nodeType==1){
            if(trueSelector(children[i], sep, value)){
              out[out.length]=children[i];
            }
            nodeRun(sep, value, children[i], out);
          }
        }
      }
    }
    return out;
  }
  function trueSelector(element, selector, value){
    if(element){
      switch(selector){
        case 'tag':{
          if(element.tagName && element.tagName.toLowerCase()==value){
            return 1;
          }
          break;
        }
        case '#':{
          if(element.id==value){
            return 1;
          }
          break;
        }
        case '.':{
          if(element.className.indexOf(' ')!=-1){
            var split=element.className.split(' ');
            for(var i=0;i<split.length;i++){
              if(split[i]==value){
                return 1;
              }
            }
          }else if(element.className==value){
            return 1;
          }
          break;
        }
        case '[':{
          value=value.substring(0, value.length-1);
          
          if(value.search(/=/)!=-1){
            var attr=value.substring(0, value.indexOf('='));
            var prev=value.substring(attr.length, attr.length+1);
            var attr_value=value.substring(attr.length+1, value.length);
            //alert(element.attributes['class']);
            
            
            if(attribute(element, attr) || attribute(element, attr+prev)){
              switch(prev){
                case '~':{
                  if(attribute(element, attr).indexOf(' ')!=-1){                  
                    var split=element.attributes[attr].split(' ');
                    for(var i=0;i<split.length;i++){
                      if(split[i]==attr_value){
                        return 1;
                      }
                    }
                  }else if(attribute(element, attr)==attr_value){
                    return 1;
                  }
                  break;
                }
                case '^':{
                  if(attribute(element, attr).substring(0, attr_value.length)==attr_value){                  
                    return 1;
                  }
                  break;
                }
                case '$':{
                  if(attribute(element, attr).substring(0, attr_value.length)==attr_value){                  
                    return 1;
                  }
                  break;
                }
                case '*':{
                  if(attribute(element, attr).indexOf(attr_value)!=-1){                  
                    return 1;
                  }
                  break;
                }
                case '|':{
                  if(attribute(element, attr).indexOf('-')!=-1 && element.attributes[attr].substring(0, attr_value.length)==attr_value){                  
                    return 1;
                  }
                  break;
                }
                case '!':{
                  if(attribute(element, attr)!=attr_value){                  
                    return 1;
                  }
                  break;
                }
                default:{
                  attr=value.substring(0, value.indexOf('='));
                  
                  if(attribute(element, attr).indexOf(' ')!=-1){
                    var split=attribute(element, attr).split(' ');
                    for(var i=0;i<split.length;i++){
                      if(split[i]==attr_value){
                        return 1;
                      }
                    }
                  }else if(attribute(element, attr)==attr_value){
                    return 1;
                  }
                }
              }
            }
          }else{
            if(attribute(element, value)){
              return 1;
            }
          }
          break;
        }
      }
    }
    return 0;
  }
  function attribute(element, value){
    if(element.hasAttribute){
      if(element.hasAttribute(value)){
        return element.getAttribute(value);
      }
    }else{
      //alert();
      return element.getAttribute(value);
    }
  }
  if(temp_out){
    this.output=this.output.concat(temp_out);
  }
 
  this.length=this.output.length;
  if(this.output.length==1){
    this.output=this.output[0];
    this.length=1;
  }else if(!this.output.length){
    return 0;
  }
  return this;
}
function isArray(a){
  if(typeof a=='object' && a.constructor==Array){
    return 1;
  }
  return 0;
}

selector.prototype.focus=function(){
  if(isArray(this.output)){
    for(x in this.output){
      this.output[x].focus();
    }
  }else{
    this.output.focus();
  }
}
selector.prototype.blur=function(){
  if(isArray(this.output)){
    for(x in this.output){
      this.output[x].blur();
    }
  }else{
    this.output.blur();
  }
}
selector.prototype.css=function(style, value){
  if(style){
    if(style.indexOf('-')!=-1){
      style=style.substring(0, style.indexOf('-'))+style.substring(style.indexOf('-')+1, style.indexOf('-')+2).toUpperCase()+style.substring(style.indexOf('-')+2, style.length);
    }
    if(style=='float'){style='cssFloat';}
    if(value){
      if(isArray(this.output)){
        for(x in this.output){
          if(isArray(value) && value.length){
          eval('this.output['+x+'].style.'+style+'="'+value[0]+'"');
          var _self=this.output[x];
          var y=setInterval(function(){eval('if('+value.length+'){value=value.splice(1, value.length);_self.style.'+style+'="'+value[0]+'";}else{clearInterval(y);}');}, 50);
          }else{
            eval('this.output['+x+'].style.'+style+'="'+value+'"');
          }
        }
      }else{
        if(isArray(value) && value.length){
          eval('this.output.style.'+style+'="'+value[0]+'"');
          var _self=this.output;
          var y=setInterval(function(){eval('if('+value.length+'){value=value.splice(1, value.length);_self.style.'+style+'="'+value[0]+'";}else{clearInterval(y);}');}, 50);
        }else{
          eval('this.output.style.'+style+'="'+value+'"');
        }
      }
    }else{
      if(isArray(this.output)){
        for(x in this.output){
          return eval('window.getComputedStyle(this.output['+x+'], null).'+style);
        }
      }else{
        return eval('window.getComputedStyle(this.output, null).'+style);
      }
    }
  }
}
selector.prototype.attr=function(attr, value){
  if(attr){
    if(value){
      if(this.output){
        if(isArray(this.output)){
          for(x in this.output){
            this.output[x].setAttribute(attr, value);
          }
        }else{
          this.output.setAttribute(attr, value);
        }
      }
    }else{
      if(this.output){
        if(isArray(this.output)){
          var temp=new Array();
          for(x in this.output){
            if(!is_ie){
              if(this.output[x].hasAttribute(attr)){
                temp.push(this.output[x].getAttribute(attr));
              }
            }else{
              alert();
              temp.push(this.output[x].attributes[attr]);
            }
          }
          return temp;
        }else{
          if(this.output.hasAttribute){
            if(this.output.hasAttribute(value)){
              return this.output.getAttribute(attr);
            }
          }else{
            return this.output.attributes[attr];
          }
        }
      }
      return 0;
    }
  }
}
selector.prototype.removeAttr=selector.prototype.removeAttribute=function(attr){
  if(attr){
    if(this.output){
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].removeAttribute(attr);
        }
      }else{
        this.output.removeAttribute(attr);
      }
      return 1;
    }
  }
  return 0;
}
selector.prototype.addClass=function(cName){
  if(cName){
    if(this.output){
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].className+=' '+cName;
        }
      }else{
        this.output.className+=' '+cName;
      }
      return 1;
    }
  }
  return 0;
}
selector.prototype.removeClass=function(cName){
  if(cName){
    if(this.output){
      if(isArray(this.output)){
        for(x in this.output){
          if(this.output[x].className){
            var arrClass=this.output[x].className.split(' ');
            this.output[x].className='';
            for(var i=0;i<arrClass.length;i++){
              if(arrClass[i]!=cName){
                this.output[x].className+=' '+arrClass[i];
              }
            }
          }
        }
      }else{
        if(this.output.className){
          var arrClass=this.output.className.split(' ');
          this.output.className='';
          for(var i=0;i<arrClass.length;i++){
            if(arrClass[i]!=cName){
              this.output.className+=' '+arrClass[i];
            }
          }
        }
      }
      return 1;
    }
  }
  return 0;
}
selector.prototype.html=selector.prototype.innerHTML=function(html){
  if(html){
    if(this.output){
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].innerHTML=html;
        }
      }else{
        this.output.innerHTML=html;
      }
      return 1;
    }
  }else{
    if(this.output){
      if(isArray(this.output)){
        var temp=new Array();
        for(x in this.output){
          temp.push(this.output[x].innerHTML);
        }
        return temp;
      }else{
        return this.output.innerHTML;
      }
    }
  }
  return 0;
}
selector.prototype.text=selector.prototype.innerText=function(text){
  if(text){
    if(this.output){
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].innerText=text;
        }
      }else{
        this.output.innerText=text;
      }
      return 1;
    }
  }else{
    if(this.output){
      if(isArray(this.output)){
        var temp=new Array();
        for(x in this.output){
          temp.push(this.output[x].innerText);
        }
        return temp;
      }else{
        return this.output.innerText;
      }
    }
  }
  return 0;
}
selector.prototype.val=selector.prototype.value=function(value){
  if(value){
    if(this.output){
      if(isArray(this.output)){
        var temp=new Array();
        for(x in this.output){
          var tag=this.output[x].tagName.toLowerCase();
          if(tag=='input' || tag=='select' || tag=='textarea'){
            switch(tag){
              case 'input':{
                var type=this.output[x].type.toLowerCase();
                switch(type){
                  case 'checkbox':
                  case 'radio':{
                    if((this.output[x].checked && this.output[x].value!=value) || (!this.output[x].checked && this.output[x].value==value)){
                      this.output[x].click();
                    }
                    break;
                  }
                  default:{
                    this.output[x].value=value;
                  }
                }
                break;
              }
              case 'select':{
                for(var i=0;i<this.output[x].getElementsByTagName('option').length;i++){
                  if((this.output[x].getElementsByTagName('option')[i].selected && this.output[x].getElementsByTagName('option')[i].value!=value) || (!this.output[x].getElementsByTagName('option')[i].selected && this.output[x].getElementsByTagName('option')[i].value==value)){
                    this.output[x].getElementsByTagName('option')[i].click();
                  }
                }
                break;
              }
              case 'textarea':{
                this.output[x].value=value;
              }
            }
          }
        }
      }else{
        var tag=this.output.tagName.toLowerCase();
        if(tag=='input' || tag=='select' || tag=='textarea'){
          switch(tag){
            case 'input':{
              var type=this.output.type.toLowerCase();
              switch(type){
                case 'checkbox':
                case 'radio':{
                  break;
                }
                default:{
                  this.output.value=value;
                }
              }
              break;
            }
            case 'select':{
              var temp=new Array();
              for(var i=0;i<this.output.getElementsByTagName('option').length;i++){
                if((this.output.getElementsByTagName('option')[i].selected && this.output.getElementsByTagName('option')[i].value!=value) || (!this.output.getElementsByTagName('option')[i].selected && this.output.getElementsByTagName('option')[i].value==value)){
                  this.output.getElementsByTagName('option')[i].click();
                }
              }
              return temp;
              break;
            }
            case 'textarea':{
              return this.output.value;
            }
          }
        }
      }
      return 1;
    }
  }else{
    if(this.output){
      if(isArray(this.output)){
        var temp=new Array();
        for(x in this.output){
          var tag=this.output[x].tagName.toLowerCase();
          if(tag=='input' || tag=='select' || tag=='textarea'){
            switch(tag){
              case 'input':{
                var type=this.output[x].type.toLowerCase();
                switch(type){
                  case 'checkbox':{
                    if(this.output[x].checked){
                      temp.push(this.output[x].value);
                    }else{
                      temp.push('0');
                    }
                    break;
                  }
                  case 'radio':{
                    if(this.output[x].checked){
                      temp.push(this.output[x].value);
                    }
                    break;
                  }
                  default:{
                    temp.push(this.output[x].value);
                  }
                }
                break;
              }
              case 'select':{
                for(var i=0;i<this.output[x].getElementsByTagName('option').length;i++){
                  if(this.output[x].getElementsByTagName('option')[i].selected){
                    temp.push(this.output[x].getElementsByTagName('option')[i].value);
                  }
                }
                break;
              }
              case 'textarea':{
                temp.push(this.output[x].value);
              }
            }
            return temp;
          }
        }
      }else{
        var tag=this.output.tagName.toLowerCase();
        if(tag=='input' || tag=='select' || tag=='textarea'){
          switch(tag){
            case 'input':{
              var type=this.output.type.toLowerCase();
              switch(type){
                case 'checkbox':{
                  if(this.output.checked){
                    return this.output.value;
                  }else{
                    return 0;
                  }
                  break;
                }
                case 'radio':{
                  if(this.output.checked){
                    return this.output.value;
                  }
                  break;
                }
                default:{
                  return this.output.value;
                }
              }
              break;
            }
            case 'select':{
              var temp=new Array();
              for(var i=0;i<this.output.getElementsByTagName('option').length;i++){
                if(this.output.getElementsByTagName('option')[i].selected){
                  temp.push(this.output.getElementsByTagName('option')[i].value);
                }
              }
              return temp;
              break;
            }
            case 'textarea':{
              return this.output.value;
            }
          }
        }
      }
    }
  }
  return 0;
}
selector.prototype.childrens=selector.prototype.childrenNodes=function(){
  if(isArray(this.output)){
    var temp=new Array();
    for(x in this.output){
      temp.push(this.output[x].childrenNodes);
    }
    return temp;
  }else{
    return this.output.childrenNodes;
  }
}
selector.prototype.next=selector.prototype.nextSibling=function(){
  if(isArray(this.output)){
    var temp=new Array();
    for(x in this.output){
      temp.push(this.output[x].nextSibling);
    }
    return temp;
  }else{
    return this.output.nextSibling;
  }
}
selector.prototype.prev=selector.prototype.previousSibling=function(){
  if(isArray(this.output)){
    var temp=new Array();
    for(x in this.output){
      temp.push(this.output[x].previousSibling);
    }
    return temp;
  }else{
    return this.output.previousSibling;
  }
}
selector.prototype.parent=selector.prototype.parentNode=function(){
  if(isArray(this.output)){
    var temp=new Array();
    for(x in this.output){
      temp.push(this.output[x].parentNode);
    }
    return temp;
  }else{
    return this.output.parentNode;
  }
}
selector.prototype.append=selector.prototype.appendChild=function(html){
  var type='object';
  if(typeof html=='string'){
    type='string';
  }
  switch(type){
    case 'object':{
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].appendChild(html);
        }
      }else{
        this.output.appendChild(html);
      }
      break;
    }
    case 'string':{
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].innerHTML+=html;
        }
      }else{
        this.output.innerHTML+=html;
      }
      break;
    }
  }
}
selector.prototype.after=selector.prototype.insertAfter=function(html){
  var type='object';
  if(typeof html=='string'){
    type='string';
  }
  switch(type){
    case 'object':{
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].parentNode.insertBefore(html, this.output[x].nextSibling);
        }
      }else{
        this.output.parentNode.insertBefore(html, this.output.nextSibling);
      }
      break;
    }
    case 'string':{
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].innerHTML+=html;
        }
      }else{
        this.output.innerHTML+=html;
      }
      break;
    }
  }
}
selector.prototype.before=selector.prototype.insertBefore=function(html, object){
  var type='object';
  if(typeof html=='string'){
    type='string';
  }
  switch(type){
    case 'object':{
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].insertBefore(html, object);
        }
      }else{
        this.output.insertBefore(html, object);
      }
      break;
    }
    case 'string':{
      if(isArray(this.output)){
        for(x in this.output){
          this.output[x].innerHTML=html+this.output[x].innerHTML;
        }
      }else{
        this.output.innerHTML=html+this.output.innerHTML;
      }
      break;
    }
  }
}
selector.prototype.first=selector.prototype.firstChild=function(){
  var arr=new Array();
  if(isArray(this.output)){
    for(x in this.output){
      arr.push(this.output[x].firstChild);
    }
  }else{
    arr.push(this.output.firstChild);
  }
  if(arr.length==1){
    return arr[0];
  }
  return arr;
}
selector.prototype.empty=function(){
  if(isArray(this.output)){
    for(x in this.output){
      this.output[x].innerHTML='';
    }
  }else{
    this.output.innerHTML='';
  }
}
selector.prototype.remove=function(){
  if(isArray(this.output)){
    for(x in this.output){
      this.output[x].parentNode.removeChild(this.output[x]);
    }
  }else{
    this.output.parentNode.removeChild(this.output);
  }
}

var agt=navigator.appName;
var is_ie=((agt.indexOf("msie")!=-1) && (agt.indexOf("opera")==-1));
var is_ie5=((agt.indexOf("msie 5")!=-1) && (agt.indexOf("opera")==-1));
var is_ie6=((agt.indexOf("msie 6")!=-1) && (agt.indexOf("opera")==-1));
var is_ie7=((agt.indexOf("msie 7")!=-1) && (agt.indexOf("opera")==-1));

var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
var is_opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1);
var is_opera8 = (agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1);
var is_opera9 = (agt.indexOf("opera 9") != -1 || agt.indexOf("opera/9") != -1);

var is_gecko = (agt.indexOf('gecko') != -1);