$(document).ready(function() {
			
	 $('ul.menu').superfish({animation: {opacity:'show',height:'show'}}); 
	 $('ul.filter').superfish({animation: {opacity:'show',height:'show'}});
	 
	
	 
	 	 
	 simpl_overlay();
	 
	 
	  
	  
	
	 
	 	if($('#author').val() != ''){
				$('#clabel-author').hide();
			}
			
		if($('#email').val() != ''){
				$('#clabel-email').hide();
			}
			
		if($('#url').val() != ''){
				$('#clabel-url').hide();
			} 
			
		
	 
	 	$('#author').focus(function() {
			$('#clabel-author').hide();
		});
		$('#author').blur(function() {
			if($('#author').val() == ''){
				$('#clabel-author').show();
				alert($('#author').val());
			}
		});
		
		$('#email').focus(function() {
			$('#clabel-email').hide();
		});
		$('#email').blur(function() {
			if($('#email').val() == ''){
				$('#clabel-email').show();
			}
		});
		
		$('#url').focus(function() {
			$('#clabel-url').hide();
		});
		$('#url').blur(function() {
			if($('#url').val() == ''){
				$('#clabel-url').show();
			}
		});

		
	$("ul.tabs").tabs("div.panes > div",{// enable "cross-fading" effect
										effect: 'fade',
										fadeOutSpeed: "fast"});
	 
	
	 
	if ($().easySlider) {
	
		$("#slider").easySlider({
			auto: true, 
		  	continuous: true,
		  	controlsFade:true,
		  	vertical:false,
		  	allControls: true,
			speed: 	800,
			pause:	5000	
			
			
		});
		
		
		
		$('#controls').center(true);
		
	}
	
		
	simple_lightboxes ();
	
	
	
	 
});




function simple_lightboxes () {

	if ($().prettyPhoto) {
							
		$(".gallery a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'facebook',slideshow:3000, autoplay_slideshow: false});
		
	}
	
	if ($().fancybox) {
	
		
			
			$("a.fancybox").fancybox({
						'opacity'		: true,
						'transitionIn'	: 'elastic',
						'transitionOut'	: 'none'});
						
			$("a.iframe").fancybox({
						'opacity'		: true,
						'type'			:'iframe',
						'transitionIn'	: 'elastic',
						'transitionOut'	: 'none'});

	}

}


function simpl_overlay() {

	$('.overlay').animate({"opacity": "0"}, "fast"); 

	$(".post-thumb a").hover(
	 
		function() {
			$(this).find('.overlay').animate({"opacity": "1"}, "slow");
		},
		function() {
			$(this).find('.overlay').animate({"opacity": "0"}, "slow");
		}
		
	);


}

// Custom sorting plugin
(function($) {
  $.fn.sorted = function(customOptions) {
    var options = {
      reversed: false,
      by: function(a) { return a.text(); }
    };
    $.extend(options, customOptions);
    $data = $(this);
    arr = $data.get();
    arr.sort(function(a, b) {
      var valA = options.by($(a));
      var valB = options.by($(b));
      if (options.reversed) {
        return (valA < valB) ? 1 : (valA > valB) ? -1 : 0;				
      } else {		
        return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;	
      }
    });
    return $(arr);
  };
})(jQuery);

// DOMContentLoaded
$(function() {

  // bind radiobuttons in the form
  var $filterType = $('#filter a');

  // get the first collection
  var $applications = $('#items');

  // clone applications to get a second collection
  var $data = $applications.clone();

  // attempt to call Quicksand on every form change
  $filterType.click(function(e) {
  
  	
  	
  	//alert($(this).attr('data-value'));
  	
    if ($(this).attr('data-value') == 'all') {
      var $filteredData = $data.find('li');
    } else {
      var $filteredData = $data.find('li.' + $(this).attr('data-value'));
    }

    // finally, call quicksand
    $applications.quicksand($filteredData, {
      duration: 800,
      easing: 'easeInOutQuad'
    },function () {
			simpl_overlay();
			simple_lightboxes();
	});
    
    e.preventDefault();

  });

});
		
		
