﻿// JScript File
//--------------------Constantes-------------------------
var MSG_CONFIRMAR_ALTERACAO = "Confirma alteração?"; 
var MSG_CONFIRMAR_INCLUSAO = "Confirma inclusão?"; 
var MSG_CONFIRMAR_EXCLUSAO = "Confirma exclusão?"; 
var DIV_INFO = "DivErro";

function SubmeterFormulario(){
    document.forms[0].submit();
}
function Mensagem(mensagem){
    window.alert(mensagem);
}
function Confirmar(mensagem){
    return confirm(mensagem);
}
function ConfirmarAlteracao(){
    return Confirmar(MSG_CONFIRMAR_ALTERACAO);
}
function ConfirmarInclusao(){
    return Confirmar(MSG_CONFIRMAR_INCLUSAO);
}
function ConfirmarExclusao(){
    return Confirmar(MSG_CONFIRMAR_EXCLUSAO);
}

//Exibe ou oculta elemento
//vReturn - Se vai retornar true ou false - Para asp button
function ExibirOcultar(idTag, vReturn){
    //Testar em outros navegadores Netscape = show/hide
    //confirm(idTag);
    document.getElementById(idTag).style.visibility = (document.getElementById(idTag).style.visibility == "hidden") ? "visible" : "hidden";
    return vReturn;
}
function Exibir(idTag, vReturn){
    //Testar em outros navegadores Netscape = show/hide
    document.getElementById(idTag).style.visibility = "visible";
    return vReturn;
}
function Ocultar(idTag, vReturn){
    document.getElementById(idTag).style.visibility = "hidden";
    return vReturn;
}

function CheckMarcarTodos(braapID, obj){
    for (i=0; i< document.forms[0].length; i++){
        
		if (document.forms[0].elements[i].getAttribute("BrappID") == braapID)
		{
		    if (document.forms[0].elements[i].disabled == false)
		    document.forms[0].elements[i].checked = obj.checked;
		}
	}
	return true;
}
function DesmarcaTodos(type, braapID, obj){
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == braapID)
		    if (document.forms[0].elements[i].type == type)
		        document.forms[0].elements[i].checked = false;
	}
    if (obj != null)
    obj.checked = true;
}
//Validar seleção de componente radio/checkbox
function ValidarSelecao(type, braapID){
    var flagSelecionado = false;
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == braapID)
		    if ((document.forms[0].elements[i].type == type) && (document.forms[0].elements[i].checked = true)){
		        flagSelecionado = true;
		        break;
		    }
	}
    return flagSelecionado;
}

/*
    Método que retorna à janela os valores dos elementos selecionados
    Quando mais de um elemento for selecionado (multi-seleção) as chaves
    são concatenadas com ";". Os valores que tiverem chaves compostas já
    estão concatenadas com ",".
*/
function RetornarValorJanelaSelecaoGrid(braapID){
    var valor = "";
    var valor2 = "";
    for (i=0; i< document.forms[0].length; i++){
        valor2 = "";
		if (document.forms[0].elements[i].getAttribute("BrappID") == braapID){
		   //if (document.forms[0].elements[i].type == "checkbox"){
		      if (document.forms[0].elements[i].checked == true)
	            valor2 = document.forms[0].elements[i].value;
	       /*}
	       else {
	          if (document.forms[0].elements[i].checked == true)
	          valor2 = document.forms[0].elements[i].value;
	       }*/
		}
		if (valor2 != ""){
		    if (valor != "")
		        valor = valor + ";";
		    valor = valor + valor2;
		}
	}
	if (valor == ""){
	    Mensagem("Por favor selecione pelo menos um registro");
	} else {
	    //Mensagem(valor);
	    window.returnVal = valor;
	    //window.parent.returnVal = valor;
	    //Mensagem(valor);
	    FecharJanelaModal();
	}
	return false;
}

//Função do botão alterar para subcadastros
//braapID - BrappID do radio
//BrappIDHiddenAlterar - Hidden onde é armazenado o valor do objeto 
//que está sendo altarado
function BotaoAlterarInternoClick(braapID, brappIDHiddenAlterar){
    var js = "";
    var objSerializado = "";
    for (i=0; i< document.forms[0].length; i++)
    {
		if (document.forms[0].elements[i].getAttribute("BrappID") == braapID)
		{
		    if (document.forms[0].elements[i].checked == true)
		    {
		         js = document.forms[0].elements[i].getAttribute("BrappJS");
		         objSerializado = document.forms[0].elements[i].value;
		         break;
		    }
		 }
	}
	//Atribuindo o valor do hidden
	for (i=0; i< document.forms[0].length; i++)
    {
		if (document.forms[0].elements[i].getAttribute("BrappID") == brappIDHiddenAlterar)
		{
		    document.forms[0].elements[i].value = objSerializado;
		    break;
		 }
	}
	
	eval(js);
    return false;
}


//---------Funções de validação-----------------

//Verificar se o valor é vazio
function isEmpty(s) {   
	return ((s == null) || (s.length == 0))
}

//Verificar se é apenas espaços
function isWhitespace(s) {   
	var i;
    var whitespace = " \t\n\r";
    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++) {   
		var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;    
}
//Verificar se numérico
function isNumeric(s){
    var i;
    var c;
    if (isWhitespace(s)) return false;
	   for (i=0; i<s.length; i++){
 		c = s.charAt(i);
		if (!((c >= "0") && (c <= "9")))
			return false;
		}
	return true;
}

//Verificar se é boleano
function isBool(s){
    s = s.toUpperCase();
    if (s == "TRUE" || s == "FALSE" )
	    return true;
    else
	    return false;
}
//Verificar se é decimal
function isDecimal(s){
    var i,dotCounter;
    var c;
    dotCounter = 0;
    //if (isWhitespace(s)) return false;
	   for (i=0; i<s.length; i++){
 		c = s.charAt(i);
		if (!((c >= "0") && (c <= "9")))
		   if ((c !=",") && (c !="."))
			  return false;
		   else
		   	  ++dotCounter;
		}
		if (dotCounter > 1)
			return false;
		else if (dotCounter == s.length)
			return false;
	return true;
}
//Verifica se é uma data válida
function isDateValid(s){
	var i,j,k;
    var c;
    j = 0;
    k = 0;
    if (isWhitespace(s)) return false;
	   for (i=0; i<s.length; i++){
 		c = s.charAt(i);
 		if (!((c >= "0") && (c <= "9")))
			if (c!="/")
				return false;
			else
				if (k == 0)
					if ((i < 1) || (i > 2))
						return false;
					else
					{	
						var No;
						k = i;
						No = GetValue(s,0,i);
						if (!((No > 0) && (No<=31)))
							return false;
						else
							j +=1;	
					}	
				else
					if ((i-k-1)>2)
						return false;
					else
					{
						var No;
						No = GetValue(s,k+1,i);
						if (!((No > 0) && (No <= 12))) 
							return false;
						else
						{
							j +=1;
							if (j != 2)
								return false;
							k = i;
						}
					}
		}
		
		if (j != 2)
			return false;
			
		j = s.substring(k+1,s.length);
		if (j.length > 4 || j.length < 4 )
			return false;
	return true;
}

function GetValue(s,from,to)
{
	var Str,No;
	Str = s.substring(from,to);
	if (Str.length == 2)
	{
		No = (Str.charAt(0)-"0")*10;
		No +=(Str.charAt(1)-"0");
	}
	else
		No = (Str.charAt(0)-"0");
	
	return No;	
}

function MostraInfo(idTag,str){
    if (isEmpty(idTag))
    {
        alert(str);
    }
    else
    {
	    document.getElementById(idTag).innerHTML += str+"<br/>";
	    var v = Exibir(idTag, true);
	}
}
function LimpaInfo(idTag){
    document.getElementById(idTag).innerHTML = '';
    var v = Ocultar(idTag, true);
}

function Validate(fieldName,fieldValue,fieldMaxRange,fieldMinRange,fieldType,IsNullable,idTagErro)
{
    var error;
    
    if (IsNullable == false)
    {
        if (isEmpty(fieldValue))
           {
             error = "Campo "+ fieldName +" não deve ser vazio";
             MostraInfo(idTagErro,error);
             return false;
           }
        else
            if (isWhitespace(fieldValue))
            {
                error = "Campo "+ fieldName +" deve ter um valor válido";
                MostraInfo(idTagErro,error);
                return false;
            }
    } // end if IsRequired
   if (fieldValue.length != 0)
   {
		if (fieldType.search("bigint") != -1 || fieldType.search("int") != -1 || fieldType.search("Int16") != -1 || fieldType.search("Int32") != -1 || fieldType.search("Int64") != -1 || fieldType.search("Byte") != -1 || fieldType.search("UNSIGNEDLONG") != -1)
		   if (!isNumeric(fieldValue))
		   {
		         error = "Somente números são permitidos no campo "+ fieldName;
		         MostraInfo(idTagErro,error);
		         return false;
		   }
		   else if (!validateRange(fieldName,fieldValue,fieldMaxRange,fieldMinRange,fieldType))
				 return false;
				 
		if (fieldType.search("numeric") != -1 || fieldType.search("Single") != -1 || fieldType.search("Double") != -1 || fieldType.search("Decimal") != -1)
		    if (!isDecimal(fieldValue))
		     {
		         error = "Somente números ou ponto decimal são permitidos no campo "+ fieldName;
		         MostraInfo(idTagErro,error);
		         return false;
		     }
		     else if (!validateRange(fieldName,fieldValue,fieldMaxRange,fieldMinRange,fieldType))
				 return false;
		if (fieldType.search("datetime") != -1 || fieldType.search("DateTime") != -1)
		    if (!isDateValid(fieldValue))
		     {
		         error = "Por favor informe uma data válida no campo "+ fieldName + " (dd/mm/yyyy)";
		         MostraInfo(idTagErro,error);
		         return false;
		     }
		     else if (!validateRange(fieldName,fieldValue,fieldMaxRange,fieldMinRange,fieldType))
				 return false;
		if (fieldType.search("bit") != -1 || fieldType.search("boolean") != -1 || fieldType.search("bool") != -1 || fieldType.search("Boolean") != -1)
		    if (!isBool(fieldValue))
		     {
		         error = "Por favor inform um valor booleano no campo "+ fieldName + ".O valor pode ser 'true' or 'false'.";
		         MostraInfo(idTagErro,error);
		         return false;
		     }	
   }
   return true;
}// end validate

//Validando tamanho
function validateRange(Name,value,maxRange,minRange,type)
{
	if (maxRange == 0 && minRange == 0)
		return true;
	if (maxRange != 0)
	{
		if (type.search("Int16") != -1 || type.search("Int32") != -1 ||
			type.search("Int64") != -1 || type.search("Byte") != -1 ||
			type.search("Single") != -1 || type.search("Double") != -1 ||
			type.search("Decimal") != -1)
		{
			if (value > maxRange)
			{
				error = "O tamnho máximo de " + Name + " não pode ser menor que " + maxRange;
			    MostraInfo(idTagErro,error);
			    return false;
			}
		}
		else if (type.search("UNSIGNEDLONG") != -1)
		{
			if (value < maxRange)
			{
				error = "Value of " + Name + " must be greater than 0";
			    MostraInfo(idTagErro,error);
			    return false;
			}
		}
	}
	if (minRange != 0)
	{
		if (type.search("Int16") != -1 || type.search("Int32") != -1 ||
			type.search("Int64") != -1 || type.search("Byte") != -1 ||
			type.search("Single") != -1 || type.search("Double") != -1 ||
			type.search("Decimal") != -1)
		{
			if (value < minRange)
			{
				error = "Value of " + Name + " must be greater than " + minRange;
			    MostraInfo(idTagErro,error);
			    return false;
			}
		}
		else if (type.search("UNSIGNEDLONG") != -1)
		{
			if (value < minRange)
			{
				error = "Value of " + Name + " must be greater than 0";
			    MostraInfo(idTagErro,error);
			    return false;
			}
		}
	}
	return true;
}

function TimeStampValidation(value)
{
	var stringArray,date,time;
	if (value.length < 14)
	   return false;
	stringArray = value.split(" ");
	if (stringArray.length > 2 || stringArray.length == 1)
	   return false;
        date = stringArray[0].split("-");
	time = stringArray[1].split(":");
   	if (date.length == 3)
      	{
	   var month,day;
           if (date[0].length != 4)
	      return false;
           else if (!isNumeric(date[0]))
	      return false;
           if (date[1].length > 2)
              return false;
	   else if (!isNumeric(date[1]))
	      return false;
	   else
	   {
		month = GetNo(date[1]);
                if (month == 0 || month > 12)
		    return false;
	   }
	   if (date[2].length > 2)
              return false;
	   else if (!isNumeric(date[2]))
	      return false;
	   else
	   {
		day = GetNo(date[2]);
                if (day == 0 || day > 31)
		    return false;
	   }	
        }
       else
	   return false;
       if (time.length == 3)
       {
	  var thour,tsec,tmin;
	  if (time[0].length > 2)
	     return false;
          else if (!isNumeric(time[0]))
	     return false;
          else
	   {
		thour = GetNo(time[0]);
                if (thour > 60)
		    return false;
	   }
	  if (time[1].length > 2)
            return false;
	  else if (!isNumeric(time[1]))
	    return false;
	  else
	   {
		tmin = GetNo(time[1]);
                if (tmin > 60)
		    return false;
	   }  
          if (time[2].length > 2)
	  {
	     var index;
	     index = time[2].indexOf(".");
	     if (index == -1)
	        return false;
	     else
	     {
		var second,milisecond;
		second = time[2].substring(0,index);
		milisecond = time[2].substring(index+1,time[2].length);
		if (second.length > 2 )
		   return false;
		else if (!isNumeric(second))
	   	   return false;
		else
	        {
		   tsec = GetNo(time[2]);
                   if (tsec > 60)
		      return false;
	        }
                if (milisecond.length == 0)
		   return false;
		else if (milisecond.length > 3)
		   return false;
		else if (!isNumeric(milisecond))
	   	   return false;
		}
	  }
	  else if (!isNumeric(time[2]))
	       return false;
          else
	   {
		tsec = GetNo(time[2]);
                if (tsec > 60)
		    return false;
	   }
       }
       else
	   return false;
       if (value.length != stringArray[0].length + stringArray[1].length + 1)
	  return false;
       if (value.search(date[0]) != 0)
	  return false;
       return true;
}

function validateTime(value)
{
    var stringArray;
	var hour,min,sec;
        if (value.length < 5)
	   return false;
	stringArray = value.split(":");
	if (stringArray.length != 3)
	   return false;
	else
	{
	   if (stringArray[0].length > 2)
	      return false;
           else if (!isNumeric(stringArray[0]))
	      return false;
           else
	   {
		hour = GetNo(stringArray[0]);
                if (hour > 60)
		    return false;
	   }
	   if (stringArray[1].length > 2)
              return false;
	   else if (!isNumeric(stringArray[1]))
	      return false;
           else
	   {
		min = GetNo(stringArray[1]);
                if (min > 60)
		    return false;
	   }
	   if (stringArray[2].length > 2)
              return false;
           else if (!isNumeric(stringArray[2]))
	      return false;
           else
	   {
		sec = GetNo(stringArray[2]);
                if (sec > 60)
		    return false;
	   }
	}
        return true;
}

function GetNo(s)
{
     var No;
     if (s.length == 2)
	{
		No = (s.charAt(0)-"0")*10;
		No +=(s.charAt(1)-"0");
	}
     else
		No = (s.charAt(0)-"0");
	return No;	
}

function GetDate()
{
    return Date();
}


function Formatar(campo, mask) {
 
    if(document.all) 
    { 
        key = event.keyCode; // Internet Explorer
    }
    else
    { 
        key = event.which;// Nestcape
    }

    if (key == 8) 
    {
        return true;
    }

    string = campo.value;  
    i = string.length;

    if (i < mask.length) 
    {
        if (mask.charAt(i) == '?') 
        {
            return (key > 47 && key < 58);
        } 
        else 
        {
            if (mask.charAt(i) == '!') {  return true;  }
  
            for (c = i; c < mask.length; c++) 
            {
                if (mask.charAt(c) != '?' && mask.charAt(c) != '!')
                    campo.value = campo.value + mask.charAt(c);
                else if (mask.charAt(c) == '!'){
                    return true;
                } else {
                    return (key > 47 && key < 58);
                }
            }
        }
    } else return false;
}


//---------Funções de Máscara-----------------
function filtraTecla(Objeto,event){
	var tecla;
	var key;
	var strValidos = "0123456789"
	tecla =  (navigator.appName.indexOf("Netscape")!= -1) ? event.which : event.keyCode;
	return (strValidos.indexOf(String.fromCharCode(tecla)) == -1) ? false : true;
}

function FormatarMoeda(campo, separador_mil, separador_dec, e){
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	
	
		var whichCode = (window.Event) ? e.which : e.keyCode;

	//if (whichCode == 13) return true; // Enter
	
	
	
	key = String.fromCharCode(whichCode); // Get key value from key code

	//if (strCheck.indexOf(key) == -1) return false; // Not a valid key

	len = campo.value.length;
	        
    //Mensagem(whichCode);
        
    if ((whichCode==8) || (whichCode == 9) || (whichCode == 0)|| (whichCode == 13)) 
    {
        return true;
    }
    else 
    {
        if (!filtraTecla(campo,e))
          return false;
	    for(i = 0; i < len; i++)
	    if ((campo.value.charAt(i) != '0') && (campo.value.charAt(i) != separador_dec)) break;

	    aux = '';
	    for(; i < len; i++)
	    if (strCheck.indexOf(campo.value.charAt(i))!=-1) aux += campo.value.charAt(i);

	    aux += key;
	    len = aux.length;

	    if (len == 0) campo.value = '';

	    if (len == 1) campo.value = '0'+ separador_dec + '0' + aux;

	    if (len == 2) campo.value = '0'+ separador_dec + aux;

	    if (len > 2)
	    {
		    aux2 = '';
		    for (j = 0, i = len - 3; i >= 0; i--)
		    {
			    if (j == 3)
			    {
				    aux2 += separador_mil;
				    j = 0;
			    }
			    aux2 += aux.charAt(i);
			    j++;
		    }

		    campo.value = '';
		    len2 = aux2.length;

		    for (i = len2 - 1; i >= 0; i--)
		    campo.value += aux2.charAt(i);
		    campo.value += separador_dec + aux.substr(len - 2, len);
	    }
	    return false;
	}
}



/*
    Função usada no onkeyPress
    Recebe o campo e a máscara
    Ex: ##/##/#### = 99/99/9999
*/
function FormatarCampo(objCampo, strMascara, tipoAlpha, e)
{
    
    //var intDigito = (window.Event) ? window.Event.which : event.keyCode;
    var intDigito = (window.Event) ? e.which : e.keyCode;
    //Mensagem('oi' + intDigito);
    
    // Expressão regular para validação de caractere dígitado.
    // São aceitos apenas números entre "0-9", são feitos dois testes pois existem "dois teclados numéricos" e seus caracteres ASCII são diferentes.
    var objER = /^(4[8-9]|5[0-7]|9[6-9]|10[0-5])$/;

    //Tamanho do campo
    var intTamanho   = objCampo.value.length;
    if ((intDigito != 8) && (intDigito != 0))
    {
        //Validando o tamanho do campo
        if (intTamanho < strMascara.length)
        {
            //if ((!tipoAlpha)&&(!objER.test(intDigito)))
            //    return false;
            if ((!tipoAlpha) && (!filtraTecla(objCampo,e)))
                    return false;  
            
            var strCaractere = '#';//strMascara.charAt(0);
            var strMascara   = strMascara.substring(intTamanho)

            if (strMascara.charAt(0) != strCaractere)
               objCampo.value += strMascara.charAt(0);
            
        } else {
            return false;
        }
    }
}


//---------Funções do sistema-----------------
//Fecha a janela modal
function FecharJanelaModal(){
    window.parent.hidePopWin(true);
    return false;
}

function ConfirmarSelecaoUnica(){
    var valorRetorno = "";
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "RadioSelect")
		   if (document.forms[0].elements[i].checked == true)
		        valorRetorno = document.forms[0].elements[i].value;
	}
	if (valorRetorno != ""){
	    window.returnVal = valorRetorno;
	    window.parent.hidePopWin(true);  
	} else {
	    
	}
	return false;
}

//Exibe informação ao carregar a página
function MostraInfoPaginaCarregada(){
    if (!isEmpty(document.forms[0].getAttribute("BrappStatus"))){
        var key = document.forms[0].getAttribute("BrappStatus");
        if (key == "IOK")
            MostraInfo(DIV_INFO,"Inclusao realizada");
        else if (key == "AOK")
            MostraInfo(DIV_INFO,Date() +": Alteração realizada");
        else if (key == "EOK")
            MostraInfo(DIV_INFO,"Exclusão realizada");
    }
}



//---------------------------------------Validações do negócio-----------------------------------------


//Validação dos campos do cadastro de evento
function ValidarEvento(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeEvento")
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoEvento(flagInclusao){
    var flagErro = ValidarEvento();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoEvento(flagInclusao){
    return ConfirmarExclusao();
}


//Validação dos campos do cadastro de evento
function ValidarHotel(NID){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbNomeHotel"+NID)){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbCNPJ"+NID)){
		    if (!Validate("CNPJ",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	    if (document.forms[0].elements[i].getAttribute("BrappID") == ("DropCidade"+NID)){
		    if (!Validate("cidade",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoHotel(flagInclusao, NID){
    var flagErro = ValidarHotel(NID);
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoHotel(flagInclusao){
    return ConfirmarExclusao();
}


//Validação dos campos do cadastro de caracteristica de unidade habitacional
function ValidarCaracteristicaUnidadeHabitacional(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeCaracteristicaUnidadeHabitacional")
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoCaracteristicaUnidadeHabitacional(flagInclusao){
    var flagErro = ValidarCaracteristicaUnidadeHabitacional();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoCaracteristicaUnidadeHabitacional(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de leito
function ValidarLeito(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeLeito"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbQuantidadeVaga"){
		    if (!Validate("quantidade de vaga",document.forms[0].elements[i].value,3,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoLeito(flagInclusao){
    var flagErro = ValidarLeito();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoLeito(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de motivo de cancelamento
function ValidarMotivoCancelamento(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeMotivoCancelamento"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoMotivoCancelamento(flagInclusao){
    var flagErro = ValidarMotivoCancelamento();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoMotivoCancelamento(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de produto
function ValidarProduto(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeProduto"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoProduto(flagInclusao){
    var flagErro = ValidarProduto();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoProduto(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro do tipo de divulgação de evento
function ValidarTipoDivulgacaoEvento(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeTipoDivulgacaoEvento"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoTipoDivulgacaoEvento(flagInclusao){
    var flagErro = ValidarTipoDivulgacaoEvento();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoTipoDivulgacaoEvento(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro do tipo de divulgação de evento
function ValidarTipoUnidadeHabitacional(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeTipoUnidadeHabitacional"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbSiglaTipoUnidadeHabitacional"){
		    if (!Validate("sigla",document.forms[0].elements[i].value,4,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbQuantidadeVagaTipoUnidadeHabitacional"){
		    if (!Validate("quantidade de vaga padrão",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoTipoUnidadeHabitacional(flagInclusao){
    var flagErro = ValidarTipoUnidadeHabitacional();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoTipoUnidadeHabitacional(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro do tipo de divulgação de evento
function ValidarEventoEdicao(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DropEventoEdicao"){
		    if (!Validate("nome",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNumeroEdicao"){
		    if (!Validate("numero edicao",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDataRealizacaoInicial"){
		    if (!Validate("data de realização inicial",document.forms[0].elements[i].value,10,0,"DateTime",false,DIV_INFO))
		        flagErro = true;
		}
		
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDataRealizacaoFinal"){
		    if (!Validate("data de realização final",document.forms[0].elements[i].value,10,0,"DateTime",false,DIV_INFO))
		        flagErro = true;
		}
		
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDataLimiteParticipacao"){
		    if (!Validate("data limite de participação",document.forms[0].elements[i].value,10,0,"DateTime",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDataLimiteParticipacao"){
		    if (!Validate("data limite de participação",document.forms[0].elements[i].value,10,0,"DateTime",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DropUF"){
		    if (!Validate("UF",document.forms[0].elements[i].value,2,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DropCidade"){
		     var valorCidade = document.forms[0].elements[i].value;
		     if (valorCidade == "0")
		        valorCidade = "";
		     if (!Validate("cidade",valorCidade,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoEventoEdicao(flagInclusao){
    
    var flagErro = ValidarEventoEdicao();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoEventoEdicao(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro do tipo de divulgação de evento
function ValidarEventoEdicaoAtividadeComplementar(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DropEventoEdicao"){
		    if (!Validate("evento",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNumeroEdicao"){
		    if (!Validate("numero edicao",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeEventoEdicaoAtividadeComplementar"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDescricaoEventoEdicaoAtividadeComplementar"){
		    if (!Validate("descrição",document.forms[0].elements[i].value,200,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDataRealizacaoInicial"){
		    if (!Validate("data de realização inicial",document.forms[0].elements[i].value,10,0,"DateTime",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDataRealizacaoFinal"){
		    if (!Validate("data de realização final",document.forms[0].elements[i].value,10,0,"DateTime",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbHoraInicial"){
		    if (!Validate("hora inicial",document.forms[0].elements[i].value,5,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbHoraFinal"){
		    if (!Validate("hora final",document.forms[0].elements[i].value,5,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoEventoEdicaoAtividadeComplementar(flagInclusao){
    var flagErro = ValidarEventoEdicaoAtividadeComplementar();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoEventoEdicaoAtividadeComplementar(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de alimentação da edição do evento
function ValidarEventoEdicaoAlimentacao(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DropEventoEdicao"){
		    if (!Validate("evento",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNumeroEdicao"){
		    if (!Validate("numero edicao",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeEventoEdicaoAlimentacao"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDescricaoEventoEdicaoAlimentacao"){
		    if (!Validate("descrição",document.forms[0].elements[i].value,200,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbValorUnitario"){
		    if (!Validate("valor unitario",document.forms[0].elements[i].value,10,0,"Decimal",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoEventoEdicaoAlimentacao(flagInclusao){
    var flagErro = ValidarEventoEdicaoAlimentacao();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoEventoEdicaoAlimentacao(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de inscrição da edição do evento
function ValidarEventoEdicaoInscricao(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DropEventoEdicao"){
		    if (!Validate("evento",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNumeroEdicao"){
		    if (!Validate("numero edicao",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeEventoEdicaoAlimentacao"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbDescricaoEventoEdicaoAlimentacao"){
		    if (!Validate("descrição",document.forms[0].elements[i].value,200,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbValorUnitario"){
		    if (!Validate("valor unitario",document.forms[0].elements[i].value,10,0,"Decimal",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoEventoEdicaoInscricao(flagInclusao){
    var flagErro = ValidarEventoEdicaoInscricao();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoEventoEdicaoInscricao(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de produto da edição do evento
function ValidarEventoEdicaoProduto(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DropEventoEdicao"){
		    if (!Validate("evento",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNumeroEdicao"){
		    if (!Validate("numero edicao",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbQuantidadeEstoque"){
		    if (!Validate("quantidade estoque",document.forms[0].elements[i].value,4,0,"Int32",false,DIV_INFO))
		        flagErro = true;
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbQuantidadeEvento"){
		    if (!Validate("quantidade mínima do evento",document.forms[0].elements[i].value,4,1,"Int32",false,DIV_INFO)){
		        flagErro = true;
		    }
		    else 
		    {
		        var quantidade = int.parse(document.forms[0].elements[i].value);
		        if (quantidade == 0)
		        {
		            flagErro = true;
		            Mensagem("Quantidade mínima para participação é 1");
		        }
		    }
		}
		else if (document.forms[0].elements[i].getAttribute("BrappID") == "DbValorUnitario"){
		    if (!Validate("valor unitario",document.forms[0].elements[i].value,10,0,"Decimal",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoEventoEdicaoProduto(flagInclusao){
    var flagErro = ValidarEventoEdicaoProduto();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoEventoEdicaoProduto(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de instituicao ensino
function ValidarInstituicaoEnsino(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeInstituicaoEnsino"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoInstituicaoEnsino(flagInclusao){
    var flagErro = ValidarInstituicaoEnsino();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoInstituicaoEnsino(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de instituicao ensino
function ValidarCurso(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeCurso"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoCurso(flagInclusao){
    var flagErro = ValidarCurso();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoCurso(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de instituicao ensino
function ValidarReligiao(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeReligiao"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoReligiao(flagInclusao){
    var flagErro = ValidarReligiao();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoReligiao(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de instituicao ensino
function ValidarReligiao(){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == "DbNomeReligiao"){
		    if (!Validate("nome",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoReligiao(flagInclusao){
    var flagErro = ValidarReligiao();
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoReligiao(flagInclusao){
    return ConfirmarExclusao();
}

//Componente do pacote
function ConfirmarExclusaoComponentePacote(flagInclusao){
    return ConfirmarExclusao();
}

//Validação dos campos do cadastro de participante
function ValidarParticipante(NID){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbNomeParticipante"+NID)){
		    if (!Validate("nome do participante",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbDataNascimento"+NID)){
		    if (!Validate("data de nascimento",document.forms[0].elements[i].value,10,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbNomeEndereco"+NID)){
		    if (!Validate("endereço",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbBairroEndereco"+NID)){
		    if (!Validate("bairro",document.forms[0].elements[i].value,60,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DropCidade"+NID)){
		    if (!Validate("cidade",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbTelefoneContato"+NID)){
		    if (!Validate("telefone",document.forms[0].elements[i].value,14,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbEnderecoEmailContato"+NID)){
		    if (!Validate("e-mail",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbCPF"+NID)){
		    if (!Validate("CPF",document.forms[0].elements[i].value,14,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbNumeroRG"+NID)){
		    if (!Validate("RG",document.forms[0].elements[i].value,14,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoParticipante(flagInclusao, NID){
    var flagErro = ValidarParticipante(NID);
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoParticipante(flagInclusao){
    return ConfirmarExclusao();
}

//Validar delegação
function ValidarDelegacao(NID){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DropUF"+NID)){
		    if (!Validate("UF",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DropEventoEdicao"+NID)){
		    if (!Validate("edição do evento",document.forms[0].elements[i].value,8,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DropEvento"+NID)){
		    if (!Validate("evento",document.forms[0].elements[i].value,8,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DropDelegado"+NID)){
		    if (!Validate("delegado",document.forms[0].elements[i].value,8,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbNomeDelegacao"+NID)){
		    if (!Validate("nome da delegação",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		/*if (document.forms[0].elements[i].getAttribute("BrappID") == ("DBDescricaoDelegacao"+NID)){
		    if (!Validate("descrição da delegação",document.forms[0].elements[i].value,80,0,"String",false,DIV_INFO)){
		        //flagErro = true;
		        Mensagem("Conteudo: " + document.forms[0].elements[i].value);
		        }
		}*/
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoDelegacao(flagInclusao, NID){
    var flagErro = ValidarDelegacao(NID);
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoDelegacao(flagInclusao){
    return ConfirmarExclusao();
}


//Validar delegado
function ValidarDelegado(NID){
    var flagErro = false;
    LimpaInfo(DIV_INFO);
    for (i=0; i< document.forms[0].length; i++){
		
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DropEventoEdicao"+NID)){
		    if (!Validate("edição do evento",document.forms[0].elements[i].value,8,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DropEvento"+NID)){
		    if (!Validate("evento",document.forms[0].elements[i].value,8,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
		if (document.forms[0].elements[i].getAttribute("BrappID") == ("DbCPFDelegado"+NID)){
		    if (!Validate("CPF do delegado",document.forms[0].elements[i].value,14,0,"String",false,DIV_INFO))
		        flagErro = true;
		}
	}
    return flagErro;
}

function ConfirmarInclusaoAlteracaoDelegado(flagInclusao, NID){
    var flagErro = ValidarDelegacao(NID);
	
	if (!flagErro){
	    if (flagInclusao)
	    return ConfirmarInclusao();
	    else
        return ConfirmarAlteracao();
    }
    else {
        return false;
    }
}
function ConfirmarExclusaoDelegado(flagInclusao){
    return ConfirmarExclusao();
}
function ParticipanteNaoEncontrato(){
    Mensagem("Participante não encontrado.");
}

function ConfirmarParticipacaoContextoParticipante(){
    return Confirmar("Confirmar participação?");
}

function ConfirmarParticipacaoContextoDelegacao(){
    return Confirmar("Confirma participação");
}
function ConfirmarCancelamentoFatura(){
    return Confirmar("Após a confirmação será registrado crédito equivalente a soma da parcelas pagas. Deseja continuar?");
}
function ConfirmarCancelamentoParticipacao(){
    return Confirmar("Cancelando a participação também será cancelada Fatura e Reserva. Deseja continuar?");
}
function ConfirmarCancelamentoReservaUnidadeHabitacional(){
    return Confirmar("Deseja continuar?");
}

function ConfirmarExclusaoParticipacao(){
    return Confirmar("Esta operação irá apagar todos registros, inclusive dados de pagamento e boleto. Deseja continuar?");
}
/* Brapp Tecnologia
 * Data: 24/11/2208
 * Autor: Leirson Barreto
 * Objetivo: Funções de confirmação da tela de detalhes da participação
 *           no contexto administrativo
 */
function ConfirmarInclusaoParcelaParticipacaoDetalhes(){
    return Confirmar("Confirma inclusão da parcela?");
}
function ConfirmarExclusaoParcelaParticipacaoDetalhes(){
    return Confirmar("Confirma exclusão?");
}
function ConfirmarAlteracaoParcelaParticipacaoDetalhes(){
    return Confirmar("Confirma alteração?");
}
