var ret;
if (!Array.prototype.push) {
    Array.prototype.push = function(obj){
        for (var i=0;i<arguments.length;i++){
            this[this.length]=arguments[i];
        }
        return this.length;
    }
}
if (!Array.prototype.shift) {
    Array.prototype.shift = function(){
        var result = this[0];
        for (var i=0;i<this.length-1;i++) {this[i]=this[i+1];}
        this.length--;
        return result;
    }
}
if (!Array.prototype.unshift) {
    Array.prototype.unshift = function(){
        this.reverse();
        for (var i=arguments.length-1;i>=0;i--) {this[this.length]=arguments[i]}
        this.reverse();
        return this.length;
    }
}
if (!Array.prototype.pop) {
    Array.prototype.pop = function(){
        lastElement = this[this.length-1];
        this.length = Math.max(this.length-1,0);
        return lastElement;
    }
}
Object.extend = function(destination,source) {
    for (property in source) {destination[property]=source[property];}
    return destination;
}
function $old(){
    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;
}
function getElementsByClassName(strClass,strTag,objContElm) {
	strTag = strTag || "*";
	objContElm = objContElm || document;
	var objColl = (strTag=='*'&&document.all) ? document.all: objContElm.getElementsByTagName(strTag);
	var arr = new Array();
	var delim = strClass.indexOf('|')!=-1?'|':' ';
	var arrClass = strClass.split(delim);
	if (objColl.length) {
        for(i=0,j=objColl.length;i<j;i++) {
            if (objColl[i].className) {	
                var arrObjClass = objColl[i].className.split(' ');
                if (delim==' ' && arrClass.length>arrObjClass.length) { continue; }
                var c = 0;
                comparisonLoop:for(k=0,l=arrObjClass.length;k<l;k++) {
                    for (m=0,n=arrClass.length;m<n;m++) {
                        if (arrClass[m]==arrObjClass[k]) {c++;}
                        if ((delim=='|'&&c==1) || (delim==' '&&c==arrClass.length)) {
                            arr.push(objColl[i]);
                            break comparisonLoop;
                        }
                    }
                }
            }
        }
	}
	return arr;
}
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload!='function') {
        window.onload = func;
    } else {
        window.onload = function(){oldonload();func();}
    }
}
function addEvent(elm,evType,fn,useCapture) {
    if (elm.addEventListener) {
        elm.addEventListener(evType,fn,useCapture);
        return true;
    } else if (elm.attachEvent) {
        var r = elm.attachEvent('on'+evType,fn);
        EventCache.add(elm,evType,fn);
        return r;
    } else {
        elm['on'+evType] = fn;
    }
}
var EventCache = function(){
    var listEvents = [];
    return {
        listEvents: listEvents,
        add: function(node,sEventName,fHandler,bCapture){
            listEvents.push(arguments);
        },
        flush: function(){
            var i,item;
            for (i=listEvents.length-1;i>=0;i=i-1) {
                item = listEvents[i];
                if (item[0].removeEventListener) {
                    item[0].removeEventListener(item[1],item[2],item[3]);
                };
                if (item[1].substring(0,2)!="on") {
                    item[1] = "on"+item[1];
                };
                if (item[0].detachEvent) {
                    item[0].detachEvent(item[1],item[2]);
                };
                item[0][item[1]] = null;
            };
        }
    };
}();
addEvent(window,'unload',EventCache.flush,false);

var LoadEvents = new Array();
function pushLoadEvent(func) {
    LoadEvents.push(func);
}
function LoadEventsStart() {
    for (var i=0;i<LoadEvents.length;i++) {
        LoadEvents[i]();
    }
}
addEvent(window,'load',LoadEventsStart,false);
