/* -------------------------------------------------- *
 * ToggleVal 3.0 * Updated: 01/15/2010
 * -------------------------------------------------- *
 * Author: Aaron Kuzemchak * URL: http://aaronkuzemchak.com/
 * Copyright: 2008-2010 Aaron Kuzemchak * License: MIT License
** -------------------------------------------------- */

(function($){$.fn.toggleVal=function(theOptions){if(!theOptions||typeof theOptions=='object'){theOptions=$.extend({},$.fn.toggleVal.defaults,theOptions);}else if(typeof theOptions=='string'&&theOptions.toLowerCase()=='destroy'){var destroy=true;}return this.each(function(){if(destroy){$(this).unbind('focus.toggleval').unbind('blur.toggleval').removeData('defText');return false;}var defText='';switch(theOptions.populateFrom){case'title':if($(this).attr('title')){defText=$(this).attr('title');$(this).val(defText);}break;case'label':if($(this).attr('id')){defText=$('label[for="'+$(this).attr('id')+'"]').text();$(this).val(defText);}break;case'custom':defText=theOptions.text;$(this).val(defText);break;default:defText=$(this).val();}$(this).addClass('toggleval').data('defText',defText);if(theOptions.removeLabels==true&&$(this).attr('id')){$('label[for="'+$(this).attr('id')+'"]').remove();}$(this).bind('focus.toggleval',function(){if($(this).val()==$(this).data('defText')){$(this).val('');}$(this).addClass(theOptions.focusClass);}).bind('blur.toggleval',function(){if($(this).val()==''&&!theOptions.sticky){$(this).val($(this).data('defText'));}$(this).removeClass(theOptions.focusClass);if($(this).val()!=''&&$(this).val()!=$(this).data('defText')){$(this).addClass(theOptions.changedClass);}else{$(this).removeClass(theOptions.changedClass);}});});};$.fn.toggleVal.defaults={focusClass:'tv-focused',changedClass:'tv-changed',populateFrom:'default',text:null,removeLabels:false,sticky:false};$.extend($.expr[':'],{toggleval:function(elem){return $(elem).data('defText')||false;},changed:function(elem){if($(elem).data('efText')&&$(elem).val()!=$(elem).data('defText')){return true;}return false;}});})(jQuery);


/***
 * Twitter JS v1.13.3 * http://code.google.com/p/twitterjs/
 * Copyright (c) 2009 Remy Sharp / MIT License (MIT-LICENSE.txt)
 * http://remysharp.com/2007/05/18/add-twitter-to-your-blog-step-by-step/
 */
 typeof renderTwitters!="function"&&function(){function v(a){var c;for(c in a.user)a["user_"+c]=a.user[c];a.time=s(a.created_at);return a}function w(a){t?a.call():u.push(a)}function q(){t=true;for(var a;a=u.shift();)a.call()}function x(){if(document.addEventListener&&!r.webkit)document.addEventListener("DOMContentLoaded",q,false);else if(r.msie){document.write("<script id=__ie_init defer=true src=//:><\/script>");var a=document.getElementById("__ie_init");if(a)a.onreadystatechange=function(){if(this.readyState==
 "complete"){this.parentNode.removeChild(this);q.call()}};a=null}else if(r.webkit)var c=setInterval(function(){if(document.readyState=="loaded"||document.readyState=="complete"){clearInterval(c);c=null;q.call()}},10)}function s(a){function c(d){var h=d.getHours();d=d.getMinutes()+"";var f="AM";if(h==0)h=12;else if(h==12)f="PM";else if(h>12){h-=12;f="PM"}if(d.length==1)d="0"+d;return h+":"+d+" "+f}function g(d){d.toDateString().split(/ /);var h=y[d.getMonth()],f=d.getDate()+"",i=parseInt(f);d=d.getFullYear();
 var n=(new Date).getFullYear(),l="th";if(i%10==1&&f.substr(0,1)!="1")l="st";else if(i%10==2&&f.substr(0,1)!="1")l="nd";else if(i%10==3&&f.substr(0,1)!="1")l="rd";if(f.substr(0,1)=="0")f=f.substr(1);return h+" "+f+l+(n!=d?", "+d:"")}var b=a.split(" "),e=Date.parse(b[1]+" "+b[2]+", "+b[5]+" "+b[3]);b=new Date(e);var j=arguments.length>1?arguments[1]:new Date;e=parseInt((j.getTime()-e)/1E3);var m="";e+=j.getTimezoneOffset()*60;return m=e<5?"less than 5 seconds ago":e<30?"half a minute ago":e<60?"less than a minute ago":
 e<120?"1 minute ago":e<2700?parseInt(e/60).toString()+" minutes ago":e<10800?"about 1 hour ago":e<86400?"about "+parseInt(e/3600).toString()+" hours ago":e<172800?c(b)+" yesterday":c(b)+" "+g(b)}var r=function(){var a=navigator.userAgent.toLowerCase();return{webkit:/(webkit|khtml)/.test(a),opera:/opera/.test(a),msie:/msie/.test(a)&&!/opera/.test(a),mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)}}(),o=0,u=[],t=false,y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
 window.ify=function(){return{link:function(a){return a.replace(/[a-z]+:\/\/[a-z0-9-_]+\.[a-z0-9-_:~%&\?#\/.=]+[^:\.,\)\s*$]/ig,function(c){return'<a href="'+c+'">'+(c.length>25?c.substr(0,24)+"...":c)+"</a>"})},at:function(a){return a.replace(/(^|[^\w]+)\@([a-zA-Z0-9_]{1,15}(\/[a-zA-Z0-9-_]+)*)/g,function(c,g,b){return g+'@<a href="http://twitter.com/'+b+'">'+b+"</a>"})},hash:function(a){return a.replace(/(^|[^&\w'"]+)\#([a-zA-Z0-9_]+)/g,function(c,g,b){return g+'#<a href="http://search.twitter.com/search?q=%23'+
 b+'">'+b+"</a>"})},clean:function(a){return this.hash(this.at(this.link(a)))}}}();window.renderTwitters=function(a,c){function g(k){return document.createElement(k)}function b(k){return document.createTextNode(k)}var e=document.getElementById(c.twitterTarget),j=null,m=g("ul"),d,h,f,i,n=a.length>c.count?c.count:a.length;for(i=0;i<n&&a[i];i++){j=v(a[i]);if(c.ignoreReplies&&a[i].text.substr(0,1)=="@")n++;else{d=g("li");if(c.template)d.innerHTML=c.template.replace(/%([a-z_\-\.]*)%/ig,function(k,p){k=
 j[p]+""||"";if(p=="text"&&c.enableLinks)k=ify.clean(k);return k});else{h=g("span");h.className="twitterStatus";f=g("span");f.className="twitterTime";h.innerHTML=a[i].text;if(c.enableLinks==true)h.innerHTML=ify.clean(h.innerHTML);f.innerHTML=s(a[i].created_at);if(c.prefix){var l=g("span");l.className="twitterPrefix";l.innerHTML=c.prefix.replace(/%(.*?)%/g,function(k,p){return a[i].user[p]});d.appendChild(l);d.appendChild(b(" "))}d.appendChild(h);d.appendChild(b(" "));d.appendChild(f)}if(c.newwindow)d.innerHTML=
 d.innerHTML.replace(/<a href/gi,'<a target="_blank" href');m.appendChild(d)}}if(c.clearContents)for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(m);typeof c.callback=="function"&&c.callback()};window.getTwitters=function(a,c,g,b){o++;if(typeof c=="object"){b=c;c=b.id;g=b.count}g||(g=1);if(b)b.count=g;else b={};if(!b.timeout&&typeof b.onTimeout=="function")b.timeout=10;if(typeof b.clearContents=="undefined")b.clearContents=true;if(b.withFriends)b.withFriends=false;b.twitterTarget=a;if(typeof b.enableLinks==
 "undefined")b.enableLinks=true;window["twitterCallback"+o]=function(e){b.timeout&&clearTimeout(window["twitterTimeout"+o]);renderTwitters(e,b)};w(function(e,j){return function(){if(document.getElementById(e.twitterTarget)){var m="http://www.twitter.com/statuses/"+(e.withFriends?"friends_timeline":"user_timeline")+"/"+c+".json?callback=twitterCallback"+j+"&count=20&cb="+Math.random();if(e.timeout)window["twitterTimeout"+j]=setTimeout(function(){if(e.onTimeoutCancel)window["twitterCallback"+j]=function(){};
 e.onTimeout.call(document.getElementById(e.twitterTarget))},e.timeout*1E3);var d=document.createElement("script");d.setAttribute("src",m);document.getElementsByTagName("head")[0].appendChild(d)}}}(b,o))};x()}();

/* ---- COLLAPSING SIDEBAR MENU --- */
jQuery(document).ready(function($){
	//only add dropdown and hover classes to an li with a child ul
	$('.sidebar-menu > li > ul').parent().addClass('slider').hover( 
		function () { $(this).addClass("hover"); }, 
		function () { $(this).removeClass("hover"); } 
	  ); 
	//hide all the subnavs
	$('.slider > ul').hide(); 
	// show the subnav if already in, and give it the show class
	$('.current_page_item, .current-cat').parents().show().addClass('slide-open'); 	
	$(".sidebar-menu > li.slider > a").click(function() { //slide nav toggle
		$(this).find("+ ul").slideToggle("fast").parent().toggleClass('slide-open');
		return false;
	});
	//make project classes open on project classes pages
	$('.page-item-10063.slider > ul').show().parent().addClass('slide-open'); 
	// toggle search input init
	$("#searchform input.keyword").toggleVal({populateFrom: "custom", text:"Search AE", removeLabels: true});
});


/* ----  GOOGLE ANALYTICS--- */
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4900166-3']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
/* ----  END GOOGLE ANALYTICS--- */
