//Style last item in tabs list
$(document).ready(function(){
$("body.home .box ul li:last").addClass("no-image");
//Open all links with rel="external" in new window
$('a').filter(function(){
			return (!this.target && (this.href.indexOf(window.location.hostname) == -1 || this.href.match(/\.pdf$/i)));
		}).attr('target', '_blank');
 });



	$('body.resources table').each(function() {
		$("tr:nth-child(even)").addClass("even");
	});
	
//Clear value in search input box
$(function() {
	swapValues = [];
	$("#Header1_searchbox1").each(function(i){
		swapValues[i] = $(this).val();
		$(this).focus(function(){
			if ($(this).val() == swapValues[i]) {
				$(this).val("");
			}
		}).blur(function(){
	if ($.trim($(this).val()) == "") {
		$(this).val(swapValues[i]);
	}
});
});
});


// Twitter Mini
getTwitters('tweet', { 
  id: 'stratagemni', 
  count: 1, 
  enableLinks: true, 
  ignoreReplies: true, 
  clearContents: true,
  template: '"%text%" <a class="info" href="http://twitter.com/%user_screen_name%/statuses/%id%/">%time%</a>'
});


// Twitter Mini
getTwitters('twitter-holder', { 
  id: 'stratagemni', 
  count: 3, 
  enableLinks: true, 
  ignoreReplies: true, 
  clearContents: true,
  template: '<li>"%text%" <a href="http://twitter.com/%user_screen_name%/statuses/%id%/">%time%</a></li>'
});

var mylib =
{
	showreel :
	{
		init : function()
		{
		$(window).load(function() {
			$(".showreel .slide").hide();
			$(".showreel .slide").first().fadeIn(500);
			$(".showreel .slide").first().addClass("current-slide");
			$(".current-slide .caption").animate({"bottom":"0px"},500);
			$("#showreel-nav li a").first().addClass("current");
			var total = $(".showreel .slide").length;
			
			
			var loop = function showreelLoop() {
				var currentSlide = ($(".current-slide").attr("id")).slice(5);
				var newSlide = parseInt(currentSlide) + 1;
				if (newSlide > total){
					newSlide = 1;
				}
				$(".showreel .slide").fadeOut(500);
				$(".current-slide .caption").animate({"bottom":"-90px"},250);
				$(".showreel #slide"+currentSlide).removeClass("current-slide");
				$("#showreel-nav li a").removeClass("current");
				$(".showreel #slide"+newSlide).addClass("current-slide");
				$("#slide"+newSlide).fadeIn(500);
				$("#showreel-nav li a[href=#slide"+newSlide+"]").addClass("current");
				$("#slide"+newSlide+" .caption").animate({"bottom":"0px"},500);	
				
			}
			
			var timer = window.setInterval(loop,5000);
			
			$(window).blur(function() {
				clearInterval(timer);
			});
			
			$("#showreel-nav li a").click(function(){
				clearInterval(timer);
	  			var clicked = $(this).attr("href");
				$(".current-slide .caption").animate({"bottom":"-90px","opacity":"0"},250);				
				$(".showreel .slide").fadeOut(500);
	  			$(clicked).fadeIn(500);
				$(clicked + " .caption").animate({"bottom":"0px","opacity":"1"},500);
				$("#showreel-nav li a").removeClass("current");
				$("#showreel-nav li a[href="+clicked+"]").addClass("current");
				return false;
			});
			
			$(".slide").hover(function() {
				$(this).parent().css("border","9px solid #c2c2c2");					   
		  	}, function() {
				$(this).parent().css("border","9px solid #d9d9d9");
			});
			
		  });

		}
	},
	twitter_home :
	{
		init : function() 
		{
			$(function() {
				getTwitters('tweet-feed', { 
					id: 'stratagemni', 
					count: 3, 
					enableLinks: true, 
					ignoreReplies: true, 
					clearContents: true,
					template: '<div>%text%</div> <div><a href="http://twitter.com/%user_screen_name%/statuses/%id%/" class="time" rel="external">%time%</a></div>'
				});
			});
		}
	}
}
