
jQuery(document).ready(function($){
	
	$('a.fancybox').fancybox({
		
		'titlePosition'	: 'under',
		'transitionIn'	: 'fade',
		'transitionOut'	: 'fade',

		'autoDimensions': false,
		'titleFromAlt'	: true,
		'titleFormat'   : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span class="url"></span><span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + title + '</span>';
		}

	});
	
	var fb_opts = {
		'titleDisplay' : false,
		'autoScale'	: false,
		'swf'		: {
		   	'wmode'			: 'opacity',
			'allowfullscreen'	: 'true',
		},
		'padding'	: 0,
		
		'titlePosition'	: 'under',
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		
		'autoDimensions': false,
		'titleFromAlt'	: true,
		'titleFormat'   : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">'  + title + '</span>';
		}
		
	};
	
	
	$('a.fancybox-vimeo-EricFix').click(function() {
		$.fancybox(
			$.extend(fb_opts, {
				'width'		: 960,
				'height'	: 540,
				'href'		: this.href.replace(new RegExp('([0-9])', 'i'), '$1'),
				'type'		: 'iframe',
				'title'		: this.title
				
			})
		);
	
	
		return false;
	});
	
	
	$('a.fancybox-vimeo').click(function() {
		$.fancybox(
				   
			$.extend(fb_opts, {
				'width'		: 960,
				'height'	: 540,
				'href'		: this.href.replace(new RegExp('([0-9])', 'i'), 'moogaloop.swf?clip_id=$1'),
				'type'		: 'swf',
				
			})
				
		);
		return false;
	});
	
	$('a.fancybox-vimeo-small').click(function() {
		$.fancybox(
			$.extend(fb_opts, {
				'width'		: 520,
				'height'	: 300,
				'href'		: this.href.replace(new RegExp('([0-9])', 'i'), 'moogaloop.swf?clip_id=$1'),
				'type'		: 'swf'
			})
		);
		return false;
	});
	
	
	
	$("#love").fancybox({
		'width'				: 580,
		'height'			: 534,
        'autoScale'     	: false,
		'type'				: 'iframe',
		'scrolling'			: 'no'
	});

	
	if(location.hash) {
		$(location.hash).click();
	}
});

jQuery(document).ready(function($){

	$("a.gallery").tooltip({ 
	    track: true, 
	    delay: 0, 
	    showURL: false, 
	    showBody: " - ", 
		fade: 600,
		fixPNG: true
	});
	
	var map = { t:"*", 
	            p:".category-archive", 
	            d:".category-feature", 
	            v:".category-commercial",
				m:".category-recent", 
	            w:".tweet"
				};
				
	$.keyNav();
	$.each(map, function(key, selector) {
		$.whenPressed(key,function(){
			$("#grid-wrapper article.post").not(selector).fadeTo(200, 0.1)
	                             .end().filter(selector).fadeTo(200, 1);
		});
	});


	$.fn.showdelay = function(){
		var delay = 0;
		return this.each(function(){
			$(this).delay(delay).fadeIn(1000);
			delay += 150;
		});
	};

	$(window).load(function(e){
		var columnW = 241;
		var primaryW = Math.floor( $(window).width() / columnW ) * columnW;
		$("#container,header,footer").css({width: primaryW});
		$("#container").css({visibility: "visible"});
		$(".x2").hide().showdelay();
		setTimeout(function(){
			$("nav,footer").fadeIn("slow");
			$("#grid-wrapper article.post").delay(700).fadeTo(700, 0.1);
			$("#grid-wrapper article.category-commercial").delay(100).fadeTo(700, 1);
		}, 3000);
	});
	
	$(window).resize(function(){
		var columnW = 241;
		var primaryW = Math.floor( $(window).width() / columnW ) * columnW;
		$("#container,header,footer,aside").css({width: primaryW});
	});
    
	$(".thumb").hover(
		function () {
			$(this).children(".zoom,.zoom-mov").show();
		},
		function () {
			$(".zoom,.zoom-mov").hide();
		}
	);
		
	$(".categories a").click(function() {
		var cat = $(this).attr("class");
		$("#grid-wrapper article.post").not("."+cat).fadeTo(200, 0.1);
		$("#grid-wrapper article.post").filter("."+cat).fadeTo(200, 1);
		$(".categories a").parent().removeClass("active");
		$(this).parent().addClass("active");
		return false;
	});
	
	$(".categories a.all").click(function() {
		$("#grid-wrapper article.post").filter("."+cat).fadeTo(10, 1);
		
	});
	


	$(".category-commercial").click(function() {
			$("html,body").animate({scrollTop: 0}, 300);
	});




	
	$(".category-recent").click(function() {
			$("html,body").animate({scrollTop: 0}, 300);
	});
	


	$(".category-feature").click(function() {
			$("html,body").animate({scrollTop: 400}, 300);
	});

	$(".category-archive").click(function() {
			$("html,body").animate({scrollTop: 530}, 300);
	});


	
	$("#grid-wrapper").masonry({ 
		singleMode: true,
		itemSelector: ".x1",
		animate: true,
		animationOptions: {
			duration: 750,
			easing: "swing",
			queue: true
		}
	});
    
    $(".top").click(function() {
		$("html,body").animate({scrollTop: 0}, 300);
	});

});
