(function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);
$(document).ready(function() {
	
	
	$("a[href$=pdf]").each(
	   function(){
	      $(this).attr('target', '_blank');
	});
	$("a[href^=http]").each(
	   function(){
		  if(this.href.indexOf(location.hostname) == -1) { 
	      $(this).attr('target', '_blank');
	    }
	});
	
	$('#primenav li:last').css("background-image","none");
	$('#langselect a:last').css("border-right","0 none");
	$('#langselect a:first').css("border-left","0 none");
	$('.a_3x .appetizer:nth-child(3n)').css("margin-right","0");
	$('.a_3x .appetizer').hover(
	  	function () {
	    	$(this).addClass('hover');
	  	},function () {
	    	$(this).removeClass('hover');
	  	}
	);
	
	$('#randomquotes').shuffle();
	$('#randomquotes div:first').removeClass("h");
	
	$('.a_start .appetizer').hover(
	  	function () {
	    	$(this).addClass('hover');
	  	},function () {
	    	$(this).removeClass('hover');
	  	}
	);
	$('.a_wide .appetizer').hover(
	  	function () {
	    	$(this).addClass('hover');
	  	},function () {
	    	$(this).removeClass('hover');
	  	}
	);
	$('.a_thin .appetizer').hover(
	  	function () {
	    	$(this).addClass('hover');
	  	},function () {
	    	$(this).removeClass('hover');
	  	}
	);
	$('.a_scol .appetizer').hover(
	  	function () {
	    	$(this).addClass('hover');
	  	},function () {
	    	$(this).removeClass('hover');
	  	}
	);
	$('.gallery a').fancybox({
		'titlePosition'	: 'inside'
	});
});
