// Plugins v0.1

// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || [];   // store logs to an array for reference
log.history.push(arguments);
arguments.callee = arguments.callee.caller; 
if(this.console) console.log( Array.prototype.slice.call(arguments) );
};

// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info, log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});

// jQuery/helper plugins

/*!
 * HTML5 Placeholder jQuery Plugin v1.8.2
 * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
 * @author Mathias Bynens <http://mathiasbynens.be/>
 */
 
;(function($) {

	var isInputSupported = 'placeholder' in document.createElement('input'),
	    isTextareaSupported = 'placeholder' in document.createElement('textarea');
	if (isInputSupported && isTextareaSupported) {
		$.fn.placeholder = function() {
			return this;
		};
		$.fn.placeholder.input = $.fn.placeholder.textarea = true;
	} else {
		$.fn.placeholder = function() {
			return this.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
				.bind('focus.placeholder', clearPlaceholder)
				.bind('blur.placeholder', setPlaceholder)
			.trigger('blur.placeholder').end();
		};
		$.fn.placeholder.input = isInputSupported;
		$.fn.placeholder.textarea = isTextareaSupported;
	}

	function args(elem) {
		// Return an object of element attributes
		var newAttrs = {},
		    rinlinejQuery = /^jQuery\d+$/;
		$.each(elem.attributes, function(i, attr) {
			if (attr.specified && !rinlinejQuery.test(attr.name)) {
				newAttrs[attr.name] = attr.value;
			}
		});
		return newAttrs;
	}

	function clearPlaceholder() {
		var $input = $(this);
		if ($input.val() === $input.attr('placeholder') && $input.hasClass('placeholder')) {
			if ($input.data('placeholder-password')) {
				$input.hide().next().attr('id', $input.removeAttr('id').data('placeholder-id')).show().focus();
			} else {
				$input.val('').removeClass('placeholder');
			}
		}
	}

	function setPlaceholder(elem) {
		var $replacement,
		    $input = $(this),
		    $origInput = $input,
		    id = this.id;
		if ($input.val() === '') {
			if ($input.is(':password')) {
				if (!$input.data('placeholder-textinput')) {
					try {
						$replacement = $input.clone().attr({ type: 'text' });
					} catch(e) {
						$replacement = $('<input>').attr($.extend(args(this), { type: 'text' }));
					}
					$replacement
						.removeAttr('name')
						// We could just use the `.data(obj)` syntax here, but that wouldn’t work in pre-1.4.3 jQueries
						.data('placeholder-password', true)
						.data('placeholder-id', id)
						.bind('focus.placeholder', clearPlaceholder);
					$input
						.data('placeholder-textinput', $replacement)
						.data('placeholder-id', id)
						.before($replacement);
				}
				$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
			}
			$input.addClass('placeholder').val($input.attr('placeholder'));
		} else {
			$input.removeClass('placeholder');
		}
	}

	$(function() {
		// Look for forms
		$('form').bind('submit.placeholder', function() {
			// Clear the placeholder values so they don’t get submitted
			var $inputs = $('.placeholder', this).each(clearPlaceholder);
			setTimeout(function() {
				$inputs.each(setPlaceholder);
			}, 10);
		});
	});

	// Clear placeholder values upon page reload
	$(window).bind('unload.placeholder', function() {
		$('.placeholder').val('');
	});

}(jQuery)); /* End placeholder */

/*
 * jQuery Cycle Lite Plugin
 * http://malsup.com/jquery/cycle/lite/
 * Copyright (c) 2008-2011 M. Alsup
 * Version: 1.3 (01-JUN-2011)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.3.2 or later
 */
;(function($) {	var ver = 'Lite-1.3';

	$.fn.cycle = function(options) {
	    return this.each(function() {
	        options = options || {};

	        if (this.cycleTimeout) clearTimeout(this.cycleTimeout);
	        this.cycleTimeout = 0;
	        this.cyclePause = 0;

	        var $cont = $(this);
	        var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
	        var els = $slides.get();
	        if (els.length < 2) {
	            return; // don't bother
	        }

	        // support metadata plugin (v1.0 and v2.0)
	        var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
			var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
			if (meta)
				opts = $.extend(opts, meta);

	        opts.before = opts.before ? [opts.before] : [];
	        opts.after = opts.after ? [opts.after] : [];
	        opts.after.unshift(function(){ opts.busy=0; });

	        // allow shorthand overrides of width, height and timeout
	        var cls = this.className;
	        opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1]) || opts.width;
	        opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1]) || opts.height;
	        opts.timeout = parseInt((cls.match(/t:(\d+)/)||[])[1]) || opts.timeout;

	        if ($cont.css('position') == 'static') 
	            $cont.css('position', 'relative');
	        if (opts.width) 
	            $cont.width(opts.width);
	        if (opts.height && opts.height != 'auto') 
	            $cont.height(opts.height);

	        var first = 0;
	        $slides.css({position: 'absolute', top:0, left:0}).each(function(i) { 
	            $(this).css('z-index', els.length-i) 
	        });

	        $(els[first]).css('opacity',1).show(); // opacity bit needed to handle reinit case
	        if ($.browser.msie) els[first].style.removeAttribute('filter');

	        if (opts.fit && opts.width) 
	            $slides.width(opts.width);
	        if (opts.fit && opts.height && opts.height != 'auto') 
	            $slides.height(opts.height);
	        if (opts.pause) 
	            $cont.hover(function(){this.cyclePause=1;}, function(){this.cyclePause=0;});

	        var txFn = $.fn.cycle.transitions[opts.fx];
			txFn && txFn($cont, $slides, opts);

	        $slides.each(function() {
	            var $el = $(this);
	            this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
	            this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
	        });

	        if (opts.cssFirst)
	            $($slides[first]).css(opts.cssFirst);

	        if (opts.timeout) {
	            // ensure that timeout and speed settings are sane
	            if (opts.speed.constructor == String)
	                opts.speed = {slow: 600, fast: 200}[opts.speed] || 400;
	            if (!opts.sync)
	                opts.speed = opts.speed / 2;
	            while((opts.timeout - opts.speed) < 250)
	                opts.timeout += opts.speed;
	        }
	        opts.speedIn = opts.speed;
	        opts.speedOut = opts.speed;

	 		opts.slideCount = els.length;
	        opts.currSlide = first;
	        opts.nextSlide = 1;

	        // fire artificial events
	        var e0 = $slides[first];
	        if (opts.before.length)
	            opts.before[0].apply(e0, [e0, e0, opts, true]);
	        if (opts.after.length > 1)
	            opts.after[1].apply(e0, [e0, e0, opts, true]);

	        if (opts.click && !opts.next)
	            opts.next = opts.click;
	        if (opts.next)
	            $(opts.next).bind('click', function(){return advance(els,opts,opts.rev?-1:1)});
	        if (opts.prev)
	            $(opts.prev).bind('click', function(){return advance(els,opts,opts.rev?1:-1)});

	        if (opts.timeout)
	            this.cycleTimeout = setTimeout(function() {
	                go(els,opts,0,!opts.rev)
	            }, opts.timeout + (opts.delay||0));
	    });
	};

	function go(els, opts, manual, fwd) {
	    if (opts.busy) return;
	    var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
	    if (p.cycleTimeout === 0 && !manual) 
	        return;

	    if (manual || !p.cyclePause) {
	        if (opts.before.length)
	            $.each(opts.before, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
	        var after = function() {
	            if ($.browser.msie)
	                this.style.removeAttribute('filter');
	            $.each(opts.after, function(i,o) { o.apply(next, [curr, next, opts, fwd]); });
	        };

	        if (opts.nextSlide != opts.currSlide) {
	            opts.busy = 1;
	            $.fn.cycle.custom(curr, next, opts, after);
	        }
	        var roll = (opts.nextSlide + 1) == els.length;
	        opts.nextSlide = roll ? 0 : opts.nextSlide+1;
	        opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
	    }
	    if (opts.timeout)
	        p.cycleTimeout = setTimeout(function() { go(els,opts,0,!opts.rev) }, opts.timeout);
	};

	// advance slide forward or back
	function advance(els, opts, val) {
	    var p = els[0].parentNode, timeout = p.cycleTimeout;
	    if (timeout) {
	        clearTimeout(timeout);
	        p.cycleTimeout = 0;
	    }
	    opts.nextSlide = opts.currSlide + val;
	    if (opts.nextSlide < 0) {
	        opts.nextSlide = els.length - 1;
	    }
	    else if (opts.nextSlide >= els.length) {
	        opts.nextSlide = 0;
	    }
	    go(els, opts, 1, val>=0);
	    return false;
	};

	$.fn.cycle.custom = function(curr, next, opts, cb) {
	    var $l = $(curr), $n = $(next);
	    $n.css(opts.cssBefore);
	    var fn = function() {$n.animate(opts.animIn, opts.speedIn, opts.easeIn, cb)};
	    $l.animate(opts.animOut, opts.speedOut, opts.easeOut, function() {
	        $l.css(opts.cssAfter);
	        if (!opts.sync) fn();
	    });
	    if (opts.sync) fn();
	};

	$.fn.cycle.transitions = {
	    fade: function($cont, $slides, opts) {
			$slides.not(':eq(0)').hide();
			opts.cssBefore = { opacity: 0, display: 'block' };
			opts.cssAfter  = { display: 'none' };
			opts.animOut = { opacity: 0 };
			opts.animIn = { opacity: 1 };
	    },
	    fadeout: function($cont, $slides, opts) {
			opts.before.push(function(curr,next,opts,fwd) {
				$(curr).css('zIndex',opts.slideCount + (fwd === true ? 1 : 0));
				$(next).css('zIndex',opts.slideCount + (fwd === true ? 0 : 1));
			});
			$slides.not(':eq(0)').hide();
			opts.cssBefore = { opacity: 1, display: 'block', zIndex: 1 };
			opts.cssAfter  = { display: 'none', zIndex: 0 };
			opts.animOut = { opacity: 0 };
	    }
	};

	$.fn.cycle.ver = function() { return ver; };

	// @see: http://malsup.com/jquery/cycle/lite/
	$.fn.cycle.defaults = {
		animIn:        {},
		animOut:       {},
		fx:           'fade',
	    after:         null, 
	    before:        null, 
		cssBefore:     {},
		cssAfter:      {},
	    delay:         0,    
	    fit:           0,    
	    height:       'auto',
		metaAttr:     'cycle',
	    next:          null, 
	    pause:         0,    
	    prev:          null, 
	    speed:         1000, 
	    slideExpr:     null,
	    sync:          1,    
	    timeout:       4000 
	};
}(jQuery));


/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */

;(function($){
	$.fn.superfish = function(op){

		var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
			over = function(){
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function(){
				var $$ = $(this), menu = getMenu($$), o = sf.op;
				clearTimeout(menu.sfTimer);
				menu.sfTimer=setTimeout(function(){
					o.retainPath=($.inArray($$[0],o.$path)>-1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
				},o.delay);	
			},
			getMenu = function($menu){
				var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
			
		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({},sf.defaults,op);
			o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
				$(this).addClass([o.hoverClass,c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;
			
			$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
				if (o.autoArrows) addArrow( $('>a:first-child',this) );
			})
			.not('.'+c.bcClass)
				.hideSuperfishUl();
			
			var $a = $('a',this);
			$a.each(function(i){
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
			});
			o.onInit.call(this);
			
		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function(){
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
			this.toggleClass(sf.c.shadowClass+'-off');
		};
	sf.c = {
		bcClass     : 'sf-breadcrumb',
		menuClass   : 'sf-js-enabled',
		anchorClass : 'sf-with-ul',
		arrowClass  : 'sf-sub-indicator',
		shadowClass : 'sf-shadow'
	};
	sf.defaults = {
		hoverClass	: 'sfHover',
		pathClass	: 'overideThisToUse',
		pathLevels	: 1,
		delay		: 800,
		animation	: {opacity:'show'},
		speed		: 'normal',
		autoArrows	: true,
		dropShadows : true,
		disableHI	: false,		// true disables hoverIntent detection
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){}
	};
	$.fn.extend({
		hideSuperfishUl : function(){
			var o = sf.op,
				not = (o.retainPath===true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility','hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl : function(){
			var o = sf.op,
				sh = sf.c.shadowClass+'-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility','visible');
			sf.IE7fix.call($ul);
			o.onBeforeShow.call($ul);
			$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);

;(function($){
	/* hoverIntent by Brian Cherne */
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			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; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
	
})(jQuery);
/*
 * Supersubs v0.2b - jQuery plugin
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 *
 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
 * their longest list item children. If you use this, please expect bugs and report them
 * to the jQuery Google Group with the word 'Superfish' in the subject line.
 *
 */

;(function($){ // $ will refer to jQuery within this closure

	$.fn.supersubs = function(options){
		var opts = $.extend({}, $.fn.supersubs.defaults, options);
		// return original object to support chaining
		return this.each(function() {
			// cache selections
			var $$ = $(this);
			// support metadata
			var o = $.meta ? $.extend({}, opts, $$.data()) : opts;
			// get the font size of menu.
			// .css('fontSize') returns various results cross-browser, so measure an em dash instead
			var fontsize = $('<li id="menu-fontsize">&#8212;</li>').css({
				'padding' : 0,
				'position' : 'absolute',
				'top' : '-999em',
				'width' : 'auto'
			}).appendTo($$).width(); //clientWidth is faster, but was incorrect here
			// remove em dash
			$('#menu-fontsize').remove();
			// cache all ul elements
			$ULs = $$.find('ul');
			// loop through each ul in menu
			$ULs.each(function(i) {	
				// cache this ul
				var $ul = $ULs.eq(i);
				// get all (li) children of this ul
				var $LIs = $ul.children();
				// get all anchor grand-children
				var $As = $LIs.children('a');
				// force content to one line and save current float property
				var liFloat = $LIs.css('white-space','nowrap').css('float');
				// remove width restrictions and floats so elements remain vertically stacked
				var emWidth = $ul.add($LIs).add($As).css({
					'float' : 'none',
					'width'	: 'auto'
				})
				// this ul will now be shrink-wrapped to longest li due to position:absolute
				// so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
				.end().end()[0].clientWidth / fontsize;
				// add more width to ensure lines don't turn over at certain sizes in various browsers
				emWidth += o.extraWidth;
				// restrict to at least minWidth and at most maxWidth
				if (emWidth > o.maxWidth)		{ emWidth = o.maxWidth; }
				else if (emWidth < o.minWidth)	{ emWidth = o.minWidth; }
				emWidth += 'em';
				// set ul to width in ems
				$ul.css('width',emWidth);
				// restore li floats to avoid IE bugs
				// set li width to full width of this ul
				// revert white-space to normal
				$LIs.css({
					'float' : liFloat,
					'width' : '100%',
					'white-space' : 'normal'
				})
				// update offset position of descendant ul to reflect new width of parent
				.each(function(){
					var $childUl = $('>ul',this);
					var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right';
					$childUl.css(offsetDirection,emWidth);
				});
			});
			
		});
	};
	// expose defaults
	$.fn.supersubs.defaults = {
		minWidth		: 9,		// requires em unit.
		maxWidth		: 25,		// requires em unit.
		extraWidth		: 0			// extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
	};
	
})(jQuery); // plugin code ends

