///////////////////////////////////////////////////////////////////////////////////////////////////////////
////////                            Criado por : Flávio Theruo Kaminisse                           ////////
////////                                 email: flavio@japs.etc.br                                 ////////
////////                                 url: http://www.japs.etc.br                               ////////
////////                                  Data Criação : 30/08/2005                                ////////
////////                                                                                           ////////
////////                            - Compatível com Firefox, Opera e MSIE.                        ////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////

function $Get(s) {
	return document.getElementById(s);
}

//Função que valida a data
function valida_data() {
	var date = $Get('data').value;
	var array_data = new Array;
	var ExpReg = new RegExp("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/[12][0-9]{3}");
	//vetor que contem o dia o mes e o ano
	array_data = date.split("/");
	erro = false;
	//Valido se a data esta no formato dd/mm/yyyy e se o dia tem 2 digitos e esta entre 01 e 31
	//se o mes tem d2 digitos e esta entre 01 e 12 e o ano se tem 4 digitos e esta entre 1000 e 2999
	if ( date.search(ExpReg) == -1 )
		erro = true;
	//Valido os meses que nao tem 31 dias com execao de fevereiro
	else if ( ( ( array_data[1] == 4 ) || ( array_data[1] == 6 ) || ( array_data[1] == 9 ) || ( array_data[1] == 11 ) ) && ( array_data[0] > 30 ) )
		erro = true;
	//Valido o mes de fevereiro
	else if ( array_data[1] == 2 ) {
		//Valido ano que nao e bissexto
		if ( ( array_data[0] > 28 ) && ( ( array_data[2] % 4 ) != 0 ) )
			erro = true;
		//Valido ano bissexto
		if ( ( array_data[0] > 29 ) && ( ( array_data[2] % 4 ) == 0 ) )
			erro = true;
	}
	if ( erro ) {
		alert("Data Inválida");
		$Get('data').focus();
	}
}

//Funcao para validar os Comentarios
function valida_comentario() {
	if ( $Get('author').value == '' ) {
		alert("O NOME e campo obrigatorio!");
		$Get('author').focus();
		return false;
	}
	if ( $Get('email').value == '' ) {
		alert("O E-MAIL e campo obrigatorio!");
		$Get('email').focus();
		return false;
	}
	else {
		var ExpReg = new RegExp("[A-Za-z0-9_.-]+@([A-Za-z0-9_]+\.)+[A-Za-z]{2,4}");
		if ( $Get('email').value.search(ExpReg) == -1 ) {
			alert("O E-MAIL e invalido!");
			$Get('email').focus();
			return false;
		}
	}
	if ( $Get('comment').value == '' ) {
		alert("O COMENTARIO e campo obrigatorio!");
		$Get('comment').focus();
		return false;
	}
	return true;
}

//Funcao para validar o Contato
function valida_contato() {
	if ( $Get('nome').value == '' ) {
		alert("O NOME e campo obrigatorio!");
		$Get('nome').focus();
		return false;
	}
	if ( $Get('email').value == '' ) {
		alert("O E-MAIL e campo obrigatorio!");
		$Get('email').focus();
		return false;
	}
	else {
		var ExpReg = new RegExp("[A-Za-z0-9_.-]+@([A-Za-z0-9_]+\.)+[A-Za-z]{2,4}");
		if ( $Get('email').value.search(ExpReg) == -1 ) {
			alert("O E-MAIL e invalido!");
			$Get('email').focus();
			return false;
		}
	}
	if ( $Get('comentariopost').value == '' ) {
		alert("O COMENTARIO e campo obrigatorio!");
		$Get('comentariopost').focus();
		return false;
	}
	return true;
}

function VisualizarImagem( imagem, title ) {
	PositionX = 0;
	PositionY = 0;
	window.open('http://www.japs.etc.br/imagem.php?imagem=' + imagem + '&title=' + title, '', 'resizable=1,scrollbars=no,width=100,height=100,left='+PositionX+',top='+PositionY);
}


function SearchValue()
{
	var sValue = document.getElementById("s");

	if(sValue.value == "Buscar no Blog por...")
	{
		sValue.value = "";
	}	
	else if(sValue.value == "")
	{
		sValue.value = "Buscar no Blog por...";
	}	
		
}



  $(document).ready(function()
	{
	
	 $(".entry").each(function()
	 {						
		if($(this).children("h1").text().length >= 43 || $(this).children("h1").text().indexOf("Calma eu explico") != "-1")
		{
			$(this).addClass("lines2");	 	
		}			
				
	 })
	 	
		$(".txtfield").bind("focus", function()
		{			
			$(this).addClass("textActive");						
		});		
		
		$(".txtfield").bind("blur", function()
		{			
			$(this).removeClass("textActive");
		});		
				
				
		$(".comment:odd").addClass("commentPar");		
		
		
		if( $(".wpcf7-mail-sent-ok").length != 0 )
		{
			$(".wpcf7-form").hide();
		}
				
  })
