//**** Função mouseOver ****
function mouseOver(imageName)
{
	document[imageName].src = "img/" + imageName + "_on.gif";
}


//**** Função mouseOut ****
function mouseOut(imageName)
{
	document[imageName].src = "img/" + imageName + ".gif";
}


//**** Função para exibir a descrição dos programas, esconde e exibe divs ****
function showProgram(prg)
{
	var displayPrg = document.getElementById(prg).style.display;

	for (i=1; i<9; i++){
		document.getElementById('prg'+i).style.display = 'none';
	}
	if (displayPrg == ''){
		document.getElementById(prg).style.display = 'none';
	}
	else{
		document.getElementById(prg).style.display = '';
	}
}


//**** Função para limpar o value dos campos ****
function limparTexto(obj){
	if(obj!=null)
			obj.value ='';
}

$(document).ready(function () {

    //$("#campoNasc").mask("99/99/9999");
    //$("#campoTel").mask("(99) 9999-9999");
    //$("#campoCel").mask("(99) 9999-9999");
    //$("#campoCep").mask("99999-999");

    $('.campo_reset').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('.campo_reset').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoNome').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoNome').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoNasc').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoNasc').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoTel').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoTel').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoCel').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoCel').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoEmail').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoEmail').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoProf').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoProf').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoEnd').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoEnd').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoCep').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoCep').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoUF').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoUF').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#campoHobby').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#campoHobby').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#siteEntrevista').focus(function () {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#siteEntrevista').blur(function () {
        if ($.trim(this.value) == '') {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    $('#cb_outro').click(function () {
        if ($(this).is(":checked")) {
            $(this).next().removeAttr("disabled");
        } else
            $(this).next().attr("disabled", "disabled");

    })

});


//**** Função para enviar o formulário de contato ****
function enviarContato(){
	if((document.frm.nome.value=='')||(document.frm.nome.value=='Nome')){
		alert('Preencha corretamente o campo Nome.');
		document.frm.nome.focus();
	}
	else if((document.frm.telefone.value=='')||(document.frm.telefone.value=='Telefone')){
		alert('Preencha corretamente o campo Telefone.');
		document.frm.telefone.focus();
	}
	else if(!checkMail()){
		alert('Preencha corretamente o campo E-mail.');
		document.frm.email.focus();
	}
	else if((document.frm.mensagem.value=='')||(document.frm.mensagem.value=='Mensagem')){
		alert('Escreva uma mensagem.');
		document.frm.mensagem.focus();
	}
	else {
		document.frm.action='contato_feedback.asp';
		document.frm.submit();
	}
}


//**** Função para validar email ****
function checkMail(){
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if(typeof(document.frm.email.value) == "string"){
		if(er.test(document.frm.email.value)){
			return true;
		}
	}else if(typeof(document.frm.email.value) == "object"){
		if(er.test(document.frm.email.value)){ 
			return true; 
		}
	}else{
		return false;
		}
}


//**** Função que permite apenas a digitação de números em um campo ****
function somenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
    
	if (tecla >95 && tecla<106)
	    return true;

    if (tecla == 9)
        return true;
		    
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if ((tecla != 8)&& (tecla != 16) && (tecla != 37) && (tecla != 39) && (tecla != 46) && (tecla != 35) && (tecla != 36)) return false;
    else return true;
    }
}


function somenteDTnasc(e) {    
    var tecla = (window.event) ? event.keyCode : e.which;    
    if (tecla > 95 && tecla < 106)
        return true;

    if (tecla == 9)
        return true;

    if ((tecla > 47 && tecla < 58) || (tecla == 193)) return true;
    else {
        if ((tecla != 8) && (tecla != 16) && (tecla != 37) && (tecla != 39) && (tecla != 46) && (tecla != 35) && (tecla != 36)) return false;
        else return true;
    }
}

function somenteTel(e) {
    var tecla = (window.event) ? event.keyCode : e.which;
    if (tecla > 95 && tecla < 106)
        return true;

    if (tecla == 9)
        return true;

    if ((tecla > 47 && tecla < 58) || (tecla == 109)) return true;
    else {
        if ((tecla != 8) && (tecla != 16) && (tecla != 37) && (tecla != 39) && (tecla != 46) && (tecla != 35) && (tecla != 36)) return false;
        else return true;
    }
}


//**** Função que permite apenas a digitação de letras em um campo ****
function somenteLetras(e){
    var tecla=(window.event)?event.keyCode:e.which;
       
	if (tecla >96 && tecla<105)
		return false;
   
	if (( tecla < 47 || tecla > 58 )) return true;
    else{
		if (tecla != 8) 
			return false;
		else 
			return true;
    }
}


//Função para determinar o maxLength em campos textarea
function maxLength(textAreaField, limit) {
	var ta = document.getElementById(textAreaField);
	
	if (ta.value.length >= limit) {
		ta.value = ta.value.substring(0, limit-1);
	}
}

//Função para abrir janela popup
function OpenWindow(pagina,largura,altura) {
	//pega a resolução do visitante
	w = screen.width;
	h = screen.height;
	
	//divide a resolução por 2, obtendo o centro do monitor
	meio_w = w/2;
	meio_h = h/2;
	
	//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
	altura2 = altura/2;
	largura2 = largura/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;
	
	//abre a nova janela, já com a sua devida posição
	self.open(pagina,'pop','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+''); 
}

