(function(){var root=this;var previousUnderscore=root._;var breaker={};var ArrayProto=Array.prototype,ObjProto=Object.prototype,FuncProto=Function.prototype;var slice=ArrayProto.slice,concat=ArrayProto.concat,unshift=ArrayProto.unshift,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty;var nativeForEach=ArrayProto.forEach,nativeMap=ArrayProto.map,nativeReduce=ArrayProto.reduce,nativeReduceRight=ArrayProto.reduceRight,nativeFilter=ArrayProto.filter,nativeEvery=ArrayProto.every,nativeSome=ArrayProto.some,nativeIndexOf=ArrayProto.indexOf,nativeLastIndexOf=ArrayProto.lastIndexOf,nativeIsArray=Array.isArray,nativeKeys=Object.keys,nativeBind=FuncProto.bind;var _=function(obj){return new wrapper(obj)};if(typeof exports!=='undefined'){if(typeof module!=='undefined'&&module.exports)exports=module.exports=_;exports._=_}else if(typeof define==='function'&&define.amd)define('underscore',function(){return _});else root._=_;_.VERSION='1.2.3';var each=_.each=_.forEach=function(obj,iterator,context){if(obj==null)return;if(nativeForEach&&obj.forEach===nativeForEach)obj.forEach(iterator,context);else if(obj.length===+obj.length){for(var i=0,l=obj.length;i<l;i++)if(i in obj&&iterator.call(context,obj[i],i,obj)===breaker)return}else for(var key in obj)if(hasOwnProperty.call(obj,key)){if(iterator.call(context,obj[key],key,obj)===breaker)return}};_.map=function(obj,iterator,context){var results=[];if(obj==null)return results;if(nativeMap&&obj.map===nativeMap)return obj.map(iterator,context);each(obj,function(value,index,list){results[results.length]=iterator.call(context,value,index,list)});return results};_.reduce=_.foldl=_.inject=function(obj,iterator,memo,context){var initial=arguments.length>2;if(obj==null)obj=[];if(nativeReduce&&obj.reduce===nativeReduce){if(context)iterator=_.bind(iterator,context);return initial?obj.reduce(iterator,memo):obj.reduce(iterator)};each(obj,function(value,index,list){if(!initial){memo=value;initial=true}else memo=iterator.call(context,memo,value,index,list)});if(!initial)throw new TypeError('Reduce of empty array with no initial value');return memo};_.reduceRight=_.foldr=function(obj,iterator,memo,context){var initial=arguments.length>2;if(obj==null)obj=[];if(nativeReduceRight&&obj.reduceRight===nativeReduceRight){if(context)iterator=_.bind(iterator,context);return initial?obj.reduceRight(iterator,memo):obj.reduceRight(iterator)};var reversed=_.toArray(obj).reverse();if(context&&!initial)iterator=_.bind(iterator,context);return initial?_.reduce(reversed,iterator,memo,context):_.reduce(reversed,iterator)};_.find=_.detect=function(obj,iterator,context){var result;any(obj,function(value,index,list){if(iterator.call(context,value,index,list)){result=value;return true}});return result};_.filter=_.select=function(obj,iterator,context){var results=[];if(obj==null)return results;if(nativeFilter&&obj.filter===nativeFilter)return obj.filter(iterator,context);each(obj,function(value,index,list){if(iterator.call(context,value,index,list))results[results.length]=value});return results};_.reject=function(obj,iterator,context){var results=[];if(obj==null)return results;each(obj,function(value,index,list){if(!iterator.call(context,value,index,list))results[results.length]=value});return results};_.every=_.all=function(obj,iterator,context){var result=true;if(obj==null)return result;if(nativeEvery&&obj.every===nativeEvery)return obj.every(iterator,context);each(obj,function(value,index,list){if(!(result=result&&iterator.call(context,value,index,list)))return breaker});return result};var any=_.some=_.any=function(obj,iterator,context){iterator||(iterator=_.identity);var result=false;if(obj==null)return result;if(nativeSome&&obj.some===nativeSome)return obj.some(iterator,context);each(obj,function(value,index,list){if(result||(result=iterator.call(context,value,index,list)))return breaker});return !!result};_.include=_.contains=function(obj,target){var found=false;if(obj==null)return found;if(nativeIndexOf&&obj.indexOf===nativeIndexOf)return obj.indexOf(target)!=-1;found=any(obj,function(value){return value===target});return found};_.invoke=function(obj,method){var args=slice.call(arguments,2);return _.map(obj,function(value){return (method.call?method||value:value[method]).apply(value,args)})};_.pluck=function(obj,key){return _.map(obj,function(value){return value[key]})};_.max=function(obj,iterator,context){if(!iterator&&_.isArray(obj))return Math.max.apply(Math,obj);if(!iterator&&_.isEmpty(obj))return -Infinity;var result={computed:-Infinity};each(obj,function(value,index,list){var computed=iterator?iterator.call(context,value,index,list):value;computed>=result.computed&&(result={value:value,computed:computed})});return result.value};_.min=function(obj,iterator,context){if(!iterator&&_.isArray(obj))return Math.min.apply(Math,obj);if(!iterator&&_.isEmpty(obj))return Infinity;var result={computed:Infinity};each(obj,function(value,index,list){var computed=iterator?iterator.call(context,value,index,list):value;computed<result.computed&&(result={value:value,computed:computed})});return result.value};_.shuffle=function(obj){var shuffled=[],rand;each(obj,function(value,index,list){if(index==0)shuffled[0]=value;else{rand=Math.floor(Math.random()*(index+1));shuffled[index]=shuffled[rand];shuffled[rand]=value}});return shuffled};_.sortBy=function(obj,iterator,context){return _.pluck(_.map(obj,function(value,index,list){return {value:value,criteria:iterator.call(context,value,index,list)}}).sort(function(left,right){var a=left.criteria,b=right.criteria;return a<b?-1:a>b?1:0}),'value')};_.groupBy=function(obj,val){var result={};var iterator=_.isFunction(val)?val:function(obj){return obj[val]};each(obj,function(value,index){var key=iterator(value,index);(result[key]||(result[key]=[])).push(value)});return result};_.sortedIndex=function(array,obj,iterator){iterator||(iterator=_.identity);var low=0,high=array.length;while(low<high){var mid=(low+high)>>1;iterator(array[mid])<iterator(obj)?low=mid+1:high=mid};return low};_.toArray=function(iterable){if(!iterable)return [];if(iterable.toArray)return iterable.toArray();if(_.isArray(iterable))return slice.call(iterable);if(_.isArguments(iterable))return slice.call(iterable);return _.values(iterable)};_.size=function(obj){return _.toArray(obj).length};_.first=_.head=function(array,n,guard){return (n!=null)&&!guard?slice.call(array,0,n):array[0]};_.initial=function(array,n,guard){return slice.call(array,0,array.length-((n==null)||guard?1:n))};_.last=function(array,n,guard){if((n!=null)&&!guard)return slice.call(array,Math.max(array.length-n,0));else return array[array.length-1]};_.rest=_.tail=function(array,index,guard){return slice.call(array,(index==null)||guard?1:index)};_.compact=function(array){return _.filter(array,function(value){return !!value})};_.flatten=function(array,shallow){return _.reduce(array,function(memo,value){if(_.isArray(value))return memo.concat(shallow?value:_.flatten(value));memo[memo.length]=value;return memo},[])};_.without=function(array){return _.difference(array,slice.call(arguments,1))};_.uniq=_.unique=function(array,isSorted,iterator){var initial=iterator?_.map(array,iterator):array;var result=[];_.reduce(initial,function(memo,el,i){if(0==i||(isSorted===true?_.last(memo)!=el:!_.include(memo,el))){memo[memo.length]=el;result[result.length]=array[i]};return memo},[]);return result};_.union=function(){return _.uniq(_.flatten(arguments,true))};_.intersection=_.intersect=function(array){var rest=slice.call(arguments,1);return _.filter(_.uniq(array),function(item){return _.every(rest,function(other){return _.indexOf(other,item)>=0})})};_.difference=function(array){var rest=_.flatten(slice.call(arguments,1));return _.filter(array,function(value){return !_.include(rest,value)})};_.zip=function(){var args=slice.call(arguments);var length=_.max(_.pluck(args,'length'));var results=new Array(length);for(var i=0;i<length;i++)results[i]=_.pluck(args,""+i);return results};_.indexOf=function(array,item,isSorted){if(array==null)return -1;var i,l;if(isSorted){i=_.sortedIndex(array,item);return array[i]===item?i:-1};if(nativeIndexOf&&array.indexOf===nativeIndexOf)return array.indexOf(item);for(i=0,l=array.length;i<l;i++)if(i in array&&array[i]===item)return i;return -1};_.lastIndexOf=function(array,item){if(array==null)return -1;if(nativeLastIndexOf&&array.lastIndexOf===nativeLastIndexOf)return array.lastIndexOf(item);var i=array.length;while(i--)if(i in array&&array[i]===item)return i;return -1};_.range=function(start,stop,step){if(arguments.length<=1){stop=start||0;start=0};step=arguments[2]||1;var len=Math.max(Math.ceil((stop-start)/step),0);var idx=0;var range=new Array(len);while(idx<len){range[idx++]=start;start+=step};return range};var ctor=function(){};_.bind=function bind(func,context){var bound,args;if(func.bind===nativeBind&&nativeBind)return nativeBind.apply(func,slice.call(arguments,1));if(!_.isFunction(func))throw new TypeError();args=slice.call(arguments,2);return bound=function(){if(!(this instanceof bound))return func.apply(context,args.concat(slice.call(arguments)));ctor.prototype=func.prototype;var self=new ctor();var result=func.apply(self,args.concat(slice.call(arguments)));if(Object(result)===result)return result;return self}};_.bindAll=function(obj){var funcs=slice.call(arguments,1);if(funcs.length==0)funcs=_.functions(obj);each(funcs,function(f){obj[f]=_.bind(obj[f],obj)});return obj};_.memoize=function(func,hasher){var memo={};hasher||(hasher=_.identity);return function(){var key=hasher.apply(this,arguments);return hasOwnProperty.call(memo,key)?memo[key]:(memo[key]=func.apply(this,arguments))}};_.delay=function(func,wait){var args=slice.call(arguments,2);return setTimeout(function(){return func.apply(func,args)},wait)};_.defer=function(func){return _.delay.apply(_,[func,1].concat(slice.call(arguments,1)))};_.throttle=function(func,wait){var context,args,timeout,throttling,more;var whenDone=_.debounce(function(){more=throttling=false},wait);return function(){context=this;args=arguments;var later=function(){timeout=null;if(more)func.apply(context,args);whenDone()};if(!timeout)timeout=setTimeout(later,wait);if(throttling)more=true;else func.apply(context,args);whenDone();throttling=true}};_.debounce=function(func,wait){var timeout;return function(){var context=this,args=arguments;var later=function(){timeout=null;func.apply(context,args)};clearTimeout(timeout);timeout=setTimeout(later,wait)}};_.once=function(func){var ran=false,memo;return function(){if(ran)return memo;ran=true;return memo=func.apply(this,arguments)}};_.wrap=function(func,wrapper){return function(){var args=concat.apply([func],arguments);return wrapper.apply(this,args)}};_.compose=function(){var funcs=arguments;return function(){var args=arguments;for(var i=funcs.length-1;i>=0;i--)args=[funcs[i].apply(this,args)];return args[0]}};_.after=function(times,func){if(times<=0)return func();return function(){if(--times<1)return func.apply(this,arguments)}};_.keys=nativeKeys||function(obj){if(obj!==Object(obj))throw new TypeError('Invalid object');var keys=[];for(var key in obj)if(hasOwnProperty.call(obj,key))keys[keys.length]=key;return keys};_.values=function(obj){return _.map(obj,_.identity)};_.functions=_.methods=function(obj){var names=[];for(var key in obj)if(_.isFunction(obj[key]))names.push(key);return names.sort()};_.extend=function(obj){each(slice.call(arguments,1),function(source){for(var prop in source)if(source[prop]!==void(0))obj[prop]=source[prop]});return obj};_.defaults=function(obj){each(slice.call(arguments,1),function(source){for(var prop in source)if(obj[prop]==null)obj[prop]=source[prop]});return obj};_.clone=function(obj){if(!_.isObject(obj))return obj;return _.isArray(obj)?obj.slice():_.extend({},obj)};_.tap=function(obj,interceptor){interceptor(obj);return obj}
function eq(a,b,stack){if(a===b)return a!==0||1/a==1/b;if(a==null||b==null)return a===b;if(a._chain)a=a._wrapped;if(b._chain)b=b._wrapped;if(a.isEqual&&_.isFunction(a.isEqual))return a.isEqual(b);if(b.isEqual&&_.isFunction(b.isEqual))return b.isEqual(a);var className=toString.call(a);if(className!=toString.call(b))return false;switch(className){case'[object String]':return a==String(b);case'[object Number]':return a!=+a?b!=+b:(a==0?1/a==1/b:a==+b);case'[object Date]':case'[object Boolean]':return +a==+b;case'[object RegExp]':return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase};if(typeof a!='object'||typeof b!='object')return false;var length=stack.length;while(length--)if(stack[length]==a)return true;stack.push(a);var size=0,result=true;if(className=='[object Array]'){size=a.length;result=size==b.length;if(result){while(size--)if(!(result=size in a==size in b&&eq(a[size],b[size],stack)))break}}else{if('constructor' in a!='constructor' in b||a.constructor!=b.constructor)return false;for(var key in a)if(hasOwnProperty.call(a,key)){size++;if(!(result=hasOwnProperty.call(b,key)&&eq(a[key],b[key],stack)))break};if(result){for(key in b)if(hasOwnProperty.call(b,key)&&!(size--))break;result=!size}};stack.pop();return result};_.isEqual=function(a,b){return eq(a,b,[])};_.isEmpty=function(obj){if(_.isArray(obj)||_.isString(obj))return obj.length===0;for(var key in obj)if(hasOwnProperty.call(obj,key))return false;return true};_.isElement=function(obj){return !!(obj&&obj.nodeType==1)};_.isArray=nativeIsArray||function(obj){return toString.call(obj)=='[object Array]'};_.isObject=function(obj){return obj===Object(obj)};_.isArguments=function(obj){return toString.call(obj)=='[object Arguments]'};if(!_.isArguments(arguments))_.isArguments=function(obj){return !!(obj&&hasOwnProperty.call(obj,'callee'))};_.isFunction=function(obj){return toString.call(obj)=='[object Function]'};_.isString=function(obj){return toString.call(obj)=='[object String]'};_.isNumber=function(obj){return toString.call(obj)=='[object Number]'};_.isNaN=function(obj){return obj!==obj};_.isBoolean=function(obj){return obj===true||obj===false||toString.call(obj)=='[object Boolean]'};_.isDate=function(obj){return toString.call(obj)=='[object Date]'};_.isRegExp=function(obj){return toString.call(obj)=='[object RegExp]'};_.isNull=function(obj){return obj===null};_.isUndefined=function(obj){return obj===void(0)};_.noConflict=function(){root._=previousUnderscore;return this};_.identity=function(value){return value};_.times=function(n,iterator,context){for(var i=0;i<n;i++)iterator.call(context,i)};_.escape=function(string){return (''+string).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#x27;').replace(/\//g,'&#x2F;')};_.mixin=function(obj){each(_.functions(obj),function(name){addToWrapper(name,_[name]=obj[name])})};var idCounter=0;_.uniqueId=function(prefix){var id=idCounter++;return prefix?prefix+id:id};_.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};_.template=function(str,data){var c=_.templateSettings;var tmpl='var __p=[],print=function(){__p.push.apply(__p,arguments);};'+'with(obj||{}){__p.push(\''+str.replace(/\\/g,'\\\\').replace(/'/g,"\\'").replace(c.escape,function(match,code){return "',_.escape("+code.replace(/\\'/g,"'")+"),'"}).replace(c.interpolate,function(match,code){return "',"+code.replace(/\\'/g,"'")+",'"}).replace(c.evaluate||null,function(match,code){return "');"+code.replace(/\\'/g,"'").replace(/[\r\n\t]/g,' ')+";__p.push('"}).replace(/\r/g,'\\r').replace(/\n/g,'\\n').replace(/\t/g,'\\t')+"');}return __p.join('');";var func=new Function('obj','_',tmpl);if(data)return func(data,_);return function(data){return func.call(this,data,_)}};var wrapper=function(obj){this._wrapped=obj};_.prototype=wrapper.prototype;var result=function(obj,chain){return chain?_(obj).chain():obj};var addToWrapper=function(name,func){wrapper.prototype[name]=function(){var args=slice.call(arguments);unshift.call(args,this._wrapped);return result(func.apply(_,args),this._chain)}};_.mixin(_);each(['pop','push','reverse','shift','sort','splice','unshift'],function(name){var method=ArrayProto[name];wrapper.prototype[name]=function(){method.apply(this._wrapped,arguments);return result(this._wrapped,this._chain)}});each(['concat','join','slice'],function(name){var method=ArrayProto[name];wrapper.prototype[name]=function(){return result(method.apply(this._wrapped,arguments),this._chain)}});wrapper.prototype.chain=function(){this._chain=true;return this};wrapper.prototype.value=function(){return this._wrapped}}).call(this);if(Globals.PRODUCTION||!window.console){var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];window.console={};for(var i=0,len=names.length;i<len;++i)window.console[names[i]]=function(){}};$(document).ready(function(){$(window).resize(fixLightboxes);if(Globals.TOUCH){$("body").addClass("touch");jQuery.fx.off=true};$(".shareButton").live('click',function(){var WIDTH=550,HEIGHT=450;var url=$(this).attr('data-url');var type=$(this).attr('data-type');Analytics.trackEvent("Viral",type+" Share",$(this).attr('data-id'));if(type!=='Email'){var top=($(window).height()-HEIGHT)/2;var left=($(window).width()-WIDTH)/2;window.open(url,type,"top="+top+",left="+left+",width=550,height=450,scrollbars=no,toolbar=no,location=no,menubar=no")}});$("#logo").click(function(){Analytics.trackEvent("Navigation","Logo")});$("#indexCrumb").click(function(){Analytics.trackEvent("Navigation","Start Over")});$("#editCrumb").click(function(){Analytics.trackEvent("Navigation","Edit Crumb")});$("#resultsCrumb").click(function(){Analytics.trackEvent("Navigation","Results Crumb")});$("#footerFB").click(function(){Analytics.trackPage('viral/footer/facebook');Analytics.trackEvent("Navigation","Facebook")});$("#footerTwitter").click(function(){Analytics.trackPage('viral/footer/twitter');Analytics.trackEvent("Navigation","Twitter")});$("body").ajaxError(function(evt,xhr,settings){if(settings.suppressErrors)return;var msg="<p class='lightboxHeader first centered'>We're sorry. Something went wrong.</p>";msg+="<p><strong>Don't panic.</strong> Wait a moment and try what you were doing again.</p>";msg+="<p>We apologize for the inconvenience. We've been notified and are looking into your problem.</p>";lightbox(msg,{width:620})})});if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0;i<this.length;i++)if(this[i]==obj)return i;return -1}}
function fixLightboxes(){if($("#message").length==1)positionLightbox()}
function validateEmail(email){var regex=/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i;return !!email.match(regex)};String.prototype.capitalize=function(){return this.replace(/\S+/g,function(a){return a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()})};(function($){$.fn.extend({_is:$.fn.is,is:function(s){return s?this._is(s):!!this.length}})})(jQuery)
function htmlEncode(value){return $('<div/>').text(value).html()}
function htmlDecode(value){return $('<div/>').html(value).text()};var Analytics={};Analytics.debug=!Globals.PRODUCTION;Analytics.makeCalls=Globals.PRODUCTION;if(Globals.DEBUG!==undefined)Analytics.debug=Globals.DEBUG;if(Globals.MAKE_CALLS!==undefined)Analytics.makeCalls=Globals.MAKE_CALLS;if(Analytics.makeCalls){var _gaq=_gaq||[];var DEBUG="UA-15938449-4",PROD="UA-15938449-5",tag=(Analytics.debug?DEBUG:PROD);_gaq.push(['_setAccount',tag],['_setAllowHash',false],['_setAllowLinker',true],(Globals.PAGE_TRACK_URL?['_trackPageView',Globals.PAGE_TRACK_URL]:['_trackPageView']))};if(Analytics.debug)console.log("Loaded page. debug mode enabled, makeCalls mode "+(Analytics.makeCalls?"enabled":"disabled"));(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s)})();Analytics.trackEvent=function(category,action,label,value){if(this.debug)this.eventLog(category,action,label,value);if(this.makeCalls)_gaq.push(['_trackEvent',category,action,label,value])};Analytics.trackPage=function(url){url='/'+url;if(this.debug)console.log(url);if(this.makeCalls)_gaq.push(['_trackPageview',url])};Analytics.eventLog=function(category,action,label,value){var msg='';if(category)msg+=category;if(action)msg+=" > "+action;if(label)msg+=" > "+label;if(value)msg+=" > "+value;console.log(msg)};if(ref!=null)Analytics.trackEvent('Referrer',ref);(function($){var $scrollTo=$.scrollTo=function(target,duration,settings){$(window).scrollTo(target,duration,settings)};$scrollTo.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};$scrollTo.window=function(scope){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var elem=this,isWin=!elem.nodeName||$.inArray(elem.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return elem;var doc=(elem.contentWindow||elem).document||elem.ownerDocument||elem;return $.browser.safari||doc.compatMode=='BackCompat'?doc.body:doc.documentElement})};$.fn.scrollTo=function(target,duration,settings){if(typeof duration=='object'){settings=duration;duration=0};if(typeof settings=='function')settings={onAfter:settings};if(target=='max')target=9e9;settings=$.extend({},$scrollTo.defaults,settings);duration=duration||settings.speed||settings.duration;settings.queue=settings.queue&&settings.axis.length>1;if(settings.queue)duration/=2;settings.offset=both(settings.offset);settings.over=both(settings.over);return this._scrollable().each(function(){var elem=this,$elem=$(elem),targ=target,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':{if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break};targ=$(targ,this)};case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()};$.each(settings.axis.split(''),function(i,axis){var Pos=axis=='x'?'Left':'Top',pos=Pos.toLowerCase(),key='scroll'+Pos,old=elem[key],max=$scrollTo.max(elem,axis);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(settings.margin){attr[key]-=parseInt(targ.css('margin'+Pos))||0;attr[key]-=parseInt(targ.css('border'+Pos+'Width'))||0};attr[key]+=settings.offset[pos]||0;if(settings.over[pos])attr[key]+=targ[axis=='x'?'width':'height']()*settings.over[pos]}else{var val=targ[pos];attr[key]=val.slice&&val.slice(-1)=='%'?parseFloat(val)/100*max:val};if(/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&settings.queue){if(old!=attr[key])animate(settings.onAfterFirst);delete attr[key]}});animate(settings.onAfter)
function animate(callback){$elem.animate(attr,duration,settings.easing,callback&&function(){callback.call(this,target,settings)})}}).end()};$scrollTo.max=function(elem,axis){var Dim=axis=='x'?'Width':'Height',scroll='scroll'+Dim;if(!$(elem).is('html,body'))return elem[scroll]-$(elem)[Dim.toLowerCase()]();var size='client'+Dim,html=elem.ownerDocument.documentElement,body=elem.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[size],body[size])}
function both(val){return typeof val=='object'?val:{top:val,left:val}}})(jQuery);(function($){$.fn.friendlyHover=function(callback){if(Globals.TOUCH)return this.on('touchend',callback);else return this.hoverIntent(callback,function(){})}})(jQuery);(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t)ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1)ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1)ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);var EMAIL_SAVE=0;var EMAIL_SHARE=1;var EMAIL_CONTACTUS=2
function showEmailLightbox(type,url,label){var out='';var w=500;switch(type){case EMAIL_SAVE:{var title="<p class='first lightboxHeader centered'>Want to come back later?</p>";var intro="<p>Send yourself a link to this page so you don't have to add your courses again the next time.</p>";var form="<form><span>your email:</span><input type='text' name='email' id='email' tabindex='1'/><br/><input id='submit' type='submit' tabindex='2' value='Send'/></div></form>";out=title+intro+form;break};case EMAIL_SHARE:{var title="<p class='first lightboxHeader centered'>"+label+"</p>";var intro="<p class='centered'>Are your friends taking this course? E-mail them a link to this course so they can save on textbooks!</p>";var form="<form><span>your name:</span><input type='text' name='yourname' id='yourname' tabindex='1'/><br/><span>friend's name:</span><input type='text' name='friendname' id='friendname' tabindex='2'/><br/><span>friend's email:</span><input type='text' name='friendemail' id='friendemail' tabindex='3'/><br/><button id='submit' type='submit' tabindex='4' value='Send'/></div></form>";out=title+intro+form;break};case EMAIL_CONTACTUS:{var title="<p class='first lightboxHeader centered'>Contact Us</p>";var intro="<p class='centered'>Do you have any questions, comments, or concerns about GetchaBooks?</p><p class='centered'>E-mail us at <a href='mailto:feedback@getchabooks.com' class='emailLink'>feedback@getchabooks.com</a>.</p>";out=title+intro;w=450;break}};lightbox(out,{width:w,top:100})}
function isValidEmailAddress(emailAddress){var pattern=new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);return pattern.test(emailAddress)};var settings;var tracked=false
function lightbox(data,options,callback){if($("#shade").length>0)hideLightbox(function(){createLightbox(data,options,callback)});else createLightbox(data,options,callback,true)}
function filter_for_escape_key(e){if(e.keyCode===27){Analytics.trackEvent('UI','Closed lightbox','Escape Key');hideLightboxAndShade()}}
function listen_for_escape_key(){$(document).bind('keyup',filter_for_escape_key)}
function unlisten_for_escape_key(){$(document).unbind('keyup',filter_for_escape_key)}
function createLightbox(data,options,callback,doCreateShade){var defaultTop=100;if(Globals.TOUCH)defaultTop=80;settings=$.extend({width:730,top:defaultTop,easyDismiss:true},options||{});if(doCreateShade){var shade="<div id='shade'></div>";$(shade).appendTo("html").fadeIn('fast').show()};var content="<div id='message'>"+data+"</div>";$(content).width(settings.width).appendTo("body");positionLightbox();if(callback)callback();if(settings.easyDismiss)$("#shade").click(hideLightboxAndShade);listen_for_escape_key();$("#message").fadeIn().show()}
function addCancelAndShow(top){var $message=$("#message");$message.fadeIn('fast').show();$("<img src='"+Globals.IMG_PATH+"cancel.png' id='cancel'/>").appendTo("#message").click(hideLightboxAndShade);$("#cancel").fadeIn('fast').show()}
function hideLightboxAndShade(){var source=$(this).attr('id');if(source==='shade'||source==='cancel')Analytics.trackEvent("UI","Closed Lightbox",source.capitalize());unlisten_for_escape_key();hideLightbox();hideShade()}
function hideLightbox(callbackFn){$("#message").fadeOut('fast',function(){$(this).remove();if(callbackFn)callbackFn()})}
function hideShade(){$("#shade").fadeOut('fast',function(){$(this).remove()})}
function positionLightbox(doCreateShade){var $message=$('#message');var top=settings.top;var left=($(document).width()-$message.width())/2;var CANCEL=25;var windowWidth=$(window).width();var messageWidth=$message.outerWidth();while(((left*2+CANCEL+messageWidth)>windowWidth)&&left>0)left--;$message.css('left',left);var windowHeight=$(window).height();var messageHeight=$message.outerHeight();while(((top+messageHeight)>windowHeight)&&top>CANCEL)top--;$message.css('top',top);if($("#cancel").length!==1){addCancelAndShow(top);$("#message").show()}};(function($){$.fn.tooltip=function(options){var defaults={html:'',side:'bottom',width:-1,height:-1,margin:10,type:'standard',touch:false,canMouseIn:false,autoHeight:false,boundingElem:"#main",forceInsideBounds:forceInsideBounds};if(options.height==='auto'||!options.height)options.autoHeight=true;if(options.touch)options.type='touch';var opts=$.extend(defaults,options);var $parent,$elem,closeFn;var TAIL_SIZE=12
function closeStandardTooltips(){$("div.tooltip:not(.important, .hover)").remove();$(".hasTooltip:not(.hasImportantTooltip)").removeClass("hasTooltip");if($("div.tooltip:not(.important,.hover)").size()===0)$("body").off("click keyup",closeStandardTooltips)}
function closeTouchTooltips(){$("div.tooltip").remove();$(".hasTooltip").removeClass("hasTooltip");$("body").off("touchend",closeTouchTooltips)}
function closeHoverTooltips(){var _removeInactiveHoverTips=function(){$('div.tooltip.hover:not(.activeHover)').remove();$('.hasTooltip.hasHoverTooltip').removeClass('hasTooltip hasHoverTooltip')};setTimeout(_removeInactiveHoverTips,100);$(this).off('mouseleave',closeHoverTooltips)}
function setCloseFunction(e){closeFn=closeStandardTooltips;switch(opts.type){case'touch':{if($parent.hasClass('hasTooltip')){closeTouchTooltips();e.stopPropagation()};closeFn=closeTouchTooltips;closeTouchTooltips();break};case'hover':{closeFn=closeHoverTooltips;break};case'important':{closeFn=$.closeImportantTooltips;break}};return closeFn}
function getPosition(){var p=$.extend($parent.offset(),{height:$parent.innerHeight(),width:$parent.width()});var css={width:opts.width};if(!opts.autoHeight)css.height=opts.height;switch(opts.side){case'top':{css.top=p.top-(opts.height+TAIL_SIZE+opts.margin);css.left=p.left-(opts.width-p.width)/2;break};case'bottom':{css.top=p.top+p.height+TAIL_SIZE+opts.margin;css.left=p.left-(opts.width-p.width)/2;break};case'left':{css.left=p.left-(opts.width+TAIL_SIZE+opts.margin);css.top=p.top-(opts.height-p.height)/2;break};case'right':{css.left=p.left+p.width+TAIL_SIZE+opts.margin;css.top=p.top-(opts.height-p.height)/2;break}};return css}
function renderTooltip(){$elem=$("<div class='tooltip "+opts.side+"'/>").html(opts.html).css(getPosition()).append("<div class='tail'><div class='shadow'></div></div>").appendTo('body');if(opts.autoHeight){opts.height=$elem.height();opts.autoHeight=false;$elem.css(getPosition())};if(typeof opts.forceInsideBounds==='function')opts.forceInsideBounds($elem)}
function bindEvents(){switch(opts.type){case'standard':{$("body").on('click keyup',closeFn);break};case'touch':{$("body").on('touchend',closeFn);break};case'hover':{$elem.addClass("hover");$parent.addClass('hasHoverTooltip');$parent.on('mouseleave',closeFn);if(opts.canMouseIn)$elem.on('mouseenter mouseleave',function(){$elem.toggleClass("activeHover");closeFn()});break};case'important':{$elem.addClass("important");$parent.addClass('hasImportantTooltip');break}}}
function forceInsideBounds($elem){var $tail=$elem.find('div.tail'),$bounds=$(opts.boundingElem),offset=$bounds.offset();tailPos=$tail.position(),isVertical=(opts.side==='top'||opts.side==='bottom'),pos=$.extend($elem.position(),{width:$elem.width(),height:$elem.height()});var CSS={},tailCSS={},changed=false;var rightDiff=($bounds.outerWidth()+offset.left)-pos.left;if(rightDiff<pos.width){CSS.left=pos.left+(rightDiff-pos.width);if(isVertical)tailCSS.left=tailPos.left-(rightDiff-pos.width);changed=true};var bottomDiff=($bounds.outerHeight()+offset.top)-(pos.top+pos.height);if(bottomDiff<0){CSS.top=pos.top+(bottomDiff-10);if(!isVertical)tailCSS.top=tailPos.top-bottomDiff;changed=true};if(changed){$elem.css(CSS);$tail.css(tailCSS)}};return this.each(function(e){$parent=$(this);setCloseFunction(e);if($parent.hasClass('hasTooltip')){closeFn();return this};$parent.addClass('hasTooltip');renderTooltip();bindEvents();return this})};$.tooltip={closeImportant:function(){$("div.tooltip").remove();$(".hasTooltip.hasImportantTooltip").removeClass("hasTooltip hasImportantTooltip")}}})(jQuery);$.fn.fitText=function(desiredHeight){var font;return this.each(function(){font=parseFloat($(this).css('font-size'));if(!desiredHeight){while($(this).scrollHeight>$(this).clientHeight){updateFont();$(this).css('font-size',font)};true}else{while($(this).outerHeight()>desiredHeight){updateFont();$(this).css('font-size',font)};true}})
function updateFont(){font*=0.9}};$.autocomplete=function(userOptions,userFunctions){var defaultOptions={type:undefined,inputSelector:undefined,outputContainerSelector:undefined,ajaxThrottleTimeout:0,touch:false,hideOnBlur:false,hideOnEmptySearch:false};var currentScrollPosition=-1;var usingArrowKeys=true;var ajaxTimeout=null;var lastQuery="";var xhr=null;var opts=$.extend({},defaultOptions,userOptions);var fns;var defaultFunctions={ajaxURL:function(){return undefined},getLocalData:function(query){throw ("Unimplemented function: getLocalData()")},filterLocalData:function(data,query){throw ("Unimplemented function: filterLocalData()")},stringifyListItem:function(object,query){throw ("Unimplemented function: stringifyListItem()")},stringifyFailedSearch:function(query){throw ("Unimplemented function: stringifyFailedSearch()")},listItemWasSelected:function(elem){return},filterQuery:function(query){return query},init:function(){$(document).ready(function(){$(opts.outputContainerSelector).on('mouseover','li',fns.mouseoverListItem);$(opts.outputContainerSelector).on('mouseout','li',fns.mouseoutListItem);$(opts.outputContainerSelector).on('click','li',fns.clickListItem);$(opts.inputSelector).on('keyup',fns.keyupSearchBox);$(opts.inputSelector).on('keydown',fns.keydownSearchBox);$(opts.inputSelector).on('blur',fns.blurSearchBox);$(opts.inputSelector).on('focus',fns.focusSearchBox)})},stringifyItems:function(data,query){var s='';_.each(data,function(value){s+=(fns.stringifyListItem(value,query))});return s},clearAndHide:function(){currentScrollPosition=-1;$(opts.inputSelector).val("");$(opts.outputContainerSelector).html("").hide()},onSuccessfulSearch:function(){return},onFailedSearch:function(){return},displayData:function(data,query){var html;if(data.length===0){html=fns.stringifyFailedSearch(query);$(opts.outputContainerSelector).html(html);fns.onFailedSearch()}else{html=fns.stringifyItems(data,query);$(opts.outputContainerSelector).html(html);fns.adjustScrollPositionAndHighlight($.autocomplete.FIRST);fns.onSuccessfulSearch()}},setQuery:function(query){$(opts.inputSelector).val(query);fns.parseInputAndUpdateList()},parseInputAndUpdateList:function(){var query=fns.filterQuery($(opts.inputSelector).val());if(query===lastQuery)return;lastQuery=query;if(opts.hideOnEmptySearch){if(query.replace(/\s/g,"")===""){fns.clearAndHide();return}else $(opts.outputContainerSelector).show()};if(opts.type==="remote"){window.clearTimeout(ajaxTimeout);ajaxTimeout=window.setTimeout(function(){if(xhr&&xhr.abort)xhr.abort();xhr=$.cachedAjax({suppressErrors:true,url:fns.ajaxURL()+encodeURIComponent(query),dataType:"json",success:fns.displayData},query)},opts.ajaxThrottleTimeout)}else fns.displayData(fns.filterLocalData(fns.getLocalData(),query))},focus:function(){$(opts.inputSelector).focus()},blur:function(){$(opts.inputSelector).blur()},getIndexOfLastListItem:function(){return $("li",opts.outputContainerSelector).length-1},getSelectedListItem:function(){return $($("li",opts.outputContainerSelector).get(currentScrollPosition))},adjustScrollPositionAndHighlight:function(movement){if(usingArrowKeys===false&&(movement===$.autocomplete.DOWN||movement===$.autocomplete.UP)){fns.getSelectedListItem().addClass("hover");usingArrowKeys=true;return};$("li",opts.outputContainerSelector).removeClass("hover");switch(movement){case $.autocomplete.DOWN:{currentScrollPosition++;break};case $.autocomplete.UP:{currentScrollPosition--;break};case $.autocomplete.FIRST:{usingArrowKeys=true;currentScrollPosition=0;break};case $.autocomplete.OFF:{usingArrowKeys=false;return};case $.autocomplete.NONE:{if(opts.hideOnBlur)currentScrollPosition=-1;return};default:currentScrollPosition=movement};if(currentScrollPosition<=-1){currentScrollPosition=-1;$(opts.outputContainerSelector).scrollTo(0,0);return};if(currentScrollPosition>fns.getIndexOfLastListItem())currentScrollPosition=fns.getIndexOfLastListItem();var $selectedListItem=fns.getSelectedListItem();if($selectedListItem.length===0)return;var viewTop=$(opts.outputContainerSelector).offset().top;var viewBottom=viewTop+$(opts.outputContainerSelector).height();var itemTop=$selectedListItem.offset().top;var itemBottom=itemTop+$selectedListItem.outerHeight();var isScrolledIntoView=((itemBottom>=viewTop)&&(itemTop<=viewBottom)&&(itemBottom<=viewBottom)&&(itemTop>=viewTop));if(!isScrolledIntoView){if(movement===$.autocomplete.UP)$(opts.outputContainerSelector).scrollTo($selectedListItem,0);else if(movement===$.autocomplete.DOWN){var properTopOffset=$(opts.outputContainerSelector).scrollTop()+(itemBottom-viewBottom);$(opts.outputContainerSelector).scrollTo(properTopOffset,0)}};if(!opts.touch)$selectedListItem.addClass("hover")},mouseoverListItem:function(){fns.adjustScrollPositionAndHighlight($(this).index())},mouseoutListItem:function(){usingArrowKeys=false;fns.adjustScrollPositionAndHighlight($.autocomplete.OFF)},clickListItem:function(e){fns.listItemWasSelected(fns.getSelectedListItem())},keyupSearchBox:function(e){switch(e.keyCode){case 38:break;case 40:break;case 27:{fns.adjustScrollPositionAndHighlight($.autocomplete.NONE);fns.blurSearchBox();break};case 13:{if(currentScrollPosition>=0)fns.listItemWasSelected(fns.getSelectedListItem(),e);break};default:{fns.parseInputAndUpdateList();break}};return false},keydownSearchBox:function(e){switch(e.keyCode){case 38:{fns.adjustScrollPositionAndHighlight($.autocomplete.UP);break};case 40:{$(opts.outputContainerSelector).show();fns.adjustScrollPositionAndHighlight($.autocomplete.DOWN);break};default:break}},focusSearchBox:function(){if(opts.hideOnBlur)$(opts.outputContainerSelector).show()},blurSearchBox:function(e){window.setTimeout(function(){if(opts.hideOnBlur){$(opts.outputContainerSelector).scrollTo(0);$(opts.outputContainerSelector).hide()};fns.adjustScrollPositionAndHighlight($.autocomplete.OFF)},100)}};fns=$.extend({},defaultFunctions,userFunctions);if(!opts.type)throw ("Autocomplete: need to initialize 'type'");if(!opts.inputSelector)throw ("Autocomplete: need to initialize 'inputSelector'");if(!opts.outputContainerSelector)throw ("Autocomplete: need to initialize 'outputContainerSelector'");if(opts.type==="remote"){if(fns.ajaxURL===defaultFunctions.ajaxURL)throw ("Autocomplete: need to initalize 'ajaxURL'")}else if(opts.type==="local"){if(fns.getLocalData===defaultFunctions.getLocalData)throw ("Autocomplete: need to initialize getLocalData()");if(fns.filterLocalData===defaultFunctions.filterLocalData)throw ("Autocomplete: need to initialize filterLocalData()");if(fns.stringifyListItem===defaultFunctions.stringifyListItem)throw ("Autocomplete: need to initialize stringifyListItem()");if(fns.stringifyFailedSearch===defaultFunctions.stringifyListItem)throw ("Autocomplete: need to initialize stringifyListItem()")}else throw ("Autocomplete: invalid type, "+opts.type);return $.extend(fns,opts)};$.autocomplete.DOWN=false;$.autocomplete.UP=true;$.autocomplete.FIRST=0;$.autocomplete.OFF=-2;$.autocomplete.NONE=-1;$.cachedAjax=(function(){var cache={};var x=function(conf,callbackData){console.log("AJAX URL: "+conf.url);if(!cache[conf.url]){var succ=conf.success;conf.success=function(data){cache[conf.url]=data;succ(data,callbackData)};return $.ajax(conf)}else{conf.success(cache[conf.url],callbackData);return null}};x.clear=function(){cache={}};return x})()
