/*
 * jQuery shuffle
 *
 * Copyright (c) 2008 Ca-Phun Ung <caphun at yelotofu dot com>
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://yelotofu.com/labs/jquery/snippets/shuffle/
 *
 * Shuffles an array or the children of a element container.
 * This uses the Fisher-Yates shuffle algorithm <http://jsfromhell.com/array/shuffle [v1.0]>
 */

(function($){

	$.fn.shuffle = function() {
		return this.each(function(){
			var items = $(this).children().clone(true);
			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;
	}

/*
 * Random header
 *
 * This is function that generates a random header out of a set of two arrays.
 * Thanks to Fabio Pittol <www.fabiopittol.com> and Julio Nunes <www.twitter.com/parnes> for the help.
 * Feel free to use it and let me know if you do.
 *
 * http://diasnormais.com
 */		

	$(document).ready(function() { 
	
		var pos = 0;
		var total = 0;
		
		var dias = ['derrames',
			'doces',
			'dicas',
			'doninhas',
			'dados',
			'dorgas',
			'desejos',
			'delícias',
			'danças',
			'distúrbios',
			'deslizes',
			'druídas',
			'dançarinas',
			'discos',
			'duendes',
			'dedos',
			'duplas',
			'doenças',
			'deuses',
			'damas',
			'dúvidas',
			'dúvidas',
			'distâncias',
			'desejos',
			'dançarinas',
			'dardos',
			'dentes',
			'dores',
			'detectores',
			'diabos',
			'dinamites',
			'direitos',
			'doses',
			'destinos',
			'derrotas',
			'delegações',
			'danos',
			'doses',
			'diarréias',
			'diamantes',
			'detectores',
			'descargas',
			'desafios',
			'donzelas',
			'desjejuns',
			'danos',
			'doutrinas',
			'devaneios',
			'destroços',
			'delegados',
			'desertos',
			'domingos',
			'doidos',
			'dildos',
			'dráculas',
			'deliverys'];
		var normais = ['cerebrais',
			 'demais',
			 'reais',
			 'legais',
			 'espaciais',
			 'focais',
			 'anais',
			 'animais',
			 'semanais',
			 'matinais',
			 'passionais',
			 'sentimentais',
			 'profissionais',
			 'incrementais',
			 'sacais',
			 'elementais',
			 'virtuais',
			 'finais',
			 'mundiais',
			 'funcionais',
			 'triviais',
			 'renais',
			 'paradoxais',
			 'seminais',
			 'terminais',
			 'carnais',
			 'sensacionais',
			 'infernais',
			 'colossais',
			 'pessoais',
			 'internacionais',
			 'minerais',
			 'sexuais',
			 'formais',
			 'cabais',
			 'parciais',
			 'literais',
			 'instrumentais',
			 'monumentais',
			 'tradicionais',
			 'mortais',
			 'boçais',
			 'fundamentais',
			 'processuais',
			 'nasais',
			 'termais',
			 'paranormais',
			 'tropicais',
			 'estruturais',
			 'motivacionais'];
		
		if (dias.length < normais.length) {
			total = dias.length;
		} else { 
			total = normais.length;
		}
		
		var shufflePair = function() {
			dias = $.shuffle(dias);
			normais = $.shuffle(normais);
		}
			
		shufflePair();
	
		$('#revolve a').click(function(){
			if (pos >= total) {
				pos = 0;
				shufflePair();
			}
			$('.blog-title').fadeOut('medium')
							.queue(function() {
									$('.blog-title').html('<a href="http://www.diasnormais.com">' + dias[pos] + ' ' + normais[pos] +'</a>')
													.dequeue();
									pos++;
											})
							.fadeIn('fast');
			 return false;
		});
	
		$('#revolve a').click();
	
	});

})(jQuery);