function abreLink(pag)
{
    document.location = pag;
}
function abreLinkParent(pag)
{
	window.opener.document.location = pag;
	window.close();
}
function popup(url, largura, altura, scroll, resizable) {
  var posicaoX = (screen.availWidth - largura) / 2;
  var posicaoY = (screen.availHeight - altura) / 2;

  janelaPopup = window.open(url, 'popup', 'status=no,resizable=' + resizable + ',scrollbars=' + scroll + ',menubar=no,width=' + largura + ',height=' + altura + ',left=' + posicaoX + ',top=' + posicaoY);
  janelaPopup.focus();
}
function abreCruzamento()
{
	var idCavalo = document.getElementById('ctl00_cphConteudo_listGaranhoes').value;
	var idEgua = document.getElementById('ctl00_cphConteudo_listEgua').value;

	if(idCavalo=='' || idEgua=='')
		alert('Escolha um Cavalo');
	else
        popUpCruzamento(idCavalo,idEgua);
}
//
function popUpAviso(pag,largura,altura)
{
	var posX=(screen.availWidth-largura)/2;
	var posY=(screen.availHeight-altura)/2;		

	windowAviso = window.open('../popUps/'+pag,'Aviso','status=no,resizable=no,scrollbars=no,menubar=no,width='+largura+',height='+altura+',left='+posX+',top='+posY);
	windowAviso.focus();
}
//
function popUpSenha(pag,largura,altura)
{
	var posX=(screen.availWidth-largura)/2;
	var posY=(screen.availHeight-altura)/2;		

	windowAviso = window.open(pag,'Aviso','status=no,resizable=no,scrollbars=no,menubar=no,width='+largura+',height='+altura+',left='+posX+',top='+posY);
	windowAviso.focus();
}
//
function popUpGene(idCavalo) {
  var largura = 740;
  var altura = 500;
  var posX = (screen.availWidth - largura) / 2;
  var posY = (screen.availHeight - altura) / 2;

  windowCavalo = window.open('../consultaGen/Genealogia.aspx?idCavalo=' + idCavalo, 'Genealogia', 'status=no,resizable=no,scrollbars=yes,menubar=no,width=' + largura + ',height=' + altura + ',left=' + posX + ',top=' + posY);
  windowCavalo.focus();
}
//
function popUpRegistro(Registro) {
  var largura = 740;
  var altura = 500;
  var posX = (screen.availWidth - largura) / 2;
  var posY = (screen.availHeight - altura) / 2;

  windowCavalo = window.open('../consultaGen/Genealogia.aspx?Registro=' + Registro, 'Genealogia', 'status=no,resizable=no,scrollbars=yes,menubar=no,width=' + largura + ',height=' + altura + ',left=' + posX + ',top=' + posY);
  windowCavalo.focus();
}
//
function popUpCruzamento(idCavalo,idEgua)
{
	var largura=740;
	var altura=500;
	var posX=(screen.availWidth-largura)/2;
	var posY=(screen.availHeight-altura)/2;		

	windowCavalo  = window.open('../cruzamento/Genealogia.aspx?idCavalo='+idCavalo+'&idEgua='+idEgua,'CruzamentoVirtual','status=no,resizable=no,scrollbars=yes,menubar=no,width='+largura+',height='+altura+',left='+posX+',top='+posY);
	windowCavalo.focus();
}
//
function downloadArquivo(alvo, objetoSelecionado) {
    eval(alvo + ".location='" + objetoSelecionado.options[objetoSelecionado.selectedIndex].value + "'");

}
//
function newDownloadArquivo(objetoSelecionado) {
    window.open(objetoSelecionado.options[objetoSelecionado.selectedIndex].value);
    objetoSelecionado.selectedIndex = 0;
}
//
function enviaFormGene() {
    document.forms[0].submit();
}
//

function testaVoto(meuForm)
{
	var retorno = false;
	for(i=0;i<aspnetForm.opcCavalo.length;i++)
	{			
		if(aspnetForm.opcCavalo[i].checked)
		{
			retorno = true;
			break;
		}	
	}
    
    if (retorno==false)
        alert('Selecione uma das opcoes');
            
    return retorno;
}

function logIn()
{
  if(document.getElementById("txtLogin").value.length == 0)
  {
    alert("Digite seu usuario!");
    document.getElementById("txtLogin").focus();
    return;
  }
  else
  {
    if(document.getElementById("txtSenha").value.length == 0)
    {
      alert("Digite sua senha!");
      document.getElementById("txtSenha").focus();
      return;
    }
    else
    {
      document.location.href = "../login/login.aspx?user=" + document.getElementById("txtLogin").value + "&pass=" + document.getElementById("txtSenha").value;
    }
  }
}

function checkEquestre()
{
  if(document.getElementById('ctl00_cphConteudo_rbEquestreSim').checked)
  {
    document.getElementById('divModalidade').style.display = "block";
    document.getElementById('divCategoria').style.display = "block";    
    document.getElementById('ctl00_cphConteudo_txtModalidade').focus();
  }
  else
  {
    document.getElementById('ctl00_cphConteudo_txtModalidade').value = "";
    document.getElementById('ctl00_cphConteudo_txtCategoria').value = "";
    document.getElementById('divModalidade').style.display = "none";
    document.getElementById('divCategoria').style.display = "none";    
  }
}

function checkFiliado()
{
  if(document.getElementById('ctl00_cphConteudo_rbFiliadoSim').checked)
  {
    document.getElementById('divEntidade').style.display = "block";
    document.getElementById('ctl00_cphConteudo_txtEntidade').focus();
  }
  else
  {
    document.getElementById('ctl00_cphConteudo_txtEntidade').value = "";
    document.getElementById('divEntidade').style.display = "none"; 
  }
}

function checkCavalos()
{
  if(document.getElementById('ctl00_cphConteudo_rbCavalosSim').checked)
  {
    document.getElementById('divQuantidade').style.display = "block";
    document.getElementById('divRaca').style.display = "block";    
    document.getElementById('ctl00_cphConteudo_txtQuantidadeCavalos').focus();
  }
  else
  {
    document.getElementById('ctl00_cphConteudo_txtQuantidadeCavalos').value = "";
    document.getElementById('ctl00_cphConteudo_txtRaca').value = "";
    document.getElementById('divQuantidade').style.display = "none";
    document.getElementById('divRaca').style.display = "none";    
  }
}

/*
FUNÇÕES UTILIZADAS PARA DEIXAR UM TEXTO FIXO NO TEXTBOX
*/
function limpaCampo(campo, msg) {
    if (campo.value == msg) {
        campo.value = "";
    }
}

function retornaCampo(campo, msg) {
    if (campo.value.length == 0) {
        campo.value = msg;
    }
}
/*
*/

/*
FUNÇÕES UTILIZADAS PARA TROCAR SLIDES
*/
var time;
function carregaSlide(slide, arrSlides) {

    clearTimeout(time);

    if (slide > arrSlides.length - 1) {
        slide = 0;
    }
    slideAtual = slide;

    document.getElementById("linkDest0").className = "";
    document.getElementById("linkDest1").className = "";
    document.getElementById("linkDest2").className = "";
    document.getElementById("linkDest3").className = "";
    document.getElementById("linkDest4").className = "";

    document.getElementById("linkDest" + slideAtual).className = "aDestHover";

    document.getElementById("lojaDestaques").style.background = "url(" + arrSlides[slideAtual] + ") no-repeat";

    time = setTimeout("carregaSlide(slideAtual+1, arrSlides);", 5000);
}
/*
*/



function isNum(caractere)
{
    var strValidos = "0123456789"

    if (strValidos.indexOf(caractere) == -1)
    {
        return false;
    }
    else
    {
        return true;
    }
}

function validaTecla(campo, event)
{
    var key;
    var tecla;

    CheckTAB = true;

    if (navigator.appName.indexOf("Netscape") != -1)
    {
        tecla = event.which;
    }
    else
    {
        if (event.keyCode == 44)
        {
            event.keyCode = 46;
        }

        tecla = event.keyCode;
    }

    key = String.fromCharCode(tecla);
    //alert( 'key: ' + tecla + ' -> campo: ' + campo.value);
    if (tecla == 13)
    {
        return false;
    }

    if (tecla == 8 || tecla == 0 || tecla == 9)
    {
        return true;
    }

    return (isNum(key));
  }

  function soNumero(event) {
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    //alert('keyCode='+keyCode);
    if ((keyCode > 47 && keyCode < 58) || keyCode == 8 || keyCode == 9) return true;
    else return false;
  }