var const_WhiteChars = ' \t\n\r';

function fctCortina(obool){
	
}

$(document).ready(function () {
    //$('.menu_idioma').animate({opacity:'0.2'}, 1000);
});

var _down = true
function fctListaDownloads(lnk_id){
	
	if($('.ul_lista_downloads > li').length > 2){
		if(_down){
			$("#"+lnk_id).removeClass('lnkVerTodos').addClass('lnkVoltar');
			var height = $('.ul_lista_downloads > li').length * $('.ul_lista_downloads > li:eq(0)').outerHeight(true);
			$('.ul_lista_downloads').animate({height:height}, 500);
			_down = false;
		}else{
			$("#"+lnk_id).removeClass('lnkVoltar').addClass('lnkVerTodos');
			$('.ul_lista_downloads').animate({height:'150px'}, 500);
			_down = true;
		}
	}
}

var class_atual = "";
function Contato (div_class, a_class, o_lnk){
	if(class_atual != div_class){
		$(".lnkVendas").removeClass('on1');
		$(".lnkSuporte").removeClass('on2');
		$(".lnkCorporativo").removeClass('on3');
		$(".lnkCarreira").removeClass('on4');
		
		$(o_lnk).addClass(a_class);
		
		$(".contato_vendas").css({display:'none',opacity:'0'});
		$(".contato_suporte").css({display:'none',opacity:'0'});
		$(".contato_corporativo").css({display:'none',opacity:'0'});
		$(".contato_carreiras").css({display:'none',opacity:'0'});
		
		$("."+ div_class).css({display:'block'}).animate({opacity:'1'}, 800, function(){
			$("."+ div_class).attr('style', 'display:block')
		});
		class_atual = div_class;
	}
}

function ValidarNumero(sender){
	sender.onkeypress=function(e){
		var e=window.event || e;
		var keyunicode=e.charCode || e.keyCode;
		return (keyunicode>=48 && keyunicode<=57 || keyunicode==8 || keyunicode==9 || keyunicode==46 || keyunicode==37 || keyunicode==39);
	};
}


//------------------------------------------------------------------//
// ValidarEmail()                                                   //
// Função que valida o formulário de envio de e-mail                //
// Criado por: --                   	Data: 14/02/2008            //
// Modificado por: Rafael K. Une                Em: 13/08/2009      //
//------------------------------------------------------------------//
function ValidarEmail()
{
    if(document.getElementById('txtNome').value == "")
    {
        alert('O campo nome é obrigatório. \r\n The field name is mandatory. \r\n El campo nombre es obligatorio.');
        document.getElementById('txtNome').focus();
        return false;
    }
    
    if(document.getElementById('txtEmail').value == "")
    {
        alert('O campo e-mail é obrigatório. \r\n The field e-mail is mandatory. \r\n El campo de correo electrónico es obligatoria.')
        document.getElementById('txtEmail').focus();
        return false;
    }
    else
    {
        if(!document.getElementById('txtEmail').value.isValidEmail())
        {
            alert('O e-mail deve estar em um formato válido. \r\n Field email must be in a valid format. \r\n El campo de correo electrónico debe ser un formato válido.')
            document.getElementById('txtEmail').select();
            return false;
        }
    }
    if(document.getElementById('txtNomeDest1').value == "")
    {
        alert('O campo nome do destinatário é obrigatório. \r\n The field name of the receiver is required. \r\n El nombre del campo del destinatario es obligatorio.');
        document.getElementById('txtNomeDest1').focus();
        return false;
    }
    
    if(document.getElementById('txtEmailDes1').value == "")
    {
        alert('O campo e-mail do destinatário é obrigatório. \r\n The field e-mail of the receiver is required. \r\n El campo de destinatario de correo electrónico es obligatorio.');
        document.getElementById('txtEmailDes1').focus();
        return false;
    }
    else
    {
        if(!document.getElementById('txtEmailDes1').value.isValidEmail())
        {
            alert('O e-mail deve estar em um formato válido. \r\n The e-mail must be in a valid format. \r\n El correo electrónico debe estar en un formato válido.');
            document.getElementById('txtEmailDes1').select();
            return false;
        }
    }
   if(document.getElementById('txtNomeDest2').value != "" && document.getElementById('txtEmailDes2').value=="")
    {
        alert('O campo e-mail do destinatário é obrigatório. \r\n The field e-mail of the receiver is required. \r\n El campo de destinatario de correo electrónico es obligatorio.');
        document.getElementById('txtEmailDes2').focus();
        return false;
    }
    else
    {
        if(document.getElementById('txtNomeDest2').value == "" && document.getElementById('txtEmailDes2').value!="")
        {
            alert('O campo nome do destinatário é obrigatório. \r\n The field name of the receiver is required. \r\n El nombre del campo del destinatario es obligatorio.');
            document.getElementById('txtNomeDest2').focus();
            return false;
        }
        else
        {
             if(document.getElementById('txtNomeDest2').value != "" && document.getElementById('txtEmailDes2').value!="")
            {
                if(!document.getElementById('txtEmailDes2').value.isValidEmail())
                {
                    alert('O e-mail deve estar em um formato válido. \r\n The e-mail must be in a valid format. \r\n El correo electrónico debe estar en un formato válido.');
                    document.getElementById('txtEmailDes2').select();
                    return false;
                }
            }
        }
    } 
    if(document.getElementById('txtNomeDest3').value != "" && document.getElementById('txtEmailDes3').value=="")
    {
        alert('O campo e-mail do destinatário é obrigatório. \r\n The field e-mail of the receiver is required. \r\n El campo de destinatario de correo electrónico es obligatorio.');
        document.getElementById('txtEmailDes3').focus();
        return false;
    }
    else
    {
        if(document.getElementById('txtNomeDest3').value == "" && document.getElementById('txtEmailDes3').value!="")
        {
            alert('O campo nome do destinatário é obrigatório. \r\n The field name of the receiver is required. \r\n El nombre del campo del destinatario es obligatorio.');
            document.getElementById('txtNomeDest3').focus();
            return false;
        }
        else
        {
             if(document.getElementById('txtNomeDest3').value != "" && document.getElementById('txtEmailDes3').value!="")
            {
                
                if(!document.getElementById('txtEmailDes3').value.isValidEmail())
                {
                    alert('O e-mail deve estar em um formato válido. \r\n The e-mail must be in a valid format. \r\n El correo electrónico debe estar en un formato válido.');
                    document.getElementById('txtEmailDes3').select();
                    return false;
                }
            }
        }
    }
    if(document.getElementById('txtComentario').value.isEmpty())
    {
        alert('O campo comentário é obrigatório. \r\n The field commentary is mandatory. \r\n El campo de comentario es obligatorio.');
        document.getElementById('txtComentario').focus();
        return false;
    }
}


String.prototype.isValidEmail = function(){
	pattern = new RegExp("^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([a-z,A-Z]){2,3}([0-9,a-z,A-Z])?$");
	if(this.search(pattern) == -1)
		return false;
	else
		return true;
}

// isEmpty() //
String.prototype.isEmpty = function(){
	var iCount, sChar;
	if(this==null || this.length<=0)
		return true;
	for(iCount=0; iCount<this.length; iCount++){
		sChar = this.charAt(iCount);
		if(const_WhiteChars.indexOf(sChar)==-1) return false;
	}
	return true;
}