if(typeof SmallMeans =='undefined'){
 SmallMeans={
  updater : function(url, elemId, callBack) {
  o = new XMLHttpReq(url);
  o.callback = function(responseText, responseStatus)
  {
	 e=SmallMeans.DOM.$(elemId)
	 if(responseStatus == 200) {
		if(e)
		  e.innerHTML = responseText;
		  if(callBack) callBack.call(SmallMeans);
	 }
	 else {
		SmallMeans.DOM.addClass(e,'error');
		e.innerHTML = responseText;
	 }
  };
  o.update('');
 }
 }
}

SmallMeans.DOM = {
 $E: function(tag) {
   return document.getElementsByTagName(tag);
 },
 require: function(src,callback) {
   var script = document.createElement("script");
   script.src = src;
   script.type = "text/javascript";
   this.$E("head")[0].appendChild(script);
   if(callback){
     script.onload=callback;
   }
 },
 createElements:function(args) {
    var el;     
    if( typeof(args) == "string" ) {  
       el = document.createTextNode(args);  
    } else if ( typeof(args) == "object" ) {  
       el = document.createElement( args.tag );  
       if ( args.attributes ) {  
          for ( i in args.attributes ) {  
             el.setAttribute(i, args.attributes[i]);  
          }  
       }  
       if ( args.style ) {  
          for ( i in args.style ) {  
             el.style[i] = args.style[i];  
          }  
       }  
       if ( args.children ) {  
          for ( var i = 0; i < args.children.length; i++ ) {  
             el.appendChild(SmallMeans.DOM.createElements( args.children[i] ) );  
          }  
       }  
    }  
    return el;  
 },
 $: function() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i ++ ) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
 },
 removeClass: function(o,klass){
      o.className = o.className.replace(new RegExp('\\s*\\b'+klass+'\\b'),'') 
 },
 addClass : function(o,klass){
      if(!this.hasClass(o,klass))
         o.className += ' ' + klass; 
 },
  toggleClass : function(elem, klass){
      var func = this.hasClass(elem,klass)?this.removeClass:this.addClass;
      func.apply(this,  new Array(elem,klass));
     //console.log(func+', this: '+this)
 },
 hasClass : function(o,klass){
      if(!o.className)
         return false;
      //note the word boundary \b, no partial match
      return new RegExp('\\b'+klass+'\\b').test(o.className);
   },
   removeClasses : function(list,klass) {
      for(n=0, size=list.length; n < size; n++){
         this.removeClass(list[n], klass);
      }
   },
   getElementsByClass : function ( searchClass, domNode, tagName) {
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) {
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1)
			el[j++] = tags[i];
	}
	return el;
  },
  openWindow : function(pageurl,width,height){
    var scroll=1,resize=1;
    id = new Date().getTime();
    if(window.screen){
      lpos = (screen.width/2)-(width/2);
      hpos = (screen.height/3)-(height/3);
    }
    else{
      lpos = 1;
      hpos = 1;
    }
    eval("popWin"+id+" = window.open('"+pageurl+"','"+id+"','toolbar=0,scrollbars="+scroll+",location=0,status=0,menubar=0,resizable="+resize+",width="+width+",height="+height+",left="+lpos+",top="+hpos+"')");
    return false;
  }
}


if (!Array.prototype.forEach){
  Array.prototype.forEach = function(fun /*, thisp*/){
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
      {
        if (i in this)
          fun.call(thisp, this[i], i, this);
      }
  }
  ;
}
String.prototype.equals = function (s) {
 return String(this) === s;
}; 
String.prototype.isEmpty = function () {
  return this.trim().length<1;
};
String.prototype.contains = function (s) {
 return this.indexOf(s)!==-1;
};
String.prototype.trim = function() {
  return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  //return(this.replace(/^\s*|\s*$/g, ""));
};
String.prototype.stripHTML = function() {
  return this.replace(/<.*?>/g, '');
};
String.prototype.reverse = function () {
	return this.split('').reverse().join('');
};
if (!Array.prototype.filter)
{
  Array.prototype.filter = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var res = new Array();
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
      {
        var val = this[i]; // in case fun mutates this
        if (fun.call(thisp, val, i, this))
          res.push(val);
      }
    }

    return res;
  };
}
//var filtered = [12, 5, 8, 130, 44].filter(function(element, index, array){});
