window.onload = function()
{    
    fctDivTamanho();
}

function fctDivTamanho()
{   
    try
    {
        if(document.getElementById("cont_centro_geral").offsetHeight > document.getElementById("cont_esq").offsetHeight)
        {
            document.getElementById("cont_esq").style.height = (document.getElementById("cont_centro_geral").offsetHeight + 10) + 'px';
        }
        else
        {
            if(document.getElementById("cont_esq").offsetHeight > document.getElementById("cont_centro_geral").offsetHeight)
            {
                document.getElementById("cont_centro_mid").style.height = (document.getElementById("cont_esq").offsetHeight - 40 - document.getElementById("cont_centro_top").offsetHeight - document.getElementById("cont_centro_bot").offsetHeight) + 'px';
            }
        }
    }
    catch(e){
        if(document.getElementById("cont_centro_mid")==null)
        try{
            
            if(document.getElementById("cont_centro_geral").offsetHeight > document.getElementById("cont_esq").offsetHeight)
            {
                document.getElementById("cont_esq").style.height = (document.getElementById("cont_centro_geral").offsetHeight + 10) + 'px';
            }
            else
            {
                if(document.getElementById("cont_esq").offsetHeight > document.getElementById("cont_centro_geral").offsetHeight)
                {
                    document.getElementById("cont_centro_mid_2").style.height = (document.getElementById("cont_esq").offsetHeight - 40 - document.getElementById("cont_centro_top_2").offsetHeight - document.getElementById("cont_centro_bot_2").offsetHeight) + 'px';
                }
            }    
        }
        catch(e){}
    }
}

function FormatDate(oEvent)
{
	var oCampo, inteCodigo;
	if (window.event)
	{
		oCampo	=	oEvent.srcElement;
		inteCodigo = oEvent.keyCode;
	}
	else
	{
		oCampo	=	oEvent.target;
		inteCodigo = oEvent.which;
	}
	
	if ((inteCodigo > 47 && inteCodigo < 58) || inteCodigo == 8 || inteCodigo == 9 || (inteCodigo == 37 && !oEvent.shiftKey) || inteCodigo == 39)
	{
		if (oCampo.value.length == 10 && inteCodigo != 8)
			return false;
		
		if (((oCampo.value.length==2)||(oCampo.value.length==5)) && inteCodigo != 8)
			oCampo.value += "/";
		
	}
	else
	{
		return false
	}
}

function formatar(src, mask)
{
    var i = src.value.length;
    var saida = mask.substring(0,1);
    var texto = mask.substring(i)
    if (texto.substring(0,1) != saida)
    {
            src.value += texto.substring(0,1);
    }
}

/*
|----------------------------------------------------------------------------------------------------|
|           Função: Request()                                                              |
|        Descrição: Solicita a página via Ajax                                       |
|  ================================================ |
|       Parâmetros: url : string   														|
|           Evento: onclick                                                                  |
|  Tipo de Retorno: string                                                                |
|  ================================================  |
|           Criado: 14/02/2008 | Por: Rafael Une					                |
|----------------------------------------------------------------------------------------------------|
*/
function Request(url_send)
{
    new Ajax(url_send, {
		method: 'get',
		update: $('popup_content'),
		//evento realizado apos obter uma resposta a solicitação
		onComplete: function() {
		},
		onFailure: function() {
		}
	}).request();
}

/*
|----------------------------------------------------------------------------------------------------|
|           Função: Close()                                                              |
|        Descrição: Solicita a página via Ajax                                       |
|  ================================================ |
|       Parâmetros: url : string   														|
|           Evento: onclick                                                                  |
|  Tipo de Retorno: void	                                                                |
|  ================================================  |
|           Criado: 14/02/2008 | Por: Rafael Une					                |
|----------------------------------------------------------------------------------------------------|
*/
function Close(element_id)
{
	$(element_id).innerHTML = '';
}

//--------------------------------------------------------------------------//
// VersaoParaImpressao()										//
// Função que imprime a página								//
// Criado por: Rafael Une				Data: 14/02/2008  //
// Modificado por:                 Em: __/__/____		  //
//------------------------------------------------------------------------//
function VersaoParaImpressao(L_ROOT)
{    
    //Configurando as dimensões da janela
	var inteWindowWidth		= 700;
	var inteWindowHeight	= 500;
	//Recuperando a resolução do clienye
	var inteWidth			= screen.width;
	var inteHeight			= screen.height;
	//Configurando a posição da janela
	var inteWindowTop		= ((inteHeight - inteWindowHeight)/2);
	var inteWindowLeft		= ((inteWidth - inteWindowWidth)/2);
	//Abrindo a janela com as configurações anteriores
	var oPopup	= window.open(L_ROOT + '/Imprimir.aspx', 'VersaoParaImpressao', 'top='+ inteWindowTop +', left='+ inteWindowLeft +', width='+ inteWindowWidth +', height='+ inteWindowHeight +', scrollbars=1');
	
	oPopup.focus();
	
	return false;
}

function teste()
{
    var inteWidth = screen.width;
    
    alert(inteWidth);
}

/*
|----------------------------------------------------------------------------------------------------|
|           Função: OnlyNumbersData()                                                                |
|        Descrição: Permite somente números entre 0 e 9 e as "/" para data.                          |
|  ================================================================================================  |
|       Parâmetros: oEvent = Objeto event, necessário para funcionar Cross-Browser                   |
|           Evento: onkeypress                                                                       |
|  Tipo de Retorno: void                                                                             |
|  ================================================================================================  |
|           Criado: 19/02/2008 | Por: Clayton Caliari                                                |
|       Modificado: __/__/____ | Por:                                                                |
|----------------------------------------------------------------------------------------------------|
*/
function OnlyNumbersData(src, mask, oEvent)
{
    var oRegExp = /[0-9]/;
    var tecla_codigo;
    var tecla_char;
    
    if (oEvent.keyCode)
        tecla_codigo = oEvent.keyCode;
    else if (oEvent.which)
        tecla_codigo = oEvent.which;
    
    tecla_char = String.fromCharCode(tecla_codigo);
    
    var i = src.value.length;
    var saida = mask.substring(0,1);
    var texto = mask.substring(i);
    if (texto.substring(0,1) != saida)
    {
        if (tecla_codigo != 8)
            src.value += texto.substring(0,1);
    }
        
    //Permite algumas teclas
    if (tecla_codigo == 8 || tecla_codigo == 9 || (tecla_codigo == 35 && oEvent.shiftKey) || (tecla_codigo == 36 && oEvent.shiftKey) || (tecla_codigo == 37 && (oEvent.shiftKey || tecla_char != '%')) || (tecla_codigo == 39 && tecla_char != "'") || (tecla_codigo == 46 && tecla_char != '.') || (tecla_codigo == 47))
    {                
        return true;
    }
    //Se for número
    else if (!oRegExp.test(tecla_char))
        return false;
    //Se não for número
    else
        return true;
}

//--------------------------------------------------------------------------//
// EnviarPagina()														//
// Função que envia a página									//
// Criado por: Rafael Une				Data: 14/02/2008  //
// Modificado por:                 Em: __/__/____		  //
//------------------------------------------------------------------------//
function EnviarPagina(L_ROOT,page)
{    
    //Configurando as dimensões da janela
	var inteWindowWidth		= 700;
	var inteWindowHeight	= 500;
	//Recuperando a resolução do clienye
	var inteWidth			= screen.width;
	var inteHeight			= screen.height;
	//Configurando a posição da janela
	var inteWindowTop		= ((inteHeight - inteWindowHeight)/2);
	var inteWindowLeft		= ((inteWidth - inteWindowWidth)/2);
	//Abrindo a janela com as configurações anteriores
	var oPopup	= window.open(L_ROOT + '/EnviarPagina.aspx?page=' + page, 'VersaoParaImpressao', 'top='+ inteWindowTop +', left='+ inteWindowLeft +', width='+ inteWindowWidth +', height='+ inteWindowHeight +', scrollbars=1');
	
	oPopup.focus();
	
	return false;
}

//--------------------------------------------------------------------//
// ValidarEmail()                                                    //
// Função que valida o formulário de envio de e-mail //
// Criado por: Rafael Une				Data: 14/02/2008  //
// Modificado por:                 Em: __/__/____    //
//----------------------------------------------------------------//
function ValidarEmail()
{
    if(document.getElementById('txtRemetente').value == "")
    {
        alert('Por favor, informe seu nome');
        document.getElementById('txtRemetente').focus();
        return false;
    }
    
    if(document.getElementById('txtEmailRemetente').value == "")
    {
        alert('Por favor, informe seu e-mail')
        document.getElementById('txtEmailRemetente').focus();
        return false;
    }
    else
    {
        if(!document.getElementById('txtEmailRemetente').value.isValidEmail())
        {
            alert('Por favor, informe um e-mail válido')
            document.getElementById('txtEmailRemetente').select();
            return false;
        }
    }
    if(document.getElementById('txtDestinatario1').value == "")
    {
        alert('Por favor, informe o nome do destinatário');
        document.getElementById('txtDestinatario1').focus();
        return false;
    }
    
    if(document.getElementById('txtEmailDestinatario1').value == "")
    {
        alert('Por favor, informe o e-mail do destinatário');
        document.getElementById('txtEmailDestinatario1').focus();
        return false;
    }
    else
    {
        if(!document.getElementById('txtEmailDestinatario1').value.isValidEmail())
        {
            alert('Por favor, informe um e-mail válido')
            document.getElementById('txtEmailDestinatario1').select();
            return false;
        }
    }
   if(document.getElementById('txtDestinatario2').value != "" && document.getElementById('txtEmailDestinatario2').value=="")
    {
        alert('Por favor, informe o e-mail do segundo destinatário');
        document.getElementById('txtEmailDestinatario2').focus();
        return false;
    }
    else
    {
        if(document.getElementById('txtDestinatario2').value == "" && document.getElementById('txtEmailDestinatario2').value!="")
        {
            alert('Por favor, informe o nome do segundo destinatário');
            document.getElementById('txtDestinatario2').focus();
            return false;
        }
        else
        {
             if(document.getElementById('txtDestinatario2').value != "" && document.getElementById('txtEmailDestinatario2').value!="")
            {
                if(!document.getElementById('txtEmailDestinatario2').value.isValidEmail())
                {
                    alert('Por favor, informe um e-mail válido')
                    document.getElementById('txtEmailDestinatario2').select();
                    return false;
                }
            }
        }
    } 
    if(document.getElementById('txtDestinatario3').value != "" && document.getElementById('txtEmailDestinatario3').value=="")
    {
        alert('Por favor, informe o e-mail do terceiro destinatário');
        document.getElementById('txtEmailDestinatario3').focus();
        return false;
    }
    else
    {
        if(document.getElementById('txtDestinatario3').value == "" && document.getElementById('txtEmailDestinatario3').value!="")
        {
            alert('Por favor, informe o nome do terceiro destinatário');
            document.getElementById('txtDestinatario3').focus();
            return false;
        }
        else
        {
             if(document.getElementById('txtDestinatario3').value != "" && document.getElementById('txtEmailDestinatario3').value!="")
            {
                
                if(!document.getElementById('txtEmailDestinatario3').value.isValidEmail())
                {
                    alert('Por favor, informe um e-mail válido')
                    document.getElementById('txtEmailDestinatario3').select();
                    return false;
                }
            }
        }
    }
    if(document.getElementById('txtComentario').value.isEmpty())
    {
        alert('Por favor, insira o seu comentario!');
        document.getElementById('txtComentario').focus();
        return false;
    }
}

//-----------------------------------------------//
// Request()                                    //
// Ajusta tamanho da fonte                       //
// Criado por: Rafael Une Data: 19/02/2008    //
// Modificado por:             Em: __/__/____    //
//-----------------------------------------------//
function Request(url_send)
{
    new Ajax(url_send, {
		method: 'get',
		update: $('clipping_content'),
		onComplete: function() {
		},
		onFailure: function() {
		}
	}).request();
}

