// Plugins

// 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));

/*
 * jQuery FlexSlider v1.6
 * http://flex.madebymufffin.com
 *
 * Copyright 2011, Tyler Smith
 * Free to use under the MIT license.
 *
 */
(function(a){a.flexslider=function(c,b){var d=c;d.init=function(){d.vars=a.extend({},a.flexslider.defaults,b);d.data("flexslider",true);d.container=a(".slides",d);d.slides=a(".slides > li",d);d.count=d.slides.length;d.animating=false;d.currentSlide=d.vars.slideToStart;d.eventType=("ontouchstart" in document.documentElement)?"touchstart":"click";if(d.vars.controlsContainer!=""){d.controlsContainer=a(d.vars.controlsContainer).eq(a(".slides").index(d.container));d.containerExists=d.controlsContainer.length>0}if(d.vars.manualControls!=""){if(d.containerExists){d.manualControls=a(d.vars.manualControls,d.controlsContainer)}else{d.manualControls=a(d.vars.manualControls,d)}d.manualExists=d.manualControls.length>0}if(d.vars.randomize&&d.count>1){d.slides.sort(function(){return(Math.round(Math.random())-0.5)});d.container.empty().append(d.slides)}if(d.vars.animation.toLowerCase()=="slide"&&d.count>1){d.css({overflow:"hidden"});d.container.append(d.slides.filter(":first").clone().addClass("clone")).prepend(d.slides.filter(":last").clone().addClass("clone"));d.container.width(((d.count+2)*d.width())+2000);d.newSlides=a(".slides > li",d);setTimeout(function(){d.newSlides.width(d.width()).css({"float":"left"}).show()},100);d.container.css({marginLeft:(-1*(d.currentSlide+1))*d.width()+"px"})}else{d.slides.hide().eq(d.currentSlide).fadeIn(400)}if(d.vars.controlNav&&d.count>1){if(d.manualExists){d.controlNav=d.manualControls}else{var e=a('<ol class="flex-control-nav"></ol>');var f=1;for(var g=0;g<d.count;g++){e.append("<li><a>"+f+"</a></li>");f++}if(d.containerExists){a(d.controlsContainer).append(e);d.controlNav=a(".flex-control-nav li a",d.controlsContainer)}else{d.append(e);d.controlNav=a(".flex-control-nav li a",d)}}d.controlNav.eq(d.currentSlide).addClass("active");d.controlNav.bind(d.eventType,function(i){i.preventDefault();if(!(a(this).hasClass("active")||d.animating)){d.controlNav.removeClass("active");a(this).addClass("active");var h=d.controlNav.index(a(this));d.flexAnimate(h);if(d.vars.pauseOnAction){clearInterval(d.animatedSlides)}}})}if(d.vars.directionNav&&d.count>1){if(d.containerExists){a(d.controlsContainer).append(a('<ul class="flex-direction-nav"><li><a class="prev" href="#">'+d.vars.prevText+'</a></li><li><a class="next" href="#">'+d.vars.nextText+"</a></li></ul>"));d.directionNav=a(".flex-direction-nav li a",d.controlsContainer)}else{d.append(a('<ul class="flex-direction-nav"><li><a class="prev" href="#">'+d.vars.prevText+'</a></li><li><a class="next" href="#">'+d.vars.nextText+"</a></li></ul>"));d.directionNav=a(".flex-direction-nav li a",d)}d.directionNav.bind(d.eventType,function(h){h.preventDefault();if(d.animating){return}else{if(a(this).hasClass("next")){var i=(d.currentSlide==d.count-1)?0:d.currentSlide+1}else{var i=(d.currentSlide==0)?d.count-1:d.currentSlide-1}if(d.vars.controlNav){d.controlNav.removeClass("active");d.controlNav.eq(i).addClass("active")}d.flexAnimate(i);if(d.vars.pauseOnAction){clearInterval(d.animatedSlides)}}})}if(d.vars.keyboardNav&&d.count>1&&a("ul.slides").length==1){a(document).keyup(function(h){if(d.animating){return}else{if(h.keyCode!=39&&h.keyCode!=37){return}else{if(h.keyCode==39){var i=(d.currentSlide==d.count-1)?0:d.currentSlide+1}else{if(h.keyCode==37){var i=(d.currentSlide==0)?d.count-1:d.currentSlide-1}}if(d.vars.controlNav){d.controlNav.removeClass("active");d.controlNav.eq(i).addClass("active")}d.flexAnimate(i);if(d.vars.pauseOnAction){clearInterval(d.animatedSlides)}}}})}if(d.vars.slideshow){d.animatedSlides;if(d.vars.pauseOnHover&&d.vars.slideshow){d.hover(function(){clearInterval(d.animatedSlides)},function(){d.animatedSlides=setInterval(d.animateSlides,d.vars.slideshowSpeed)})}if(d.count>1){d.animatedSlides=setInterval(d.animateSlides,d.vars.slideshowSpeed)}}if(d.vars.touchSwipe&&"ontouchstart" in document.documentElement&&d.count>1){d.each(function(){var h,i=20;isMoving=false;function l(){this.removeEventListener("touchmove",j);h=null;isMoving=false}function j(p){if(isMoving){var m=p.touches[0].pageX,n=h-m;if(Math.abs(n)>=i){l();if(n>0){var o=(d.currentSlide==d.count-1)?0:d.currentSlide+1}else{var o=(d.currentSlide==0)?d.count-1:d.currentSlide-1}if(d.vars.controlNav){d.controlNav.removeClass("active");d.controlNav.eq(o).addClass("active")}d.flexAnimate(o);if(d.vars.pauseOnAction){clearInterval(d.animatedSlides)}}}}function k(m){if(m.touches.length==1){h=m.touches[0].pageX;isMoving=true;this.addEventListener("touchmove",j,false)}}if("ontouchstart" in document.documentElement){this.addEventListener("touchstart",k,false)}})}if(d.vars.animation.toLowerCase()=="slide"&&d.count>1){d.sliderTimer;a(window).resize(function(){d.newSlides.width(d.width());d.container.width(((d.count+2)*d.width())+2000);clearTimeout(d.sliderTimer);d.sliderTimer=setTimeout(function(){d.flexAnimate(d.currentSlide)},300)})}};d.flexAnimate=function(e){if(!d.animating){d.animating=true;if(d.vars.animation.toLowerCase()=="slide"){if(d.currentSlide==0&&e==d.count-1){d.container.animate({marginLeft:"0px"},d.vars.animationDuration,function(){d.container.css({marginLeft:(-1*d.count)*d.slides.filter(":first").width()+"px"});d.animating=false;d.currentSlide=e})}else{if(d.currentSlide==d.count-1&&e==0){d.container.animate({marginLeft:(-1*(d.count+1))*d.slides.filter(":first").width()+"px"},d.vars.animationDuration,function(){d.container.css({marginLeft:-1*d.slides.filter(":first").width()+"px"});d.animating=false;d.currentSlide=e})}else{d.container.animate({marginLeft:(-1*(e+1))*d.slides.filter(":first").width()+"px"},d.vars.animationDuration,function(){d.animating=false;d.currentSlide=e})}}}else{d.css({minHeight:d.slides.eq(d.currentSlide).height()});d.slides.eq(d.currentSlide).fadeOut(d.vars.animationDuration,function(){d.slides.eq(e).fadeIn(d.vars.animationDuration,function(){d.animating=false;d.currentSlide=e});d.css({minHeight:"inherit"})})}}};d.animateSlides=function(){if(d.animating){return}else{var e=(d.currentSlide==d.count-1)?0:d.currentSlide+1;if(d.vars.controlNav){d.controlNav.removeClass("active");d.controlNav.eq(e).addClass("active")}d.flexAnimate(e)}};d.init()};a.flexslider.defaults={animation:"fade",slideshow:true,slideshowSpeed:7000,animationDuration:500,directionNav:true,controlNav:true,keyboardNav:true,touchSwipe:true,prevText:"Previous",nextText:"Next",randomize:false,slideToStart:0,pauseOnAction:true,pauseOnHover:false,controlsContainer:"",manualControls:""};a.fn.flexslider=function(b){return this.each(function(){if(a(this).data("flexslider")!=true){new a.flexslider(a(this),b)}})}})(jQuery);

/*
 * jQuery Reveal Plugin 1.0
 * www.ZURB.com
 * Copyright 2010, ZURB
 * Free to use under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
*/
(function($){$('a[data-reveal-id]').live('click',function(e){e.preventDefault();var modalLocation=$(this).attr('data-reveal-id');$('#'+modalLocation).reveal($(this).data());});$.fn.reveal=function(options){var defaults={animation:'fadeAndPop',animationspeed:300,closeonbackgroundclick:true,dismissmodalclass:'close-reveal-modal'};var options=$.extend({},defaults,options);return this.each(function(){var modal=$(this),topMeasure=parseInt(modal.css('top')),topOffset=modal.height()+topMeasure,locked=false,modalBG=$('.reveal-modal-bg');if(modalBG.length==0){modalBG=$('<div class="reveal-modal-bg" />').insertAfter(modal);}
modal.bind('reveal:open',function(){modalBG.unbind('click.modalEvent');$('.'+options.dismissmodalclass).unbind('click.modalEvent');if(!locked){lockModal();if(options.animation=="fadeAndPop"){modal.css({'top':$(document).scrollTop()-topOffset,'opacity':0,'visibility':'visible'});modalBG.fadeIn(options.animationspeed/2);modal.delay(options.animationspeed/2).animate({"top":$(document).scrollTop()+topMeasure+'px',"opacity":1},options.animationspeed,unlockModal());}
if(options.animation=="fade"){modal.css({'opacity':0,'visibility':'visible','top':$(document).scrollTop()+topMeasure});modalBG.fadeIn(options.animationspeed/2);modal.delay(options.animationspeed/2).animate({"opacity":1},options.animationspeed,unlockModal());}
if(options.animation=="none"){modal.css({'visibility':'visible','top':$(document).scrollTop()+topMeasure});modalBG.css({"display":"block"});unlockModal()}}
modal.unbind('reveal:open');});modal.bind('reveal:close',function(){if(!locked){lockModal();if(options.animation=="fadeAndPop"){modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);modal.animate({"top":$(document).scrollTop()-topOffset+'px',"opacity":0},options.animationspeed/2,function(){modal.css({'top':topMeasure,'opacity':1,'visibility':'hidden'});unlockModal();});}
if(options.animation=="fade"){modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);modal.animate({"opacity":0},options.animationspeed,function(){modal.css({'opacity':1,'visibility':'hidden','top':topMeasure});unlockModal();});}
if(options.animation=="none"){modal.css({'visibility':'hidden','top':topMeasure});modalBG.css({'display':'none'});}}
modal.unbind('reveal:close');});modal.trigger('reveal:open')
var closeButton=$('.'+options.dismissmodalclass).bind('click.modalEvent',function(){modal.trigger('reveal:close')});if(options.closeonbackgroundclick){modalBG.css({"cursor":"pointer"})
modalBG.bind('click.modalEvent',function(){modal.trigger('reveal:close')});}
$('body').keyup(function(e){if(e.which===27){modal.trigger('reveal:close');}});function unlockModal(){locked=false;}
function lockModal(){locked=true;}});}})(jQuery);

