/* 'Magic' date parsing, by Simon Willison (6th October 2003)
   http://simon.incutio.com/archive/2003/10/06/betterDateInput
*/

/* Finds the index of the first occurence of item in the array, or -1 if not found */
Array.prototype.indexOf = function(item) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == item) {
            return i;
        }
    }
    return -1;
};
/* Returns an array of items judged 'true' by the passed in test function */
Array.prototype.filter = function(test) {
    var matches = [];
    for (var i = 0; i < this.length; i++) {
        if (test(this[i])) {
            matches[matches.length] = this[i];
        }
    }
    return matches;
};

// this is the little object even parser guy I made
function addObjectEventFunction(elem, eventtype, obj, funcname, captures){
	try {
		elem.addEventListener(eventtype, function(e) { obj[funcname](e); }, captures);
	}
	catch(e){
		//alert(eventtype + " " + obj + " " +  funcname);
		e.message += " in event " + eventtype + " calling " + funcname;
		throw e;

	}
}


