// jQuery Cookies

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('n.5=v(9,d,2){8(f d!=\'F\'){2=2||{};4 3=\'\';8(2.3&&(f 2.3==\'l\'||2.3.k)){4 6;8(f 2.3==\'l\'){6=D C();6.B(6.x()+(2.3*z*m*m*A))}j{6=2.3}3=\'; 3=\'+6.k()}4 a=2.a?\'; a=\'+2.a:\'\';4 7=2.7?\'; 7=\'+2.7:\'\';4 b=2.b?\'; b\':\'\';c.5=[9,\'=\',q(d),3,a,7,b].s(\'\')}j{4 g=t;8(c.5&&c.5!=\'\'){4 h=c.5.w(\';\');y(4 i=0;i<h.e;i++){4 5=n.p(h[i]);8(5.o(0,9.e+1)==(9+\'=\')){g=u(5.o(9.e+1));E}}}r g}};',42,42,'||options|expires|var|cookie|date|domain|if|name|path|secure|document|value|length|typeof|cookieValue|cookies||else|toGMTString|number|60|jQuery|substring|trim|encodeURIComponent|return|join|null|decodeURIComponent|function|split|getTime|for|24|1000|setTime|Date|new|break|undefined'.split('|'),0,{}));

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 3/9/2009
 * @author Ariel Flesler
 * @version 1.4.1
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function($){var m=$.scrollTo=function(b,h,f){$(window).scrollTo(b,h,f)};m.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};m.window=function(b){return $(window).scrollable()};$.fn.scrollable=function(){return this.map(function(){var b=this,h=!b.nodeName||$.inArray(b.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!h)return b;var f=(b.contentWindow||b).document||b.ownerDocument||b;return $.browser.safari||f.compatMode=='BackCompat'?f.body:f.documentElement})};$.fn.scrollTo=function(l,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};if(l=='max')l=9e9;a=$.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=$(k),d=l,p,g={},q=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px)?$/.test(d)){d=n(d);break}d=$(d,this);case'object':if(d.is||d.style)p=(d=$(d)).offset()}$.each(a.axis.split(''),function(b,h){var f=h=='x'?'Left':'Top',i=f.toLowerCase(),c='scroll'+f,r=k[c],s=h=='x'?'Width':'Height';if(p){g[c]=p[i]+(q?0:r-o.offset()[i]);if(a.margin){g[c]-=parseInt(d.css('margin'+f))||0;g[c]-=parseInt(d.css('border'+f+'Width'))||0}g[c]+=a.offset[i]||0;if(a.over[i])g[c]+=d[s.toLowerCase()]()*a.over[i]}else g[c]=d[i];if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],u(s));if(!b&&a.queue){if(r!=g[c])t(a.onAfterFirst);delete g[c]}});t(a.onAfter);function t(b){o.animate(g,j,a.easing,b&&function(){b.call(this,l,a)})};function u(b){var h='scroll'+b;if(!q)return k[h];var f='client'+b,i=k.ownerDocument.documentElement,c=k.ownerDocument.body;return Math.max(i[h],c[h])-Math.min(i[f],c[f])}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);

/**
 * jQuery Tabs
 * Part of Interface 1.2 http://interface.eyecon.ro/
 * Improved version
 **/

jQuery.iTTabs = {
	doTab : function(e) {
		pressedKey = e.charCode || e.keyCode || -1;
		if (pressedKey == 9 && !e.ctrlKey) { // mod
			if (window.event) {
				window.event.cancelBubble = true;
				window.event.returnValue = false;
			} else {
				e.preventDefault();
				e.stopPropagation();
			}
			if (this.createTextRange) {
				document.selection.createRange().text="\t";
				this.onblur = function() { 
					this.focus(); 
					this.onblur = null;
				};
			} else if (this.setSelectionRange) {
				start = this.selectionStart;
				end = this.selectionEnd;
				scroll = this.scrollTop; // mod
				this.value = this.value.substring(0, start) + "\t" + this.value.substr(end);
				this.setSelectionRange(start + 1, start + 1);
				this.focus();
				this.scrollTop = scroll; // mod
			}
			return false;
		}
	},
	destroy : function() {
		return this.each(
			function() {
				if (this.hasTabsEnabled && this.hasTabsEnabled == true) {
					jQuery(this).unbind('keydown', jQuery.iTTabs.doTab);
					this.hasTabsEnabled = false;
				}
			}
		);
	},
	build : function() {
		return this.each(
			function() {
				if (this.tagName.toLowerCase() == 'textarea' && (!this.hasTabsEnabled || this.hasTabsEnabled == false)) {
					jQuery(this).bind('keydown', jQuery.iTTabs.doTab);
					this.hasTabsEnabled = true;
				}
			}
		);			
	}
};

jQuery.fn.extend ({
	enableTabs : jQuery.iTTabs.build,
	disableTabs : jQuery.iTTabs.destroy
});

// jQuery Tablesorter
 
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(8($){$.O.7=8(o){f 6={20:0,1g:1d,27:\'3z\',1X:\'2W\',1S:1d,13:t,1z:t,3r:0,2c:0,2J:-1,2S:t,1U:t,1B:t,2H:U,3s:t,1Q:\'2n\',1x:t,1O:t,18:U,2p:t,1s:t,2A:t,1m:\'1k/1u/1o\'};k m.1y(8(){$.3v(6,o);f 1n;f 1b;f F;f 1q=[];f 1W;f 15;f 1D;f 22;f 1I=t;f 1F=-1;f 2K=6.20;f y=m;h(6.2S&&6.13){$.7.H.1Y(6,y)}$(m).18("3q",1V);$(m).18("30",8(31){1b=[]});$(m).18("32",2g);f 2a=(y.1l[0]&&y.1l[0].19.N-1)||0;2g();2F();8 2F(){f 1v=y.19[0];f 28=y.19[1];1D=1v.W.N;Z(f i=0;i<1D;i++){f I=1v.W[i];h(28&&!$.7.H.29(6,I,6.2J,i)){f 2y=$.7.H.1p(6,28.W[i],\'P\',i);h(1c(6.1g)=="2D"){h(6.1g.1r()==$.7.H.1p(6,I,\'26\',i).1r()){6.1g=i}}1q[i]=$.7.p.2T(6,2y);h(6.1U){f a=6.1U;f l=a.N;Z(f j=0;j<l;j++){h(i==a[j][0]){1q[i]=$.7.p.2l(a[j][1]);33}}}h(6.1S){$(I).1e(6.1S)}h(6.2p){$(I).34({35:\'<a 36="#">\',37:\'a\',38:\'B\'});$(".B",I).1A(8(e){25($(m).2h(),((6.1s)?6.1s:$(m).2h()[0].1Z++)%2,$(m).2h()[0].n);k t})}x{$(I).1A(8(e){25($(m),((6.1s)?6.1s:$(m)[0].1Z++)%2,$(m)[0].n);k t})}I.n=i;I.1Z=6.20}}h(6.2A){2C(1v)}h(6.1g!=1d){$(1v.W[6.1g]).2d("1A")}h(6.1B){$("> 17:16/1f",y).1A(8(){h(1I){1I.1a(6.1B)}1I=$(m).1e(6.1B)})}}8 2g(){1n=[];1b=[];22=(y.1l[0]&&y.1l[0].19.N)||0;f l=22;Z(f i=0;i<l;i++){1n.1L(y.1l[0].19[i])}}8 2C(2E){f 1E=y.19[1];Z(f i=0;i<1D;i++){h(1E&&1E.W[i])$(2E.W[i]).3b("3c",1E.W[i].3e+"3f")}}8 25(I,Q,n){h(2a>6.2c){$(y).2d("1J")}F=n;1W=I;15=Q;$("3h 3i",y).1a(6.27).1a(6.1X);$(1W).1e((Q%2?6.27:6.1X));3k(1V,0)}8 1V(){h(F>=0){f P;h($.7.v.2N(1b,F)&&6.2H){f v=$.7.v.2M(1b,F);h(v.Q==15){P=v.X;v.Q=15}x{P=v.X.2L();v.Q=15}}x{f J=$.7.X.2O(6,1n,1q,F);J.3l(1q[F].B);h(2K!=15){J.2L()}P=$.7.X.2Q(1n,J,F,1F);$.7.v.D(1b,F,15,P);J=1d}$.7.H.2R(6,y,P,F,1F);P=1d;h(2a>6.2c){$(y).2d("2e",[F])}1F=F}}})};$.O.1J=8(O){k m.18("1J",O)};$.O.3m=8(O){k m.18("1J",O)};$.O.2e=8(O){k m.18("2e",O)};$.7={3o:{},v:{D:8(v,n,Q,X){f 1h={};1h.Q=Q;1h.X=X;v[n]=1h},2M:8(v,n){k v[n]},2N:8(v,n){f 1h=v[n];h(!1h){k t}x{k U}},3p:8(v){v=[]}},X:{2O:8(6,1t,2P,1w){f J=[];f l=1t.N;Z(f i=0;i<l;i++){J.1L([i,2P[1w].L($.7.H.1p(6,1t[i].W[1w],\'P\',1w),6)])}k J},2Q:8(1t,J,1w,3t){f l=J.N;f 2i=[];Z(f i=0;i<l;i++){2i.1L(1t[J[i][0]])}k 2i}},C:{},q:{},p:{1i:[],D:8(p){m.1i.1L(p)},3x:8(p){m.1i.3y(p)},2T:8(6,s){f 2k=t;f p=$.7.q.12;f Y=m.1i;$.1y(Y,8(i){h(!2k){h(Y[i].G(s)){2k=U;p=Y[i]}}});k p},2l:8(s){f Y=m.1i;f p=$.7.q.12;$.1y(Y,8(i){h(Y[i].K==s){p=Y[i]}});k p}},H:{1p:8(6,o,1M,n){h(!o)k"";f V="";h(1M==\'26\'){V=$(o).2v()}x h(1M==\'P\'){h(6.1x&&1c(6.1x[n])=="8"){V=6.1x[n](o)}x{h(6.1Q==\'2n\'){h(1c(6.1O)=="2I"){f d=6.1O;$.1y(d,8(i){f 14=o[d[i]];h(14&&14.N>0){V=14}})}x{h(o.1P[0]&&o.1P[0].2U()){V=o.1P[0].2s}x{V=o.2s}}}x h(6.1Q==\'2V\'){V=$(o).2v()}}}k V},2R:8(6,o,c,n,1K){f l=c.N;$("> 17:16",o).2X().2Z(c);h(6.13){$("> 17:16/1f",o).1a(6.13[0]).1a(6.13[1]);$.7.H.1Y(6,o)}h(6.1z){$.7.H.2x(6,o,n,1K)}c=1d},2x:8(6,o,n,1K){$("> 17:16/1f",o).2w("2z:2u("+1K+")").1a(6.1z);$("> 17:16/1f",o).2w("2z:2u("+n+")").1e(6.1z)},1Y:8(6,o){$("> 17:16/1f:2B:39",o).1e(6.13[0]);$("> 17:16/1f:2B:3a",o).1e(6.13[1])},29:8(6,o,M,n){h(1c(M)=="3d"){k(M==n)?U:t}x h(1c(M)=="2D"){k(M.1r()==$.7.H.1p(6,o,\'26\',n).1r())?U:t}x h(M.3j){k(o==M)?U:t}x h(1c(M)=="2I"){f l=M.N;h(!m.1H){m.1H=-1}Z(f i=0;i<l;i++){f 14=$.7.H.29(6,o,M[i],n);h(m.1H!=i&&14){m.1H=i;k 14}}}x{k t}}},C:{12:8(a,b){k((a[1]<b[1])?-1:((a[1]>b[1])?1:0))},S:8(a,b){k a[1]-b[1]}}};$.7.q.12={K:\'12\',G:8(s){k U},L:8(s){k s.1r()},B:$.7.C.12};$.7.q.1N={K:\'1N\',G:8(s){k s.R(u w(/^[Ł$?.]/g))},L:8(s){k T(s.11(u w(/[^0-9.]/g),\'\'))},B:$.7.C.S};$.7.q.1R={K:\'1R\',G:8(s){k s.R(u w(/^\\d+$/))},L:8(s){k T(s)},B:$.7.C.S};$.7.q.23={K:\'23\',G:8(s){k s.R(u w(/^(\\+|-)?[0-9]+\\.[0-9]+((E|e)(\\+|-)?[0-9]+)?$/))},L:8(s){k T(s.11(u w(/,/),\'\'))},B:$.7.C.S};$.7.q.2b={K:\'2b\',G:8(s){k s.R(/^\\d{2,3}[\\.]\\d{2,3}[\\.]\\d{2,3}[\\.]\\d{2,3}$/)},L:8(s){f a=s.3u(\'.\');f r=\'\';Z(f i=0,1j;1j=a[i];i++){h(1j.N==2){r+=\'0\'+1j}x{r+=1j}}k T(r)},B:$.7.C.S};$.7.q.2f={K:\'2f\',G:8(s){k s.R(u w(/(2o?|2q|2t):\\/\\//))},L:8(s){k s.11(u w(/(2o?|2q|2t):\\/\\//),\'\')},B:$.7.C.12};$.7.q.1T={K:\'1T\',G:8(s){k s.R(u w(/^\\d{4}[\\/-]\\d{1,2}[\\/-]\\d{1,2}$/))},L:8(s){k T((s!="")?u 1C(s.11(u w(/-/g),\'/\')).1G():"0")},B:$.7.C.S};$.7.q.24={K:\'24\',G:8(s){k s.R(u w(/^[A-2Y-z]{3,10}\\.? [0-9]{1,2}, ([0-9]{4}|\'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\\s(2m|2r)))$/))},L:8(s){k T((u 1C(s)).1G())},B:$.7.C.S};$.7.q.21={K:\'21\',G:8(s){k s.R(u w(/\\d{1,2}[\\/-]\\d{1,2}[\\/-]\\d{2,4}/))},L:8(s,6){s=s.11(u w(/-/g),\'/\');h(6.1m=="1k/1u/1o"||6.1m=="1k-1u-1o"){s=s.11(u w(/(\\d{1,2})[\\/-](\\d{1,2})[\\/-](\\d{4})/),\'$3/$1/$2\')}x h(6.1m=="1u/1k/1o"||6.1m=="1u-1k-1o"){s=s.11(u w(/(\\d{1,2})[\\/-](\\d{1,2})[\\/-](\\d{4})/),\'$3/$2/$1\')}k T((u 1C(s)).1G())},B:$.7.C.S};$.7.q.2j={K:\'2j\',G:8(s){k s.3n().R(u w(/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\\s(2m|2r)))$/))},L:8(s){k T((u 1C("3g/2G/2G "+s)).1G())},B:$.7.C.S};$.7.p.D($.7.q.1N);$.7.p.D($.7.q.1R);$.7.p.D($.7.q.1T);$.7.p.D($.7.q.21);$.7.p.D($.7.q.24);$.7.p.D($.7.q.2b);$.7.p.D($.7.q.2f);$.7.p.D($.7.q.2j);$.7.p.D($.7.q.23)})(3w);',62,222,'||||||defaults|tableSorter|function|||||||var||if|||return||this|index||analyzer|parsers|||false|new|cache|RegExp|else|oTable|||sorter|sorters|add||COLUMN_INDEX|is|utils|oCell|flatData|id|format|arg|length|fn|columns|dir|match|numeric|parseFloat|true|elementText|cells|data|list|for||replace|generic|stripingRowClass|val|COLUMN_DIR|first|tbody|bind|rows|removeClass|COLUMN_CACHE|typeof|null|addClass|tr|sortColumn|oCache|analyzers|item|mm|tBodies|dateFormat|COLUMN_DATA|yyyy|getElementText|COLUMN_SORTER_CACHE|toLowerCase|lockedSortDir|columnData|dd|oFirstTableRow|columnIndex|textExtractionCustom|each|highlightClass|click|rowHighlightClass|Date|COLUMN_HEADER_LENGTH|oSampleTableRow|COLUMN_LAST_INDEX|getTime|lastFound|ROW_LAST_HIGHLIGHT_OBJ|sortStart|lastIndex|push|type|currency|textExtractionType|childNodes|textExtraction|integer|headerClass|isoDate|columnParser|doSorting|COLUMN_CELL|sortClassDesc|stripeRows|count|sortDir|shortDate|COLUMN_ROW_LENGTH|floating|usLongDate|sortOnColumn|header|sortClassAsc|oDataSampleRow|isHeaderDisabled|tableRowLength|ipAddress|minRowsForWaitingMsg|trigger|sortStop|url|buildColumnDataIndex|parent|sortedData|time|found|getById|AM|simple|https|addHeaderLink|ftp|PM|innerHTML|file|eq|text|find|highlightColumn|oCellValue|td|enableResize|visible|addColGroup|string|columnsHeader|buildColumnHeaders|01|useCache|object|disableHeader|COLUMN_LAST_DIR|reverse|get|exist|flatten|columnCache|rebuild|appendToTable|stripeRowsOnStartUp|analyseString|hasChildNodes|complex|descending|empty|Za|append|flushCache|event|updateColumnData|continue|wrapInner|element|href|name|className|even|odd|css|width|number|clientWidth|px|2000|thead|th|parentNode|setTimeout|sort|sortReload|toUpperCase|params|clear|resort|rowLimit|debug|columnLastIndex|split|extend|jQuery|add_to_front|unshift|ascending'.split('|'),0,{}));

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @return    The object (aka "this") that called hoverIntent, and the event object
* @author    Brian Cherne <brian@cherne.net>
*/

(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 p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){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.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

// $Id: farbtastic.js,v 1.2 2007/01/08 22:53:01 unconed Exp $
// Farbtastic 1.2

jQuery.fn.farbtastic = function (callback) {
  $.farbtastic(this, callback);
  return this;
};

jQuery.farbtastic = function (container, callback) {
  var container = $(container).get(0);
  return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback));
};

jQuery._farbtastic = function (container, callback) {
  // Store farbtastic object
  var fb = this;

  // Insert markup
  $(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
  var e = $('.farbtastic', container);
  fb.wheel = $('.wheel', container).get(0);
  // Dimensions
  fb.radius = 84;
  fb.square = 100;
  fb.width = 194;

  // Fix background PNGs in IE6
  if (navigator.appVersion.match(/MSIE [0-6]\./)) {
    $('*', e).each(function () {
      if (this.currentStyle.backgroundImage != 'none') {
        var image = this.currentStyle.backgroundImage;
        image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
        $(this).css({
          'backgroundImage': 'none',
          'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
        });
      }
    });
  }

  /**
   * Link to the given element(s) or callback.
   */
  fb.linkTo = function (callback) {
    // Unbind previous nodes
    if (typeof fb.callback == 'object') {
      $(fb.callback).unbind('keyup', fb.updateValue);
    }

    // Reset color
    fb.color = null;

    // Bind callback or elements
    if (typeof callback == 'function') {
      fb.callback = callback;
    }
    else if (typeof callback == 'object' || typeof callback == 'string') {
      fb.callback = $(callback);
      fb.callback.bind('keyup', fb.updateValue);
      if (fb.callback.get(0).value) {
        fb.setColor(fb.callback.get(0).value);
      }
    }
    return this;
  }
  fb.updateValue = function (event) {
    if (this.value && this.value != fb.color) {
      fb.setColor(this.value);
    }
  }

  /**
   * Change color with HTML syntax #123456
   */
  fb.setColor = function (color) {
    var unpack = fb.unpack(color);
    if (fb.color != color && unpack) {
      fb.color = color;
      fb.rgb = unpack;
      fb.hsl = fb.RGBToHSL(fb.rgb);
      fb.updateDisplay();
    }
    return this;
  }

  /**
   * Change color with HSL triplet [0..1, 0..1, 0..1]
   */
  fb.setHSL = function (hsl) {
    fb.hsl = hsl;
    fb.rgb = fb.HSLToRGB(hsl);
    fb.color = fb.pack(fb.rgb);
    fb.updateDisplay();
    return this;
  }

  /////////////////////////////////////////////////////

  /**
   * Retrieve the coordinates of the given event relative to the center
   * of the widget.
   */
  fb.widgetCoords = function (event) {
    var x, y;
    var el = event.target || event.srcElement;
    var reference = fb.wheel;

    if (typeof event.offsetX != 'undefined') {
      // Use offset coordinates and find common offsetParent
      var pos = { x: event.offsetX, y: event.offsetY };

      // Send the coordinates upwards through the offsetParent chain.
      var e = el;
      while (e) {
        e.mouseX = pos.x;
        e.mouseY = pos.y;
        pos.x += e.offsetLeft;
        pos.y += e.offsetTop;
        e = e.offsetParent;
      }

      // Look for the coordinates starting from the wheel widget.
      var e = reference;
      var offset = { x: 0, y: 0 }
      while (e) {
        if (typeof e.mouseX != 'undefined') {
          x = e.mouseX - offset.x;
          y = e.mouseY - offset.y;
          break;
        }
        offset.x += e.offsetLeft;
        offset.y += e.offsetTop;
        e = e.offsetParent;
      }

      // Reset stored coordinates
      e = el;
      while (e) {
        e.mouseX = undefined;
        e.mouseY = undefined;
        e = e.offsetParent;
      }
    }
    else {
      // Use absolute coordinates
      var pos = fb.absolutePosition(reference);
      x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x;
      y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y;
    }
    // Subtract distance to middle
    return { x: x - fb.width / 2, y: y - fb.width / 2 };
  }

  /**
   * Mousedown handler
   */
  fb.mousedown = function (event) {
    // Capture mouse
    if (!document.dragging) {
      $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
      document.dragging = true;
    }

    // Check which area is being dragged
    var pos = fb.widgetCoords(event);
    fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;

    // Process
    fb.mousemove(event);
    return false;
  }

  /**
   * Mousemove handler
   */
  fb.mousemove = function (event) {
    // Get coordinates relative to color picker center
    var pos = fb.widgetCoords(event);

    // Set new HSL parameters
    if (fb.circleDrag) {
      var hue = Math.atan2(pos.x, -pos.y) / 6.28;
      if (hue < 0) hue += 1;
      fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
    }
    else {
      var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
      var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
      fb.setHSL([fb.hsl[0], sat, lum]);
    }
    return false;
  }

  /**
   * Mouseup handler
   */
  fb.mouseup = function () {
    // Uncapture mouse
    $(document).unbind('mousemove', fb.mousemove);
    $(document).unbind('mouseup', fb.mouseup);
    document.dragging = false;
  }

  /**
   * Update the markers and styles
   */
  fb.updateDisplay = function () {
    // Markers
    var angle = fb.hsl[0] * 6.28;
    $('.h-marker', e).css({
      left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
      top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
    });

    $('.sl-marker', e).css({
      left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
      top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
    });

    // Saturation/Luminance gradient
    $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));

    // Linked elements or callback
    if (typeof fb.callback == 'object') {
      // Set background/foreground color
      $(fb.callback).css({
        backgroundColor: fb.color,
        color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
      });

      // Change linked value
      $(fb.callback).each(function() {
        if (this.value && this.value != fb.color) {
          this.value = fb.color;
        }
      });
    }
    else if (typeof fb.callback == 'function') {
      fb.callback.call(fb, fb.color);
    }
  }

  /**
   * Get absolute position of element
   */
  fb.absolutePosition = function (el) {
    var r = { x: el.offsetLeft, y: el.offsetTop };
    // Resolve relative to offsetParent
    if (el.offsetParent) {
      var tmp = fb.absolutePosition(el.offsetParent);
      r.x += tmp.x;
      r.y += tmp.y;
    }
    return r;
  };

  /* Various color utility functions */
  fb.pack = function (rgb) {
    var r = Math.round(rgb[0] * 255);
    var g = Math.round(rgb[1] * 255);
    var b = Math.round(rgb[2] * 255);
    return '#' + (r < 16 ? '0' : '') + r.toString(16) +
           (g < 16 ? '0' : '') + g.toString(16) +
           (b < 16 ? '0' : '') + b.toString(16);
  }

  fb.unpack = function (color) {
    if (color.length == 7) {
      return [parseInt('0x' + color.substring(1, 3)) / 255,
        parseInt('0x' + color.substring(3, 5)) / 255,
        parseInt('0x' + color.substring(5, 7)) / 255];
    }
    else if (color.length == 4) {
      return [parseInt('0x' + color.substring(1, 2)) / 15,
        parseInt('0x' + color.substring(2, 3)) / 15,
        parseInt('0x' + color.substring(3, 4)) / 15];
    }
  }

  fb.HSLToRGB = function (hsl) {
    var m1, m2, r, g, b;
    var h = hsl[0], s = hsl[1], l = hsl[2];
    m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
    m1 = l * 2 - m2;
    return [this.hueToRGB(m1, m2, h+0.33333),
        this.hueToRGB(m1, m2, h),
        this.hueToRGB(m1, m2, h-0.33333)];
  }

  fb.hueToRGB = function (m1, m2, h) {
    h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
    if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
    if (h * 2 < 1) return m2;
    if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
    return m1;
  }

  fb.RGBToHSL = function (rgb) {
    var min, max, delta, h, s, l;
    var r = rgb[0], g = rgb[1], b = rgb[2];
    min = Math.min(r, Math.min(g, b));
    max = Math.max(r, Math.max(g, b));
    delta = max - min;
    l = (min + max) / 2;
    s = 0;
    if (l > 0 && l < 1) {
      s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
    }
    h = 0;
    if (delta > 0) {
      if (max == r && max != g) h += (g - b) / delta;
      if (max == g && max != b) h += (2 + (b - r) / delta);
      if (max == b && max != r) h += (4 + (r - g) / delta);
      h /= 6;
    }
    return [h, s, l];
  }

  // Install mousedown handler (the others are set on the document on-demand)
  $('*', e).mousedown(fb.mousedown);

    // Init color
  fb.setColor('#000000');

  // Set linked elements/callback
  if (callback) {
    fb.linkTo(callback);
  }
};

/*
 * jqModal - Minimalist Modaling with jQuery
 *
 * Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * $Version: 2007.08.17 +r11
 * 
 */
 
(function($) {$.fn.jqm=function(o){var _o = {zIndex: 3000,overlay: 50,overlayClass: 'jqmOverlay',closeClass: 'jqmClose',trigger: '.jqModal',ajax: false,target: false,modal: false,toTop: false,onShow: false,onHide: false,onLoad: false};return this.each(function(){if(this._jqm)return; s++; this._jqm=s;H[s]={c:$.extend(_o, o),a:false,w:$(this).addClass('jqmID'+s),s:s};if(_o.trigger)$(this).jqmAddTrigger(_o.trigger);});};$.fn.jqmAddClose=function(e){hs(this,e,'jqmHide'); return this;};$.fn.jqmAddTrigger=function(e){hs(this,e,'jqmShow'); return this;};$.fn.jqmShow=function(t){return this.each(function(){if(!H[this._jqm].a)$.jqm.open(this._jqm,t)});};$.fn.jqmHide=function(t){return this.each(function(){if(H[this._jqm].a)$.jqm.close(this._jqm,t)});};$.jqm = {hash:{},open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(/^\d+$/.test(h.w.css('z-index')))?h.w.css('z-index'):c.zIndex,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});h.t=t;h.a=true;h.w.css('z-index',z); if(c.modal) {if(!A[0])F('bind');A.push(s);} else if(c.overlay > 0)h.w.jqmAddClose(o); else o=false; h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):false; if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}} if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;  r.load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});} else if(cc)h.w.jqmAddClose($(cc,h.w)); if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);	 (c.onShow)?c.onShow(h):h.w.show();e(h);return false;},close:function(s){var h=H[s];h.a=false; if(A[0]){A.pop();if(!A[0])F('unbind');} if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove(); if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return false;}};var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);},f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(e){}},F=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;},hs=function(w,e,y){var s=[];w.each(function(){s.push(this._jqm)}); $(e).each(function(){if(this[y])$.extend(this[y],s);else{this[y]=s;$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return false;});}});};
})(jQuery);
﻿/*
 *
 *	jQuery Timer plugin v0.1
 *		Matt Schmidt [http://www.mattptr.net]
 *
 *	Licensed under the BSD License:
 *		http://mattptr.net/license/license.txt
 *
 */
 
 jQuery.timer = function (interval, callback)
 {
 /**
  *
  * timer() provides a cleaner way to handle intervals  
  *
  *	@usage
  * $.timer(interval, callback);
  *
  *
  * @example
  * $.timer(1000, function (timer) {
  * 	alert("hello");
  * 	timer.stop();
  * });
  * @desc Show an alert box after 1 second and stop
  * 
  * @example
  * var second = false;
  *	$.timer(1000, function (timer) {
  *		if (!second) {
  *			alert('First time!');
  *			second = true;
  *			timer.reset(3000);
  *		}
  *		else {
  *			alert('Second time');
  *			timer.stop();
  *		}
  *	});
  * @desc Show an alert box after 1 second and show another after 3 seconds
  *
  * 
  */

	var interval = interval || 100;

	if (!callback)
		return false;
	
	_timer = function (interval, callback) {
		this.stop = function () {
			clearInterval(self.id);
		};
		
		this.internalCallback = function () {
			callback(self);
		};
		
		this.reset = function (val) {
			if (self.id)
				clearInterval(self.id);
			
			var val = val || 100;
			this.id = setInterval(this.internalCallback, val);
		};
		
		this.interval = interval;
		this.id = setInterval(this.internalCallback, this.interval);
		
		var self = this;
	};
	
	return new _timer(interval, callback);
 };

