// Helper methods

Array.prototype.Find = function (iterator){
    for (var i = 0; i < this.length; i++){
        if (iterator(this[i],i))
            return this[i];
    }
    return null;
}

Array.prototype.IndexOf = function (iterator){
    for (var i = 0; i < this.length; i++){
        if (iterator(this[i],i))
            return i;
    }
    return -1;
}

Array.prototype.Reverse = function (i1, i2){
    var temp = this[i1];
    this[i1] = this[i2];
    this[i2] = temp; 
}



// cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko by Scott Andrew
// By Scott Andrew
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);
        return r;
    } else {
        elm['on' + evType] = fn;
    }
}


// method borrowed from DOMtab Version 3.1415927 (Christian Heilmann - http://www.wait-till-i.com)
function CSSJS(a,o,c1,c2){
    switch (a){
			case 'swap':
				o.className=!CSSJS('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
			break;
			case 'add':
				if(!CSSJS('check',o,c1)){o.className+=o.className?' '+c1:c1;}
			break;
			case 'remove':
				var rep=o.className.match(' '+c1)?' '+c1:c1;
				o.className=o.className.replace(rep,'');
			break;
			case 'check':
				var found=false;
				var temparray=o.className.split(' ');
				for(var i=0;i<temparray.length;i++){
					if(temparray[i]==c1){found=true;}
				}
				return found;
            break;
    }
}
