/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
 * Contains: fontface | borderradius | boxshadow | multiplebgs | textshadow | cssanimations | generatedcontent | iepp | cssclasses | teststyles | testprop | testallprops | prefixes | domprefixes | load
 */
;window.Modernizr=function(a,b,c){function D(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+p.join(c+" ")+c).split(" ");return C(d,b)}function C(a,b){for(var d in a)if(k[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function B(a,b){return!!~(""+a).indexOf(b)}function A(a,b){return typeof a===b}function z(a,b){return y(o.join(a+";")+(b||""))}function y(a){k.cssText=a}var d="2.0.6",e={},f=!0,g=b.documentElement,h=b.head||b.getElementsByTagName("head")[0],i="modernizr",j=b.createElement(i),k=j.style,l,m=":)",n=Object.prototype.toString,o=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),p="Webkit Moz O ms Khtml".split(" "),q={},r={},s={},t=[],u=function(a,c,d,e){var f,h,j,k=b.createElement("div");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:i+(d+1),k.appendChild(j);f=["&shy;","<style>",a,"</style>"].join(""),k.id=i,k.innerHTML+=f,g.appendChild(k),h=c(k,a),k.parentNode.removeChild(k);return!!h},v,w={}.hasOwnProperty,x;!A(w,c)&&!A(w.call,c)?x=function(a,b){return w.call(a,b)}:x=function(a,b){return b in a&&A(a.constructor.prototype[b],c)};var E=function(a,c){var d=a.join(""),f=c.length;u(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.generatedcontent=i.generatedcontent.offsetHeight>=1,e.fontface=/src/i.test(g)&&g.indexOf(c.split(" ")[0])===0},f,c)}(['@font-face {font-family:"font";src:url("https://")}',['#generatedcontent:after{content:"',m,'";visibility:hidden}'].join("")],["fontface","generatedcontent"]);q.multiplebgs=function(){y("background:url(https://),url(https://),red url(https://)");return/(url\s*\(.*?){3}/.test(k.background)},q.borderradius=function(){return D("borderRadius")},q.boxshadow=function(){return D("boxShadow")},q.textshadow=function(){return b.createElement("div").style.textShadow===""},q.cssanimations=function(){return D("animationName")},q.fontface=function(){return e.fontface},q.generatedcontent=function(){return e.generatedcontent};for(var F in q)x(q,F)&&(v=F.toLowerCase(),e[v]=q[F](),t.push((e[v]?"":"no-")+v));y(""),j=l=null,a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function s(a){var b=-1;while(++b<g)a.createElement(f[b])}a.iepp=a.iepp||{};var d=a.iepp,e=d.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",f=e.split("|"),g=f.length,h=new RegExp("(^|\\s)("+e+")","gi"),i=new RegExp("<(/*)("+e+")","gi"),j=/^\s*[\{\}]\s*$/,k=new RegExp("(^|[^\\n]*?\\s)("+e+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),l=b.createDocumentFragment(),m=b.documentElement,n=m.firstChild,o=b.createElement("body"),p=b.createElement("style"),q=/print|all/,r;d.getCSS=function(a,b){if(a+""===c)return"";var e=-1,f=a.length,g,h=[];while(++e<f){g=a[e];if(g.disabled)continue;b=g.media||b,q.test(b)&&h.push(d.getCSS(g.imports,b),g.cssText),b="all"}return h.join("")},d.parseCSS=function(a){var b=[],c;while((c=k.exec(a))!=null)b.push(((j.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(h,"$1.iepp_$2")+c[4]);return b.join("\n")},d.writeHTML=function(){var a=-1;r=r||b.body;while(++a<g){var c=b.getElementsByTagName(f[a]),d=c.length,e=-1;while(++e<d)c[e].className.indexOf("iepp_")<0&&(c[e].className+=" iepp_"+f[a])}l.appendChild(r),m.appendChild(o),o.className=r.className,o.id=r.id,o.innerHTML=r.innerHTML.replace(i,"<$1font")},d._beforePrint=function(){p.styleSheet.cssText=d.parseCSS(d.getCSS(b.styleSheets,"all")),d.writeHTML()},d.restoreHTML=function(){o.innerHTML="",m.removeChild(o),m.appendChild(r)},d._afterPrint=function(){d.restoreHTML(),p.styleSheet.cssText=""},s(b),s(l);d.disablePP||(n.insertBefore(p,n.firstChild),p.media="print",p.className="iepp-printshim",a.attachEvent("onbeforeprint",d._beforePrint),a.attachEvent("onafterprint",d._afterPrint))}(a,b),e._version=d,e._prefixes=o,e._domPrefixes=p,e.testProp=function(a){return C([a])},e.testAllProps=D,e.testStyles=u,g.className=g.className.replace(/\bno-js\b/,"")+(f?" js "+t.join(" "):"");return e}(this,this.document),function(a,b,c){function k(a){return!a||a=="loaded"||a=="complete"}function j(){var a=1,b=-1;while(p.length- ++b)if(p[b].s&&!(a=p[b].r))break;a&&g()}function i(a){var c=b.createElement("script"),d;c.src=a.s,c.onreadystatechange=c.onload=function(){!d&&k(c.readyState)&&(d=1,j(),c.onload=c.onreadystatechange=null)},m(function(){d||(d=1,j())},H.errorTimeout),a.e?c.onload():n.parentNode.insertBefore(c,n)}function h(a){var c=b.createElement("link"),d;c.href=a.s,c.rel="stylesheet",c.type="text/css";if(!a.e&&(w||r)){var e=function(a){m(function(){if(!d)try{a.sheet.cssRules.length?(d=1,j()):e(a)}catch(b){b.code==1e3||b.message=="security"||b.message=="denied"?(d=1,m(function(){j()},0)):e(a)}},0)};e(c)}else c.onload=function(){d||(d=1,m(function(){j()},0))},a.e&&c.onload();m(function(){d||(d=1,j())},H.errorTimeout),!a.e&&n.parentNode.insertBefore(c,n)}function g(){var a=p.shift();q=1,a?a.t?m(function(){a.t=="c"?h(a):i(a)},0):(a(),j()):q=0}function f(a,c,d,e,f,h){function i(){!o&&k(l.readyState)&&(r.r=o=1,!q&&j(),l.onload=l.onreadystatechange=null,m(function(){u.removeChild(l)},0))}var l=b.createElement(a),o=0,r={t:d,s:c,e:h};l.src=l.data=c,!s&&(l.style.display="none"),l.width=l.height="0",a!="object"&&(l.type=d),l.onload=l.onreadystatechange=i,a=="img"?l.onerror=i:a=="script"&&(l.onerror=function(){r.e=r.r=1,g()}),p.splice(e,0,r),u.insertBefore(l,s?null:n),m(function(){o||(u.removeChild(l),r.r=r.e=o=1,j())},H.errorTimeout)}function e(a,b,c){var d=b=="c"?z:y;q=0,b=b||"j",C(a)?f(d,a,b,this.i++,l,c):(p.splice(this.i++,0,a),p.length==1&&g());return this}function d(){var a=H;a.loader={load:e,i:0};return a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=r&&!s,u=s?l:n.parentNode,v=a.opera&&o.call(a.opera)=="[object Opera]",w="webkitAppearance"in l.style,x=w&&"async"in b.createElement("script"),y=r?"object":v||x?"img":"script",z=w?"img":y,A=Array.isArray||function(a){return o.call(a)=="[object Array]"},B=function(a){return Object(a)===a},C=function(a){return typeof a=="string"},D=function(a){return o.call(a)=="[object Function]"},E=[],F={},G,H;H=function(a){function f(a){var b=a.split("!"),c=E.length,d=b.pop(),e=b.length,f={url:d,origUrl:d,prefixes:b},g,h;for(h=0;h<e;h++)g=F[b[h]],g&&(f=g(f));for(h=0;h<c;h++)f=E[h](f);return f}function e(a,b,e,g,h){var i=f(a),j=i.autoCallback;if(!i.bypass){b&&(b=D(b)?b:b[a]||b[g]||b[a.split("/").pop().split("?")[0]]);if(i.instead)return i.instead(a,b,e,g,h);e.load(i.url,i.forceCSS||!i.forceJS&&/css$/.test(i.url)?"c":c,i.noexec),(D(b)||D(j))&&e.load(function(){d(),b&&b(i.origUrl,h,g),j&&j(i.origUrl,h,g)})}}function b(a,b){function c(a){if(C(a))e(a,h,b,0,d);else if(B(a))for(i in a)a.hasOwnProperty(i)&&e(a[i],h,b,i,d)}var d=!!a.test,f=d?a.yep:a.nope,g=a.load||a.both,h=a.callback,i;c(f),c(g),a.complete&&b.load(a.complete)}var g,h,i=this.yepnope.loader;if(C(a))e(a,0,i,0);else if(A(a))for(g=0;g<a.length;g++)h=a[g],C(h)?e(h,0,i,0):A(h)?H(h):B(h)&&b(h,i);else B(a)&&b(a,i)},H.addPrefix=function(a,b){F[a]=b},H.addFilter=function(a){E.push(a)},H.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",G=function(){b.removeEventListener("DOMContentLoaded",G,0),b.readyState="complete"},0)),a.yepnope=d()}(this,this.document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};
/*****************************************************************************
jQuery Placeholder 1.1.1
Copyright (c) 2010 Michael J. Ryan (http://tracker1.info/)
Dual licensed under the MIT and GPL licenses:
	http://www.opensource.org/licenses/mit-license.php
	http://www.gnu.org/licenses/gpl.html
*****************************************************************************/
(function($){var ph="PLACEHOLDER-INPUT";var phl="PLACEHOLDER-LABEL";var boundEvents=false;var default_options={labelClass:'placeholder'};var input=document.createElement("input");if('placeholder'in input){$.fn.placeholder=$.fn.unplaceholder=function(){};delete input;return;};delete input;$.fn.placeholder=function(options){bindEvents();var opts=$.extend(default_options,options)
this.each(function(){var rnd=Math.random().toString(32).replace(/\./,''),input=$(this),label=$('<label style="position:absolute;display:none;top:0;left:0;"></label>');if(!input.attr('placeholder')||input.data(ph)===ph)return;if(!input.attr('id'))input.attr('id')='input_'+rnd;label.attr('id',input.attr('id')+"_placeholder").data(ph,'#'+input.attr('id')).attr('for',input.attr('id')).addClass(opts.labelClass).addClass(opts.labelClass+'-for-'+this.tagName.toLowerCase()).addClass(phl).text(input.attr('placeholder'));input.data(phl,'#'+label.attr('id')).data(ph,ph).addClass(ph).after(label);itemIn.call(this);itemOut.call(this);});};$.fn.unplaceholder=function(){this.each(function(){var input=$(this),label=$(input.data(phl));if(input.data(ph)!==ph)return;label.remove();input.removeData(ph).removeData(phl).removeClass(ph);});};function bindEvents(){if(boundEvents)return;$('.'+ph).live('click',itemIn).live('focusin',itemIn).live('focusout',itemOut);bound=true;boundEvents=true;};function itemIn(){var input=$(this),label=$(input.data(phl));label.css('display','none');};function itemOut(){var that=this;setTimeout(function(){var input=$(that);$(input.data(phl)).css('top',input.position().top+'px').css('left',input.position().left+'px').css('display',!!input.val()?'none':'block');},200);};}(jQuery));
/********************************************************/
/******* Background Position Animation Plugin ********/
/******************************************************/
/**
 * @author Alexander Farkas
 * v. 1.22
 */
(function($){if(!document.defaultView||!document.defaultView.getComputedStyle){var oldCurCSS=$.curCSS;$.curCSS=function(elem,name,force){if(name==='background-position'){name='backgroundPosition';}
if(name!=='backgroundPosition'||!elem.currentStyle||elem.currentStyle[name]){return oldCurCSS.apply(this,arguments);}
var style=elem.style;if(!force&&style&&style[name]){return style[name];}
return oldCurCSS(elem,'backgroundPositionX',force)+' '+oldCurCSS(elem,'backgroundPositionY',force);};}
var oldAnim=$.fn.animate;$.fn.animate=function(prop){if('background-position'in prop){prop.backgroundPosition=prop['background-position'];delete prop['background-position'];}
if('backgroundPosition'in prop){prop.backgroundPosition='('+prop.backgroundPosition;}
return oldAnim.apply(this,arguments);};function toArray(strg){strg=strg.replace(/left|top/g,'0px');strg=strg.replace(/right|bottom/g,'100%');strg=strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var res=strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];}
$.fx.step.backgroundPosition=function(fx){if(!fx.bgPosReady){var start=$.curCSS(fx.elem,'backgroundPosition');if(!start){start='0px 0px';}
start=toArray(start);fx.start=[start[0],start[2]];var end=toArray(fx.end);fx.end=[end[0],end[2]];fx.unit=[end[1],end[3]];fx.bgPosReady=true;}
var nowPosX=[];nowPosX[0]=((fx.end[0]-fx.start[0])*fx.pos)+fx.start[0]+fx.unit[0];nowPosX[1]=((fx.end[1]-fx.start[1])*fx.pos)+fx.start[1]+fx.unit[1];fx.elem.style.backgroundPosition=nowPosX[0]+' '+nowPosX[1];};})(jQuery);
/** Utilities **/
jQuery(document).ready(function(){

	// Catch all external links and downloads so they open in a new window
	jQuery('body').delegate('a[href^="http://"]:not([href*="'+location.hostname+'"]),a[rel~="external"],a[rel~="download"]', 'click', function(e){ jQuery(e.currentTarget).attr('target', '_blank'); });
});

/** Setup **/
jQuery(document).ready(function(){
	
	nav.init();
	carousel.init();
	summary.init();

	jQuery('input[placeholder],textarea[placeholder]').placeholder();
});

/************************************************************************************/
/******************************* Navigation Functions ******************************/
/***********************************************************************************/
var nav = (function($){
	
	var v = {
		root : '#nav',
		menuItem : '#nav>li',
		subMenu : 'ul',
		toTopSelector : '#backtotop',
		isHovering : false,
		speed : 250,
		speedBetween : 50,
		timer : 0,
		timeout : 250,
		old : null,
		current : null,
		delayMenu : true
	};
	
	var prvt = {
		focused : null,
		is : { IE : $.browser.msie }
	};
	
	function toTop(e){ 
		e.preventDefault();
		var el = prvt.is.IE ? document.documentElement : document.body;
		$(el).animate({scrollTop:0},'slow') ;
	}
	
	function eHovOver(e){
		
		// Clear timeout if it's not 0
		if( v.delayMenu && v.timer != 0 && v.current != null)
			clearTimeout(v.timer);
		
		// Hide the currently active menu if we're switching between items
		// And only if we're using the delayed menus feature
		if( v.delayMenu && e.currentTarget !== v.current && v.isHovering && v.current != null ){
			toggleMenu( v.current, 'hide' );
		}
		
		// Only toggle the menu if the user is hovering on something new
		if( v.current !== e.currentTarget ){
			toggleMenu( e.currentTarget, 'show' );
			v.current = e.currentTarget;
		}
		v.isHovering = true;
	}
	
	function eHovOut(e){
		
		// Set the timeout if we're delaying the menu
		if( v.delayMenu ){
			v.timer = setTimeout(function(){
				v.isHovering = false;
				$(v.current).removeClass('hover');
				toggleMenu(v.current, 'hide');
				v.current = null;
			}, v.timeout);
		
		// Otherwise, hide it now
		}else{
			$(v.current).removeClass('hover');
			v.current = null;
			toggleMenu( e.currentTarget, 'hide' );
			v.isHovering = false;
		}
	}
	
	// Toggles the menu item specified
	function toggleMenu( item, dir ){
		if( item == null || typeof item !== 'object' || $(item).attr('id') == v.root.slice(1) ) return false;

		// Show the menu
		if( dir == 'show' ){
			$(v.subMenu, item).stop(true,true).slideDown(v.speed);
			
		// Hide the menu
		}else if( dir == 'hide' ){
			$(v.subMenu, item).stop(true,true).slideUp(v.speed);
		}
	}
	
	function setupHandlers(){
		
		$(v.menuItem).hover(eHovOver,eHovOut);
		
		$('a', v.menuItem).focusin(function(e){
			if( prvt.focused == null)
				prvt.focused = e.currentTarget;
			
			if( ! $(v.current).has(this).length ){
				$(this).closest(v.menuItem).triggerHandler('mouseenter');
				$(v.current).addClass('hover');
			}
			v.old = prvt.focused;
			prvt.focused = e.currentTarget;
		})
		
		$('body').click(function(e){
			// Don't waste time if this click had nothing to do with navigation
			if( v.current !== null && v.isHovering ){
				// Now check to see make sure we're not inside of the menu
				if( ! $(v.current).has( e.target ) ){
					$(v.current).trigger('mouseleave');
					prvt.focused = null;
				}
			}
		});
			
		$('body').delegate(v.toTopSelector, 'click', toTop);
	}
	
	/*****************************************************************/
	/********** PUBLICLY AVAILABLE FUNCTIONS FOR NAV **********/
	/****************************************************************/
	return {
		init : function(opts){
			$.extend(v, opts);
			setupHandlers();
		}
	}
})(jQuery);

/************************************************************************************/
/******************************** Carousel Functions *******************************/
/***********************************************************************************/
var carousel = (function($){
	
	var v = {
		carouselID : 'carousel',
		navID : 'carousel-nav',
		contentClass : 'details',
		btnLeftID : 'carousel-left',
		btnRightID : 'carousel-right',
		current : 0,
		prev : null,
		delay : 5000,
		timer : 0,
		cancel : false,
		isRunning : false,
		auto : true,
		isRightAligned : false,
		totalWidth : 0,
		width : 0,
		spacing : 8,
		speed : 400,
		navHeight : 36
	};
	
	function navClick(e){
		e.preventDefault();
		goTo( (v.isRightAligned) ? v.total - 1 - $(e.currentTarget).parent('li').index() : $(e.currentTarget).parent('li').index() );
	}
	
	function goTo(num){
		if(isNaN(num) || v.isRunning || num == v.current)
			return false;
		
		// Queue up the sequence
		$(v.carouselID).queue(function(next){
			v.isRunning = true;
			toggleNavItems([num,v.current]);

			$('ul', v.carouselID).animate({'left' : Math.round( -(v.width+v.spacing) * num, 0 ) }, v.speed, function(){
				v.current = num;
				next();
			});
		});
		$(v.carouselID).queue(function(next){ v.isRunning = false;next(); });
	}
	
	function toggleNavItems(arg){
		// Check to see what type of argument is passed
		if(typeof arr === 'string'){
			if(v.isRightAligned) arg = v.total-1-arg;
			toggleBg( $("li:eq("+arg+") a",v.navID), -v.navHeight );
		}else{
			for(i in arg){
				if(v.isRightAligned) arg[i] = v.total-1-arg[i];
				toggleBg( $("li:eq("+arg[i]+") a",v.navID), -v.navHeight );
			}
		}
	}
	
	function toggleBg(item,dist){
		
		if( typeof Modernizr === 'undefined' || ! Modernizr.cssanimations ){
			if( item.hasClass('active') )
				item.animate({'backgroundPosition' : "0 0"}, 200);
			else
				item.animate({'backgroundPosition' : '0 '+dist+"px"}, 200);
		}
		
		item.toggleClass('active');
	}
	
	function next(){ goTo( (v.current+1 <= v.total-1) ? v.current+1 : 0 ); clearTimer(); }
	function prev(){ goTo( (v.current-1 >= 0) ? v.current-1 : v.total ); clearTimer(); }
	function startTimer(){ v.timer = setInterval(function(){ next(); }, v.delay); }
	function clearTimer(){ clearInterval(v.timer); startTimer(); }
	function stopTimer(){ clearInterval(v.timer); }
	
	/****************************************************************************/
	/********** PUBLICLY AVAILABLE FUNCTIONS FOR THE CAROUSEL **********/
	/**************************************************************************/
	return {
		init : function(opts){
			$.extend(v,opts);
			
			// Convert these into easy to use internals
			v.navID = '#'+v.navID;
			v.carouselID = '#'+v.carouselID;
			v.contentClass = '.'+v.contentClass;
			v.total = $('li',v.carouselID).length;
			v.isRightAligned = ($('a', v.navID).css('float') == 'right') ? true : false;
			
			if( v.total > 0 ){
				
				v.width = $('li',v.carouselID).first().width();
				v.totalWidth = Math.round( (v.width + v.spacing) * v.total, 0);
				$('li',v.carouselID).width( v.width );
				$('ul', v.carouselID).width( v.totalWidth );
				
				$('body')
					.delegate(v.navID+' a', 'click', navClick)
					.delegate('#'+v.btnRightID, 'click', function(e){ next(); e.preventDefault() })
					.delegate('#'+v.btnLeftID, 'click', function(e){ prev(); e.preventDefault() });
				
				if(v.auto){
					$(v.carouselID+" li"+", "+v.navID).hover(stopTimer,startTimer);
					startTimer();
				}
			}
		},
		/** Returns the (logical) number of the active item in the carousel **/
		current : function(){ return v.current+1; },
		stop : function(){ stopTimer(); }
	}
})(jQuery)

var summary = (function($){
	
	v = {
		toggle : '.toggle',
		toggleBtn : '.toggle-btn',
		toggleCont : '.toggle-title',
		toggleItem : '.toggle-item',
		speed : 250
	};
	
	function setup(){
		
		$('body').delegate(v.toggleBtn, 'click', function(e){
			$(this).closest(v.toggleCont).next(v.toggleItem).slideToggle(v.speed);
			var oldText = $(this).text();
			var newText = $(this).data('alt');
			$(this).text( newText ).data('alt', oldText);
			e.preventDefault();
		});
	}

	return {
		init : function(opts){
			
			$.extend(v, opts);
			
			if( ! $(v.toggle).length )
				return false;
			
			setup();
		}
	}
})(jQuery);
