//jquery//
$j = jQuery.noConflict();
function paginarTodos(pag,limit) {
	$j.ajax({
			type: "GET",
			url: "inc/geraposts.php",
			data: "limit="+limit+"&pag="+pag,
			cache: false,
			success: function(result) {
				$j("#resultpaginacao").fadeIn(2000).html(result);
				$j.scrollTo( "#busca", 800);
			}
		});
};
function paginarTodosMais(pag,limit) {
	$j.ajax({
			type: "GET",
			url: "inc/gerapostsmais.php",
			data: "limit="+limit+"&pag="+pag,
			cache: false,
			success: function(result) {
				$j("#resultpaginacao").fadeIn(2000).html(result);
				$j.scrollTo( "#busca", 800);
			}
		});
};
function carregaCalendario(m,ano){
	$j("#calendario").fadeTo(100, 0);
	$j.ajax({
			type: "GET",
			url: "inc/calendario.php",
			data: "m="+ m +"&ano="+ ano,
			cache: false,
			success: function(result) {
				$j("#calendario").fadeTo(1000,1).html(result);
				//$j.scrollTo( "#busca", 800);
			}
		});
};
function abrirFormContato(){
	$j("#contato").fadeTo(100, 0.9).show(2000);
}
function fecharFormContato(){
	$j("#contato").hide(2000);
}
function abrirPost(postCodigo){
	$j("#resultadopost").fadeOut(2000);
	$j.ajax({
			type: "GET",
			url: "inc/lerposts2.php",
			data: "postCodigo="+postCodigo,
			cache: false,
			success: function(result) {
				$j("#resultadopost").fadeIn(2000).html(result);
				$j.scrollTo( "#resultadopost", 800);
			}
		});
};
function enviarComentario(postCodigo){
	var comentNome = $j("#comentNome").val();
	var comentEmail = $j("#comentEmail").val();
	var comentSite = $j("#comentSite").val();
	var comentTexto = $j("#comentTexto").val();
	$j.ajax({
			type: "GET",
			url: "inc/comentarios.php",
			data: "comentNome="+comentNome+"&comentEmail="+comentEmail+"&comentSite="+comentSite+"&comentTexto="+comentTexto+"&postCodigo="+postCodigo+"&acao=inserir",
			cache: false,
			success: function(result){
				if(result > 0){
					var msg = "Inserido com sucesso";
					var comentNome = $j("#comentNome").val("");
					var comentEmail = $j("#comentEmail").val("");
					var comentSite = $j("#comentSite").val("http://");
					var comentTexto = $j("#comentTexto").val("");
				}else{
					var msg = "Falha ao inserir o comentário";
				}
				$j("#idcoment").fadeIn(2000).html(msg);
				setTimeout(reabrirComentario(postCodigo),3000);
			}
		});
};
function reabrirComentario(postCodigo){
	$j.ajax({
			type: "GET",
			url: "inc/comentarios.php",
			data: "postCodigo="+postCodigo+"&acao=exibir",
			cache: false,
			success: function(result){
				$j.scrollTo( "#comentario", 800);
				$j("#resultcoment").fadeIn(2000).html(result);
			}
		});
}
function mainmenu(){
$(" #nav ul "). css({display: "none"});
$(" #nav li").hover(function(){
$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(200);
},function(){
$(this).find('ul:first').css({visibility: "hidden"});
});
}

$(document).ready(function(){
mainmenu();
});

$j(function() {
			
			
				var options = {
					target: "#amigo",
					beforeSubmit: showRequest,
					success: showResponse,
					clearForm: true
				};
				
				$j("#formAmigo").validate({
					rules: {
					
					},
					messages: {
						
					},
					errorElement: "em",
					errorClass: "error",
					highlight: function(element, errorClass) {
						$j(element).addClass(errorClass);
					},
					submitHandler: function(form) {
						$j(form).ajaxSubmit(options);
					}
				});
				
			});
						
			function showRequest(formData, jqForm, options) {
				return true;
			}
			
			function showResponse(responseText, statusText) {
				$j("#amigo").fadeOut(1000);
				if(responseText != ""){
					$j("#amigo").fadeIn(1000).html(responseText);
				}
			}


$j(function() {
			
			
				var options = {
					target: "#amigo",
					beforeSubmit: showRequest,
					success: showResponse,
					clearForm: true
				};
				
				$j("#formAmigo").validate({
					rules: {
					
					},
					messages: {
						
					},
					errorElement: "em",
					errorClass: "error",
					highlight: function(element, errorClass) {
						$j(element).addClass(errorClass);
					},
					submitHandler: function(form) {
						$j(form).ajaxSubmit(options);
					}
				});
				
			});
						
			function showRequest(formData, jqForm, options) {
				return true;
			}
			
			function showResponse(responseText, statusText) {
				$j("#amigo").fadeOut(1000);
				if(responseText != ""){
					$j("#amigo").fadeIn(1000).html(responseText);
				}
			}
			
$j(function() {
			
				var options = {
					target: "#news",
					beforeSubmit: showRequest,
					success: showResponse,
					clearForm: true
				};
				
				$j("#formnews").validate({
					rules: {
					
					},
					messages: {
						
					},
					errorElement: "em",
					errorClass: "error",
					highlight: function(element, errorClass) {
						$j(element).addClass(errorClass);
					},
					submitHandler: function(form) {
						$j(form).ajaxSubmit(options);
					}
				});
				
			});
						
			function showRequest(formData, jqForm, options) {
				return true;
			}
			
			function showResponse(responseText, statusText) {
				$j("#news").fadeOut(1000);
				if(responseText != ""){
					$j("#news").fadeIn(1000).html(responseText);
				}
			}
