/*!
  * Valentine: JavaScript's Sister
  * copyright Dustin Diaz 2011 (@ded)
  * https://github.com/ded/valentine
  * License MIT
  */!function(a){function j(a,b){for(var c in b)a[c]=b[c]}var b=function(a,b){return new n(a,b)},c=[],d={},e=c.slice,f="map"in c,g="reduce"in c,h=/(^\s*|\s*$)/g,i={each:f?function(a,b,d){c.forEach.call(a,b,d)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)d in a&&b.call(c,a[d],d,a)},map:f?function(a,b,d){return c.map.call(a,b,d)}:function(a,b,c){var d=[],e;for(e=0,l=a.length;e<l;e++)e in a&&(d[e]=b.call(c,a[e],e,a));return d},some:f?function(a,b,c){return a.some(b,c)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(d in a&&b.call(c,a[d],d,a))return!0;return!1},every:f?function(a,b,c){return a.every(b,c)}:function(a,b,c){for(var d=0,e=a.length;d<e;d++)if(d in a&&!b.call(c,a[d],d,a))return!1;return!0},filter:f?function(a,b,c){return a.filter(b,c)}:function(a,b,c){var d=[];for(var e=0,f=0,g=a.length;e<g;e++)if(e in a){if(!b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},indexOf:f?function(a,b,c){return a.indexOf(b,isFinite(c)?c:0)}:function(a,b,c){c=c||0;for(var d=0;d<a.length;d++)if(d in a&&a[d]===b)return d;return-1},lastIndexOf:f?function(a,b,c){return a.lastIndexOf(b,isFinite(c)?c:a.length)}:function(a,b,c){c=c||a.length,c=c>=a.length?a.length:c<0?a.length+c:c;for(var d=c;d>=0;--d)if(d in a&&a[d]===b)return d;return-1},reduce:g?function(a,b,d,e){return c.reduce.call(a,b,d,e)}:function(a,b,c,d){!a&&(a=[]);var e=0,f=a.length;if(arguments.length<3)do{if(e in a){c=a[e++];break}if(++e>=f)throw new TypeError("Empty array")}while(1);for(;e<f;e++)e in a&&(c=b.call(d,c,a[e],e,a));return c},reduceRight:g?function(a,b,d,e){return c.reduceRight.call(a,b,d,e)}:function(a,b,c,d){!a&&(a=[]);var e=a.length,f=e-1;if(arguments.length<3)do{if(f in a){c=a[f--];break}if(--f<0)throw new TypeError("Empty array")}while(1);for(;f>=0;f--)f in a&&(c=b.call(d,c,a[f],f,a));return c},find:function(a,b,c){var d;i.some(a,function(a,e,f){if(b.call(c,a,e,f)){d=a;return!0}});return d},reject:function(a,b,c){var d=[];for(var e=0,f=0,g=a.length;e<g;e++)if(e in a){if(b.call(c,a[e],e,a))continue;d[f++]=a[e]}return d},size:function(a){return m.toArray(a).length},pluck:function(a,b){return i.map(a,function(a){return a[b]})},compact:function(a){return i.filter(a,function(a){return!!a})},flatten:function(a){return i.reduce(a,function(a,b){if(k.arr(b))return a.concat(i.flatten(b));a[a.length]=b;return a},[])},uniq:function(a){var b=[],c,d;label:for(c=0;c<a.length;c++){for(d=0;d<b.length;d++)if(b[d]==a[c])continue label;b[b.length]=a[c]}return b}},k={fun:function(a){return typeof a=="function"},str:function(a){return typeof a=="string"},ele:function(a){!!a&&!!a.nodeType&&a.nodeType==1},arr:function(a){return a instanceof Array},arrLike:function(a){return a&&a.length&&isFinite(a.length)},num:function(a){return typeof a=="number"},bool:function(a){return a===!0||a===!1},args:function(a){return!!a&&!!d.hasOwnProperty.call(a,"callee")},emp:function(a){var b=0;return k.arr(a)?a.length===0:k.obj(a)?function(){for(var c in a){b++;break}return b===0}():a===""},dat:function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)},reg:function(a){return!(!(a&&a.test&&a.exec)||!a.ignoreCase&&a.ignoreCase!==!1)},nan:function(a){return a!==a},nil:function(a){return a===null},und:function(a){return typeof a=="undefined"},obj:function(a){return a instanceof Object&&!k.fun(a)&&!k.arr(a)}},m={each:function(a,b,c){k.arrLike(a)?i.each(a,b,c):function(){for(var e in a)d.hasOwnProperty.call(a,e)&&b.call(c,e,a[e],a)}()},map:function(a,b,c){var e=[],f=0;return k.arrLike(a)?i.map(a,b,c):!function(){for(var g in a)d.hasOwnProperty.call(a,g)&&(e[f++]=b.call(c,g,a[g],a))}()&&e},toArray:function(a){if(!a)return[];if(a.toArray)return a.toArray();if(k.arr(a))return a;if(k.args(a))return e.call(a);return i.map(a,function(a){return a})},first:function(a){return a[0]},last:function(a){return a[a.length-1]},keys:Object.keys?function(a){return Object.keys(a)}:function(a){var b=[];for(var c in a)d.hasOwnProperty.call(a,c)&&(b[b.length]=c);return b},values:function(a){return m.map(a,function(a,b){return b})},extend:function(a){m.each(e.call(arguments,1),function(b){for(var c in b)!k.und(b[c])&&(a[c]=b[c])});return a},trim:String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(h,"")},bind:function(a,b){return function(){b.apply(a,arguments)}}};j(b,i),j(b,m),b.is=k,b.v=b;var n=function(a,b){this.val=a,this._scope=b||null,this._chained=0};b.each(b.extend({},i,m),function(a,c){n.prototype[a]=function(){var a=b.toArray(arguments);a.unshift(this.val);var d=c.apply(this._scope,a);this.val=d;return this._chained?this:d}}),n.prototype.chain=function(){this._chained=1;return this},n.prototype.value=function(){return this.val};var o=a.v;b.noConflict=function(){a.v=o;return this},typeof module!="undefined"&&module.exports?module.exports=b:a.v=b}(this)
