/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Joseph Myers | http://www.codelib.net/ */
function colorscale(a,b){function g(a){return a==f?Infinity:a/(f-a)}function h(a){return a==Infinity?f:f*a/(1+a)}var c=b,d,e;if(c<0||typeof a!="string")return a;a=a.replace(/[^0-9a-f]+/ig,"");if(a.length==3)d=a.split("");else if(a.length==6)d=a.match(/(\w{2})/g);else return a;for(e=0;e<d.length;e++)d[e].length==2?d[e]=parseInt(d[e],16):(d[e]=parseInt(d[e],16),d[e]=d[e]*16+d[e]);var f=parseInt("ff",16);for(e=0;e<d.length;e++)d[e]=h(g(d[e])*c),d[e]=Math.floor(d[e]).toString(16),d[e].length==1&&(d[e]="0"+d[e]);return d.join("")}function showrainbow(a){var b,c,d,e;c=a.orig.value,c=c.replace(/\W/g,""),e=colorscale(c,a.scalef.value-0);if(e!=c){a.outp.value=e,b=document.getElementById("origcolor"),d=document.getElementById("newcolor"),b.style.background="#"+c,d.style.background="#"+e;for(d=0;d<256;d++)b=document.getElementById("colorcell"+d),e=colorscale(c,d/(256-d)),b.style.background="#"+e,b.nhexvalue=e}}(function(a,b,c){function d(d,e){function h(b){a(f).each(function(){var c=a(this);this!==b.target&&!c.has(b.target).length&&c.triggerHandler(e,[b.target])})}e=e||d+c;var f=a(),g=d+"."+e+"-special-event";a.event.special[e]={setup:function(){f=f.add(this),f.length===1&&a(b).bind(g,h)},teardown:function(){f=f.not(this),f.length===0&&a(b).unbind(g)},add:function(a){var b=a.handler;a.handler=function(a,c){a.target=c,b.apply(this,arguments)}}}}a.map("click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup".split(" "),function(a){d(a)}),d("focusin","focus"+c),d("focusout","blur"+c),a.addOutsideEvent=d})(jQuery,document,"outside"),function(a){function e(c){function n(){c?f.removeData(c):k&&delete b[k]}function o(){g.id=setTimeout(function(){g.fn()},l)}var e=this,f,g={},h=c?a.fn:a,i=arguments,j=4,k=i[1],l=i[2],m=i[3];typeof k!="string"&&(j--,k=c=0,l=i[1],m=i[2]),c?(f=e.eq(0),f.data(c,g=f.data(c)||{})):k&&(g=b[k]||(b[k]={})),g.id&&clearTimeout(g.id),delete g.id;if(m)g.fn=function(a){typeof m=="string"&&(m=h[m]),m.apply(e,d.call(i,j))===!0&&!a?o():n()},o();else{if(g.fn)return l===undefined?n():g.fn(l===!1),!0;n()}}var b={},c="doTimeout",d=Array.prototype.slice;a[c]=function(){return e.apply(window,[0].concat(d.call(arguments)))},a.fn[c]=function(){var a=d.call(arguments),b=e.apply(this,[c+a[0]].concat(a));return typeof a[0]=="number"||typeof a[1]=="number"?this:b}}(jQuery),function(a){function d(b,c){var d=document.createElementNS("http://www.w3.org/2000/svg",b||"svg");return c&&a.each(c,function(a,b){d.setAttributeNS(null,a,b)}),a(d)}a.fn.activity=function(d){return this.each(function(){var e=a(this),f=e.data("activity");f&&(clearInterval(f.data("interval")),f.remove(),e.removeData("activity"));if(d!==!1){d=a.extend({color:e.css("color")},a.fn.activity.defaults,d),f=b(e,d).css("position","absolute").prependTo(d.outside?"body":e);var g=e.outerHeight()-f.height(),h=e.outerWidth()-f.width(),i={top:d.valign=="top"?d.padding:d.valign=="bottom"?g-d.padding:Math.floor(g/2),left:d.align=="left"?d.padding:d.align=="right"?h-d.padding:Math.floor(h/2)},j=e.offset();d.outside?f.css({top:j.top+"px",left:j.left+"px"}):(i.top-=f.offset().top-j.top,i.left-=f.offset().left-j.left),f.css({marginTop:i.top+"px",marginLeft:i.left+"px"}),c(f,d.segments,Math.round(10/d.speed)/10),e.data("activity",f)}}),this},a.fn.activity.defaults={segments:12,space:3,length:7,width:4,speed:1.2,align:"center",valign:"center",padding:4},a.fn.activity.getOpacity=function(a,b){var c=a.steps||a.segments-1,d=a.opacity!==undefined?a.opacity:1/c;return 1-Math.min(b,c)*(1-d)/c};var b=function(){return a("<div>").addClass("busy")},c=function(){};if(document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect){b=function(b,c){var e=c.width*2+c.space,f=e+c.length+Math.ceil(c.width/2)+1,g=d().width(f*2).height(f*2),h=d("g",{"stroke-width":c.width,"stroke-linecap":"round",stroke:c.color}).appendTo(d("g",{transform:"translate("+f+","+f+")"}).appendTo(g));for(var i=0;i<c.segments;i++)h.append(d("line",{x1:0,y1:e,x2:0,y2:e+c.length,transform:"rotate("+360/c.segments*i+", 0, 0)",opacity:a.fn.activity.getOpacity(c,i)}));return a("<div>").append(g).width(2*f).height(2*f)};if(document.createElement("div").style.WebkitAnimationName!==undefined){var e={};c=function(a,b,c){if(!e[b]){var d="spin"+b,f="@-webkit-keyframes "+d+" {";for(var g=0;g<b;g++){var h=Math.round(1e5/b*g)/1e3,i=Math.round(1e5/b*(g+1)-1)/1e3,j="% { -webkit-transform:rotate("+Math.round(360/b*g)+"deg); }\n";f+=h+j+i+j}f+="100% { -webkit-transform:rotate(100deg); }\n}",document.styleSheets[0].insertRule(f),e[b]=d}a.css("-webkit-animation",e[b]+" "+c+"s linear infinite")}}else c=function(a,b,c){var d=0,e=a.find("g g").get(0);a.data("interval",setInterval(function(){e.setAttributeNS(null,"transform","rotate("+ ++d%b*(360/b)+")")},c*1e3/b))}}else{var f=a("<shape>").css("behavior","url(#default#VML)");a("body").append(f);if(f.get(0).adj){var g=document.createStyleSheet();a.each(["group","shape","stroke"],function(){g.addRule(this,"behavior:url(#default#VML);")}),b=function(b,c){var d=c.width*2+c.space,e=d+c.length+Math.ceil(c.width/2)+1,f=e*2,g=-Math.ceil(f/2),h=a("<group>",{coordsize:f+" "+f,coordorigin:g+" "+g}).css({top:g,left:g,width:f,height:f});for(var i=0;i<c.segments;i++)h.append(a("<shape>",{path:"m "+d+",0  l "+(d+c.length)+",0"}).css({width:f,height:f,rotation:360/c.segments*i+"deg"}).append(a("<stroke>",{color:c.color,weight:c.width+"px",endcap:"round",opacity:a.fn.activity.getOpacity(c,i)})));return a("<group>",{coordsize:f+" "+f}).css({width:f,height:f,overflow:"hidden"}).append(h)},c=function(a,b,c){var d=0,e=a.get(0);a.data("interval",setInterval(function(){e.style.rotation=++d%b*(360/b)},c*1e3/b))}}a(f).remove()}}(jQuery),new function(){function c(){$("h1,h2,h3,h4,h5,h6").widont()}function d(a){return a.replace(b.regexp,"&#160;$1")}var a={auto:function(a){return a!=undefined?b.auto=a:b.auto},init:function(){return b.init()},transform:function(a){return b.widont(a)}};$.jqwidont=a;var b={auto:!0,init:c,widont:d,regexp:new RegExp("[\\n\\r\\s]+([^\\n\\r\\s(?:&#160;)]+[\\n\\r\\s]*)$","m")};$(document).ready(function(){b.auto&&c()}),$.fn.widont=function(){return $(this).each(function(){var a=$(this);a.html(b.widont(a.html()))})}},function(a){var b=a.event,c;b.special.smartresize={setup:function(){a(this).bind("resize",b.special.smartresize.handler)},teardown:function(){a(this).unbind("resize",b.special.smartresize.handler)},handler:function(a,b){var d=this,e=arguments;a.type="smartresize",c&&clearTimeout(c),c=setTimeout(function(){jQuery.event.handle.apply(d,e)},b==="execAsap"?0:100)}},a.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])}}(jQuery),function(a){function d(a){a=a.replace(/left|top/g,"0px"),a=a.replace(/right|bottom/g,"100%"),a=a.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var b=a.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(b[1],10),b[2],parseFloat(b[3],10),b[4]]}if(!document.defaultView||!document.defaultView.getComputedStyle){var b=a.curCSS;a.curCSS=function(a,c,d){c==="background-position"&&(c="backgroundPosition");if(c!=="backgroundPosition"||!a.currentStyle||a.currentStyle[c])return b.apply(this,arguments);var e=a.style;return!d&&e&&e[c]?e[c]:b(a,"backgroundPositionX",d)+" "+b(a,"backgroundPositionY",d)}}var c=a.fn.animate;a.fn.animate=function(a){return"background-position"in a&&(a.backgroundPosition=a["background-position"],delete a["background-position"]),"backgroundPosition"in a&&(a.backgroundPosition="("+a.backgroundPosition),c.apply(this,arguments)},a.fx.step.backgroundPosition=function(b){if(!b.bgPosReady){var c=a.curCSS(b.elem,"backgroundPosition");c||(c="0px 0px"),c=d(c),b.start=[c[0],c[2]];var e=d(b.end);b.end=[e[0],e[2]],b.unit=[e[1],e[3]],b.bgPosReady=!0}var f=[];f[0]=(b.end[0]-b.start[0])*b.pos+b.start[0]+b.unit[0],f[1]=(b.end[1]-b.start[1])*b.pos+b.start[1]+b.unit[1],b.elem.style.backgroundPosition=f[0]+" "+f[1]}}(jQuery),function(a){function b(a,b){return typeof a=="function"?a.call(b):a}function c(b,c){this.$element=a(b),this.options=c,this.enabled=!0,this.fixTitle()}c.prototype={show:function(){var c=this.getTitle(),d=this.options;if(c&&this.enabled){var e=this.tip();e.find("."+d.clsStyle+"-tipsy-inner")[this.options.html?"html":"text"](c),e[0].className=d.clsStyle+"-tipsy",e.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).prependTo(document.body);var f=a.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight}),g=e[0].offsetWidth,h=e[0].offsetHeight,i=b(this.options.gravity,this.$element[0]),j;switch(i.charAt(0)){case"n":j={top:f.top+f.height+this.options.offset,left:f.left+f.width/2-g/2};break;case"s":j={top:f.top-h-this.options.offset,left:f.left+f.width/2-g/2};break;case"e":j={top:f.top+f.height/2-h/2,left:f.left-g-this.options.offset};break;case"w":j={top:f.top+f.height/2-h/2,left:f.left+f.width+this.options.offset}}i.length==2&&(i.charAt(1)=="w"?j.left=f.left+f.width/2-15:j.left=f.left+f.width/2-g+15),e.css(j).addClass(d.clsStyle+"-tipsy-"+i),e.find("."+d.clsStyle+"-tipsy-arrow")[0].className=d.clsStyle+"-tipsy-arrow "+d.clsStyle+"-tipsy-arrow-"+i.charAt(0),this.options.className&&e.addClass(b(this.options.className,this.$element[0])),this.options.fade?e.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity}):e.css({visibility:"visible",opacity:this.options.opacity})}},hide:function(){this.options.fade?this.tip().stop().fadeOut(function(){a(this).remove()}):this.tip().remove()},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("original-title")!="string")&&a.attr("original-title",a.attr("title")||"").removeAttr("title")},getTitle:function(){var a,b=this.$element,c=this.options;this.fixTitle();var a,c=this.options;return typeof c.title=="string"?a=b.attr(c.title=="title"?"original-title":c.title):typeof c.title=="function"&&(a=c.title.call(b[0])),a=(""+a).replace(/(^\s*|\s*$)/,""),a||c.fallback},tip:function(){var b=this.options;return this.$tip||(this.$tip=a('<div class="'+b.clsStyle+'-tipsy"></div>').html('<div class="'+b.clsStyle+'-tipsy-arrow"></div><div class="'+b.clsStyle+'-tipsy-inner"></div>')),this.$tip},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled}},a.fn.tipsy=function(b){function e(d){var e=a.data(d,"tipsy");return e||(e=new c(d,a.fn.tipsy.elementOptions(d,b)),a.data(d,"tipsy",e)),e}function f(){var a=e(this);a.hoverState="in",b.delayIn==0?a.show():(a.fixTitle(),setTimeout(function(){a.hoverState=="in"&&a.show()},b.delayIn))}function g(){var a=e(this);a.hoverState="out",b.delayOut==0?a.hide():setTimeout(function(){a.hoverState=="out"&&a.hide()},b.delayOut)}if(b===!0)return this.data("tipsy");if(typeof b=="string"){var d=this.data("tipsy");return d&&d[b](),this}b=a.extend({},a.fn.tipsy.defaults,b),b.live||this.each(function(){e(this)});if(b.trigger!="manual"){var h=b.live?"live":"bind",i=b.trigger=="hover"?"mouseenter":"focus",j=b.trigger=="hover"?"mouseleave":"blur";this[h](i,f)[h](j,g)}return this},a.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:!1,fallback:"",gravity:"n",html:!1,live:!1,offset:0,opacity:.8,title:"title",trigger:"hover",clsStyle:"default"},a.fn.tipsy.elementOptions=function(b,c){return a.metadata?a.extend({},c,a(b).metadata()):c},a.fn.tipsy.autoNS=function(){return a(this).offset().top>a(document).scrollTop()+a(window).height()/2?"s":"n"},a.fn.tipsy.autoWE=function(){return a(this).offset().left>a(document).scrollLeft()+a(window).width()/2?"e":"w"},a.fn.tipsy.autoBounds=function(b,c){return function(){var d={ns:c[0],ew:c.length>1?c[1]:!1},e=a(document).scrollTop()+b,f=a(document).scrollLeft()+b,g=a(this);return g.offset().top<e&&(d.ns="n"),g.offset().left<f&&(d.ew="w"),a(window).width()+a(document).scrollLeft()-g.offset().left<b&&(d.ew="e"),a(window).height()+a(document).scrollTop()-g.offset().top<b&&(d.ns="s"),d.ns+(d.ew?d.ew:"")}}}(jQuery),function(a){function c(){var b=d(this);return isNaN(b.datetime)||a(this).text(e(b.datetime)),this}function d(c){c=a(c);if(!c.data("timeago")){c.data("timeago",{datetime:b.datetime(c)});var d=a.trim(c.text());d.length>0&&c.attr("title",d)}return c.data("timeago")}function e(a){return b.inWords(f(a))}function f(a){return(new Date).getTime()-a.getTime()}a.timeago=function(b){return b instanceof Date?e(b):typeof b=="string"?e(a.timeago.parse(b)):e(a.timeago.datetime(b))};var b=a.timeago;a.extend(a.timeago,{settings:{refreshMillis:6e4,allowFuture:!1,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",numbers:[]}},inWords:function(b){function k(d,e){var f=a.isFunction(d)?d(e,b):d,g=c.numbers&&c.numbers[e]||e;return f.replace(/%d/i,g)}var c=this.settings.strings,d=c.prefixAgo,e=c.suffixAgo;this.settings.allowFuture&&(b<0&&(d=c.prefixFromNow,e=c.suffixFromNow),b=Math.abs(b));var f=b/1e3,g=f/60,h=g/60,i=h/24,j=i/365,l=f<45&&k(c.seconds,Math.round(f))||f<90&&k(c.minute,1)||g<45&&k(c.minutes,Math.round(g))||g<90&&k(c.hour,1)||h<24&&k(c.hours,Math.round(h))||h<48&&k(c.day,1)||i<30&&k(c.days,Math.floor(i))||i<60&&k(c.month,1)||i<365&&k(c.months,Math.floor(i/30))||j<2&&k(c.year,1)||k(c.years,Math.floor(j));return a.trim([d,l,e].join(" "))},parse:function(b){var c=a.trim(b);return c=c.replace(/\.\d\d\d+/,""),c=c.replace(/-/,"/").replace(/-/,"/"),c=c.replace(/T/," ").replace(/Z/," UTC"),c=c.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"),new Date(c)},datetime:function(c){var d=a(c).get(0).tagName.toLowerCase()==="time",e=d?a(c).attr("datetime"):a(c).attr("title");return b.parse(e)}}),a.fn.timeago=function(){var a=this;a.each(c);var d=b.settings;return d.refreshMillis>0&&setInterval(function(){a.each(c)},d.refreshMillis),a},document.createElement("abbr"),document.createElement("time")}(jQuery),function(a){a.fn.tweep=function(b,c){var d=a.extend({user:"fk",count:1},b),e="",f=this,g=function(a){var b=/(\b(https?|ftp|file):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|])/ig,c=/\B@([_a-z0-9]+)/ig;return a.replace(b,"<a href='$1'>$1</a>").replace(c,"<a href='http://twitter.com/$1'>@$1</a>")},h=function(b){f.each(function(){var c=a(this);a.each(b,function(b,e){timestamp=a.timeago(new Date(e.created_at)),c.append('<span id="'+e.id_str+'">'+g(e.text)+""+'<a class="timestamp" href="http://twitter.com/'+d.user+"/status/"+e.id_str+'">'+timestamp+"</a></span>")})}),typeof c=="function"&&c(f)},i=a('<span class="loading">Fetching latest tweet …</span>');a(this).append(i),i.activity({segments:8,align:"left",width:2,space:0,length:2,color:"#fff",speed:1.5});var j="http://twitter.com/status/user_timeline/"+d.user+".json?count="+d.count+"&callback=?";return a.getJSON(j,function(a){i.fadeTo("50",0,function(){i.remove(),h(a)})}),this}}(jQuery),function(a){function b(b){var c;return b&&b.constructor==Array&&b.length==3?b:(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))?[parseInt(c[1]),parseInt(c[2]),parseInt(c[3])]:(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))?[parseFloat(c[1])*2.55,parseFloat(c[2])*2.55,parseFloat(c[3])*2.55]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))?[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)]:(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))?[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]:(c=/rgba\(0, 0, 0, 0\)/.exec(b))?d.transparent:d[a.trim(b).toLowerCase()]}function c(c,d){var e;do{e=a.curCSS(c,d);if(e!=""&&e!="transparent"||a.nodeName(c,"body"))break;d="backgroundColor"}while(c=c.parentNode);return b(e)}a.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(d,e){a.fx.step[e]=function(a){a.colorInit||(a.start=c(a.elem,e),a.end=b(a.end),a.colorInit=!0),a.elem.style[e]="rgb("+[Math.max(Math.min(parseInt(a.pos*(a.end[0]-a.start[0])+a.start[0]),255),0),Math.max(Math.min(parseInt(a.pos*(a.end[1]-a.start[1])+a.start[1]),255),0),Math.max(Math.min(parseInt(a.pos*(a.end[2]-a.start[2])+a.start[2]),255),0)].join(",")+")"}});var d={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}}(jQuery),jQuery.extend({hexDigits:["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],hex2rgb:function(a){var b=new Array;try{return a=this.checkHex(a),b[0]=parseInt(a.substr(1,2),16),b[1]=parseInt(a.substr(3,2),16),b[2]=parseInt(a.substr(5,2),16),b}catch(c){throw c}},hex:function(a){return isNaN(a)?"00":this.hexDigits[(a-a%16)/16]+this.hexDigits[a%16]},rgb2hex:function(a){try{return this.checkRGB(a),"#"+hex(a[0])+hex(a[1])+hex(a[2])}catch(b){throw b}},checkRGB:function(a){if(a.length!=3)throw"this is not a valid rgb-array";if(isNaN(a[0])||isNaN(a[1])||isNaN(a[2]))throw"this is not a valid rgb-array";if(a[0]<0||a[0]>255||a[1]<0||a[1]>255||a[2]<0||a[3]>255)throw"this is not a valid rgb-array";return a},checkHex:function(a){if(!a||a==""||a=="#")throw"No valid hexadecimal given.";a=a.toUpperCase();switch(a.length){case 6:a="#"+a;break;case 7:break;case 3:a="#"+a;break;case 4:a="#"+a.substr(1,1)+a.substr(1,1)+a.substr(2,1)+a.substr(2,1)+a.substr(3,1)+a.substr(3,1)}if(a.substr(0,1)!="#"||!this.checkHexDigits(a.substr(1)))throw"No valid hexadecimal given.";return a},checkHexDigits:function(a){var b,c;for(var d=0;d<a.length;d++){c=!1;for(b=0;b<this.hexDigits.length;b++)a.substr(d,1)==this.hexDigits[b]&&(c=!0);if(!c)return!1}return!0},calculateColor:function(a,b,c){if(!c||!c.type||!c.type[0]||!c.type[1]||!c.type[2]||!c.count)c=this.colorGradientOptions;var d=new Array;try{try{var e=this.hex2rgb(a),f=this.hex2rgb(b)}catch(g){this.checkRGB(a);var e=a;this.checkRGB(b);var f=b}var h=new Array;h[0]=this.calculateGradient(e[0],f[0],c.count,c.type[0]),h[1]=this.calculateGradient(e[1],f[1],c.count,c.type[1]),h[2]=this.calculateGradient(e[2],f[2],c.count,c.type[2]);for(var i=0;i<c.count;i++)d[i]="#"+this.hex(h[0][i])+this.hex(h[1][i])+this.hex(h[2][i])}catch(g){throw g}return d},calculateGradient:function(a,b,c,d){var e=new Array;if(!d||!c)return null;if(1<c&&c<3)return e[0]=a,e[1]=b,e;if(c==1)return e[0]=b,e;switch(d){case 1:var f;for(f=0;f<c;f++)e[f]=Math.round(a+(b-a)*f/(c-1));break;case 2:var f;for(f=0;f<c;f++)e[f]=Math.round(a+(b-a)*((Math.sin(-Math.PI/2+Math.PI*f/(c-1))+1)/2));break;case 3:var f;for(f=1;f<c-1;f++)e[f]=Math.round(a+(b-a)*Math.random());e[0]=a,e[c-1]=b;break;case 4:var f;for(f=1;f<c-1;f++)e[f]=Math.round(a+(b-a)*Math.random());e[0]=a,e[c-1]=b,typeof e.sort=="function"&&typeof e.reverse=="function"&&(e.sort(this.cmp),a>b&&e.reverse())}return e},cmp:function(a,b){return a-b},colorGradientOptions:{count:5,type:[1,1,1]}}),jQuery.fn.extend({colorize:function(a,b,c,d){var e=jQuery.calculateColor(a,b,{count:this.length,type:c}),f=0;for(var g=0;g<this.length;g++)$(this[g]).css(d,e[g])}}),function(a){a.isHexadecimalColor=function(a){return a&&a.match&&(a.match(/^#[0-9a-fA-F]{3}$/)||a.match(/^#[0-9a-fA-F]{6}$/))?!0:!1},a.isRGBColor=function(a){return a&&a.match&&a.match(/^rgb\(([0-9]|[1-9][0-9]|[1][0-9]{2}|[2][0-4][0-9]|[2][5][0-5]),[ ]{0,1}([0-9]|[1-9][0-9]|[1][0-9]{2}|[2][0-4][0-9]|[2][5][0-5]),[ ]{0,1}([0-9]|[1-9][0-9]|[1][0-9]{2}|[2][0-4][0-9]|[2][5][0-5])\)$/)?!0:!1},a.isColor=function(a){var b=jQuery;return b.isHexadecimalColor(a)||b.isRGBColor(a)?!0:!1},a.RGB=function(a){var b=jQuery;return typeof a=="string"?b.isRGBColor(b.fmtColor(a,"rgb"))?[parseInt(RegExp.$1),parseInt(RegExp.$2),parseInt(RegExp.$3)]:[]:a instanceof Array&&a.length==3&&isFinite(a[0]-0)&&isFinite(a[1]-0)&&isFinite(a[2]-0)&&0<=a[0]-0&&a[0]-0<=255&&0<=a[1]-0&&a[1]-0<=255&&0<=a[2]-0&&a[2]-0<=255?"rgb("+a[0]+", "+a[1]+", "+a[2]+")":a},a.colorVectorValue=function(a){var b=jQuery,c=b.RGB(a);if(c.length==3){var d=c[0],e=c[1],f=c[2];return Math.sqrt(d*d+e*e+f*f).toFixed(2)}return 0},a.colorDecimalValue=function(a){var b=jQuery;return b.isColor(a)?(a=b.fmtColor(a,"hexadecimal"),parseInt(a.substr(1,6),16)):0},a.fmtColor=function(a,b){var c=jQuery;if(c.isColor(a)==0)return a;var d=function(a){if(a.length<2)for(var b=0,c=2-a.length;b<c;b++)a="0"+a;return a};if(a.match(/^#[0-9a-fA-F]{3}$/)){var e=a.substr(1,1),f=a.substr(2,1),g=a.substr(3,1);a="#"+e+e+f+f+g+g}b=b?b:function(a){return c.isRGBColor(a)?"hexadecimal":c.isHexadecimalColor(a)?"rgb":""}(a);if(b=="rgb"&&c.isHexadecimalColor(a)){var e=parseInt(a.substr(1,2),16),f=parseInt(a.substr(3,2),16),g=parseInt(a.substr(5,2),16);a=c.RGB([e,f,g])}else if(b=="hexadecimal"){var h=c.RGB(a);if(h.length==3){var e=d(h[0].toString(16)),f=d(h[1].toString(16)),g=d(h[2].toString(16));a="#"+e+f+g}}return a},a.modColor=function(a,b,c,d){var e=function(a,b,c,d){if((b=="r"||b=="g"||b=="b")&&isFinite(c)){var e=jQuery;tmp=e.fmtColor(a,"rgb");var f=function(a,b,c){var d=parseInt(a)+(b-0);return c?(d=d>255?d-255:d,d=d<0?d+255:d):(d=d>255?255:d,d=d<0?0:d),d};if(e.isRGBColor(tmp)){var g=parseInt(RegExp.$1),h=parseInt(RegExp.$2),i=parseInt(RegExp.$3);b=="r"?g=f(RegExp.$1,c,d):b=="g"?h=f(RegExp.$2,c,d):b=="b"&&(i=f(RegExp.$3,c,d)),a=e.RGB([g,h,i])}}return a};b instanceof Array&&b.length==3&&(b={r:b[0],g:b[1],b:b[2]});if(b instanceof Object){d=c;var f=["r","g","b"];for(var g=0,h=f.length;g<h;g++){var i=b[f[g]];i&&isFinite(i)&&(a=e(a,f[g],i,d))}return a}if(typeof b=="string"&&isFinite(c))return e(a,b,c,d)},a.averageColor=function(a){var b=jQuery,c=[0,0,0],d=0;for(var e=0,f=a.length;e<f;e++){var g=b.RGB(a[e]);g.length==3&&(c[0]=c[0]+g[0],c[1]=c[1]+g[1],c[2]=c[2]+g[2],d++)}return b.RGB([Math.round(c[0]/d),Math.round(c[1]/d),Math.round(c[2]/d)])},a.colorize=function(a){var b=jQuery;if(typeof a=="string"){var c="#"+a.replace(/o/gi,"0").replace(/[li]/gi,"1").replace(/z/gi,"2").replace(/b/gi,"6").replace(/\?/gi,"7").replace(/q/gi,"9");if(b.isColor(c))return c}else if(a instanceof Object&&isFinite(a.min)&&isFinite(a.max)&&isFinite(a.value)){var d=a.max-a.min,e=parseInt(a.value*1677216/d).toString(16);for(var f=0,g=6-e.length;f<g;f++)e="0"+e;return"#"+e}return"#000000"},a.fn.modColor=function(a,b,c,d){var e=jQuery,f=e(this).css(a);return e(this).css(a,e.modColor(f,b,c,d)),this},a.fn.averageColor=function(a){a=a?a:"backgroundColor";var b=jQuery,c=[];for(var d=0,e=this.length;d<e;d++){var f=this.eq(d).css(a);b.isColor(f)&&c.push(f)}return b.averageColor(c)},a.fn.sortByColor=function(a){function d(a,b,e,f){var g=a[parseInt(b+(e-b)/2)],h=b-1,i=e+1;for(;;){while(c(a[++h],g,f)<0);while(c(a[--i],g,f)>0);if(h>=i)break;var j=a[h];a[h]=a[i],a[i]=j}return b<h-1&&d(a,b,h-1,f),i+1<e&&d(a,i+1,e,f),a}var b=jQuery;a=a?a:"backgroundColor";var c=function(a,c,d){var e=b.colorDecimalValue(b(a).css(d))-b.colorDecimalValue(b(c).css(d));return e==0?b.colorVectorValue(b(a).css(d))-b.colorVectorValue(b(c).css(d)):e};return d(this,0,this.length-1,a)}}(jQuery),site=function(){palette=[],duration=100,positionIn="",positionOut="",hidetooltip=function(){$.doTimeout("someid"),$(".tweet").stop().fadeTo("0","0"),$("#overlay").stop().animate({backgroundColor:"#ffffff"},duration),$(".tweet").parent().parent().find("dd a").stop().animate({color:linkColor},duration),$(".tweet").parent().find("a:eq(0)").stop().animate({color:linkColor,marginLeft:"0px",paddingLeft:"6px",backgroundPosition:positionOut},duration)},updateLayout=function(a){var b;if(!b){b=!0;var c=$(window).width(),d=$(window).height();$("#overlay").css({width:c,height:d}),b=!1}},drawShape=function(a){var b=document.getElementById("canvas");if(b.getContext){b.width=b.width;var c=b.getContext("2d"),d=c.createLinearGradient(0,0,80,80);for(var e=0;e<a.length;e++){var f=100/(a.length+1),g=Math.round(f)/100*e,h=a[e];d.addColorStop(g,h)}c.beginPath(),c.arc(40,40,40,0,Math.PI*2,!0),c.closePath(),c.fillStyle=d,c.fill()}},mixColors=function(){var a=$("#content dd"),b=[Math.floor(Math.random()*256),Math.floor(Math.random()*192),Math.floor(Math.random()*192)],c=[Math.floor(Math.random()*128),Math.floor(Math.random()*128),Math.floor(Math.random()*128)],d=$.calculateColor($.fmtColor($.RGB(b)),$.fmtColor($.RGB(c)),{count:a.length,type:[1,2,1]});a.each(function(a){$(this).data("color",d[a]);var b="#"+colorscale(d[a],5);$(this).data("brighterColor",b),palette[a]=$(this).data("brighterColor")})},setupNav=function(){var a="-300px",b="-400px";$("#content dd > a").each(function(){linkColor=$(this).css("color"),$(this).bind("mouseover",function(){hidetooltip(),$(this).parent().toggleClass("active");var c=$(this).parent().data("brighterColor");$("#overlay").stop().animate({backgroundColor:c},duration),$(this).hasClass("email")?(positionIn="0 "+a,positionOut="-100px "+b):(positionIn="0 "+b,positionOut="-100px "+a),$(this).hasClass("email")||$(this).hasClass("twitter")?$(this).stop().animate({color:"#000",marginLeft:"-20px",paddingLeft:"26px",backgroundPosition:positionIn},duration):$(this).stop().animate({color:"#000",marginLeft:"-10px",paddingLeft:"16px",backgroundPosition:positionIn},duration),$(this).parent().parent().find("dd").not(".active").find("a").stop().animate({color:c,marginLeft:"0px",paddingLeft:"6px",backgroundPosition:positionOut},duration);if($(this).parent().hasClass("tweep"))if($(".tweet").length)$(this).parent().hasClass("active")&&$(".tweet").stop().fadeTo("50","0.8").find("a").stop().animate({color:c},duration);else{var d=$('<span class="tweet"></span>');$(this).parent().append(d),$(".tweet").tweep({user:"fk",count:1},function(){$(".tweet").stop().find("a").stop().animate({color:c},duration)})}}).bind("mouseout",function(){$(this).parent().toggleClass("active"),$(this).hasClass("email")?positionOut="-100px "+a:positionOut="-100px "+b,$(this).parent().hasClass("tweep")?($.doTimeout("someid",100,function(){hidetooltip()}),$(".tweet").hover(function(){$.doTimeout("someid")},function(){hidetooltip()})):($("#overlay").stop().animate({backgroundColor:"#fff"},duration),$(this).parent().parent().find("dd a").stop().animate({color:linkColor},duration),$(this).stop().animate({marginLeft:"0px",paddingLeft:"6px",color:linkColor,backgroundPosition:positionOut},duration))})})},$("dd a.project").tipsy({fade:!0,gravity:"w",clsStyle:"custom"}),$("#page").before('<canvas id="canvas"></canvas><div id="overlay"></div>'),$("#canvas").hide(),$(window).bind("smartresize",updateLayout),$("html").hasClass("canvas")&&$("#logo").attr("title","Click to change colors").tipsy({fade:!0,gravity:"w"}).bind({click:function(){mixColors(),drawShape(palette)},mouseenter:function(){$("#canvas").show(),$(this).css("cursor","pointer").addClass("hovered")},mouseleave:function(){$("#canvas").hide(),$(this).css("cursor","default").removeClass("hovered")}}),updateLayout(),mixColors(),drawShape(palette),setupNav()},$(document).ready(function(){$("p").widont();if($("body").hasClass("index"))return site()})
