/*
	Copyright (c) 2008-2012 Leslie Owusu-Appiah
	Design and Development by Leslie Owusu-Appiah | http://www.leslieowusuappiah.com/ | l@leslieoa.com


	'||''|.                      .
	 ||   ||    ...   .. ...   .||.       ....    ...   ... ...  .... ...
	 ||    || .|  '|.  ||  ||   ||      .|   '' .|  '|.  ||'  ||  '|.  |
	 ||    || ||   ||  ||  ||   ||      ||      ||   ||  ||    |   '|.|
	.||...|'   '|..|' .||. ||.  '|.'     '|...'  '|..|'  ||...'     '|
														 ||      .. |
														''''      ''
	  .   '||                .
	.||.   || ..    ....   .||.
	 ||    ||' ||  '' .||   ||
	 ||    ||  ||  .|' ||   ||
	 '|.' .||. ||. '|..'|'  '|.'


	  .'|. '||                                     .|.
	.||.    ||    ...   ... ...  ... ...  .... ... |||
	 ||     ||  .|  '|.  ||'  ||  ||'  ||  '|.  |  '|'
	 ||     ||  ||   ||  ||    |  ||    |   '|.|    |
	.||.   .||.  '|..|'  ||...'   ||...'     '|     .
						 ||       ||      .. |     '|'
						''''     ''''      ''


	http://www.youtube.com/watch?v=up863xKGUI


	Bye now.
*/



$(document).ready(function() { 

	// onFirstLoad defaults and pre-defined variables
	//var clickObj = this;

	// Animation variables __________
	window.fadeDur = 400; 

		// Grouped elements
		$textElements = $('p, h1, h2, h3, h4, h5, h6, span, small, strong, nav ul li a, nav ul li a:visited'); // Main text elements
		$linkElements = $('a, a:link, a:visited, a:visited'); // Main text elements
		$specialTextElements = $('ins, mark');
		$bgElements = $('html, body, div, span, object, iframe, article, aside'); // Background elements

		window.loadingText = 'Loading...';




	/* Init Homepage Animation __________________________________________________ */
	$('body #container #ajax').animate({height: 'hide', opacity: '0'}, 0); 
	if(e==l||e==l+'#') { /* Animation */
		$('body.fouc').append('<div id="intro" class="intro"><div><h1 class="intro logo">Leslie Owusu-Appiah - Interaction Design &amp; Development</h1><h1 class="intro logoText">Leslie Owusu-Appiah - Interaction Design &amp; Development</h1><div class="intro loading" title="Loading...">Loading...</div></div></div>');
		$('.loading').animBg({'step':35,'steps':12,'interval':55});
		window.introSlide = parseInt(($(window).height()/2)-($('#intro').height()/2)); $('#intro').css({'top': introSlide}); 
		$('.fouc #intro').fadeIn(350); document.title = window.loadingText;
		} else { /* No Animation */ }

	});

//$('.fouc #intro').load(function() { 
$(window).ready(function() { 
	/* Start Homepage Animation __________________________________________________ */
	if(e==l||e==l+'#') { 
		/*@cc_on @if(@_jscript) $('.fouc #intro, .fouc #intro div, .fouc #intro h1').css('background-color', 'transparent'); @*/
		$('body.fouc #intro div').animate({'dummy':'1'}, 700, function() {
			$('body.fouc .logoText').delay(1000).animate({'left': '-150px', 'opacity': '0'}, {queue: false, easing: 'easeInQuart', duration: 350});
			$('body.fouc .logo').delay(1000).animate({'padding-top': '95px'}, {queue: false, easing: 'swing', duration: 350});
			$('body.fouc .loading').fadeOut(150, function() { $('body.fouc .loading').remove(); });			
			/*@cc_on // */ $('.fouc #intro div').animate({'top': (introSlide*-1)+106}, {queue: false, easing: 'easeOutQuart', duration: 350}); /* @*/
			/*@cc_on $('.fouc #intro').animate({'top': '68px'}, {queue: true, easing: 'easeOutQuart', duration: 350}); @*/
			$('body.fouc #intro div').delay(350).animate({'left':'0'}, '350', function() {
				$('body #container').delay(700).fadeIn(700, function() {  
					$('body.fouc #intro').remove(); 
					/*@cc_on $('.fouc #container').css('background-color', 'transparent'); @*/
					document.title = $('body #container #page').attr('data-title'); 
					$('#container .loading').fadeOut('fast', function() { $('#container .loading').remove(); });
					}); 
				});
			/*@cc_on $bodyBgClr=$('body').css('background-color'); $('.fouc #container').css('background-color', $bodyBgClr); @*/

			});
		} else { }
	/*@end @*/


	});






/* Main ______________________________________________________________________________________________________________ */
$(document).ready(function() {

//if ($('.slideshow').length) { slideshow(); $('.loading').remove(); }; // Works here (load indicator stays)


	/* loajax v0.4 __________________________________________________________________________________ */
	/*@cc_on @if(@_jscript) $('body').delegate('a', 'click', function() { @else @*/
		$('body #container').delegate('a', 'click', function(e) {
			if( (!$.browser.msie && e.button == 0) || ($.browser.msie && e.button == 1) ) { /*@end @*/
				var hash = this.href; /*alert(this.href); */
				if (hash.indexOf(window.location.hostname) > 0) { /*alert('Local');*/
					$('html, body').animate({scrollTop: '0'}, 500, 'swing'); 
					hash = hash.substr((window.location.protocol+'//'+window.location.host+'/').length); $.history.load(hash); return false;		
				} else if (hash.indexOf(window.location.hostname) == -1) { /*alert('External');*/ window.open(hash); return false; 
				//} else if (hash.indexOf('?s=') == 1) { alert('Search'); return false; 
				} else { alert('Wha happen? Strange error make me a scared :-(. [onClick, else]'); }
			/*@cc_on @if(@_jscript) @else @*/ } else if(e.button == 2) { /*alert('Right click');*/ } /*@end @*/
			});

		$.history.init(function (hash) {	
			$('#loading').remove(); document.title = window.loadingText; 
			$('#container').append('<div id="loading" title="Loading...">Loading...</div>'); 
				$('#loading').animBg({'step':35,'steps':12,'interval':55}); $('#loading').fadeIn('fast');

			$('body #container #ajax').animate({height: 'hide', opacity: '0'}, 'medium', 'easeOutQuint');

			$('body #container #ajax').load('/' + hash + ' #page', '', function(response, status, xhr) {
				switch (xhr.status) { 
					case 200: ajaxLoad(); break;
					case 404: $('body #container #ajax').load('/404 #page','', ajaxLoad); break;
					default: alert('We\'re experiencing technical difficulties. Try refreshing.'); break;
					}
				});
			}, { unescape: '/,&,#'}); // See http://github.com/tkyk/jquery-history-plugin/issues/unreads#issue/6 
			// history.init()

		ajaxLoad = function() {
			$('body #container #ajax').animate({height: 'show', opacity: '1'}, 'medium', 'easeOutQuint');
			$('#loading').fadeOut('fast', function() { 
				document.title = $('body #container #ajax #page').attr('data-title'); $(this).remove(); 
				if ($('.slideshow').length) { slideshow(); };
				if ($('#sort').length) { $('#sort').removeClass('noscript'); };
				$('#loading').remove(); 
				});
			}
	/* End loajax ___________________________________________________________________________________ */





	/* Sortable ____________________________________________ */
	$('body').delegate('ul#sort li', 'click', function() {
		$this = $(this).attr('data-sort'); fadeDur = 200;
		$('ul#sort li').removeClass('selected'); $(this).addClass('selected');
		if(window.$this == 'all') { 
			$('.g8.row.grid div').fadeOut(fadeDur, function() { $(this).fadeIn(fadeDur); }); 
		} else { 
			$('.g8.row.grid div').not('div.tag-'+$this).fadeOut(fadeDur, function() { $('div.tag-'+$this).fadeIn(fadeDur); }); 
			}
		});





	/* Slideshow ____________________________________________*/
	slideshow = function() {

	// Flush/Reset
	//$('.slideshow').removeClass('js'); $('.nav').remove();

		// Test
		//$('.slideshow').css({'background':'#eee', 'height':'35px'}); //
		$('#container .loading').remove(); 

		// Added class ".js" to ".slideshow" (PE)
		$('.slideshow').addClass('js'); 
		$('.slideshow .wrapper').before('<div class="loading" title="Loading...">Loading...</div>').css({'height':'35px'}); 
			$('.slideshow .loading').animBg({'step':35,'steps':12,'interval':55}); $('.loading').fadeIn();
		$('.slideshow .wrapper').before('<div class="nav"><span class="prev">&larr;</span> &nbsp; <span class="next">&rarr;</span> &nbsp;&nbsp; <span class="navSlide">#</span>/<span class="navNum">#</span></div>'); 


		// Variables
		window.ssSpeed = 400; window.ssPos = 0; window.ssSlideW = 636; window.navSlide = 1; 
		window.ssEasing = 'easeOutExpo'; window.opacity = '.15'; window.fadeDur = 250;


		// Setup slideshow dimensions
		window.ssW = $('.slideshow .wrapper li').length * window.ssSlideW; 
			$('.slideshow .wrapper').css({'width': window.ssW+window.ssSlideW+'px'}); // Added extra pixels (hacky)
		window.ssH = $('.slideshow .nav').height() * 2; 
		$('.slideshow .wrapper ul li img').each(function() { 
			if($(this).outerHeight(true) > window.ssH) { window.ssH = window.ssH + $(this).outerHeight(true); /*alert($(this).outerHeight(true));*/ } 
			$(this).load(function() { $('.loading').fadeOut(); }); if($(this)[0].complete) { $('.loading').fadeOut(); }
			}); 
		$('.slideshow').animate({height: window.ssH+'px', opacity: '1'}, 'slow', window.ssEasing);

		$('.slideshow .wrapper ul li').css({'cursor':'pointer','opacity': window.opacity}); 
		$('.slideshow .wrapper ul li:eq('+(window.navSlide-1)+')').css({'opacity': '1'}).addClass('selected'); 

		$('.slideshow .nav .navSlide').empty().append(1); 
		$('.slideshow .nav .navNum').empty().append($('.slideshow .wrapper ul li').length); 


			// Prev
			$('.slideshow .nav .prev').click(function() { 
				if (window.ssPos >= 0) { 
					/*alert('First!');*/ 
				} else { 
					window.navSlide = window.navSlide - 1; $('.slideshow .nav .navSlide').empty(); 
					$('.slideshow .nav .navSlide').append(window.navSlide);	
					window.ssPos = parseInt(window.ssPos + window.ssSlideW); 
					$('.slideshow .wrapper').stop(true,false).animate({'left': window.ssPos+'px'}, {queue: true, easing: window.ssEasing, duration: window.ssSpeed}); 

					$('.slideshow .wrapper ul li').stop(true,false).animate({'opacity': window.opacity}, {queue: true, duration: 0}).removeClass('selected');
					$('.slideshow .wrapper ul li:eq('+(window.navSlide-1)+')').stop(true,false).animate({'opacity': '1'}, {queue: true, duration: window.fadeDur}).addClass('selected');

					}
				}); 

			// Next
			$('.slideshow .nav .next').click(function() { 
				if (window.ssPos == (window.ssW * -1) + window.ssSlideW) { 
					//alert('Last!'); document.title = 'Last! ' + window.ssPos; 
					window.navSlide = 1; $('.slideshow .nav .navSlide').empty(); 
					$('.slideshow .nav .navSlide').append(window.navSlide);	
					window.ssPos = 0; 
					$('.slideshow .wrapper').stop(true,false).animate({'left': '0'}, {queue: true, easing: window.ssEasing, duration: window.ssSpeed*2});

					$('.slideshow .wrapper ul li').stop(true,false).animate({'opacity': window.opacity}, {queue: true, duration: 0});
					$('.slideshow .wrapper ul li:eq('+(window.navSlide-1)+')').stop(true,false).animate({'opacity': '1'}, {queue: true, duration: window.fadeDur});
				} else {
					window.navSlide = window.navSlide + 1; $('.slideshow .nav .navSlide').empty(); 
					$('.slideshow .nav .navSlide').append(window.navSlide);	
					window.ssPos = parseInt(window.ssPos - window.ssSlideW); 
					$('.slideshow .wrapper').stop(true,false).animate({'left': window.ssPos+'px'}, {queue: true, easing: window.ssEasing, duration: window.ssSpeed});	

					$('.slideshow .wrapper ul li').stop(true,false).animate({'opacity': window.opacity}, {queue: true, duration: 0});
					$('.slideshow .wrapper ul li:eq('+(window.navSlide-1)+')').stop(true,false).animate({'opacity': '1'}, {queue: true, duration: window.fadeDur});

					}
				}); 


			// Click
			$('.slideshow .wrapper ul li').click(function() { 
				window.ssIndex = $('.slideshow .wrapper ul li').index(this);
					window.navSlide = window.ssIndex + 1; $('.slideshow .nav .navSlide').empty(); 
					$('.slideshow .nav .navSlide').append(window.navSlide);	

					//$('.slideshow .wrapper ul li:eq('+window.ssIndex+')').fadeOut();

					window.ssPos = parseInt(((window.ssIndex) * window.ssSlideW)*-1); 

					$('.slideshow .wrapper').stop(true,false).animate({'left': window.ssPos+'px'}, {queue: true, easing: window.ssEasing, duration: window.ssSpeed});	

					$('.slideshow .wrapper ul li').stop(true,false).animate({'opacity': window.opacity}, {queue: true, duration: 0});
					$(this).stop(true,false).animate({'opacity': '1'}, {queue: true, duration: window.fadeDur});

					//document.title = window.ssPos;
				});

		}; // End .slideshow


		// Slideshow keys
		$(document).keydown(function(event) { // MSIE doesn't much like $(window)
			switch (event.keyCode) {
				case 32: /*space*/ $('.next').click(); break;				
				case 37: /* left arrow */ $('.prev').click(); break; 
				case 39: /* right arrow */ $('.next').click(); break;
				}
			});



	/* Show full logo on #logo:hover _______________________ */
	$('#logo').hover(
		function() { 
			$('#container').append('<div id="logoText" title="Logo">&nbsp;</div>'); 
			/*@cc_on //$bodyBgClr=$('body').css('background-color'); $('#logoText').css('background-color', $bodyBgClr); @*/
			$('#nav').stop(true, true).fadeOut(fadeDur/4); 
			$('#logo a').stop(true, true).animate({'padding-top': '70px'});
			$('#logoText').stop(true, true).animate({'left': '324px'}, {queue: false, easing: 'easeOutQuint', duration: 'slow'}, fadeDur).fadeIn(fadeDur);
			},
		function() {
			$('#logoText').stop(true, true).animate({'left': '0px'}, {queue: false, easing: 'easeOutQuart', duration: 'normal'}, 'slow').fadeOut(fadeDur/4); 
			$('#logo a').stop(true, true).animate({'padding-top': '95px'});
			$('#nav').stop(true, true).fadeIn('slow'); $('#container').remove('#logoText'); 
			}
		);	
		/* Alt: - $('#logo').mouseenter(function() { ... }).mouseleave(function() { ... }); // ...if I was stoner */



	/* Navi _______________________ */
	$('#nav ul li a').hover(
		function() { $(this).stop(true, true).animate({'border-bottom': '4px solid'}, 'fast'); }, // border-bottom: 1px solid black;
		function() { $(this).stop(true, true).animate({'border-bottom': '1px solid'}, 'fast'); }
		);



	/* Contact Form - Contact ______________________________ */
	$('#contactButton').live('click', function() { 
		$(this).addClass('close'); $('#page .article .section:last-child div').append('<div id=\'contactForm\'>Yo!</div>');
		$('#contactForm').slideDown('medium'); $('#contactButton span').empty().append('-'); 
		});
	$('#contactButton.close').live('click', function() {
		$('#contactForm').slideUp('fast', function() { $('#page .article .section:last-child div').remove('#contactForm'); });
		$('#contactButton span').empty().append('+'); $(this).removeClass('close');
		});


	/* Comments */
	$('#respond > h4').live('click', function() {
		if($('#commentAreaWrapper').is(':visible')) {
			$('#commentAreaWrapper').animate({height: 'hide', opacity: '0'}, 'fast', 'easeInQuint');			
		} else {
			$('#commentAreaWrapper').animate({height: 'show', opacity: '1'}, 'fast', 'easeOutQuint');
			};
		});


	/* Functions ___________________________________________ */
	$('.clear, #nav').kara(); 
	//$('a[rel="external"]').click( function() { window.open( $(this).attr('href') ); return false; }); // rel='external'
	//$('a').click(function(){this.blur();});	


	});






/* Konami _____________________________________________________________________________________________________________ */
// Encrypt/obfusticate me!
/* Work in IE! */
/*var kc = [], konami = '37,39'; //  Left/Right
$(document).keydown(function(event) {
	kc.push(event.keyCode);
	if (kc.toString().indexOf(konami)>=0) {
		$(document).unbind('keydown',arguments.callee); // Ends secret code

		// Animation should happen before 'show'
		$('body').switchClass('home', 'page-template-journal-php', 1000);

		//$('body').animate({'background-color': 'rgb(255,255,180)'}, {queue: false}, fadeDur);
		//$('#grid div').animate({'background-color': 'rgb(255,255,190)'}, {queue: false}, fadeDur); 			
			//$textElements.animate({'color': 'rgb(0,0,180)'}, {queue: false}, fadeDur); 
		}
	});*/




/* Experiments _____________________________________________________________________________________________________________ */
$(document).ready(function() {

	// Nav onHover Experiment
	/*$('#nav .journal').hover(
		function() { 
			$bodyBgClr=$('body').css('background-color'); $gridBgClr=$('#grid div').css('background-color'); 
				$('body').stop(true, true).animate({'background-color': 'rgb(255,255,180)'}, {queue: false}, 50);
				$('#grid div').stop(true, true).animate({'background-color': 'rgb(255,255,200)'}, {queue: false}, 50);
			},
		function() { 
			$('body').stop(true, true).animate({'background-color': $bodyBgClr}, {queue: false}, 50);
			$('#grid div').stop(true, true).animate({'background-color': $gridBgClr}, {queue: false}, 50);
			}
		);*/

	//Simple test
	//$('.wrapper').click(function() { $('.home').addClass('page-template-journal-php').removeClass('home'); });


	});







/* Libraries  ______________________________________________________________________________________________________________ */


/* jQuery history plugin - http://www.mikage.to/jquery/jquery_history.html - Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari) - Copyright (c) 2010 Takayuki Miwa - MIT License */
(function($){var locationWrapper={put:function(hash,win){(win||window).location.hash=this.encoder(hash);},get:function(win){var hash=((win||window).location.hash).replace(/^#/, '');try{return $.browser.mozilla ? hash : decodeURIComponent(hash);}catch(error){return hash;}},encoder:encodeURIComponent};var iframeWrapper={id: "__jQuery_history",init:function(){var html='<iframe id="'+ this.id +'" style="display:none" src="javascript:false;" />';$("body").prepend(html);return this;},_document:function(){return $("#"+this.id)[0].contentWindow.document;},put:function(hash){var doc=this._document();doc.open();doc.close();locationWrapper.put(hash,doc);},get:function(){return locationWrapper.get(this._document());}};function initObjects(options){options=$.extend({unescape:false},options||{});locationWrapper.encoder=encoder(options.unescape);function encoder(unescape_){if(unescape_===true){return function(hash){return hash;};}if(typeof unescape_=="string"&&(unescape_=partialDecoder(unescape_.split("")))||typeof unescape_=="function"){return function(hash){return unescape_(encodeURIComponent(hash));};}return encodeURIComponent;}function partialDecoder(chars){var re=new RegExp($.map(chars,encodeURIComponent).join("|"),"ig");return function(enc){return enc.replace(re,decodeURIComponent);};}}var _={appState:undefined,callback:undefined,init:function(callback,options){},check:function(){},load:function(hash){}};$.history=_;var SimpleImpl={init:function(callback,options){initObjects(options);_.callback=callback;var current_hash=locationWrapper.get();_.appState=current_hash;_.callback(current_hash);setInterval(_.check,100);},check:function(){var current_hash=locationWrapper.get();if(current_hash!=_.appState){_.appState=current_hash;_.callback(current_hash);}},load:function(hash){if(hash!=_.appState){locationWrapper.put(hash);_.appState=hash;_.callback(hash);}}};var IframeImpl={init:function(callback,options){initObjects(options);_.callback=callback;var current_hash=locationWrapper.get();_.appState=current_hash;iframeWrapper.init().put(current_hash);_.callback(current_hash);setInterval(_.check, 100);},check:function(){var iframe_hash=iframeWrapper.get(),location_hash=locationWrapper.get();if(location_hash!=iframe_hash){if(location_hash==_.appState){_.appState=iframe_hash;locationWrapper.put(iframe_hash);_.callback(iframe_hash);}else{_.appState=location_hash;iframeWrapper.put(location_hash);_.callback(location_hash);}}},load:function(hash){if(hash != _.appState){locationWrapper.put(hash);iframeWrapper.put(hash);_.appState = hash;_.callback(hash);}}};if($.browser.msie&&($.browser.version<8||document.documentMode<8)){$.extend(_,IframeImpl);}else{$.extend(_,SimpleImpl);}})(jQuery);

/* jQuery UI Effects 1.8rc3 - Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about). Released under the MIT and GPL licenses. http://docs.jquery.com/UI/Effects/ */
jQuery.effects||(function(g){g.effects={};g.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(l,k){g.fx.step[k]=function(m){if(!m.colorInit){m.start=j(m.elem,k);m.end=i(m.end);m.colorInit=true}m.elem.style[k]="rgb("+Math.max(Math.min(parseInt((m.pos*(m.end[0]-m.start[0]))+m.start[0],10),255),0)+","+Math.max(Math.min(parseInt((m.pos*(m.end[1]-m.start[1]))+m.start[1],10),255),0)+","+Math.max(Math.min(parseInt((m.pos*(m.end[2]-m.start[2]))+m.start[2],10),255),0)+")"}});function i(l){var k;if(l&&l.constructor==Array&&l.length==3){return l}if(k=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(l)){return[parseInt(k[1],10),parseInt(k[2],10),parseInt(k[3],10)]}if(k=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(l)){return[parseFloat(k[1])*2.55,parseFloat(k[2])*2.55,parseFloat(k[3])*2.55]}if(k=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(l)){return[parseInt(k[1],16),parseInt(k[2],16),parseInt(k[3],16)]}if(k=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(l)){return[parseInt(k[1]+k[1],16),parseInt(k[2]+k[2],16),parseInt(k[3]+k[3],16)]}if(k=/rgba\(0, 0, 0, 0\)/.exec(l)){return a.transparent}return a[g.trim(l).toLowerCase()]}function j(m,k){var l;do{l=g.curCSS(m,k);if(l!=""&&l!="transparent"||g.nodeName(m,"body")){break}k="backgroundColor"}while(m=m.parentNode);return i(l)}var e=["add","remove","toggle"],c={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};function f(){var n=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,o={},l,m;if(n&&n.length&&n[0]&&n[n[0]]){var k=n.length;while(k--){l=n[k];if(typeof n[l]=="string"){m=l.replace(/\-(\w)/g,function(p,q){return q.toUpperCase()});o[m]=n[l]}}}else{for(l in n){if(typeof n[l]==="string"){o[l]=n[l]}}}return o}function b(l){var k,m;for(k in l){m=l[k];if(m==null||g.isFunction(m)||k in c||(/scrollbar/).test(k)||(!(/color/i).test(k)&&isNaN(parseFloat(m)))){delete l[k]}}return l}function h(k,m){var n={_:0},l;for(l in m){if(k[l]!=m[l]){n[l]=m[l]}}return n}g.effects.animateClass=function(k,l,n,m){if(g.isFunction(n)){m=n;n=null}return this.each(function(){var r=g(this),o=r.attr("style")||" ",s=b(f.call(this)),q,p=r.attr("className");g.each(e,function(t,u){if(k[u]){r[u+"Class"](k[u])}});q=b(f.call(this));r.attr("className",p);r.animate(h(s,q),l,n,function(){g.each(e,function(t,u){if(k[u]){r[u+"Class"](k[u])}});if(typeof r.attr("style")=="object"){r.attr("style").cssText="";r.attr("style").cssText=o}else{r.attr("style",o)}if(m){m.apply(this,arguments)}})})};g.fn.extend({_addClass:g.fn.addClass,addClass:function(l,k,n,m){return k?g.effects.animateClass.apply(this,[{add:l},k,n,m]):this._addClass(l)},_removeClass:g.fn.removeClass,removeClass:function(l,k,n,m){return k?g.effects.animateClass.apply(this,[{remove:l},k,n,m]):this._removeClass(l)},_toggleClass:g.fn.toggleClass,toggleClass:function(m,l,k,o,n){if(typeof l=="boolean"||l===undefined){if(!k){return this._toggleClass(m,l)}else{return g.effects.animateClass.apply(this,[(l?{add:m}:{remove:m}),k,o,n])}}else{return g.effects.animateClass.apply(this,[{toggle:m},l,k,o])}},switchClass:function(k,m,l,o,n){return g.effects.animateClass.apply(this,[{add:m,remove:k},l,o,n])}});g.extend(g.effects,{version:"1.8rc3",save:function(l,m){for(var k=0;k<m.length;k++){if(m[k]!==null){l.data("ec.storage."+m[k],l[0].style[m[k]])}}},restore:function(l,m){for(var k=0;k<m.length;k++){if(m[k]!==null){l.css(m[k],l.data("ec.storage."+m[k]))}}},setMode:function(k,l){if(l=="toggle"){l=k.is(":hidden")?"show":"hide"}return l},getBaseline:function(l,m){var n,k;switch(l[0]){case"top":n=0;break;case"middle":n=0.5;break;case"bottom":n=1;break;default:n=l[0]/m.height}switch(l[1]){case"left":k=0;break;case"center":k=0.5;break;case"right":k=1;break;default:k=l[1]/m.width}return{x:k,y:n}},createWrapper:function(k){if(k.parent().is(".ui-effects-wrapper")){return k.parent()}var l={width:k.outerWidth(true),height:k.outerHeight(true),"float":k.css("float")},m=g("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});k.wrap(m);m=k.parent();if(k.css("position")=="static"){m.css({position:"relative"});k.css({position:"relative"})}else{g.extend(l,{position:k.css("position"),zIndex:k.css("z-index")});g.each(["top","left","bottom","right"],function(n,o){l[o]=k.css(o);if(isNaN(parseInt(l[o],10))){l[o]="auto"}});k.css({position:"relative",top:0,left:0})}return m.css(l).show()},removeWrapper:function(k){if(k.parent().is(".ui-effects-wrapper")){return k.parent().replaceWith(k)}return k},setTransition:function(l,n,k,m){m=m||{};g.each(n,function(p,o){unit=l.cssUnit(o);if(unit[0]>0){m[o]=unit[0]*k+unit[1]}});return m}});function d(l,k,m,n){if(typeof l=="object"){n=k;m=null;k=l;l=k.effect}if(g.isFunction(k)){n=k;m=null;k={}}if(typeof k=="number"||g.fx.speeds[k]){n=m;m=k;k={}}k=k||{};m=m||k.duration;m=g.fx.off?0:typeof m=="number"?m:g.fx.speeds[m]||g.fx.speeds._default;n=n||k.complete;return[l,k,m,n]}g.fn.extend({effect:function(n,m,p,q){var l=d.apply(this,arguments),o={options:l[1],duration:l[2],callback:l[3]},k=g.effects[n];return k&&!g.fx.off?k.call(this,o):this},_show:g.fn.show,show:function(l){if(!l||typeof l=="number"||g.fx.speeds[l]){return this._show.apply(this,arguments)}else{var k=d.apply(this,arguments);k[1].mode="show";return this.effect.apply(this,k)}},_hide:g.fn.hide,hide:function(l){if(!l||typeof l=="number"||g.fx.speeds[l]){return this._hide.apply(this,arguments)}else{var k=d.apply(this,arguments);k[1].mode="hide";return this.effect.apply(this,k)}},__toggle:g.fn.toggle,toggle:function(l){if(!l||typeof l=="number"||g.fx.speeds[l]||typeof l=="boolean"||g.isFunction(l)){return this.__toggle.apply(this,arguments)}else{var k=d.apply(this,arguments);k[1].mode="toggle";return this.effect.apply(this,k)}},cssUnit:function(k){var l=this.css(k),m=[];g.each(["em","px","%","pt"],function(n,o){if(l.indexOf(o)>0){m=[parseFloat(l),o]}});return m}});g.easing.jswing=g.easing.swing;g.extend(g.easing,{def:"easeOutQuad",swing:function(l,m,k,o,n){return g.easing[g.easing.def](l,m,k,o,n)},easeInQuad:function(l,m,k,o,n){return o*(m/=n)*m+k},easeOutQuad:function(l,m,k,o,n){return -o*(m/=n)*(m-2)+k},easeInOutQuad:function(l,m,k,o,n){if((m/=n/2)<1){return o/2*m*m+k}return -o/2*((--m)*(m-2)-1)+k},easeInCubic:function(l,m,k,o,n){return o*(m/=n)*m*m+k},easeOutCubic:function(l,m,k,o,n){return o*((m=m/n-1)*m*m+1)+k},easeInOutCubic:function(l,m,k,o,n){if((m/=n/2)<1){return o/2*m*m*m+k}return o/2*((m-=2)*m*m+2)+k},easeInQuart:function(l,m,k,o,n){return o*(m/=n)*m*m*m+k},easeOutQuart:function(l,m,k,o,n){return -o*((m=m/n-1)*m*m*m-1)+k},easeInOutQuart:function(l,m,k,o,n){if((m/=n/2)<1){return o/2*m*m*m*m+k}return -o/2*((m-=2)*m*m*m-2)+k},easeInQuint:function(l,m,k,o,n){return o*(m/=n)*m*m*m*m+k},easeOutQuint:function(l,m,k,o,n){return o*((m=m/n-1)*m*m*m*m+1)+k},easeInOutQuint:function(l,m,k,o,n){if((m/=n/2)<1){return o/2*m*m*m*m*m+k}return o/2*((m-=2)*m*m*m*m+2)+k},easeInSine:function(l,m,k,o,n){return -o*Math.cos(m/n*(Math.PI/2))+o+k},easeOutSine:function(l,m,k,o,n){return o*Math.sin(m/n*(Math.PI/2))+k},easeInOutSine:function(l,m,k,o,n){return -o/2*(Math.cos(Math.PI*m/n)-1)+k},easeInExpo:function(l,m,k,o,n){return(m==0)?k:o*Math.pow(2,10*(m/n-1))+k},easeOutExpo:function(l,m,k,o,n){return(m==n)?k+o:o*(-Math.pow(2,-10*m/n)+1)+k},easeInOutExpo:function(l,m,k,o,n){if(m==0){return k}if(m==n){return k+o}if((m/=n/2)<1){return o/2*Math.pow(2,10*(m-1))+k}return o/2*(-Math.pow(2,-10*--m)+2)+k},easeInCirc:function(l,m,k,o,n){return -o*(Math.sqrt(1-(m/=n)*m)-1)+k},easeOutCirc:function(l,m,k,o,n){return o*Math.sqrt(1-(m=m/n-1)*m)+k},easeInOutCirc:function(l,m,k,o,n){if((m/=n/2)<1){return -o/2*(Math.sqrt(1-m*m)-1)+k}return o/2*(Math.sqrt(1-(m-=2)*m)+1)+k},easeInElastic:function(l,n,k,u,r){var o=1.70158;var q=0;var m=u;if(n==0){return k}if((n/=r)==1){return k+u}if(!q){q=r*0.3}if(m<Math.abs(u)){m=u;var o=q/4}else{var o=q/(2*Math.PI)*Math.asin(u/m)}return -(m*Math.pow(2,10*(n-=1))*Math.sin((n*r-o)*(2*Math.PI)/q))+k},easeOutElastic:function(l,n,k,u,r){var o=1.70158;var q=0;var m=u;if(n==0){return k}if((n/=r)==1){return k+u}if(!q){q=r*0.3}if(m<Math.abs(u)){m=u;var o=q/4}else{var o=q/(2*Math.PI)*Math.asin(u/m)}return m*Math.pow(2,-10*n)*Math.sin((n*r-o)*(2*Math.PI)/q)+u+k},easeInOutElastic:function(l,n,k,u,r){var o=1.70158;var q=0;var m=u;if(n==0){return k}if((n/=r/2)==2){return k+u}if(!q){q=r*(0.3*1.5)}if(m<Math.abs(u)){m=u;var o=q/4}else{var o=q/(2*Math.PI)*Math.asin(u/m)}if(n<1){return -0.5*(m*Math.pow(2,10*(n-=1))*Math.sin((n*r-o)*(2*Math.PI)/q))+k}return m*Math.pow(2,-10*(n-=1))*Math.sin((n*r-o)*(2*Math.PI)/q)*0.5+u+k},easeInBack:function(l,m,k,p,o,n){if(n==undefined){n=1.70158}return p*(m/=o)*m*((n+1)*m-n)+k},easeOutBack:function(l,m,k,p,o,n){if(n==undefined){n=1.70158}return p*((m=m/o-1)*m*((n+1)*m+n)+1)+k},easeInOutBack:function(l,m,k,p,o,n){if(n==undefined){n=1.70158}if((m/=o/2)<1){return p/2*(m*m*(((n*=(1.525))+1)*m-n))+k}return p/2*((m-=2)*m*(((n*=(1.525))+1)*m+n)+2)+k},easeInBounce:function(l,m,k,o,n){return o-g.easing.easeOutBounce(l,n-m,0,o,n)+k},easeOutBounce:function(l,m,k,o,n){if((m/=n)<(1/2.75)){return o*(7.5625*m*m)+k}else{if(m<(2/2.75)){return o*(7.5625*(m-=(1.5/2.75))*m+0.75)+k}else{if(m<(2.5/2.75)){return o*(7.5625*(m-=(2.25/2.75))*m+0.9375)+k}else{return o*(7.5625*(m-=(2.625/2.75))*m+0.984375)+k}}}},easeInOutBounce:function(l,m,k,o,n){if(m<n/2){return g.easing.easeInBounce(l,m*2,0,o,n)*0.5+k}return g.easing.easeOutBounce(l,m*2-n,0,o,n)*0.5+o*0.5+k}})})(jQuery);;


/* Michael Manning's background animation - http://actingthemaggot.com/test/jquery_example/animbg.html */
// Internet Explorer support via Conditional Compilation by Leslie Owusu-Appiah
$.fn.animBg=function(command,options){if(command && typeof command ==='string'){clearInterval($(this).data('anim'));return this;}var $this=$(this),o={'interval':100},options=(typeof command === 'object' && typeof options === 'undefined')?command:options,o=jQuery.extend({},o,options),anim;if(!o.step && !o.steps){return this;}/*@cc_on/*@if(@_jscript)anim=setInterval(function(){var bgpos=parseInt($this.css('background-position-x'));$this.css('background-position-x',(-(o.step*o.steps)>=(bgpos-o.step)?0:bgpos-o.step)+'px');},o.interval);@else @*/anim=setInterval(function(){var bgpos=parseInt($this.css('background-position'));$this.css('background-position',(-(o.step*o.steps)>=(bgpos-o.step)?0:bgpos-o.step)+'px 0'); },o.interval);/*@end @*/$this.data('anim',anim);return this;}

/* Disable selection of layout/gui objects */
$.fn.extend({kara:function(){this.each(function(){this.onselectstart=function(){return false;};this.unselectable='on';$(this).css('-moz-user-select','none');});}}); 


/* Vanilla JavaScript */

/* html5shiv MIT @rem remysharp.com/html5-enabling-script - iepp v1.5.1 MIT @jon_neal iecss.com/print-protector */
/*@cc_on(function(p,e){var q=e.createElement("div");q.innerHTML="<z>i</z>";q.childNodes.length!==1&&function(){function r(a,b){if(g[a])g[a].styleSheet.cssText+=b;else{var c=s[l],d=e[j]("style");d.media=a;c.insertBefore(d,c[l]);g[a]=d;r(a,b)}}function t(a,b){for(var c=new RegExp("\\b("+m+")\\b(?!.*[;}])","gi"),d=function(k){return".iepp_"+k},h=-1;++h<a.length;){b=a[h].media||b;t(a[h].imports,b);r(b,a[h].cssText.replace(c,d))}}for(var s=e.documentElement,i=e.createDocumentFragment(),g={},m="abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".replace(/ /g, '|'),
n=m.split("|"),f=[],o=-1,l="firstChild",j="createElement";++o<n.length;){e[j](n[o]);i[j](n[o])}i=i.appendChild(e[j]("div"));p.attachEvent("onbeforeprint",function(){for(var a,b=e.getElementsByTagName("*"),c,d,h=new RegExp("^"+m+"$","i"),k=-1;++k<b.length;)if((a=b[k])&&(d=a.nodeName.match(h))){c=new RegExp("^\\s*<"+d+"(.*)\\/"+d+">\\s*$","i");i.innerHTML=a.outerHTML.replace(/\r|\n/g," ").replace(c,a.currentStyle.display=="block"?"<div$1/div>":"<span$1/span>");c=i.childNodes[0];c.className+=" iepp_"+
d;c=f[f.length]=[a,c];a.parentNode.replaceChild(c[1],c[0])}t(e.styleSheets,"all")});p.attachEvent("onafterprint",function(){for(var a=-1,b;++a<f.length;)f[a][1].parentNode.replaceChild(f[a][0],f[a][1]);for(b in g)s[l].removeChild(g[b]);g={};f=[]})}()})(this,document);@*/
