$(document).ready(function(){

	$('#nav ul.nav li').hover(function(){
	
		$(this).find('ul:first').fadeIn(200);
		
	}, function() {
	
		$(this).find('ul:first').fadeOut(200);
		
	});
	
	
	
    var $list = $('#items');
    var $data = $list.clone();
	
	if (jQuery().quicksand) {
	    $('#filter a').click(function() {
	    
	    	$(this).parent().find('a.active').removeClass('active');
	    	$(this).addClass('active');
	
	        href = $(this).attr('href').replace('#category=', '');
	
	        var filtered_data = (href == 'all') ? $data.find('.project') : $data.find('.project.' + href);
	        $list.quicksand(filtered_data, {duration: 700});
	
	    });
    }
    
    if (jQuery().validate) {
    	$('#contactForm').validate();
    }
    
    if (jQuery().accordion) {
	    $(".toggle").each( function () {
	    	if($(this).attr('data-id') == 'closed') {
	    		$(this).accordion({ header: 'h4', collapsible: true, active: false  });
	    	} else {
	    		$(this).accordion({ header: 'h4', collapsible: true});
	    	}
	    });
    }
    
    if (jQuery().tabs) {
    	jQuery("#tabs").tabs({ fx: { opacity: 'show' } });
    	jQuery(".tabs").tabs({ fx: { opacity: 'show' } });
    }
	    
});
