$(document).ready(function() {
	
	
	
	$('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 == 'alle') {
			$('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;
	});
	
	
	$('#sorttable').tablesorter();	
	
	var options = {
	    beforeSubmit: function() {
	        return $('#theForm').validate({
	
	rules: {
		name: { required: true 	},
		emailFrom: { required: true, email: true 	}		},
		
	messages: {
		name: { required: "Bitte Namen angeben" },
		emailFrom: { required: "Bitte E-Mail Adresse angeben" },
		email: "Bitte g&uuml;tige E-Mail Adresse angeben"			
		}
			
	}).form();
	    },
		 success:    function(data){
						$("#theForm").fadeOut("normal", function() {							
						$("#theForm").before("<h3>Danke!</h3><h6>&nbsp;Deine Angaben wurden &uuml;bermittelt.</h6>");											
						});
	} 
	};
	
	
	$('#theForm').ajaxForm(options); 
	
});

$(function() {

	$("a[rel], li[rel]").overlay({mask: '#000'});
	
	$('.blog-text').truncate({max_length: 350});
	
	$('input#searchtable').quicksearch('table#blog-table tbody tr, table#sorttable tbody tr', {'loader': 'span.loading', 'delay': 500});
	
	$(".scrollable").scrollable({ keyboard: false, mousewheel: true });
	
	$("#accordion").tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide', initialIndex: null});

	$("#expose-movie, #diashow, .blog-movie, .bestof-movie").click(function() {

		$(this).expose();

	});
	
	$('.clickable').css('cursor', 'pointer')
	
	    .click(function() {
	
	        window.location = $('a', this).attr('href');
	    });
	    
	$("#back-top").click(function() {
	    		$("html, body").animate({ scrollTop:0 });
	    		return false;
	    	 });
	    
});

