function stopEvent(e) 
{ 
    e = e || event; 
    e.stopPropagation? e.stopPropagation() : e.cancelBubble = true; 
}

/*
if(typeof document.getElementsByClassName != 'function')
{
  Object.prototype.getElementsByClassName = function(classname, node)
  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
    if(re.test(els[i].className))a.push(els[i]);
    return a;
  }
}
*/

(function(w)
{
  var rh = function(s, c)
    {
      return new rh.fn.init(s, c);
    },
    boundReady = false,
    readyList = [],
    onLoad,
    slice = Array.prototype.slice;
  
  rh.fn = rh.prototype = {
    length:0,
    pointer:0,
    rhCMSObject:true,
    init: function(s, c)
    {
      if(!c)
        var c = document;
      
      if(!s)
        return this;
      
      if(typeof s === 'string')
      {
        // divide in parts
        
        var p = s.split(',');
        
        for(var i=0;i < p.length; i++)
        {
          var pt = p[i];
          
          if(typeof pt == 'function')
          	continue;
				
          if((pos = pt.indexOf('#')) != -1)
          {
            var sep = pt.split('#');
            
            var e = c.getElementById(sep[1]);
            
            if(sep[0] && e.tagName != sep[0]) // not correct tag for this ID
              continue;
            
            if(e)
            {
              this[this.length++] = e;
            }
          }
          else if((pos = pt.indexOf('.')) != -1)
          {
            var sep = pt.split('.');
            
            var obj = this;
            
            if(c.rhCMSObject)
            {
              c.each(function()
              {
                var e = this.getElementsByClassName(sep[1]);
                rh.merge(obj, e);
              });
            }
            else
            {
            	if(sep[0].length)
            	{
            		rh(sep[0], c).each(function()
								{
									if(rh(this).hasClass(sep[1]))
									{
	                	rh.append(obj, this);
	  							}
	            	});
            	}
            	else
            	{
            		var e = c.getElementsByClassName(sep[1]);
                rh.merge(obj, e);
            	}
            }
          }
          else
          {
            rh.merge(this, c.getElementsByTagName(s));
          }
        }
        
        return this;
      }
      else if(rh.isFunc(s))
      {
        this.ready(s, c);
        return this;
      }
      else if(s.nodeType)
      {
        this[0] = s;
        this.length = 1;
      }
      else if(typeof s === 'object')
      {
        return rh.merge(this, s);
      }
    },
    ready : function(f, c)
    {
      rh.bindReady();
      
      if(typeof c === 'undefined')
        var c = document;
      
      if(rh.isReady)
      {
        f();
      }
      else
      {
        readyList.push([f,c]);
      }
    },
    each : function(c, a)
    {
      return rh.each(this, c, a);
    },
    toArray : function()
    {
      return slice.call(this, 0);
    },
    reset : function(x)
    {
      this.pointer = !x || x > 0 ? 0 : this.length-1;
      
      return this;
    },
    next : function(f)
    {
      if(!this[this.pointer])
        return false;
      
      f.call(this, this[this.pointer++]);
      
      return this;
    },
    previous : function(f)
    {
      if(!this[this.pointer])
        return false;
      
      f.call(this, this[this.pointer--]);
      
      return this;
    },
    current : function(f)
    {
      if(!this[this.pointer])
        return false;
      
      return rh(this[this.pointer]);
    },
    get : function(p)
    {
      return this[!p ? 0 : p];
    }
  }
  
  rh.fn.init.prototype = rh.fn;
  
  rh.extend = rh.fn.extend = function(a)
  {
    for(key in a)
    {
      rh[key] = a[key];
    }
  }
  
  // Extend the RH function itself
  
  rh.extend({
    isFunc : function(f)
    {
      return typeof f === 'function';
    },
    bindReady : function()
    {
      if(boundReady)
        return;
      
      boundReady = true;
      
      if (document.readyState === "complete" )
      {
  			return rh.ready();
  		}
      
      if ( document.addEventListener )
      {
			  document.addEventListener( "DOMContentLoaded", onLoad, false );
		  }
      else if ( document.attachEvent )
      {
			  document.attachEvent("onreadystatechange", onLoad);
      }
    },
    isReady: false,
    ready: function()
    {
      if(rh.isReady)
        return;
      
      rh.isReady = true;
      
      if(!readyList)
        return;
      
      var fn, i = 0;
			while((fn = readyList[i++]))
      {
				fn[0].call(fn[1]);
			}
    },
    each: function(o, c, a)
    {
      var name, l = o.length, isObj = l || rh.isFunc((o));
      
      if(a)
      {
        for(name in o)
        {
          c.apply(o[name], a);
        }
      }
      else
      {
        if(isObj)
        {
          for(var name=0;name<o.length;name++)
          {
            c.call(o[name]);
          }
        }
        else if(o.length > 0)
        {
          c.call(o[0]);
        }
      }
      
      return o;
    },
    merge: function(o, a)
    {
      i = o.length;
      
      for(var c=0;c<a.length;c++)
      {
        o[i++] = a[c];
      }
      
      o.length = i;
      
      return o;
    },
    append: function(o, e)
    {
    	o[o.length++] = e;
    }
  });
  
  if(document.addEventListener)
  {
  	onLoad = function()
    {
  		document.removeEventListener("DOMContentLoaded", onLoad, false);
  		rh.ready();
  	};
  
  }
  else if(document.attachEvent)
  {
  	onLoad = function()
    {
  		if(document.readyState === "complete" )
      {
  			document.detachEvent("onreadystatechange", onLoad);
  			rh.ready();
  		}
  	};
  }
  
  w.rh = rh;
})(window);

/* hide */

(function(rh)
{
  rh.fn.hide = function()
  {
    return this.each(function()
    {
      this.style.display = 'none';
    });
  }
})(rh);

/* hidden */

(function(rh)
{
  rh.fn.hidden = function(i)
  {
    return (this.get().style.display == 'none' || this.get().style.display == '');
  }
})(rh);

/* hide */

(function(rh)
{
  rh.fn.show = function(t)
  {
    return this.each(function()
    {
      this.style.display = (typeof t == 'undefined') ? 'block' : t;
    });
  }
})(rh);

/* set width */

(function(rh)
{
  rh.fn.width = function(w)
  {
    return this.each(function()
    {
      this.style.width = w;
    });
  }
})(rh);

/* set height */

(function(rh)
{
  rh.fn.height = function(h)
  {
    return this.each(function()
    {
      this.style.height = h;
    });
  }
})(rh);

/* set CSS */

(function(rh)
{
  rh.fn.css = function(p)
  {
    return this.each(function()
    {
      for(name in p)
      {
        this.style[name] = p[name];
      }
    });
  }
})(rh);

/* click */

(function(rh)
{
  rh.fn.submit = function(cb)
  {
    return this.each(function()
    {
      this.onsubmit = cb;
    });
  }
})(rh);

/* click */

(function(rh)
{
  rh.fn.click = function(cb)
  {
    return this.each(function()
    {
      this.onclick = cb;
    });
  }
})(rh);

/* dblclick */

(function(rh)
{
  rh.fn.dblclick = function(cb)
  {
    return this.each(function()
    {
      this.ondblclick = cb;
    });
  }
})(rh);

/* onMouseOver */

(function(rh)
{
  rh.fn.mouseover = function(cb)
  {
    return this.each(function()
    {
      this.onmouseover = cb;
    });
  }
})(rh);

/* onMouseOut */

(function(rh)
{
  rh.fn.mouseout = function(cb)
  {
    return this.each(function()
    {
      this.onmouseout = cb;
    });
  }
})(rh);

/* focus */

(function(rh)
{
  rh.fn.focus = function(cb)
  {
    return this.each(function()
    {
      this.onfocus = cb;
    });
  }
})(rh);

/* blur */

(function(rh)
{
  rh.fn.blur = function(cb)
  {
    return this.each(function()
    {
      this.onblur = cb;
    });
  }
})(rh);

/* change */

(function(rh)
{
  rh.fn.change = function(cb)
  {
    return this.each(function()
    {
      this.onchange = cb;
    });
  }
})(rh);

/* keyup */

(function(rh)
{
  rh.fn.keyup = function(cb)
  {
    return this.each(function()
    {
      this.onkeyup = cb;
    });
  }
})(rh);

/* keydown */

(function(rh)
{
  rh.fn.keydown = function(cb)
  {
    return this.each(function()
    {
      this.onkeydown = cb;
    });
  }
})(rh);

/* Append HTML Element */

(function(rh)
{
  rh.fn.append = function(o, p)
  {
    if(typeof o === 'string')
      o = document.createElement(o);
    
    if(p)
    {
      for(name in p)
      {
        o.setAttribute(name, p[name] === null ? name : p[name], 0);
      }
    }
    
    this[0].appendChild(o);
    
    return rh(o);
  }
})(rh);

(function(rh)
{
  rh.fn.before = function(o)
  {
    if(typeof o === 'string')
      o = document.createElement(o);
    
    this[0].parentNode.insertBefore(o, this[0]);
    
    return rh(o);
  }
})(rh);

(function(rh)
{
  rh.fn.remove = function(o)
  {
    this.each(function()
    {
      this.parentNode.removeChild(this);
    });
  }
})(rh);

/* Fills a element with subelements */

(function(rh)
{
  rh.fn.fill = function(o, num, p)
  {
    if(typeof num === 'undefined')
      var num = 1;
    
    var list = [];
    
    this.each(function(){
      for(var i=1;i<=num;i++)
        list.push(rh(this).append(o, p)[0]);
    });
    
    return rh(list);
  }
})(rh);

/* Append HTML Element */

(function(rh)
{
  rh.fn.first = function(o, p)
  {
    if(typeof o === 'string')
      o = document.createElement(o);
    
    if(p)
    {
      for(name in p)
      {
        o.setAttribute(name, p[name] === null ? name : p[name], 0);
      }
    }
    
    this[0].insertBefore(o, this[0].firstChild);
    
    return rh(o);
  }
})(rh);

/* overwrites the current className property */

(function(rh)
{
  rh.fn.setClass = function(c)
  {
    return this.each(function(){
      this.className = c;
    });
  }
})(rh);

/* overwrites the current className property */

(function(rh)
{
  rh.fn.hasClass = function(c)
  {
    var classList = this.get().className.split(' ');
    
    for(name in classList)
    {
      if(c == classList[name])
        return true;
    }
    
    return false;
  }
})(rh);

/* overwrites the current className property */

(function(rh)
{
  rh.fn.removeClass = function(c)
  {
    return this.each(function(){
      var i = this.className.indexOf(c);
      if(i != -1)
      {
        this.className = this.className.substr(0,i) + this.className.substr(i+c.length);
      }
    });
  }
})(rh);

/* removes all classes */

(function(rh)
{
  rh.fn.removeClasses = function(c)
  {
    return this.each(function(){
      this.className = '';
    });
  }
})(rh);

/* adds a classname the current className property */

(function(rh)
{
  rh.fn.addClass = function(c)
  {
    return this.each(function()
    {
      var classes = this.className.split(' ');
      for(name in classes)
      {
        if(classes[name] == c)
          return;
      }
      
      this.className += (this.className.length > 0 ? ' ' : '') + c;
    });
  }
})(rh);

/* Sets innerHTML */

(function(rh)
{
  rh.fn.html = function(html)
  {
    return this.each(function()
    {
      this.innerHTML = html;
    });
  }
})(rh);

/* Set the .value */

(function(rh)
{
  rh.fn.value = function(v)
  {
    if(typeof v == 'undefined')
      return this.get(0).value;
    
    return this.each(function()
    {
      this.value = v;
    });
  }
})(rh);

/* Enables an element */

(function(rh)
{
  rh.fn.enable = function()
  {
    return this.each(function()
    {
      this.disabled = false;
    });
  }
})(rh);

/* Disabled an element */

(function(rh)
{
  rh.fn.disable = function()
  {
    return this.each(function()
    {
      this.disabled = true;
    });
  }
})(rh);

/* Sets a attribute */

(function(rh)
{
  rh.fn.set = function(k, v)
  {
    return this.each(function()
    {
      this.setAttribute(k, v);
    });
  }
})(rh);

/* Opens a popup from a link */

(function(rh)
{
  rh.fn.popup = function(o)
  {
    return this.each(function()
    {
      rh(this).click(function(event)
      {
        var event = event || window.event;
        
        try
        {
          event.preventDefault();
        }
        catch(e)
        {
          
        }
        
        o = o || {};
        
        var w = window.open(this.href ? this.href : o.url, this.name ? this.name : (o.name ? o.name : 'popup'), "dependent=no,hotkeys=yes,menubar=no,resizable=yes,location=yes,status=yes,toolbar=no,scrollbars=yes,left=" + (o.left ? o.left : 100) +
        ',top=' + (o.top ? o.top : 100) +
        ',width=' + (o.width ? o.width : 400) +
        ',height=' + (o.height ? o.height : 600));
        w.focus();
      })
    });
  }
})(rh);

/* get parent */

(function(rh)
{
  rh.fn.parent = function(tag)
  {
    var p = false;
    
    this.each(function()
    {
      if(p)
        return;
      
      node = this;
      
      while((node = node.parentNode) && node.tagName && node.tagName.toLowerCase() !== 'body')
      {
        if(node.tagName.toLowerCase() == tag.toLowerCase())
        {
          p = node;
          return;
        }
        
      }
    });
    
    if(!p)
      return false;
    
    return rh(p);
  }
})(rh);

/* filter elements */

(function(rh)
{
  rh.fn.filterProperty = function(f)
  {
    var filters = {
      selected:function(e)
      {
        return e.selected;
      },
      disabled:function(e)
      {
        return e.disabled;
      },
      enabled:function(e)
      {
        return !e.disabled;
      },
      hasValue:function(e)
      {
        return e.value && e.value  !== '' ? true : false;
      }
    }, tmp = [];
    
    // check if the filter exists
    if(typeof filters[f] === 'function')
      this.each(function()
      {
        if(filters[f](this))
          tmp.push(this);
      });
    
    // return new rh object with results
    return rh(tmp);
  }
})(rh);

/* filter by attributes */

(function(rh)
{
  rh.fn.filterAttribute = function(f, expr)
  {
    var filters = {
      notHasClass	:	function(e)
      {
        return e.getAttribute('class') === null || e.getAttribute('class').indexOf(expr) == -1;
      },
      type				:	function(e)
      {
        return e.getAttribute('type') !== null && e.getAttribute('type').indexOf(expr) != -1;
      }
    }, tmp = [];
    
    // check if the filter exists
    if(typeof filters[f] === 'function')
      this.each(function()
      {
        if(filters[f](this))
          tmp.push(this);
      });
    
    // return new rh object with results
    return rh(tmp);
  }
})(rh);

/* AJAX */

(function(rh)
{
  rh.fn.ajax = function(prop)
  {
    return this.each(function()
    {
      // Make AJAX Request
      
      var xmlObject, that = this;
      
      try
      {
    		xmlObject = new XMLHttpRequest();
    	}
    	catch (e)
    	{
    		try
    		{
    			xmlObject = new ActiveXObject("Msxml2.XMLHTTP");
    		}
    		catch (e)
    		{
    			try
    			{
    				xmlObject = new ActiveXObject("Microsoft.XMLHTTP");
    			}
    			catch (e)
    			{
    				alert("Your browser does not support AJAX!");
    				return false;
    			}
    		}
    	}
      
      xmlObject.onreadystatechange = function()
      {
      	if(xmlObject.readyState == 4)
        {
      		prop.ready.call(that, {
      		  text      : this.responseText,
            xml       : this.responseXML,
            status		: xmlObject.status,
            prop			:	prop
      		});
      	}
      };
      
      if(typeof prop.type === 'undefined')
        prop.type = 'GET';
      
      prop.url = prop.url.replace('$1', encodeURIComponent(this.value));
      
      if(prop.data)
      {
        for(name in prop.data)
        {
          if(!prop.data[name] || !prop.data[name].length)
            continue;
          
          if(typeof prop.data[name] == 'string')
          {
            prop.url += name + '=' + prop.data[name] + '&';
            continue;
          }
          
          prop.url += name + '[]=' + prop.data[name].join('&' + name + '[]=') + '&';
        }
      }
      
      xmlObject.open(prop.type, prop.url, true);
    	xmlObject.setRequestHeader("Cache-Control", "must-revalidate");
    	xmlObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    	
    	if(prop.type == 'GET')
     	{
     		xmlObject.send(null);
     	}
     	else
     	{
     		var postData = '';
     		if(prop.post)
     		{
     			for(name in prop.post)
        	{
     				postData += name + '=' + prop.post[name] + '&';
    			}
     		}
     		else if(prop.rawPost)
     		{
     			postData = prop.rawPost;
     		}
    		xmlObject.send(postData);
   		}
    });
  }
})(rh);

/* retreives the width */

(function(rh)
{
  rh.fn.getWidth = function()
  {
    return this[0].offsetWidth;
  }
})(rh);

/* retreives the width */

(function(rh)
{
  rh.fn.getHeight = function()
  {
    return this[0].offsetHeight;
  }
})(rh);

/* retreives the top offset */

(function(rh)
{
  rh.fn.getTop = function()
  {
    var top = 0;
    
    var o = this[0];
    
    while(typeof o.offsetTop !== 'undefined' && o.tagName && o.tagName.toLowerCase() !== 'body')
    {
      top += o.offsetTop;
      o = o.offsetParent;
    }
    
    return top;
  }
})(rh);

/* retreives the top offset */

(function(rh)
{
  rh.fn.getLeft = function()
  {
    var left = 0;
    
    var o = this[0];
    
    while(typeof o.offsetLeft !== 'undefined' && o.tagName && o.tagName.toLowerCase() !== 'body')
    {
      left += o.offsetLeft;
      o = o.offsetParent;
    }
    
    return left;
  }
})(rh);

/* top */

(function(rh)
{
  rh.fn.top = function(t)
  {
    return this.each(function(){
      this.style.top = t;
    });
  }
})(rh);

/* left */

(function(rh)
{
  rh.fn.left = function(l)
  {
    return this.each(function(){
      this.style.left = l;
    });
  }
})(rh);

/* start Rotation Images */

(function(rh)
{
  rh.fn.startImageRotation = function(imageList)
  {
    return this.each(function()
		{
      var self = this;
      var x = function()
      {
      	this.tag.current = (this.tag.current + 1) % this.tag.images.length;
      	this.src = this.tag.images[this.tag.current];
      }
      self.tag = {
    		interval:window.setInterval(x.bind(self), 500),
    		images:imageList,
    		current:0
			};
			x.call(self);
    });
  }
})(rh);

/* stop Rotation Images */

(function(rh)
{
  rh.fn.stopImageRotation = function(imageList)
  {
    return this.each(function()
		{
			window.clearInterval(this.tag.interval);
			this.src = this.tag.images[0];
			this.tag.interval = null;
    });
  }
})(rh);

/* Slider */


(function(rh)
{
  rh.fn.slider = function(options)
  {
    return this.each(function(){
      
      this.options = options;
      
      this.slider = document.getElementById(options.id);
      
      this.slide_left = document.getElementById(options.id + '_left');
      
      this.slide_right = document.getElementById(options.id + '_right');
      
      this.slide_ul = this.slider.getElementsByTagName('ul')[0];
      
      if(!this.slider ||!this.slide_left || !this.slide_right || !this.slide_ul)
        return;
      
      var that = this;
      
      if(typeof this.options.onElementClick === 'function')
      {
        var elements = this.slide_ul.getElementsByTagName('img');
        for(e=0;e<elements.length;++e)
        {
          elements[e].tag = this;
          elements[e].onclick = function()
          {
            this.tag.options.onElementClick(this, that.slider);
          }
        }
      }
      
      this.width_slider = this.slider.offsetWidth;
      
      this.slide_direction = false;
      this.slide_interval = null;
      
      this.slide_left.tag = this;
      this.slide_left.onmousedown = function()
      {
        this.tag.startSlide('-');
      }
      
      this.slide_left.onmouseup = function()
      {
        this.tag.stopSlide();
      }
      
      this.slide_right.tag = this;
      this.slide_right.onmousedown = function()
      {
        this.tag.startSlide('+');
      }
      
      this.slide_right.onmouseup = function()
      {
        this.tag.stopSlide();
      }
      
      this.startSlide = function(direction)
      {
        that.slide_direction = direction;
        that.slide();
        that.slide_interval = window.setInterval(that.slide, 12);
      }
      
      this.stopSlide = function()
      {
        that.slide_direction = false;
        window.clearInterval(that.slide_interval);
        that.slide_interval = null;
      }
      
      this.slide = function()
      {
        if(that.slide_direction === false)
          return;
        
        var margin = that.slide_ul.style.marginLeft;
        
        if(margin === '')
        {
          margin = '0px';
        }
        
        margin = parseInt(margin.substr(0,margin.indexOf('px')));
        
        var width_ul = parseInt(that.slide_ul.offsetWidth);
        
        switch(that.slide_direction)
        {
          case '+' :
            if(margin < that.width_slider - width_ul)
            {
              that.stopSlide();
              return;
            }
            
            that.slide_ul.style.marginLeft = margin - 1 + 'px';
          break;
          case '-' :
            if(margin >= 0)
            {
              that.stopSlide();
              return;
            }
        
            that.slide_ul.style.marginLeft = margin + 1 + 'px';
          break;
        }
      }
    });
  }
})(rh);

/* toggle */

(function(rh)
{
  rh.fn.toggleProperty = function(property, id1, id2, state1, state2, type, container)
  {
    return this.each(function()
    {
      var obj1 = document.getElementById(id1);
      var obj2 = document.getElementById(id2);
      
      if(type === '1' && obj1.style[property] === state2) // switch 1 back to state1
      {
        obj1.style[property] = state1;
        obj2.style[property] = state2;
        
        if(typeof container !== 'undefined')
        {
          document.getElementById(container.id).className = container.class1;
        }
      }
      else if(type === '2' && obj2.style[property] !== state1) // switch 2 to state2
      {
        obj1.style[property] = state2;
        obj2.style[property] = state1;
        
        if(typeof container !== 'undefined')
        {
          document.getElementById(container.id).className = container.class2;
        }
      }
      
    });
  }
})(rh);

/* toggle */


(function(rh)
{
  rh.fn.toggleCSSProperty = function(property, state1, state2)
  {
    return this.each(function()
    {
      var x = rh(this);
      
      if(x.hasClass(state1))
      {
        x.setClass(state2);
      }
      else
      {
        x.setClass(state1);
      }
    });
  }
})(rh);

(function(rh)
{
  rh.fn.animate = function(type, p)
  {
  	var p = p || {};
  	var offset = p.begin ? p.begin : 500;
  	
  	if(!p.speed)
  		p.speed = 10;
 		
 		if(!p.delay)
 			p.delay = 100;
 		
 		var steps = 100 / p.speed;
 		
 		if(steps < 1)
 			steps = 1;
  	
    return this.each(function()
    {
    	window.setTimeout(function()
			{
				var obj = this.that;
				var offset = this.offset;
				obj.interval = window.setInterval(function()
				{
					if(!this.step)
					{
						this.step = 1;
					}
					else
					{
						this.step++;
					}
					
					var opacity = Math.round( (1 / (this.step + 1 / steps)) * 100) / 100;
					
					if(this.step >= steps || opacity <= 0.1)
					{
						obj.parentNode.removeChild(obj);
					}
			
					this.style.opacity = opacity;
				}.bind(obj), 50);
				
				console.log(offset);
				window.setTimeout(function(){ window.clearInterval(obj.interval); }.bind(obj), offset);
      }.bind({that:this,offset:offset}), offset);
      
      offset += steps * 50;
      offset += p.delay;
    });
  }
})(rh);

/*

(function(rh)
{
  rh.fn.toggleCSSProperty = function(property, state1, state2)
  {
    return this.each(function()
    {
      if(this.style[property] == state1)
      {
        this.style[property] = state2;
      }
      else
      {
        this.style[property] = state1;
      }
    });
  }
})(rh);
*/

/* Suggest */

(function(rh)
{
  rh.fn.suggest = function(o)
  {
    var div = rh('body').first('div').hide().css({position:'absolute'}).setClass('suggest');
		
    var obj = o;
    
    var that = this;
    
    var isEmpty = false;
    
    var ajaxRequest = 0;
    
    div.width(this.getWidth() + 'px');
    div.top(this.getTop() + this.getHeight() + 'px');
    div.left(this.getLeft() + 'px');
    
    var li_list = div.append('ul').fill('li', 15);
    
    var onKeyUp = function(event)
    {
      event = event || window.event;
      
      var self = this;
			
      switch(event.keyCode)
      {
      	case 27 : // Escape
      		div.hide();
      	break;
        case 13 : // RETURN
          if(isEmpty)
          {
            if(o.urlAdd)
            {
              that.ajax({
                url:o.urlAdd,
                data:o.data,
                ready:function(r)
                {
                    o.ready.call(self, rh('element', r.xml).get());
                    rh(that).removeClass('suggest_emptySet');
                }
              });
            }
            
            event.preventDefault();
            
            break;
          }
          
          div.hide();
          
          o.ready.call(self, li_list.current().get().tag);
          
          event.preventDefault();
        break;
        case 38 : // UP
          li_list.previous(function(o)
          {
            try
            {
              li_list.current().setClass('active');
              rh(o).removeClass('active');
            }
            catch(e){
              li_list.reset(1);
            }
          });
        break;
        case 40 : // DOWN
          li_list.next(function(o)
          {
            try
            {
              li_list.current().setClass('active');
              rh(o).removeClass('active');
            }
            catch(e)
            {
              li_list.reset(-1);
            }
          });
        break;
        default :
        	ajaxRequest++;
        	
          that.ajax({
            url:o.url,
            data:o.data,
            'ajaxRequest':ajaxRequest,
            ready:function(r)
            {
            	if(r.prop.ajaxRequest != ajaxRequest)	
            	{
            		return;
            	}
            	// show basic suggest div
              div.show();
              
              // list of all list elements
              li_list
                .hide()
                .reset()
                .removeClasses()
                .current()
                .setClass('active');
              
              // remove all sections
              rh('li.section', div.get()).remove();
              
              // use sections?
              if(o.useSections)
              {
                var sections = rh('section', r.xml).toArray();
              }
              // no sections available
              else
              {
                var sections = [r.xml];
              }
              
              isEmpty = true;
              
              for(i in sections)
              {
                var section = sections[i];
                var elements = rh('element', section);
                
                if(elements.length)
                  isEmpty = false;
                else
                  continue;
                
                try
                {
                  var title = section.getAttribute('title');
                  
                  var html_section = rh(li_list.get(li_list.pointer)).before('li').setClass('section');
                  
                  if(icon = section.getAttribute('icon'))
                  {
                    html_section.addClass('vam');
                    html_section.first('img', { 'src':'admin/img/icons/' + section.getAttribute('icon')});
                    html_section.append('span').html(title);
                  }
                  else
                  {
                    html_section.html(title);
                  }
                }
                catch(e)
                {
                  
                }
                
                elements.each(function()
                {
                  var element = this, value = this.firstChild.data;
                  
                  li_list.next(function(o)
                  {
                    o.tag = element;
                    o = rh(o);
                    o.show().html(value);
                    rh(this).mouseover(function()
										{
											li_list.reset().removeClasses();
                    	rh(this).addClass('active');
                    });
                    rh(this).click(function()
                    {
                      div.hide();
                      obj.ready.call(self, this.tag);
                    });
                    
                  });
                });
                // end elements.each
              }
              
              if(isEmpty)
              {
              	div.hide();
                rh(that).addClass('suggest_emptySet');
              }
              else
              {
                rh(that).removeClass('suggest_emptySet');
              }
              
              li_list.reset();
            }
          });
        break;
      }
    }
    
    this.each(function()
    {
      rh(this).keyup(onKeyUp.bind(this));
      rh(this).keydown(function(event){
        event = event || window.event;
        
        switch(event.keyCode)
        {
          case 13 :
            event.preventDefault();
          break;
        }
      });
    });
    
    return this;
  }
})(rh);
