	function pleaseHover(target,off,over) {
		preload([over]);
		$(target).hover(function() {
			this.src = over;
		 }, function () {
			this.src = off;
		});
	}
	function preload(arrayOfImages) {
	    $(arrayOfImages).each(function(){									   
	        $('<img/>')[0].src = this;
    	});
	}
$(document).ready(function(){
   jQuery.fn.reverse = [].reverse;
	pleaseHover('#btn1','/wp-content/themes/IA/assets/images/btn_rss_off.gif','/wp-content/themes/IA/assets/images/btn_rss_over.gif');
	pleaseHover($('#btn2'),'/wp-content/themes/IA/assets/images/btn_facebook_off.gif','/wp-content/themes/IA/assets/images/btn_facebook_over.gif');
	pleaseHover($('#btn3'),'/wp-content/themes/IA/assets/images/btn_twitter_off.gif','/wp-content/themes/IA/assets/images/btn_twitter_over.gif');
	pleaseHover($('#btn4'),'/wp-content/themes/IA/assets/images/btn_linkedin_off.gif','/wp-content/themes/IA/assets/images/btn_linkedin_over.gif');
	pleaseHover($('#btn5'),'/wp-content/themes/IA/assets/images/btn_share_off.gif','/wp-content/themes/IA/assets/images/btn_share_over.gif');
//	var slideshowtimeout = 5000;
	var slideshowtimeout = 0; //CES Fix
	if (location.href.indexOf("/about/") != -1) {
		slideshowtimeout = slideshowtimeout * 3;
	}
    $('#slideshow').cycle({
        fx:      'scrollHorz',
        prev:    '#slideshow-prev',
        next:    '#slideshow-next, #slideshow',
        after: onAfter,
		timeout: slideshowtimeout,
		speed:700,
		pause: 1

    });
function onAfter(curr, next, opts) {
    var index = opts.currSlide;
	$('#slideshow-slide').html('('+ (index + 1)+' of '+opts.slideCount+')'); 
}

    
	$("#taglistcs").hide();
	$("#taglist").show();
	$("#tags").click(function() {
			$("#taglist, #taglistcs").slideToggle();
			if ($(this).html() == "TAGS +") {
				$(this).html("TAGS -");	
			} else {
				$(this).html("TAGS +");	
				$(".thumb").not(":visible").each(function(index) {
					var self = this;
					setTimeout(function() {
						$(self).fadeIn(500);
					}, index * 100);
				 });
				$(".tag").removeClass("active");
			}
		  });
	$(".thumb").hide();
	var myhash = unescape(self.document.location.hash.substring(1));
	var totalqty = $(".thumb").size();
	if (myhash != "") {
		_gaq.push(['_trackEvent', 'Tags', 'Click', myhash]);
		$("#"+myhash).addClass("active");
		
		totalqty = $("."+myhash).size();
		$("."+myhash).each(function(index) {
					var self = this;
				setTimeout(function() {
					$(self).fadeIn(500);
				}, (index * 2000) / totalqty);
		 });
	} else {
		$(".thumb").each(function(index) {
					var self = this;
				setTimeout(function() {
					$(self).fadeIn(500);
				}, (index * 2000) / totalqty);
		 });
	}
	$(".logo img").hide();
	$(".logo img").each(function(index) {
		var self = this;
		setTimeout(function() {
			$(self).fadeIn(500);
		}, index * 100);
	 });
	$("#taglist .tag").click(function() {
		var tag = $(this).attr('id');
		if (!$(this).is(".active")) {
			_gaq.push(['_trackEvent', 'Tags', 'Click', tag]);
			$(".tag").removeClass("active");
			$(this).addClass("active");
			var qty = $(".thumb:visible").not("."+tag).size();
			$(".thumb:visible").not("."+tag).each(function(index) {
				var self = this;
				setTimeout(function() {
					$(self).fadeOut(500);
				}, (index * 2000) / qty);
		   });
			var qty2 = $("."+tag).not(":visible").size();
			$("."+tag).not(":visible").each(function(index) {
				var self = this;
				setTimeout(function() {
					$(self).fadeIn(500);
				}, (index * 2000) / qty2);
			 });
		} else {
			totalqty = $(".thumb").size();
			$(".thumb").each(function(index) {
					var self = this;
				setTimeout(function() {
					$(self).fadeIn(500);
				}, (index * 2000) / totalqty);
			 });
			$(this).removeClass("active");
		}
	});
	$("#taglistcs .tag").click(function() {
		var tag = $(this).attr('id');
		window.location = 'http://iacollaborative.com/work/#'+tag;
	});

	$("#resume").fancybox({
		'type'	: 'iframe',
		'width' : 468,
		'height' : 500,
		'overlayColor' : '#000000'
	});

/*	$("#masonry").masonry({
						  itemSelector: '.thumb',
						  columnWidth: 234,
						  isAnimated: true,
	  }); */
//		$("#copy2").columnize({width: 210, accuracy: 1});
//		$("#copy3").columnize({width: 210, accuracy: 1});
		$("#copy3").column({count:3,gap:24}).css("opacity", 1);
		$("#copy2").column({count:2,gap:24}).css("opacity", 1);
		var actionbar_home = $("#action_bar").position();
		var lastover = 0;
		var clearLastover;
			$("#menu-main-navigation li").hover(function() {
				clearTimeout(clearLastover);
				 if ($("#action_bar").is(":visible")) {								 
					 $("#action_bar").stop(true).animate({left: $(this).position()['left'] + 18},200, 'linear');
				 } else {
					 if (lastover != 0) {
						 $("#action_bar").stop(true).animate({left: $(this).position()['left'] + 18},200, 'linear').show();
					} else {
						 $("#action_bar").css({left: $(this).position()['left'] + 18}).show();
					}
				 }
											 }, function() {
				if (actionbar_home['left'] > 0) {
					 $("#action_bar").stop(true).animate({left: actionbar_home['left']},200);												 
				 } else {
 					 lastover = $("#action_bar").position()['left'];
					 $("#action_bar").hide();
					 clearLastover = setTimeout(function() {lastover = 0;},200);
				 }
			 }); 
			$("#menu-main-navigation li").click(function() {
				$("#menu-main-navigation li").unbind('mouseenter').unbind('mouseleave');
			 });
/*				 $("#action_bar").css({left: $(this).position()['left'] + 22}).show();
											 }, function() {
				 $("#action_bar").hide();												 });
	*/	

});


