// <script type='text/javascript' src='OO.js'></script>	<h1>Dan's OO : The Mapmaker</h1><pre style="font-size: 120%;"><textarea cols=150 rows=110 onfocus='this.select()'>


if (!Array.prototype.map) {// from http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:map
Array.prototype.map = function (fun) {var len = this.length;if (typeof fun != "function") {throw new TypeError;}var res = new Array(len);var thisp = arguments[1];for (var i = 0; i < len; i++) {if (i in this) {res[i] = fun.call(thisp, this[i], i, this);}}return res;};}

if (!Array.prototype.filter) { //from  http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:filter
Array.prototype.filter = function (fun) {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];if (fun.call(thisp, val, i, this)) {res.push(val);}}}return res;};}

if(!window.console){ console= {info: function(s){ document.title=s; } } ; }

function OO (origOb, up, lambda ) {


function recognizeFunctionType(fn1, md){
if(window.bang)console.info(["recognizeFunctionType(fn1, md)",fn1,md]); 
	 fn1.isKnown = true;
	var arg2 = fn1.toString().split(")")[0];
//	if(fn1.toString().slice(0,11)==="function (a"){  fn1.isMap=true; }
	if( arg2.indexOf("(a")>-1){  fn1.isMap=true; }
	if( arg2.indexOf("filter")>-1){  fn1.isFilter=true; };

	//OO.itemFunctions[md]=t;
	// return t===1?1:0;
}

//	return    j
//OO.itemFunctions[md]=j ? 1 : 2 ;

//	console.info(fn1)
//	OO.counts = OO.counts ? OO.counts++ : 1;
// .035ms	return  fn1.toString().split("(")[1].split(")")[0].split(",")[0];
//0.026ms 	return  fn1.toString().slice(0,11)==="function (a";





tracker=650986025476;

OO = function(origOb, up, lambda ) {


console.info("orig: "+origOb);

if(!OO.runtime){  OO.runtime = ({}); }
if(!OO.itemFunctions){  OO.itemFunctions= ({}); }
//var hasPacks = [];
//condition the input object - accept a css query as the string, or a collection? or an array (main focus);	

if(!origOb){ origOb = []; }
if(typeof origOb==='string'){ origOb=OO.cq(origOb); }
if(typeof origOb==='number'){ origOb=[origOb]; }
if(typeof origOb ==='object' && origOb.constructor !== Array){ 

	if(origOb.nodeType){
		 origOb = [origOb];
	 }else{ 
		origOb = origOb.length ? OO.obValsl(origOb) : OO.obVals(origOb);
	}
}



   function mapIt(fun, md) { // fethches methods. builds map functions for those that need it, else shifts arguments
        var g = fun.isKnown || recognizeFunctionType(fun,md);
	if(fun.isFilter){ g= function (a2) { return OO(origOb.filter(fun, a2||origOb ));}; g.orig=fun; return g; }
	if(fun.isMap){ g= function (a2) { return OO(origOb.map(fun, a2||origOb ));}; g.orig=fun; return g; }
		g= function (a, b, c, d) { return fun(origOb,a,b,c);};
	 	g.orig = fun;
        return g;
  }



if(up){
   if(up.constructor !== Array){
         up= [ up ] ;
    }
} else {


if( OO.runtime['_isBuilt'] ){// && !up ){ //runtime already built, return early and just apply runtime.
 	var OR = OO.runtime;
	       for(var it in OR ){
	            if(OR.hasOwnProperty(it)){
	              origOb[it] = mapIt( OR[it] , it );
	            }
	        } 
    return origOb;
}//end if runtime already built && no upgrade object

	if(!OO.up ){ //&& !up ){
	console.info("no cached upgrades!");
		var tob = [], n=0;
		for(var it in OO){ tob[n++] = it ;}
		function isP(key){ return key.slice(0,1)==="_"; }
		var hasPacks = tob.filter(isP);
		up= hasPacks.map(function(S){  return OO[S];});
		OO.up = up;
	} else {   
	 up =  OO.up;  
	  } //end if no up

  }

hasPacks =  hasPacks || ['_custom']; 

    for(var i = 0, mx=up.length; i<mx;i++){
      var UT = up[i];
       for(var it in UT){
            if(UT.hasOwnProperty(it)){
		var R = UT[it] ; 
		OO.runtime[it] = R  ;
		R.package = hasPacks[i].substr(1);
		R.Name = it;
		var contex = mapIt( UT[it], it )
		R.context = contex; 
		OO.runtime['_isBuilt'] = true;
              origOb[it] = ( contex );
            }
        } 
    }


  return origOb;
}//end inner OO function


// end of core method loader


function Function2(fnBody, strName){     //a better anon function maker? seems to make real functions, not anon ala new Function()
 if( typeof fnBody === "function"){ return fnBody;	}
  fnBody = fnBody.match(/return/) ? fnBody :  "return "+fnBody ;
  var buff;
	if(  strName){
		if(strName.constructor===Array){
			// buff =   "(function ( "+ strName.join(", ") + " ){ "+fnBody+";})" ;
//			var s = strName; 
//			buff =  Function( s[0], s[1], s[2], s[3] fnBody);
				buff = Function.apply( this, strName.concat(fnBody) );
		}else { //str 2nd arg
			// buff =   "(function (a,b,c, "+strName+" ){ "+fnBody+";})" ;
			buff =  Function( "a", "b", "c", strName, fnBody);
		}//end if array
	} else{
		buff =  Function( "a", "b", "c", fnBody);
	}
     return buff;
}

// function fn (code){      return new Function("a","b","c", code.match(/return/)?code:"return "+code);     }; //outmoded by Function2 > wayyy faster

OO.fn = Function2;

OO._custom=({});

 function addMethod(strName, varFunc, strFuncType, strPack ){ //allows you to add methods during runtime.
	varFunc.split ? OO.fn(varFunc) : varFunc ;
	if(strPack && strPack[0] !== "_" ){ strPack = "_" + strPack ;} else { strPack =  "_custom" ;}
	if(strFuncType){
		if(strFuncType==="filter"){ g.isFilter = true; }
	}
	OO.runtime['_isBuilt'] = "";
	OO.up="";
	OO[ strPack ][strTitle] = g;
  return g;
}

OO.addMethod = addMethod;

tracker=650986025476;

OO._tag={
	lens:(function (a) {return a.innerHTML.length;}),
	 txtLens:(function (a) {var g = a.textContent ? a.textContent : a.innertext || a.nodeValue;return g.length;}),
	 txt:(function (a) {return a.textContent ? a.textContent : a.innertext || a.nodeValue;}), 
	text:(function (a) {if (this.split) {a.innerHTML = this;} else {return   a.textContent ? a.textContent : a.innertext || a.nodeValue ; } }), 
	inHT:(function (a) {return a.innerHTML;}), 
	hide:(function (a) {if(a.style && !! a.style.display){a._oldDisp =  a.style.display}; a.style.display = "none"; return a;}), 

	toggle:(function (a) {var as =a.style; as.display = as.display==='none' ? (a._oldDisp || "") : 'none' ; return a;}), 
	show:(function (a) {a.style.display = a._oldDisp || ""; return a;}), 
	plainLink:(function (a) {return a.innerHTML.link(a.href);}), 
	bold:function(a){ a.style.fontWeight="bold";return a;},
	unbold:function(a){ a.style.fontWeight="normal";return a;},


	getFirstChild:(function (a) {return a.getElementsByTagName(this || "*" )[0];}), 

	getChildren:(function (a) {return OO(a.getElementsByTagName(this || "*" ));}), 
	descendants:(function (a) {return OO(a.getElementsByTagName(this || "*" ));}), 
	bindEvent:(function (r, strEvent, func) {function doBind(a) {a[strEvent] = func.split ? OO.fn(func) : func;}; r.map(doBind);return r;}), 
	color:(function (a) {var as = a.style;if (this.split) {as.color = this;} else {return as.color;}return a;}), 

	append:(function (a) { if (this.split) {var cc= a.innerHTML; a.innerHTML=cc+this;} else {a.appendChild(this);}return a;}),


	 prepend:(function (a) {if (this.split) {var ht = "innerHTML";var o = a[ht];a[ht] = this + o;} else {}; return a;}), 
	cloneNodes:(function (a) {return a.cloneNode(true);}), 
	bigger:(function (a) {var as = a.style;as.fontSize = as.fontSize.slice(-1) == "%" ? (parseInt(as.fontSize) * 1.1 || 18) + "%" : "110%";return a;}),
	smaller:(function (a) {var as = a.style;as.fontSize = as.fontSize.slice(-1) == "%" ? (parseInt(as.fontSize) * 0.91 || 18) + "%" : "90%";return a;}), 
	titles:(function (a) {return a.title.link(this.length);}), 
	highlight:(function (r, kw) {  return r.map(function (a, b, c) {
		var as = a.style;if (a.innerHTML.indexOf(kw) > -1) {as.color = "#000";as.backgroundColor = "#ff5";} else {as.color = "#008";as.backgroundColor = "#fff";}return a;});}),
	css:(function (a) {return a.style.cssText ? a.style.cssText : a.getAttribute("style");}), 
	setStyle: function(a, varStyle){ 
 	 	if(varStyle.split){ a.style.cssText ? a.style.cssText = varStyle : a.setAttribute("style", varStyle); return a; }
		function applyStyle(it){ a.style[it[0]] = it[1] ; }
		OO.obMap(varStyle).map(applyStyle);
	   return a;
	}

};



OO._tag.titled= function(filter){ return filter.title;};
OO._tag.classNames= function(a){ return a.className ? OO(a.className.split(/\W/g)) : undefined;};
OO._tag.visible = function(a){ return a.style.display==='none'; };
OO._tag.kill = function (a) {   if(a.parentNode){a.parentNode.removeChild(a); return a;} if(a.parentElement){a.parentElement.removeChild(a);} return a;}



OO._math= { 
  sum: function(numRay){var tot=0; numRay.map(function(n){tot+=n;});return tot;},
  avg: function(numRay){var tot=0; numRay.map(function(n){tot+=n;});return tot / (numRay.length+1);},
//  max: function(numRay){var mx = Math.max,tot=0; numRay.map(function(n){tot=mx(tot, n);});return tot;},
max: function(r){ return Math.max.apply(0,r);},  
  //min : function(r){ var mx = Math.min,tot=Infinity; r.map(function(n){tot=mx(tot, n);});return tot;},
min: function(r){ return Math.min.apply(0,r);},  
  diff:(function (a) {return a - this;}), 
  valids :  function(r){return r.filter(OO.fn("a*1===a;")); } ,
above:function(r,n){ return r.filter(function(a){return a > n;})  },
below:function(r,n){ return r.filter(function(a){return a < n;})  },
range: function(r,lower, upper){ return r.filter(function(a){return a > lower && a< upper ;})},
round: function(a){ return Math.round(a);},
ceil: function(a){ return Math.ceil(a);},
floor: function(a){ return Math.floor(a);},
countOf:function(r,n){ return r.filter(function(a){return a===n;}).length;},
sorted:function(r,descend){ return descend ? r.sort(OO.fn("a===b?0:a<b")) : r.sort(OO.fn("a===b?0:a>b")) }
   }//end upgrade for math arrays

OO._math.median= function (that ) {
    var cmp = function (x, y) {return x - y;};
    that.sort(cmp);
    var middle = Math.floor(that.length / 2);
    return that[middle];
}

OO._array = {
first:(function (r) {return r[0];}), 
last:(function (r) {return r.reverse()[0];}), 
pluckProperty:(function (a) {return a[this];}), 
copy:(function (a) {return a;}), 
clear:(function (r) {r=OO([]); return r;}), 
flatten:(function (orig) { var that = orig;var r = []; function rpush(aa) {r[r.length] = aa;};  function extractArray(a) {if (a.constructor === Array) {a.map(rpush);} else {r.push(a);}}  that.map(extractArray);return OO(r);}),
unique:(function (r) { var t = [];var mx = r.length;for (var z = 0; z < mx; z++) {if (t.indexOf(r[z]) == -1) {t[t.length] = r[z];}}return t;}), 
cloneArray:(function (r) {return [].concat(r);}),
screen: function(r, exp){ var tempF = OO.fn(exp); return OO(r.filter( tempF ) ) },
compact: function(filter){ return  filter !== null  &&  filter !== undefined ; },
exclude: function(filter){ return filter != this; },
each: function (r, fn2) {var f = fn2.split ? OO.fn(fn2) : fn2; return r.map(f);},
censor: function(r, term){ var ff = function(a){ return a.toString().indexOf(term)<1;}; return r.filter(ff);}
}; //end array method package

OO._array._= function (that, p) {
    mx = that.length;
    r = [];
    if (p.call) {
        for (var z = 0; z < mx; z++) {
            tt = p.call(that, that[z], z, that);
            if (!!tt.type) {
                r[r.length] = tt;
            }
        }
        return OO(r);
    }
    if (p.constructor === RegExp) {
        for (var z = 0; z < mx; z++) {
            r[z] = that[z].match(p);
        }
    }
    if (typeof p === "object" && p.constructor !==Array )  {
        for (var z = 0; z < mx; z++) {
            r[z] = p;
        }
    }
    if ( p.constructor ===Array) {
        mxi = p.length;
        for (var i = 0; i < mxi; i++) {
            r[r.length] = that[p[i]];
        }
    }
    if (p.split) {
        for (var z = 0; z < mx; z++) {
            if (typeof that[z][p] != "undefined") {
                r[r.length] = that[z][p];
            }
        }
    }
    if ( typeof p === "number" ) {
        for (var z = 0; z < mx; z++) {
            r[z] = that[z][p];
        }
    }
        return OO(r);
}


OO._array.both= function (that, r) {
var or = r.indexOfArray ? r : OO(r);
function fb(a){return or.indexOfArray(a) > -1}
    return that.filter(fb);
}




OO._math.ranges= function (that ) {
    return [that.min(), that.max()];
}


OO._array.mergeArray= function (that, r, delm, blnThisLast) {
    tr = [];
    mx = [that.length, r.length].max();
    if (!delm) {
        delm = " ";
    }
    for (z = 0; z < mx; z++) {
        tr[z] = (!blnThisLast) ? that[z] + delm + r[z] : r[z] + delm + that[z];
    }
    return OO(tr);
}

OO._array.random= function (that) {
	function Rnd(w) {    return parseInt(Math.random() * (w + 1));}
    return that[Rnd(that.length - 1)];
}

OO._array.shuffle= function (that ) {
	function Rnd(w) {    return parseInt(Math.random() * (w + 1));}
    var that = [].concat(that);
    var mx = that.length;
    var r = [];
    var mx2 = mx - 1;
    for (var i = 0; i < mx; i++) {
        var slot = Rnd(mx2 - i);
        r[i] = that.splice(slot, 1)[0];
    }
    return OO(r);
}


OO._array.fill= function (that, v) {
   var  mx = that.length;
    for (var z = 0; z < mx; z++) {
        that[z] = v;
    }
    return OO(that);
}

OO._array.find= function (that, s) {
   var mf = function (a) {var rs = String(a).match(s);return rs ? a : undefined;}
    var wg = that.filter(mf);
    return OO(wg);
}


OO._array.has= function (that, s) {
   var  mx = that.length;
    for (var z = 0; z < mx; z++) {
       if( that[z] == s ){ return z || "0" ; }
    }
}



OO._array.grep= function (s, filter) {
   var rs = String(s).match(this); return rs ? s : 0;
}


OO._array.item= function (that, i) {
    return that[i];
}


OO._array.reduceArray=function(that, fn){
	var q;
	if(fn.split){ fn =OO.fn(fn); }
	var mx = that.length - 1;
	for(var i=0;i<mx;i++){
	    q = fn.apply(that, [ q || that[i] , that[i+1]])
	}
return q;
}


OO._array.labeled= function (that ) {
    var mx = that.length, r = [];
    for (z = 0; z < mx; z++) {
        r[z] = z + ":" + that[z];
    }
    return OO(r);
}

OO._array.itemLengths= function (a) {
    return String(a).length;
}

OO._array.valids=function(filter){ return filter !== undefined; }
OO._array.somethings=function(filter){ return filter; }
OO._array.numbersOnly=function(filter){ return Number(filter) == filter; }

OO._array.lf= function (that, noSorting) {
    if (noSorting) {
        return that.join("\n");
    }
    return that.sort().join("\n");
}

OO._array.transpose= function (that) {
    var o = [],    bb = that, mb = bb[0].length;
    for (var z = 0; z < mb; z++) {
        r = bb[z];
        o[z] = [];
        for (var i = 0; i < bb.length; i++) {
            o[z][i] = bb[i][z];
        }
    }
    return o;
}


OO._array.sortDate= function (that ) {
    return that.sort(function (a, b) {a = parseDate(a);b = parseDate(b);return a < b ? -1 : a > b ? 1 : 0;});
}
OO._array.sortMoney= function (that ) {
    return that.sort(function (a, b) {return a != b ? parseFloat(a.replace(/[^\d.]/g, "")) - parseFloat(b.replace(/[^\d.]/g, "")) : 0;});
}
OO._array.sortNumber= function (that ) {
    return that.sort(function (a, b) {return a != b ? parseFloat(a) - parseFloat(b) : 0;});
}
OO._array.sortText= function (that ) {
    return that.sort(function (a, b) {return (a != b) ? b.toLowerCase() < a.toLowerCase() ? 1 : -1 : 0;});
}
OO._array.sortTextAuto= function (that ) {
    return that.sort(function (a, b) {return (a != b) ? b.toString().toLowerCase() < a.toString().toLowerCase() ? 1 : -1 : 0;});
}

OO._array.sort$= function (that, scheme) {
function detectScheme(a) {
    if (a[1].match(/^[\u00a3$\u20ac]/)) {
        return "$";
    }
    if (a[1] === parseFloat(a[1])) {
        return 1;
    }
    if (a[1].match(/^[\d.,]+\%?$/)) {
        return 1;
    }
    if (a[1] === a[1].toString().split()) {
        return "A";
    }
    if (a[1].instanceOf(Date)) {
        return "date";
    }
    if (a[1].match(/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/)) {
        return "date";
    }
    if (a[1].match(/^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/)) {
        return "date";
    }
    if (a[1].match(/^\d\d[\/.-]\d\d[\/.-]\d\d$/)) {
        return "date";
    }
    return "a";
}
    if (!scheme) {
        scheme = detectScheme(that);
    }
    switch (scheme) {
      case "$":
        return that.sortMoney();
        break;
      case "a":
        return that.sortTextAuto();
        break;
      case "date":
        return that.sortDate();
        break;
      case "A":
        return that.sort();
        break;
      case 1:
        return that.sortNumber();
        break;
      default:
        return that.sort();
    }
    return that;
}

OO._array.toExcel= function (that ) {
        return that.map(function (g) {return g.join("\t");}).join("\n");
}

OO._array.toList= function (that, f) {
    var b = "\n<select size='" + that.length + "' " + (f ? "onchange='" + f.toString() + "'" : " ") + " class='autoCombo'>\n\t<option>";
    return b + that.join("</option>\n\t<option>") + "</option>\n</select>\n";
}


OO._array.toTagsHt= function (that, tg) {
	function wrapHT(r, tg) {
	    var tt = [];
	    tt[0] = "<" + tg + ">";
	    tt[3] = "</" + tg + ">\n";
	    tt[2] = r.join(tt[3] + tt[0]);
	    return tt.join("");
	}
    return wrapHT(that, tg);
}


OO._array.toTr= function (that) {
	function wrapHT(r, tg) {
	    var tt = [];
	    tt[0] = "<" + tg + ">";
	    tt[3] = "</" + tg + ">\n";
	    tt[2] = r.join(tt[3] + tt[0]);
	    return tt.join("");
	}
    return "\n<tr class='autoTR' >\n" + wrapHT(that, "td") + "</tr>\n";
}

OO._array.toTable= function (that) {
    if (1) {
        var hd = "<table class='autoTable' cols='" + that[0].length + "' cellpadding='0' cellspacing='0' style='direction:ltr'>\n";
        var ft = "</table>";
        var mx = that.length;
        var rws = [];
        for (z = 0; z < mx; z++) {
            tw = "\t" + OO(that[z]).toTr();
            rws[z] = tw ? tw : "";
        }
        return hd + rws.join("") + ft;
    }
}


OO._string={}

OO._string.wordWrap= function (that, colLen, delm) {
    if (!delm) {
        delm = "-\n";
    }
    if (!colLen) {
        colLen = that.length;
    }
    var bs = "";
    var mx = that.length;
    for (i = 0; i < mx; i += colLen) {
        bs += that.slice(i, i + colLen) + delm;
    }
    return bs.slice(0, (bs.length - delm.length));
}




OO._typeCast= {

date:(function (a) {return new Date(a);}), 
integer:(function (a) {return parseInt(a);}), 
number:(function (a) {return parseFloat(a);})
}; //end casting method package



OO._util={
op: function(r, exp){ return OO(r.map( OO.fn("a"+exp))  ) },
exec: function(r, exp){ return OO(r.map( OO.fn(exp)) ) },
clear:(function (r) {r = [];return OO(r);}), 
size:(function (r) {return r.length;}), 
without:(function (orig, term) {var that = term;if (that.constructor !== Array) {that = [that];}for (var i = 0, mx = that.length; i < mx; i++) {var it = that[i];orig = orig.filter(function (a) {return a !== it;});}return OO(orig);}), 
 pluck:(function (r, arg) {rr = this;if (arg.split) {arg = arg.split(/\,/g);}if (typeof arg === "object" && arg.construnctor !== Array) {if (arg.length) {arg = OO.obValsl(arg);} else {arg = OO.obKeys(arg);}}function rak(a) {var o = {};arg.map(function (aa) {o[aa] = a[aa];});return o;}return OO(r.map(function (a) {return rak(a);}));})
}//end util package

OO._util.listProps=function(r){ return OO(OO.obKeys(r)); } // "list all the object's properties."

OO._util.listMethods=function(r){ //List all of the OO options available on the object.
    function isM(it){ return r[it].call;}
         return OO(OO.obKeys(r).filter(isM)); 
}


OO._util.itemByValue = function (r, term) { // "A reverse lookup function, pass the value and it returns the label/key of the first match.",
for(var i=0, mx=r.length;i<mx;i++){
    if( r[i]===term){return i;}
}
return -1;
}

OO._array.indexOfArray = OO._util.itemByValue ;

OO._util.itemsByValue = function (ra, term) { // "A reverse lookup function, pass the value and it returns the labels/keys of all matches."
var r=[];
for(var i=0, mx=ra.length;i<mx;i++){
    if( ra[i]===term){r[r.length]=i;}
}
return OO(r);
}

OO._function={
   delay: function( varCode, amt){ setTimeout( varCode, amt ); return varCode; },
   defer: function( varCode ){ setTimeout( varCode, 35 ); return varCode; },
   runIf: function( varCode, condition ){ if(typeof condition === 'string'){ condition =eval(condition);} if(condition){  setTimeout( varCode, 0 );} return varCode;},
   runAt: function( varCode, date ){  
		var c = (new Date).getTime(); 
		if(! date.getTime){ date = new Date(date); }
		var d = date.getTime();
		var amt = d - c;
		if(amt < 0){ return varCode;}
		setTimeout( varCode, amt ); 
	   return varCode; 
 	},

	delayUntil : function (that, exp, numIntervalMS) {
	    if (eval(exp)) {
	        that.apply(this, [exp]);
	    } else {
	        setTimeout(function () {that.delayUntil(exp);}, numIntervalMS || 100);
	    }
	return that;
	}
}


OO._date={};

OO._date.until= function (that ) {
    var n = new Date;
    n = n.getTime();
    var d = that.getTime();
    return d - n;
}

OO._date.since= function (that ) {
    var n = new Date;
    n = n.getTime();
    var d = that.getTime();
    return n - d;
}

OO._date.now= function (that) {
    return new Date;
}

OO._date.toISOString= function (that ) {
    function f(n) {        return n < 10 ? "0" + n : n;    }
    return that.getFullYear() + "-" + f(that.getMonth() + 1) + "-" + f(that.getDate()) + "T" + f(that.getHours()) + ":" + f(that.getMinutes()) + ":" + f(that.getSeconds());
}

OO._date.toTime= function (that ) {
    return that.toISOString().split("T")[1];
}

OO._date.toDate= function (that ) {
    return that.toISOString().split("T")[0];
}

OO._date.setDate= function (that, s) {
    var d = new Date;
    var td = s.replace(/[-_\\.]/gm, "/").replace(/T!h+/, " ");
    d.setTime(Date.parse(td));
    return d;
}

OO._date.format= function (that, form) {
    function f(n) {
        return n < 10 ? "0" + n : n;
    }
    var d = form;
    d = d.replace("MM", f(that.getMonth() + 1));
    d = d.replace("M", that.getMonth() + 1);
    d = d.replace("DD", f(that.getDate()));
    d = d.replace("D", that.getDate());
    d = d.replace("YYYY", that.getFullYear());
    d = d.replace("YY", f(that.getYear() - 100));
    d = d.replace("HH", f(that.getHours()));
    d = d.replace("H", that.getHours());
    d = d.replace("mmmm", monthsLong[that.getMonth()]);
    d = d.replace("mmm", monthsShort[that.getMonth()]);
    d = d.replace("mm", f(that.getMinutes()));
    d = d.replace("m", that.getMinutes());
    d = d.replace("dddd", daysLong[that.getDay()]);
    d = d.replace("ddd", daysShort[that.getDay()]);
    return d;
}


OO._date.diff= function (that, comp) {
    var n = new Date;
	if(!that.getTime){ that = new Date(that); }
    n = comp.getTime();
    var d = that.getTime();
    return d - n;
}

OO._number={};

OO._number.round= function (that) {
    return Math.round(that);
}
OO._number.sign= function (that) {
    return that > 0 ? 1 : that == 0 ? 0 : -1;
}
OO._number.signSymb= function (that) {
    return that > 0 ? "+" : "-";
}
OO._number.signTxt= function (that) {
    return that > 0 ? "positive" : "negative";
}
OO._number.sin= function (that) {
    return Math.sin(that);
}
OO._number.sqrt= function (that) {
    return Math.sqrt(that);
}
OO._number.square= function (that) {
    return Math.pow(that, 2);
}
OO._number.subtract= function (that, x) {
    return that - x;
}
OO._number.tan= function (that) {
    return Math.tan(that);
}
OO._number.toBin= function (that) {
    return that.toString(2);
}
OO._number.toHex= function (that) {
    return that.toString(16);
}
OO._number.toOct= function (that) {
    return that.toString(8);
}


OO._number.log= function (that ) {
    return Math.log(that);
}
OO._number.multi= function (that, x) {
    return that * x;
}
OO._number.pow= function (that, x) {
    return Math.pow(that, x);
}
OO._number.floor= function (that ) {
    return Math.floor(that);
}

OO._number.isInt= function (that) {
    return !String(that).indexOf(".");
}
OO._number.isNeg= function (that) {
    return that < 0 ? true : false;
}
OO._number.isNegative= function (that) {
    return that < 0 ? true : false;
}
OO._number.isPos= function (that) {
    return that > 0 ? true : false;
}
OO._number.isPositive= function (that) {
    return that > 0 ? true : false;
}
OO._number.ceil= function (that) {
    return Math.ceil(that);
}
OO._number.cos= function (that) {
    return Math.cos(that);
}
OO._number.cube= function (that ) {
    return Math.pow(that, 3);
}
OO._number.diff= function (that, x) {
    return that - x;
}
OO._number.dividedBy= function (that, x) {
    return that / x;
}

OO._number.exp= function (that) {
    return Math.exp(that);
}
OO._number.abs= function (that) {
    return Math.abs(that);
}
OO._number.acos= function (that) {
    return Math.acos(that);
}
OO._number.addTo= function (that, x) {
    return that + x;
}
OO._number.areaCir= function (that) {
    return Math.pow(that, 2) * Math.PI;
}
OO._number.areaSq= function (that) {
    return Math.pow(that, 2);
}

OO._number.asin= function (that) {
    return Math.asin(that);
}
OO._number.atan= function (that) {
    return Math.atan(that);
}
OO._number.bitDepth= function (that) {
    return that.toString(2).length;
}
OO._number.factors= function (that ) {
    var mx = parseInt(Math.sqrt(that)) + 1;
    var facts = [];
    for (z = 1; z < mx; z++) {
        facts[z] = [z, that / z];
    }
    return facts;
}



OO._util.toJSON = function(ob){

if (!Object.prototype.toJSONString) {Array.prototype.toJSONString = function () {var a = ["["], b, i, l = this.length, v;
function p(s) {if (b) {a.push(",");}a.push(s);b = true;}for (i = 0; i < l; i += 1) {v = this[i];switch (typeof v) {case "undefined":case "function":case "unknown":break;case "object":if (v) {if (typeof v.toJSONString === "function") {p(v.toJSONString());}} else {p("null");}break;default:p(v.toJSONString());}}a.push("]");return a.join("");};Boolean.prototype.toJSONString = function () {return String(this);};Date.prototype.toJSONString = function () {
function f(n) {return n < 10 ? "0" + n : n;}return "\"" + this.getFullYear() + "-" + f(this.getMonth() + 1) + "-" + f(this.getDate()) + "T" + f(this.getHours()) + ":" + f(this.getMinutes()) + ":" + f(this.getSeconds()) + "\"";};Number.prototype.toJSONString = function () {return isFinite(this) ? String(this) : "null";};Object.prototype.toJSONString = function () {var a = ["{"], b, i, v;
function p(s) {if (b) {a.push(",");}a.push(i.toJSONString(), ":", s);b = true;}for (i in this) {if (this.hasOwnProperty(i)) {v = this[i];switch (typeof v) {case "undefined":case "function":case "unknown":break;case "object":if (v) {if (typeof v.toJSONString === "function") {p(v.toJSONString());}} else {p("null");}break;default:p(v.toJSONString());}}}a.push("}");return a.join("");};(function (s) {var m = {'\b': "\\b", '\t': "\\t", '\n': "\\n", '\f': "\\f", '\r': "\\r", '"': "\\\"", '\\': "\\\\"};s.parseJSON = function (hook) {try {if (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(this)) {var j = eval("(" + this + ")");if (typeof hook === "function") {
function walk(v) {if (v && typeof v === "object") {for (var i in v) {if (v.hasOwnProperty(i)) {v[i] = walk(v[i]);}}}return hook(v);}return walk(j);}return j;}} catch (e) {}throw new SyntaxError("parseJSON");};s.toJSONString = function () {if (/["\\\x00-\x1f]/.test(this)) {return "\"" + this.replace(/([\x00-\x1f\\"])/g, function (a, b) {var c = m[b];if (c) {return c;}c = b.charCodeAt();return "\\u00" + Math.floor(c / 16).toString(16) + (c % 16).toString(16);}) + "\"";}return "\"" + this + "\"";};}(String.prototype));}
	return ob.toJSONString();
}

OO._util.noscripts=function(a){ return a.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/gim,""); }

tracker=650986025476;	//util functions for local and protected scope:




function isType(ob, tp){  return ob.constructor === tp.constructor; }

function el(tid) { return el._ts[tid] || (el._ts[tid]= document.getElementById(tid));};el.d= document;el._ts={};
function els(tid) {return el(tid).style;}
function tags(elm, tid){var t="getElementsByTagName";if(tid){if(isType(elm, '')){elm=OO.el(elm);}return obValsl(elm[t](tid));}return obValsl(document[t](elm));}


function obValsl(ob) {
 var r = [],  mx = ob.length;
 for (var z = 0; z < mx; z++) {
	 r[z] = ob[z];
}
return r;
};




function obVals(ob) {var r = [];var i = 0;for (var z in ob) {if (ob && ob.hasOwnProperty && ob.hasOwnProperty(z)) {r[i++] = ob[z];}}return r;}
function obKeys(ob) {var r = [];var i = 0;for (var z in ob) {if (ob.hasOwnProperty(z)) {r[i++] = z;}}return r;}
function obMap(ob){var r=[];var i=0;for(var z in ob){if(ob.hasOwnProperty(z)){r[i++]=[z, ob[z]];}}return r;}

function dataURL(data, mimeType) {    return "data:"+ (mimeType ? mimeType : "text/html")+"," + escape(data);}

function cq(s){function kd(o,t){if(!o){return oks;}var B=[];function p(a){var x=tags(a,t);if(x && x[0]){B=B.concat(x);}return x;}o.map(p);return B;}var ts=s.replace(/\./g, "@%").split(/[\s\@]+/g);var idd=s.match(/\#/);var O=idd?[el(ts[0].substr(1))]:tags(ts[0]);for(var i=1, mx=ts.length; i<mx; i++){var it=ts[i];if(it[0]==="%"){var cn=it.substr(1);function c(a){return a.className==cn;}O=O.filter(c);}else{O=kd(O,it);}}return O;} // was O.unique();}


    function IO(U, V, cachedOk) {
        var X = !window.XMLHttpRequest ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest;
        X.open(V ? "PUT" : "GET", U, !!V );
        X.setRequestHeader("Content-Type", "text/html");
        if (!cachedOk) {
            X.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        }
        X.send(V ? V : "");
        return X.responseText;
    }

function jsGet(turl){var xJs=document.createElement("script");OO.tags("head")[0].appendChild(xJs);xJs.src=turl;return xJs;}


function store(k,v){
if(window.globalStorage){
	function store(key, val) {if (val) {globalStorage[document.domain][key] = val;} else {try {var tm = globalStorage[document.domain][key];if (tm) {tm = tm.toString();}} catch (rr) {return "";}return tm;}return;}
} else{
function setCookie(nm, valu) {var e2 = (new Date(2019, 1, 1)).toGMTString();document.cookie = nm + "=" + escape(valu) + "; expires=" + e2;};
function getCookie(k) {var d = document.cookie || "";var pairs = d.split(k + "=");if (pairs && pairs[1]) {return unescape(pairs[1].split(";")[0]);}}
function store(key, val) {if (val) {setCookie(key, val);} else { return       getCookie(key);}  }}
function iestorer (){var D=document;if(!D.createStyleSheet){return;}var tCSS=D.createStyleSheet();tCSS.addRule(".userData", "behavior:url(#default#userdata)", 0);var Static=D.createElement("input");var Q=function (z,x){Static.setAttribute(z,x);};Q("type", "hidden");Q("id", "EzStatic420");Q("className", "userData");tags("head")[0].appendChild(Static);var s=el("EzStatic420");
function ies(k,v){if(!v){s.load("oXMLStore");var t=s.getAttribute(k);return unescape(t) || "";}else{s.setAttribute(k, escape(String(v)));s.save("oXMLStore");}}window.store=ies;}
iestorer(); foxStore=store//jmod big compat. alias
return store(k,v);
}



	

function dnd(elm) {IE = false;   //@cc_on; IE=true; //dnd by dandavis. creative commons attribution-only license applies.
var branch = IE ? "srcElement" : "target";dnd.branch = branch;var D = document;
var PI =parseInt;
function el(tid) {return D.getElementById(tid);}
function GC(k) {var d = D.cookie || "";var pairs = d.split(k + "=");if (pairs && pairs[1]) {return unescape(pairs[1].split(";")[0]);}}
function SC(nm, valu) {var e2=(new Date(2019, 1, 1)).toGMTString();D.cookie = nm + "=" + escape(valu) + "; expires=" + e2;}
if(!dnd.hlColor){dnd.hlColor="yellow"; }
var PS= (dnd.useFixed ?  "fixed" : "absolute" )
if (!drag.items) {drag.items = [];}if (!dnd.dndTags) {dnd.dndTags = {};}if (!dnd.z) {dnd.z = 500;}if (elm.split) {elm2 = el(elm);} else {elm2 = elm;}if (!elm2) {return;}if (!elm2.id) {var tgn = elm2.tagName.toLowerCase();if (!dnd.dndTags[tgn]) {dnd.dndTags[tgn] = 0;} else {dnd.dndTags[tgn]++;}elm2.id = tgn + dnd.dndTags[tgn];}if (!dnd.items) {dnd.items = [elm2.id];} else {dnd.items.push(elm2.id);}elm2.style.cursor = "pointer";var ds7 = elm2.style;if (!ds7.position) {ds7.position=PS ;ds7.left = elm2.offsetLeft + "px";ds7.top = elm2.offsetTop + "px";}ds7.oldCursor=ds7.cursor || "";if (GC) {var od = GC(elm2.id);if (od) {try {oP = eval(od);} catch (yy) {oP = [ds7.left, ds7.top, dnd.z++];}if (oP[2] > dnd.z) {dnd.z = oP[2];} ds7.left = oP[0];ds7.top=oP[1];ds7.zIndex = oP[2] || dnd.z;}}
function drag(d, e) {var that = e[branch];if (that != d) {if (that.focus) { that.focus(); return true;}return false;}var ds = d.style;if (!ds.position) {ds.position = PS;ds.left = ds.left ? ds.left : xy(e) + "px";ds.top=ds.top ? ds.top : xy(e, 1) + "px";}ds.cursor = "move";d.buc = [ds.borderColor, ds.borderStyle, ds.borderWidth];ds.borderColor = dnd.hlColor;ds.borderWidth = "8px";ds.borderStyle = "solid"; stop2 = 0;var oX = PI(d.style.left), oY = PI(d.style.top), eX = xy(e, 0), eY = xy(e, 1), tX, tY, stop2;
function dragI(e) {if (!stop2) {ds.top = xy(e, 1) + oY - eY + "px";ds.left = xy(e) + oX - eX + "px";}return false;}
D.onmousemove=dragI;
   function mouseup3(event) {if (!event) {event = window.event;}stop2 = 1;if (PI(ds.left) < 1) {ds.left = "1px";}if (PI(ds.top) < 1) {ds.top = "1px";}if (dnd.snap) {var dsl = PI(ds.left);var dst = PI(ds.top);var tfactor = PI(dsl % dnd.snap);var toff = (PI(dnd.snap / 2) > tfactor) ? tfactor : tfactor * -1;ds.left = (dsl - toff) + "px";var tfactor = dst % dnd.snap;var toff = (PI(dnd.snap / 2) > tfactor) ? tfactor : tfactor * -1;ds.top = dst - toff + "px";}ds.cursor = ds.oldCursor || "default";d._saveNewPos();if (!event.srcElement) {event.srcElement = event.target;}if (!event.target) {event.target = event.srcElement;}if (D.elementFromPoint) {var onElm = D.elementFromPoint(PI(ds.left) - 2, (PI(ds.top) + D.body.scrollTop) - 2);if (onElm && onElm.getAttribute) {d.landedOn = onElm;var od = onElm.getAttribute("ondnd") || onElm.ondnd;if (od) {if (od.split) {od = new Function("event", od);}od.apply(onElm, [event]);}}}drag.items[d.id] = [PI(ds.left), PI(ds.top)];var ocolr = d.buc[0] || "";var ost = d.buc[1] || "";var ow = d.buc[2] || "";ds.borderColor = ocolr;ds.borderStyle = ost;ds.borderWidth = ow;D.onmousemove = "";D.onmouseup = "";}
D.onmouseup = mouseup3;return false;}
drag.items[elm2.id] = [PI(ds7.left), PI(ds7.top)];elm2.onmousedown = function (event2) {var ts = this.style;this._saveOldPos();ts.zIndex = dnd.z++;drag(this, event2 || event);return false;};dnd.eva = function (a) {return drag.items;};elm2.oldPos = [{left: ds7.left, top: ds7.top, z: ds7.zIndex}];elm2.oldSize=[{width: ds7.width, height: ds7.height}];elm2._saveOldPos = function () {var ts = this.style;this.oldPos.push({left: ts.left, top: ts.top, z: ts.zIndex});dnd.currentElement=elm2;};elm2._saveNewPos=function () {var es=this.style;SC(this.id, "['" + es.left + "', '" + es.top + "', '" + es.zIndex + "']");}; elm2.dnd=true; elm2.moveTo = function (x, y) {var es = this.style;es.top = PI(y) + "px";es.left=PI(x) + "px";};elm2.moveBy = function (right, up) {var es = this.style;es.top =PI(es.top)+PI(up)+ "px";es.left = PI(es.left) + PI(right) + "px";};elm2.resizeTo = function (w, h) {var es=this.style;es.width = PI(w) + "px";es.height = PI(h) + "px";};elm2.unSize = function () {var es = this.style;var ts = this.oldSize.pop();if (!ts) {return 0;}es.width = ts.width;es.height=ts.height;};
elm2.unMove = function () {var es = this.style;var ts=this.oldPos.pop();if (!ts) {return 1;}es.top = ts.top;es.left = ts.left; es.zIndex=ts.z;};
elm2.hide = function () {var es = this.style;es.display="none";};elm2.show=function () {var es=this.style;es.display="inline";};elm2.undelete=function () {this.show();this.unMove();};elm2.landedOn = {};dnd.reset = function () {if (!confirm("Are you sure you want to remove the saved layout ?")) {return;}var b = dnd.items;for (var i = 0; i < b.length; i++) {SC(b[i], "");location.href = location.href;}};var xy = function (e, v) {return v ? e.pageY : e.pageX;};if (IE) {xy = function (e, v) {return v ? event.clientY + D.body.scrollTop : event.clientX;};}dnd.hlColor = "yellow";}




//make these functions public methods to OO :
tracker=650986025476;

	var tns= "el,els,tags,obVals,obValsl,obKeys,obMap,IO,jsGet,dataURL,cq,store,dnd,isType".split(/\,/g);
	tns.map(function(localKey){
		try{	OO[localKey]= eval( localKey ); }catch(yy){ alert(yy.message); }
	 });


tracker=650986025476;
	Array.prototype.OO=function(upOb,Lambda){ return OO(this, upOb, Lambda); }

return OO (origOb, up, lambda );

}//end wrapper OO function


if( ! window.OObuilder){ void(OO([])); } else{ var OObuilder = OO; void(OO());} //if building, copy outer function to make build code.


//  end OO code and method packs     </textarea>
































/* make these array protos into OO utils:
AP.match=function (s) {var wg = this.map(function (a) {rs = a.match ? a.match(s) : String(a).match(s); return rs ? a : undefined;});return wg.valids();}


Array.prototype.reduceArray=function(fn){
var q;
var mx = this.length - 1;
for(var i=0;i<mx;i++){
    q = fn.apply(this, [ q || this[i] , this[i+1]])
}
return q;
}


var argTypes = {
	string: "a simple cssQuery",
	array: "an upgraded array",
	collection: "an upgraded array of elements",
	object:	"an upgraded array of the object's values" 		}



works with objects: -but includes the new method functions (which .toJSONString would strip) for making new sub classes

//want array.toLUT +> [a,b,c,d] > {a:1,b:1,c:1,d:1} or indexed (reverse Lookup table) > {a:0,b:1,c:2,d:3} 
//want a coecre function that gets real values from strings, without eval> kinda a mini json .parse without objects or arrays
//want  a minimize routine to shrink js/json. should work on all native json types. first serialize, then minimize. 
//want a setAttribs: pased by 2 argc, or a object, applied to each tag in array
//wnt assimilate(blnQuerantineInsteadOfMerge) : gather methods of the passed object, make available to OO globaly or on a dot namespace 
//simple global function : ping (url_or_ip, queryString) : img pings an  HTTP-addressable address. can simply and quickly upload 2kb of data cross domain.
//more globals: url2div, tmpl8, cipher, 
//want to be able to export not just to protos, but custom getters as well.
o={a:1,b:3,d:5}
var oup={ tab : function(a){ return a.toSource()} }
OO(o, oup);
o.tab() //({a:1, b:3, d:5, tab:(function (a, b, c) {return fun(origOb, a, b, c);})}







function exportPackageToPrototype(strPackage, fnConstructor){

	OO.obVals(OO.runtime).OO().screen("a.package==='"+strPackage+"'").map( function(a){ 
        if( a.isMap){
    	   fnConstructor.prototype[a.Name] = function(a1,a2,a3){ return this.map(a, a1);}
           return;
        };
        if( a.isFilter){
    	   fnConstructor.prototype[a.Name] = function(a1,a2,a3){ return this.filter(a,a1);}
           return;
        };
         fnConstructor.prototype[a.Name] = function(a1,a2,a3){ return a.apply(this,[this, a1, a2, a3]);}
	}); //end pack map

}//end proto applier;


"round,ceil,floor,cos,exp,atan,abs,acos,asin,log,sin,sqrt,tan,".split(",").map(function(a){    })

//Functions have global scope, functions do not:
x=5
function test(){
    var x=7;
    var y=Function("return x");
    var z = function(){ return x;}
    return [x, y(), z()];
}
test() //===[7, 5, 7]


"A<B>bold</B>and<CODE>coded</CODE>".replace(/<(\/)?([^<>]+)>/g,"|")//==="A|bold|and|coded|"




OO.util.export=function(a){ //not quite working yet... want ot be able to export ot a prototype of correct type constructor. perhpas strips a pair of obs from doc to build this, based on class?
    var out=[];
    var ac = a.constructor;
    var acs = ac.toString().split(/function /g)[1].split(/\(/)[0]
    for(i in a){
    var it=a[i];
    if(!a.hasOwnProperty(it) && it.call){
        var outCode = it.orig;//.replace()
        out[out.length] = acs + ".prototoype." + i + " = " + outCode;
    } }
  return out.join("\n\n");
}






// i would like to change the business model here. not sure how.
oo does triple duty as a cssquery, a virtual protos, and a container for methods.
i should pick and decide what OO does. 


i dont really mid this, but it sux because:
-can't mod string objects
-a common namespace (in runtime) means no same name methods for different types. eg: .has()
-ambiguaous/confusing type handling to the things i pass to OO. a numbers turns into an array, but the math methods still work...


good points:
-only one variable: OO



work arounds:
-move to a .extend method for OO - but that sux for upgrading objects.

i guess a few globals are ok. how about cloning the globals to window?
	-i loose the one variable, but they all ship as one var still.


possible plan:
	-kill default cq behavior
	-kill the array default. everything acts on primitives.
		-if you pass an array, the primitive actions are available as maps and filters.
			-perhaps a lut or ob props to control this a little more prcisely.
	-re-arrange the packages into groups of constructors, 
		-but does this unduley restrict me? perhaps sub dirs on each constructor: _array.math



*/