$(document).ready(function(){

	if ( /*$('#catalogo-touros').length > 0*/ 0 )
	{
		$('#catalogo-touros').dataTable({
			"sPaginationType": "full_numbers",
			"oLanguage": {
				"sLengthMenu": "Mostrar _MENU_ registros por página",
				"sZeroRecords": "Nenhum registro encontrado",
				"sInfo": "Mostrando _START_ a _END_ de _TOTAL_ registros",
				"sInfoEmtpy": "Mostrando 0 a 0 de 0 registros",
				"sInfoFiltered": "(filtrados dos _MAX_ registros totais)",
				"sInfoPostFix": "",
				"sSearch": "Procurar",
				"sUrl": "",
				"oPaginate": {
					"sFirst":    "Primeiro",
					"sPrevious": "Anterior",
					"sNext":     "Próximo",
					"sLast":     "Último"
				}
			},
			"aoColumns": [ 
			/* ordenacao */   { "bVisible":    false, "bSearchable": false },
			/* nome */  null,
			/* raca */ null,
			/* criador */  null,
			/* telefone */    { "bSortable" : false },
			/* email */ { "bSortable" : false },
			/* site */ { "bSortable" : false }
			],
			"aaSorting": [ [0,'asc'], [2,'asc'] ],
			"sDom": '<"sorterNav1"if>rtr<p>'

		});
	}
	
	//Link para impressão na página detalhe dos animais
	if ( $(".animal-menu ul").length > 0 )
	{
		$(".animal-menu ul").append('<li><a id="print" href="#">Imprimir</a></li>');
		$("a#print").click(function(){
			var localiza=location.search.split("=");
			var codigo = localiza[1].split("=");			
			window.open("touros_impressao.php?animal="+codigo, "_blank", "height = 450 , width = 600");
			return false;
		});
	}
	
	//Link para voltar para a página anterior
	if ( $("a.page-back") ){
		$("a.page-back").click(function(){
			history.back();
			return false;
		});
	}
	
	if ( $(".validate").length > 0 )
	{
		//Destacando campos requeridos
		$(".validate .required").parent().find("label").prepend('<span title="Campo obrigatório." style="color: #E74037; margin-right: 5px;">*</span>');
		
		//Validando formulario;
		$(".validate").submit( function(){
			var erros = 0;
			$.each( $(".required"), function(){
				$(this).removeClass('error');
				if ( $(this).val() === "" ){
					$(this).addClass('error');
					erros++;
				}
				else
				if ( $(this).hasClass("email") ){
					var textEmail = $(this).val();
					if ( textEmail.search(/(\w[\w\.\+]+)@(.+)\.(\w+)$/) < 0 ){
						$(this).addClass('error');
						erros++;
					}
				}
			} );
			return erros > 0 ? false : true;
		} );
	}
	
	//Modal	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'dark_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
	});
	
	//SE for IE 6 -> concertar o bug do box #informativo bor causa dos roundedCorners
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		$("#informativo").css("bottom","30px");
	}
	
	//bug ie 8 escondendo o box
	$('#destaque-iso').show();

	
});