// JavaScript Document
$(document).ready(function(){
	
	$('a[href^="http://"]')	.attr({ target: "_blank" });

	function smartColumns() {
		
		$("ul.column").css({ 'width' : "100%"});
		
		var colStart = 340;
		var colWrap = $("ul.column").width();
		var colNum = Math.floor(colWrap / colStart);
		var colSize = Math.floor(colWrap / colNum);
		var colFixed = Math.floor(colSize-20);
		var colFixedH = Math.floor(colFixed * 0.66);
		var colFixedCap1 = Math.floor(colFixedH - 100);
		var colFixedCap2 = Math.floor(colFixedH - 40);
		var colFixedCap3 = Math.floor(colFixedH - 0);
		
		$("ul.column").css({ 'width' : colWrap});
		$("ul.column li").css({ 'width' : colFixed });
		$("ul.column li").css({ 'height' : colFixedH});
		$(".boxcaption").css({ 'top' : colFixedCap2});
		$(".boxgrid").css({ 'height' : colFixedH});
		$(".boxgrid img").css({ 'width' : colFixed });
		$(".boxgrid img").css({ 'height' : colFixedH});
		$(".caption").css({'top' : colFixedCap3});
		
	//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
	//Vertical Sliding
	$('.boxgrid.slidedown').hover(function(){
		$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});
	//Horizontal Sliding
	$('.boxgrid.slideright').hover(function(){
		$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
	});
	//Diagnal Sliding
	$('.boxgrid.thecombo').hover(function(){
		$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
	});
	//Partial Sliding (Only show some of background)
	$('.boxgrid.peek').hover(function(){
		$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
	});
	//Full Caption Sliding (Hidden to Visible)
	$('.boxgrid.captionfull').hover(function(){
		$(".cover", this).stop().animate({top: colFixedCap1},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top: colFixedCap3},{queue:false,duration:160});
	});
	//Caption Sliding (Partially Hidden to Visible)
	$('.caption').hover(function(){
		$(".cover", this).stop().animate({top: colFixedCap1},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top: colFixedCap2},{queue:false,duration:160});
	});
		
		
	}	
	
	smartColumns();	
	$(window).resize(function () {
		smartColumns();	
	}); 
	
	//sorting portfolio script
	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'all') {
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$('ul#portfolio li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});


	
});