﻿function formatoMontoXX(control)
{
    var nStr = document.getElementById('ctl00_contentPlaceHolder1_' + control).value  ;
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    if (x[1]==undefined) 
    {
        x[1]='00';
    }
    x2 = x.length > 1 ? '.' + x[1] : '';    
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
    {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    document.getElementById('ctl00_contentPlaceHolder1_' + control).value=x1 + x2 ;    
} 
function formatoMonto(control)
{
    var nStr =  trim(document.getElementById('ctl00_contentPlaceHolder1_' + control).value.replace(/^[0]+/g,""))  ;

    nStr=  nStr.replace(',','');   
    nStr=  nStr.replace(',','');
    nStr=  nStr.replace(',','');     
    nStr += '';

    x = nStr.split('.');
    x1 = x[0];
    if (x[1]==undefined) 
    {
        x[1]='00';
    }
    x2 = x.length > 1 ? '.' + x[1] : '';    
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
    {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    var montoFF=x1 ;
     var inicio;
//     alert (montoFF);
    if(montoFF.length >14)
    {
        inicio = 17 - montoFF.length;
    }
    else
    {
        inicio=0;
    }
    
    document.getElementById('ctl00_contentPlaceHolder1_' + control).value=montoFF.substr(inicio,14) + x2.substr(0,3);    
}
function formatoMonto2Dec(control)
{
    var nStr =  trim(document.getElementById('ctl00_contentPlaceHolder1_' + control).value.replace(/^[0]+/g,""))  ;

    nStr=  nStr.replace(',','');   
    nStr=  nStr.replace(',','');
    nStr=  nStr.replace(',','');     
    nStr += '';

    x = nStr.split('.');
    x1 = x[0];
    if (x[1]==undefined) 
    {
        x[1]='00';
    }
    x2 = x.length > 1 ? '.' + x[1] : '';    
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
    {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    var montoFF=x1 ;
     var inicio;
//     alert (montoFF);
    if(montoFF.length >14)
    {
        inicio = 17 - montoFF.length;
    }
    else
    {
        inicio=0;
    }
    
    document.getElementById('ctl00_contentPlaceHolder1_' + control).value=montoFF.substr(inicio,14) + x2.substr(0,3);    
}
function formatoMontoLongitud(control,maxLength)
{
    var nStr =  trim(document.getElementById('ctl00_contentPlaceHolder1_' + control).value.replace(/^[0]+/g,""))  ;

    nStr=  nStr.replace(',','');   
    nStr=  nStr.replace(',','');
    nStr=  nStr.replace(',','');     
    nStr += '';

    x = nStr.split('.');
    x1 = x[0];
    if (x[1]==undefined) 
    {
        x[1]='00';
    }
    x2 = x.length > 1 ? '.' + x[1] : '';    
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
    {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    var montoFF=x1 ;
    var inicio;
    // alert(montoFF);
    if(montoFF.length >(maxLength - 3))
    {
        inicio = maxLength - montoFF.length;
    }
    else
    {
        inicio=0;
    }
    
    document.getElementById('ctl00_contentPlaceHolder1_' + control).value=montoFF.substr(inicio,(maxLength - 3)) + x2.substr(0,3);    
}
function formatoMontoLongitudNoSplit(control,maxLength)
{
    var nStr =  trim(document.getElementById('ctl00_contentPlaceHolder1_' + control).value.replace(/^[0]+/g,""))  ;

    nStr=  nStr.replace(',','');   
    nStr=  nStr.replace(',','');
    nStr=  nStr.replace(',','');     
    nStr += '';

    x = nStr.split('.');
    x1 = x[0];
    if (x[1]==undefined) 
    {
        x[1]='00';
    }
    x2 = x.length > 1 ? '.' + x[1] : '';    
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
    {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    var montoFF=x1 ;
    var inicio;
    //alert(montoFF);
    if(montoFF.length >(maxLength - 3))
    {
        inicio = maxLength - montoFF.length;
    }
    else
    {
        inicio=0;
    }
    
    document.getElementById('ctl00_contentPlaceHolder1_' + control).value=montoFF + x2.substr(0,3);    
}
function formatoMontoInyeccion(control)
{
    var nStr =  trim(document.getElementById(control).value.replace(/^[0]+/g,""))  ;

    nStr=  nStr.replace(',','');   
    nStr=  nStr.replace(',','');
    nStr=  nStr.replace(',','');     
    nStr += '';

    x = nStr.split('.');
    x1 = x[0];
    if (x[1]==undefined) 
    {
        x[1]='00';
    }
    x2 = x.length > 1 ? '.' + x[1] : '';    
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
    {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    var montoFF=x1 ;
     var inicio;
//     alert (montoFF);
    if(montoFF.length >14)
    {
        inicio = 17 - montoFF.length;
    }
    else
    {
        inicio=0;
    }
    
    document.getElementById(control).value=montoFF.substr(inicio,14) + x2.substr(0,3);    
}
function LimpiarCheckBoxList(elementId) 
{
 var elementRef = document.getElementById(elementId);
 var inputElementArray = elementRef.getElementsByTagName('input');

 for (var i=0; i<inputElementArray.length; i++) 
 { 
  var inputElement = inputElementArray[i];

  inputElement.checked = false;
 }
}


function Validar2Anios(textboxAnio1, textboxAnio2, indice)
{
    var txtAnio1 = document.getElementById('ctl00_contentPlaceHolder1_cuwFuerzaLaboral1_' + textboxAnio1); 
    var txtAnio2 = document.getElementById('ctl00_contentPlaceHolder1_cuwFuerzaLaboral1_' + textboxAnio2);   
    switch(indice)
    {
        case "1":
            if(parseFloat(txtAnio1.value)>=2006 && parseFloat(txtAnio1.value)<=2029)
            {
                txtAnio2.value = parseFloat(txtAnio1.value)+1;
            }
            else
            {
                if(txtAnio1.value == "")
                {
                    txtAnio1.value = 0;
                }
                alert("Debe ingresar un año entre el 2006 y 2029.");
            }
            break;
        case "2":
            if(parseFloat(txtAnio2.value)>=2007 && parseFloat(txtAnio2.value)<=2030)
            {
                txtAnio1.value = parseFloat(txtAnio2.value)-1;
            }
            else
            {
                if(txtAnio2.value == "")
                {
                    txtAnio2.value = 0;
                }
                alert("Debe ingresar un año entre el 2007 y 2030.");                
            }
            break;
    }   
}

function ValidarAnios(textboxAnio1, textboxAnio2, textboxAnio3, indice)
{
    var txtAnio1 = document.getElementById('ctl00_contentPlaceHolder1_' + textboxAnio1); 
    var txtAnio2 = document.getElementById('ctl00_contentPlaceHolder1_' + textboxAnio2); 
    var txtAnio3 = document.getElementById('ctl00_contentPlaceHolder1_' + textboxAnio3);   
    switch(indice)
    {
        case "1":
            if(parseFloat(txtAnio1.value)>=2006 && parseFloat(txtAnio1.value)<=2028)
            {
                txtAnio2.value = parseFloat(txtAnio1.value)+1;
                txtAnio3.value = parseFloat(txtAnio1.value)+2;
            }
            else
            {
                if(txtAnio1.value == "")
                {
                    txtAnio1.value = 0;
                }
                alert("Debe ingresar un año entre el 2006 y 2028.");
            }
            break;
        case "2":
            if(parseFloat(txtAnio2.value)>=2007 && parseFloat(txtAnio2.value)<=2029)
            {
                txtAnio1.value = parseFloat(txtAnio2.value)-1;
                txtAnio3.value = parseFloat(txtAnio2.value)+1;
            }
            else
            {
                if(txtAnio2.value == "")
                {
                    txtAnio2.value = 0;
                }
                alert("Debe ingresar un año entre el 2007 y 2029.");                
            }
            break;
        case "3":
            if(parseFloat(txtAnio3.value)>=2008 && parseFloat(txtAnio3.value)<=2030)
            {
                txtAnio1.value = parseFloat(txtAnio3.value)-2;
                txtAnio2.value = parseFloat(txtAnio3.value)-1;
            }
            else
            {
                if(txtAnio3.value == "")
                {
                    txtAnio3.value = 0;                    
                }
                alert("Debe ingresar un año entre el 2008 y 2030.");                
            }
            break;
    }   
}

function letras()
{
    if (event.keyCode >65 && event.keyCode  < 90) event.returnValue = false;
}

function ValidarTextBoxMultiLine(obj, maxLength)
{
    if(obj.value.length >= maxLength)
    {        
        event.returnValue = false;
    }
    else
    {        
        if ((event.keyCode >= 65 && event.keyCode <= 90) || 
        (event.keyCode >= 97 && event.keyCode <= 122) || 
        (event.keyCode >= 48 && event.keyCode <= 57) ||
        (event.keyCode == 32) ||  //backspace
        (event.keyCode == 34) ||  //"
        (event.keyCode == 36) || //$
        (event.keyCode == 127) ||  //delete
        (event.keyCode == 37) || //%
         (event.keyCode == 44) || //, coma
            (event.keyCode == 40) || //(
         (event.keyCode == 41) || //)
         (event.keyCode == 58) || //:
         (event.keyCode == 59) || //;  
         
        (event.keyCode == 38) ||  //&
        (event.keyCode == 39) ||  //'
        (event.keyCode == 45) ||  //-
        (event.keyCode == 46) ||  //.
        (event.keyCode == 209) || //Ñ
        (event.keyCode == 241) || //ñ
        (event.keyCode == 13) ||
        (event.keyCode == 225) ||
        (event.keyCode == 233) ||
        (event.keyCode == 237) ||
        (event.keyCode == 243) ||
        (event.keyCode == 250) ||
        (event.keyCode == 193) ||
        (event.keyCode == 201) ||
        (event.keyCode == 205) ||
        (event.keyCode == 211) ||
        (event.keyCode == 218))
            event.returnValue = true;
        else
            event.returnValue = false;
    }
}


function ValidaSoloLetras()
{
    //alert(window.event.keyCode);
    if ((event.keyCode >= 65 && event.keyCode <= 90) || 
        (event.keyCode >= 97 && event.keyCode <= 122) ||        
        (event.keyCode == 32) ||    
        (event.keyCode == 209) || 
        (event.keyCode == 241) || //ñ
        (event.keyCode == 225) ||
        (event.keyCode == 233) ||
        (event.keyCode == 237) ||
        (event.keyCode == 243) ||
        (event.keyCode == 250) ||
        (event.keyCode == 193) ||
        (event.keyCode == 201) ||
        (event.keyCode == 205) ||
        (event.keyCode == 211) ||
        (event.keyCode == 218))
        event.returnValue = true;
    else
        event.returnValue = false;            
}

function ValidaSoloLetrasNumerosDocumento()
{    
    //alert(window.event.keyCode);
    if ((event.keyCode >= 65 && event.keyCode <= 90) || 
        (event.keyCode >= 97 && event.keyCode <= 122) || 
        (event.keyCode >= 48 && event.keyCode <= 57) ||
         (event.keyCode == 46) ||  //.
           (event.keyCode == 32) ||  //backspace
        (event.keyCode == 209) || //Ñ
        (event.keyCode == 241)) //ñ
        event.returnValue = true;        
    else
        event.returnValue = false;
}

function ValidaSoloLetrasNumerosPersonaizado()
{    
    //alert(window.event.keyCode);
    if ((event.keyCode >= 65 && event.keyCode <= 90) || 
        (event.keyCode >= 97 && event.keyCode <= 122) || 
        (event.keyCode >= 48 && event.keyCode <= 57) ||
        (event.keyCode == 36) || //$
        (event.keyCode == 32) ||  //backspace
        (event.keyCode == 127) ||  //delete
        (event.keyCode == 37) || //%
        (event.keyCode == 209) || //Ñ
        (event.keyCode == 241)) //ñ
        event.returnValue = true;        
    else
        event.returnValue = false;
}

function ValidaSoloLetrasNumeros()
{       
    if ((event.keyCode >= 65 && event.keyCode <= 90) || 
        (event.keyCode >= 97 && event.keyCode <= 122) || 
        (event.keyCode >= 48 && event.keyCode <= 57) ||
        (event.keyCode == 32) ||  //backspace
        (event.keyCode == 34) ||  //"
        (event.keyCode == 38) ||  //&
        (event.keyCode == 39) ||  //'
        (event.keyCode == 44) ||  //,
        (event.keyCode == 45) ||  //-
        (event.keyCode == 46) ||  //.
        (event.keyCode == 209) || //Ñ
        (event.keyCode == 241) || //ñ
        (event.keyCode == 225) ||
        (event.keyCode == 233) ||
        (event.keyCode == 237) ||
        (event.keyCode == 243) ||
        (event.keyCode == 250) ||
        (event.keyCode == 193) ||
        (event.keyCode == 201) ||
        (event.keyCode == 205) ||
        (event.keyCode == 211) ||
        (event.keyCode == 218))
        event.returnValue = true;        
    else
        event.returnValue = false;
}

function ValidaDecimal(){  
var valid = "0123456789.";
return ValidaInput(valid,false); 
}
         
function ValidarInputDecimal(ctrTexbox) {  
var txtBox = trim(document.getElementById('ctl00_contentPlaceHolder1_' + ctrTexbox).value);
var resul = false ;
var resul2 = false ;

       
    for (i=0;i<txtBox.length;i++)
        {
        if (txtBox.charAt(i)==".")
            {
            resul = true;        
            }
        }                
        
        if (resul == true)
        {        
        resul2 = ValidarInputNumerico();
        }
        else
        {        
        resul2 = ValidaDecimal();
        }        
        return resul2;
 
}

function ValidarInputNumerico() {  
    var valid = "0123456789";
    return ValidaInput(valid,false); 
}

function ValidarInputFono(ctrDd1,ctrDd2,tex1) {  
    var ddlVal = trim(document.getElementById(ctrDd1).value);
    var ddlVal2 = document.getElementById(ctrDd2).value;
    var txtBox1 = document.getElementById(tex1); 
    var valid = "0123456789";
      
    var  keyAscii = event.keyCode;
    var key = String.fromCharCode(keyAscii); 
	var keyAj = key.toUpperCase();	
	 	
    if(keyAscii!=13)
    {
        if (ddlVal == '000')
        {        
         alert('Seleccione un Tipo de Teléfono.');            
         event.keyCode=0; txtBox1.value=''; return true;
         }
         
        if (ddlVal == '001')
        {  
            if (txtBox1.value.length==0)
            {
               if(keyAj!='9')
               {event.keyCode=0;return true;
               }
               return ValidaInput(valid,false); 
            }
            else
            {
                if (txtBox1.value.length>8)
                {event.keyCode=0;return true;}
                else
                {
                return ValidaInput(valid,false); 
                }
            }
        }
        else
        {
            if(ddlVal2=='000')
            {
                alert('Seleccione el discado.');            
                event.keyCode=0; txtBox1.value=''; return true;
            }
            if(ddlVal2=='001')
            {
                if (txtBox1.value.length==0)
                {
                   if(keyAj=='0' || keyAj=='1' || keyAj=='9')
                   {event.keyCode=0;return true;}
                   return ValidaInput(valid,false); 
                }
                else
                {
                    if (txtBox1.value.length>6)
                    {event.keyCode=0;return true;}
                    else
                    {
                    return ValidaInput(valid,false); 
                    }
                }
            }
            else
            {
                if (txtBox1.value.length==0)
                {
                   if(keyAj=='0' || keyAj=='1' || keyAj=='9')
                   {event.keyCode=0;return true;}
                   return ValidaInput(valid,false); 
                }
                else
                {
                    if (txtBox1.value.length>5)
                    {event.keyCode=0;return true;}
                    else
                    {
                    return ValidaInput(valid,false); 
                    }
                }
            }
        }
    }
    
}

function ValidarSalidaFono(sender, args){ 
   
    var ddlVal = trim(document.getElementById('ctl00_ContentPlaceHolder1_ucInformacionBasica_ddlTipoTelefono1').value);
    var ddlVal2 = document.getElementById('ctl00_ContentPlaceHolder1_ucInformacionBasica_ddlDeparTelef1').value;
    var txtBox1 = document.getElementById('ctl00_ContentPlaceHolder1_ucInformacionBasica_txtTelefono'); 
    
      if(args.Value != "" )
      {
            if (ddlVal == '000')
            {        
             alert('Seleccione un Tipo de Telefono.');   
             args.IsValid = false;     return;                      
             }
             
            if (ddlVal == '001')
            {  
                if (txtBox1.value.length!=9)
                {
                   alert('Para celulares debe de ingresar 9 digitos.');   
                    args.IsValid = false;     return;   
                }       
                else
                    {
                     if(txtBox1.value.charAt(0)!='9')
                        {
                            alert('Los números de celular deben de empezar en 9.');   
                             args.IsValid = false;     return;   
                        }                       
                    }         
            }
            else
            {
                if(ddlVal2=='000')
                {
                    alert('Seleccione el discado.');            
                    args.IsValid = false;     return;   
                }
                if(ddlVal2=='001')
                {
                    if (txtBox1.value.length!=7)
                    {
                        alert('Para telefonos de Lima debe de ingresar 7 digitos.');   
                        args.IsValid = false;     return;                   
                      
                    }
                    else
                    {
                     if(txtBox1.value.charAt(0)=='0' || txtBox1.value.charAt(0)=='1' || txtBox1.value.charAt(0)=='9')
                        {
                            alert('Para telefonos de Lima no debe de iniciar en 0,1,9.');   
                             args.IsValid = false;     return;   
                        }                       
                    }
                }
                else
                {                    
                   if (txtBox1.value.length!=6)
                    {
                        alert('Para telefonos de Provincia debe de ingresar 6 digitos.');   
                        args.IsValid = false;     return;                   
                      
                    }
                    else
                    {
                     if(txtBox1.value.charAt(0)=='0' || txtBox1.value.charAt(0)=='1' || txtBox1.value.charAt(0)=='9')
                        {
                            alert('Para telefonos de Provincia no debe de iniciar en 0,1,9.');   
                             args.IsValid = false;     return;   
                        }                       
                    }
                }
            }
       
      }

     	

    args.IsValid = true;
    return;
}


function ValidarSalidaFono2(sender, args){ 
   
    var ddlVal = trim(document.getElementById('ctl00_ContentPlaceHolder1_ucInformacionBasica_ddlTipoTelefono2').value);
    var ddlVal2 = document.getElementById('ctl00_ContentPlaceHolder1_ucInformacionBasica_ddlDeparTelef2').value;
    var txtBox1 = document.getElementById('ctl00_ContentPlaceHolder1_ucInformacionBasica_txtCelular'); 
    
      if(args.Value != "" )
      {
            if (ddlVal == '000')
            {        
             alert('Seleccione un Tipo de Telefono 2.');   
             args.IsValid = false;     return;                      
             }
             
            if (ddlVal == '001')
            {  
                if (txtBox1.value.length!=9)
                {
                   alert('Para celulares debe de ingresar 9 digitos.');   
                    args.IsValid = false;     return;   
                }       
                else
                    {
                     if(txtBox1.value.charAt(0)!='9')
                        {
                            alert('Los números de celular deben de empezar en 9.');   
                             args.IsValid = false;     return;   
                        }                       
                    }         
            }
            else
            {
                if(ddlVal2=='000')
                {
                    alert('Seleccione el discado.');            
                    args.IsValid = false;     return;   
                }
                if(ddlVal2=='001')
                {
                    if (txtBox1.value.length!=7)
                    {
                        alert('Para telefonos de Lima debe de ingresar 7 digitos.');   
                        args.IsValid = false;     return;                   
                      
                    }
                    else
                    {
                     if(txtBox1.value.charAt(0)=='0' || txtBox1.value.charAt(0)=='1' || txtBox1.value.charAt(0)=='9')
                        {
                            alert('Para telefonos de Lima no debe de iniciar en 0,1,9.');   
                             args.IsValid = false;     return;   
                        }                       
                    }
                }
                else
                {
                   if (txtBox1.value.length!=6)
                    {
                        alert('Para telefonos de Provincia debe de ingresar 6 digitos.');   
                        args.IsValid = false;     return;                   
                      
                    }
                    else
                    {
                     if(txtBox1.value.charAt(0)=='0' || txtBox1.value.charAt(0)=='1' || txtBox1.value.charAt(0)=='9')
                        {
                            alert('Para telefonos de Provincia no debe de iniciar en 0,1,9.');   
                             args.IsValid = false;     return;   
                        }                       
                    }
                }
            }
       
      }

     	

    args.IsValid = true;
    return;
}


function ValidaFono(ctrDd1,ctrDd2,tex1,ctrrfv1)
{
    var ddlVal = trim(document.getElementById(ctrDd1).value);
    var ddlVal2 = document.getElementById(ctrDd2);
    var txtBox1 = document.getElementById(tex1); 
    var rfv1 = document.getElementById(ctrrfv1);
    
    if (ddlVal == '000')
        {        
         alert('Seleccione un Tipo de Telefono.');            
         ddlVal2.disabled=true;
         txtBox1.disabled=true;
         txtBox1.value='';
         }
    if (ddlVal == '001')
        {                        
         ddlVal2.disabled=true;
         ValidatorEnable(rfv1, false);
         
         ddlVal2.value='00'
         txtBox1.disabled=false;
         txtBox1.value='';
         } 
    else 
        {                        
         ddlVal2.disabled=false;
         ValidatorEnable(rfv1, true);
         txtBox1.disabled=false;
         txtBox1.value='';
         }          
    
}

function ValidaFono2(ctrDd1,ctrDd2,tex1,ctrrfv1, tex2)
{
    var ddlVal = trim(document.getElementById(ctrDd1).value);
    var ddlVal2 = document.getElementById(ctrDd2);
    var txtBox1 = document.getElementById(tex1); 
    var rfv1 = document.getElementById(ctrrfv1);
    var txtBox2 = document.getElementById(tex2); 
    
    if (ddlVal == '000')
        {        
         alert('Seleccione un Tipo de Telefono.');            
         ddlVal2.disabled=true;
         txtBox2.disabled=true;
         txtBox1.disabled=true;
         txtBox1.value='';
         txtBox2.value='';
         }
    if (ddlVal == '001')
        {                        
         ddlVal2.disabled=true;         
         ValidatorEnable(rfv1, false);
         
         ddlVal2.value='00'
         txtBox1.disabled=false;
         txtBox1.value='';
         txtBox2.disabled=true;
         txtBox2.value='';
         } 
    else 
        {                        
         ddlVal2.disabled=false;
         ValidatorEnable(rfv1, true);
         txtBox1.disabled=false;
         txtBox1.value='';
         txtBox2.disabled=false;    
         txtBox2.value='';
         }              
}
 
 
function LimpiaFono(tex1)
{    
    var txtBox1 = document.getElementById(tex1); 
    txtBox1.value='';
        
    
}

function validaKeys(valor)
{
var campoKey = element.GetByI('txt').value
 

}

function ValidaInput(valid,valor)
{
    var  keyAscii = event.keyCode;
	if(keyAscii!=13){
		var key = String.fromCharCode(event.keyCode); 
	 	var keyAj=key.toUpperCase();
	 	if(valor){
		event.keyCode=keyAj.charCodeAt(0);
		}
		if(valid=='')
		    return true;
		if (valid.indexOf(keyAj) == "-1") event.keyCode=0;
			return true;
	}
}

function ValidarExistenciaDatos(gridViewName)
{
    var intRespuesta = false;
    var tableElement1 = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
    if(tableElement1 != null )
    {
        if(tableElement1.rows.length > 1)
        {
            intRespuesta = true;
        }
    }
    return intRespuesta;
}

//Validación de Datos de Seccion II: Composición Accionaria
function ValidarCompAccionaria(valorTipoDoc, valorNumDoc, gridViewName1, indColPct, valorPct, gridViewName2, indColTipoDoc, indColNroDoc, valorTipoDoc, valorNroDoc, idBoton)
{
    var blnRespuesta = false ;
        
    var boton = document.getElementById('ctl00_contentPlaceHolder1_' + idBoton);    
    
    if (boton.value == "Agregar" )
    {
        blnRespuesta = ValidarCaracteresDocumento(valorTipoDoc, valorNumDoc)
        if(!blnRespuesta)
        {
            blnRespuesta = ValidarPorcentajes(gridViewName1, indColPct, valorPct)
            if(!blnRespuesta)
            {
                blnRespuesta = ValidarDatosDuplicadosGridView(gridViewName1, indColTipoDoc, indColNroDoc, valorTipoDoc, valorNroDoc);
                //ValidarDatosDuplicadosFiltros(gridViewName1, gridViewName2, indColTipoDoc, indColNroDoc, valorTipoDoc, valorNroDoc);
                if (blnRespuesta)
                {
                    alert("Dato ingresado ya existe.");
                }  
            }
        }
    }
    else
    {
        blnRespuesta = false
    }
    return blnRespuesta;
}

 
function ValidarCompAccionariaV2(valorFilaEdit,valorTipoDoc, valorNumDoc, gridViewName1, indColPct, valorPct, gridViewName2, indColTipoDoc, indColNroDoc, valorTipoDoc, valorNroDoc, idBoton)
{
    var blnRespuesta = false ;
        
    var boton = document.getElementById('ctl00_contentPlaceHolder1_' + idBoton);    
    
    if (boton.value == "Agregar" || boton.value == "Guardar")
    {
        if (boton.value == "Agregar")
        {
             blnRespuesta = ValidarCaracteresDocumento(valorTipoDoc, valorNumDoc)
            if(!blnRespuesta)
            {
                blnRespuesta = ValidarPorcentajes(gridViewName1, indColPct, valorPct)
                if(!blnRespuesta)
                {
                    blnRespuesta = ValidarDatosDuplicadosGridView(gridViewName1, indColTipoDoc, indColNroDoc, valorTipoDoc, valorNroDoc);
                    //ValidarDatosDuplicadosFiltros(gridViewName1, gridViewName2, indColTipoDoc, indColNroDoc, valorTipoDoc, valorNroDoc);
                    if (blnRespuesta)
                    {
                        alert("Dato ingresado ya existe.");
                    }  
                }
            }
        }
        if (boton.value == "Guardar")
        {
            blnRespuesta = ValidarPorcentajesV2(valorFilaEdit,gridViewName1, indColPct, valorPct)
        }
       
    }
    else
    {
        blnRespuesta = false
    }
    return blnRespuesta;
}

//Validación de Datos de Seccion III: Participación Accionaria
function ValidarPartAccionaria(valorTipoDoc, valorNroDoc, idBoton)
{
    var intRespuesta = false;    
    var boton = document.getElementById('ctl00_contentPlaceHolder1_' + idBoton);    
    
    if (boton.value == "Agregar")
    {    
        intRespuesta = ValidarCaracteresDocumento(valorTipoDoc, valorNroDoc);
        
        if (intRespuesta == false)
        {        
            intRespuesta = ValidarDatosDuplicadosGridView('ucInformacionDireccion_gvwPartAccionaria', '2', '3', valorTipoDoc, valorNroDoc);
        
            if (intRespuesta == false)
            {
                intRespuesta  = ValidarDatosDuplicadosGridView('ucInformacionDireccion_gvwAccionistas', '2', '3', valorTipoDoc, valorNroDoc);
            } 
            
            if (intRespuesta == false)
            {
                intRespuesta  = ValidarDatosDuplicadosGridView('ucInformacionDireccion_gvwDirectorio', '3', '4', valorTipoDoc, valorNroDoc);
            }
            
            if (intRespuesta == false)
            {
                intRespuesta  = ValidarDatosDuplicadosGridView('ucInformacionDireccion_gvwEjecutivo', '3', '4', valorTipoDoc, valorNroDoc);   
            }    
            
            if (intRespuesta == true)
            {
                alert("Dato ingresado ya existe.");
            } 
        }   
    }
    else
    {
        intRespuesta = false;
    }
    return intRespuesta ; 
}

//Validación de Datos de Seccion IV y V: Directorio, Gerencia
function ValidarDatosDuplicadosFiltros(gridViewNameDirectorio, indColDirectorioTipoDoc, indColDiretorioNroDoc, gridViewNamePartAcc, indColPartAccTipoDoc, indColPartAccNroDoc, valorTipoDoc, valorNroDoc, idBoton)
{
    var intRespuesta = false;    
    intRespuesta = ValidarCaracteresDocumento(valorTipoDoc, valorNroDoc);
    var boton = document.getElementById('ctl00_contentPlaceHolder1_' + idBoton);  
    if(boton.value == "Agregar")
    {        
        if (!intRespuesta)
        {        
            intRespuesta = ValidarDatosDuplicadosGridView(gridViewNameDirectorio, indColDirectorioTipoDoc, indColDiretorioNroDoc, valorTipoDoc, valorNroDoc);
        
            if (!intRespuesta)
            {
                intRespuesta = ValidarDatosDuplicadosGridView(gridViewNamePartAcc, indColPartAccTipoDoc, indColPartAccNroDoc, valorTipoDoc, valorNroDoc);            
            }   
            if (intRespuesta)
            {
                alert("Dato ingresado ya existe.");
            }
        }
    }
    else
    {
        intRespuesta = false;
    }
    return intRespuesta ;       
}

//Validación de datos repetidos en GridViews por Tipo de Documento y Número de Documento
function ValidarDatosDuplicadosGridView(gridview, indColTipoDoc, indColNroDoc, valorTipoDoc, valorNroDoc)
{
    var intRespuesta = false;  
    var dropdownElementTipoDoc = document.getElementById('ctl00_contentPlaceHolder1_' + valorTipoDoc);  
    var textoElementNroDoc = document.getElementById('ctl00_contentPlaceHolder1_' + valorNroDoc); 
    
    var vElementTipoDoc = dropdownElementTipoDoc.options[dropdownElementTipoDoc.selectedIndex].text;
    var vElementNroDoc = trim(textoElementNroDoc.value);    
        
    var tableElementGridView = document.getElementById('ctl00_contentPlaceHolder1_' + gridview);
    
    if (tableElementGridView != null )
    {
        for (var i=1;i<tableElementGridView.rows.length;i++)
        {   
            var cellTipoDoc = tableElementGridView.rows[i].cells[indColTipoDoc];                                               
            var cellNroDoc = tableElementGridView.rows[i].cells[indColNroDoc];            
            var vTipoDoc = trim(cellTipoDoc.innerText);
            var vNroDoc = trim(cellNroDoc.innerText); 
            
            if (vTipoDoc.toUpperCase() == vElementTipoDoc.toUpperCase() && vNroDoc.toUpperCase() == vElementNroDoc.toUpperCase())
            {   
            
                intRespuesta = true ;                
            }
        }
    }
    return intRespuesta;
}

//Validacion de Cantidad de Caracteres del Nro de Documento: DNI=8, RUC=11
function ValidarCaracteresDocumento(valorTipoDoc, valorNroDoc)
{
    var blnRespuesta = false ;
    var numdoc = trim(document.getElementById('ctl00_ContentPlaceHolder1_' + valorNroDoc).value);
    var TipodocAux = document.getElementById('ctl00_ContentPlaceHolder1_' + valorTipoDoc);
    
    var Tipodoc = trim(TipodocAux.options[TipodocAux.selectedIndex].text);
    
    //Validación de Caracteres
    if(Tipodoc == "RUC")
    {
        if(numdoc.length < 11)
        {
            alert("Ingrese un número de RUC correcto (11 dígitos).");
            blnRespuesta = true ;
        }
    }
    else
    {
        if(Tipodoc == "DNI")
        {
            if(numdoc.length < 8)
            {
                alert("Ingrese un número de DNI correcto (8 dígitos).");
                blnRespuesta = true ;
            }    
        }
    }
    return blnRespuesta;
}

//Validacion de Sumatoria de Porcentajes en GridView < 100%
function ValidarPorcentajes(gridViewName1, indCol, valor1)
{
    var intRespuesta = false;
    var tableElement1 = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName1);
    var textoElement1 = document.getElementById('ctl00_contentPlaceHolder1_' + valor1);
    var vElement1 = trim(textoElement1.value);     
    var sumaPct = vElement1;
    if (tableElement1 != null )
    {           
        for (var i=1;i<tableElement1.rows.length;i++)
        {
            var cell3 = tableElement1.rows[i].cells[indCol];
            
            var v3 = cell3.innerText.replace("%","").trim();
            if (v3 != null)
            {                
                if (v3 != "")
                {                    
                    sumaPct = parseFloat(v3) + parseFloat(sumaPct);
                    sumaPct = Math.round(sumaPct*100)/100;
                    //var result=Math.round(original*100)/100  //returns 28.45
                }
            }
        }        
    }    
    
    if(parseFloat(sumaPct) > 100.00)
    {
        alert("La suma de % debe ser menor o igual a 100%.");
        intRespuestaSumatoria = true;
    }
    else
    {
        intRespuestaSumatoria = false;
    }
    return intRespuestaSumatoria
}

function ValidarPorcentajesV2(valorFilaEdit,gridViewName1, indCol, valor1)
{
    var intRespuesta = false;
    var tableElement1 = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName1);
    var textoElement1 = document.getElementById('ctl00_contentPlaceHolder1_' + valor1);
    var vHdnFila = document.getElementById('ctl00_contentPlaceHolder1_' + valorFilaEdit);
    
    var vElement1 = trim(textoElement1.value);     
    var vFila = trim(vHdnFila.value); 
    
    var sumaPct = vElement1;
    if (tableElement1 != null )
    {           
        for (var i=1;i<tableElement1.rows.length;i++)
        {
            var cell3 = tableElement1.rows[i].cells[indCol];
            
            var v3 = cell3.innerText.replace("%","").trim();
            if (v3 != null)
            {                
                if (v3 != "")
                {          
                    if (parseInt(vFila)+2 > i || parseInt(vFila)+2 < i )          
                    {
                        sumaPct = parseFloat(v3) + parseFloat(sumaPct);
                        sumaPct = Math.round(sumaPct*100)/100;
                        //var result=Math.round(original*100)/100  //returns 28.45
                    }
                    
                }
            }
        }        
    }    
    
    if(parseFloat(sumaPct) > 100.00)
    {
        alert("La suma de % debe ser menor o igual a 100%.");
        intRespuestaSumatoria = true;
    }
    else
    {
        intRespuestaSumatoria = false;
    }
    return intRespuestaSumatoria
}

//Validar Departamento en "Datos 2"
function ValidarDatosDuplicadosCombo(gridViewName,valor,valColum, idBoton)
{
    var intRespuesta = false ;
    var tableElement = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
    var ComboElement2 = document.getElementById('ctl00_contentPlaceHolder1_' + valor);
    var ValorTextCombo = trim(ComboElement2.options[ComboElement2.selectedIndex].text);
    var boton = document.getElementById('ctl00_contentPlaceHolder1_' + idBoton);
    if(boton.value == "Agregar")
    {
        if (tableElement != null )
        {
             for (var i=1;i<tableElement.rows.length;i++)
            {                             
                    var cell = tableElement.rows[i].cells[valColum];                                               
                    var v1 = trim(cell.innerText);
                    if (v1.toUpperCase() == ValorTextCombo.toUpperCase())
                    {            
                        intRespuesta = true ;                            
                    }            
             }       
        }    
        if (intRespuesta == true)
        {
           alert("El departamento ingresado ya existe.");
        }    
    }
    else
    {
        intRespuesta = false
    }
    return intRespuesta;    
}

function ValidarDatosDuplicados(gridViewName,valor,valColum, idBoton)
{
    var intRespuesta = false;
    var tableElement = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
    var textoElement = document.getElementById('ctl00_contentPlaceHolder1_' + valor);  
    var boton = document.getElementById('ctl00_contentPlaceHolder1_' + idBoton);  
    
    if (boton.value == "Agregar")
    {        
        if (tableElement != null )
        {
             for (var i=1;i<tableElement.rows.length;i++)
            {                             
                    var cell = tableElement.rows[i].cells[valColum];                                               
                    var v1 = trim(cell.innerText);
                    var v2 = trim(textoElement.value);                                                                   
                    if (v1.toUpperCase() == v2.toUpperCase())
                    {            
                    intRespuesta = true ;            
                    }            
             }       
        }    
        if (intRespuesta == true)
        {
            alert("Dato ingresado ya existe.");
        }    
    }
    else
    {
        intRespuesta = false;
    }
    return intRespuesta ;       
}

function ValidarDatosDuplicadosDoble(gridViewName,valor1,valor2,valColum1,valColum2, idBoton)
{
    var intRespuesta = false;
    var tableElement = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
    var textoElement1 = document.getElementById('ctl00_contentPlaceHolder1_' + valor1);  
    var textoElement2 = document.getElementById('ctl00_contentPlaceHolder1_' + valor2);  
    var boton = document.getElementById('ctl00_contentPlaceHolder1_' + idBoton);  
    
    if (boton.value == "Agregar")
    {        
        if (tableElement != null )
        {
             for (var i=1;i<tableElement.rows.length;i++)
            {                             
                    var cell1 = tableElement.rows[i].cells[valColum1];
                    var cell2 = tableElement.rows[i].cells[valColum2];
                    var v1 = trim(cell1.innerText);
                    var v2 = trim(textoElement1.value);
                    
                    var w1 = trim(cell2.innerText);
                    var w2 = trim(textoElement2.value);
                    
                    if (v1.toUpperCase() == v2.toUpperCase()) 
                    {          
                        if (w1.toUpperCase() == w2.toUpperCase())  
                        {
                            intRespuesta = true ;            
                        }
                    }            
             }       
        }    
        if (intRespuesta == true)
        {
            alert("Dato ingresado ya existe.");
        }    
    }
    else
    {
        intRespuesta = false;
    }
    return intRespuesta ;       
}


function ValidarDatosDuplicadosNumerDoble(gridViewName,valor1,valor2,valColum1,valColum2, idBoton)
{
    var intRespuesta = false;
    var tableElement = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
    var textoElement1 = document.getElementById('ctl00_contentPlaceHolder1_' + valor1);  
    var textoElement2 = document.getElementById('ctl00_contentPlaceHolder1_' + valor2);  
    var boton = document.getElementById('ctl00_contentPlaceHolder1_' + idBoton);  
    
    if (boton.value == "Agregar")
    {        
        if (tableElement != null )
        {
             for (var i=1;i<tableElement.rows.length;i++)
            {                             
                    var cell1 = tableElement.rows[i].cells[valColum1];
                    var cell2 = tableElement.rows[i].cells[valColum2];
                    var v1 = trim(cell1.innerText);
                    var v2 = trim(textoElement1.value);
                    
                    var w1 = trim(cell2.innerText);
                    var w2 = trim(textoElement2.value);
                    
                    if (v1.toUpperCase() == v2.toUpperCase()) 
                    {          
                        if (parseFloat(w1)== parseFloat(w2))  
                        {
                            intRespuesta = true ;            
                        }
                    }            
             }       
        }    
        if (intRespuesta == true)
        {
            alert("Dato ingresado ya existe.");
        }    
    }
    else
    {
        intRespuesta = false;
    }
    return intRespuesta ;       
}

function ValidarDatosDuplicadosSumatoriaPct(gridViewName,textbox1,textbox2,textbox3,valor,valColum)
{
    var intRespuesta = false;
    var intRespuestaSumatoria = false;
    var tableElement = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
    var textoElement = document.getElementById('ctl00_contentPlaceHolder1_' + valor);  
    var textoPct1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);  
    var textoPct2 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox2);  
    var textoPct3 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox3);  
    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value);
    
    if(parseFloat(sumaPct) > 100.00)
    {
        alert("La suma de % debe ser menor o igual a 100%.");
        intRespuestaSumatoria = true;
    }
    else
    {   
        if (tableElement != null )
        {   
            for (var i=1;i<tableElement.rows.length;i++)
            {                             
                var cell = tableElement.rows[i].cells[valColum];                                               
                var v1 = trim(cell.innerText);
                var v2 = trim(textoElement.value);                                                                   
                if (v1.toUpperCase() == v2.toUpperCase())
                {            
                    intRespuesta = true;
                }            
             }  
        }    
    }
    if (intRespuesta == true)
    {
        alert("Dato ingresado ya existe.");
    }    
    if(intRespuestaSumatoria == true)
        intRespuesta = true;
    return intRespuesta;       
}

function ValidarDatosDuplicadosSumatoria4Pct(gridViewName,textbox1,textbox2,textbox3,textbox4,valor,valColum)
{
    var intRespuesta = false;
    var intRespuestaSumatoria = false;
    var tableElement = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
    var textoElement = document.getElementById('ctl00_contentPlaceHolder1_' + valor);  
    var textoPct1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);  
    var textoPct2 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox2);  
    var textoPct3 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox3);  
    var textoPct4 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox4);
    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value)+parseFloat(textoPct4.value);
    
    if(parseFloat(sumaPct) > 100.00)
    {
        alert("La suma de % debe ser menor o igual a 100%.");
        intRespuestaSumatoria = true;
    }
    else
    {   
        if (tableElement != null )
        {   
            for (var i=1;i<tableElement.rows.length;i++)
            {                             
                var cell = tableElement.rows[i].cells[valColum];                                               
                var v1 = trim(cell.innerText);
                var v2 = trim(textoElement.value);                                                                   
                if (v1.toUpperCase() == v2.toUpperCase())
                {            
                    intRespuesta = true;
                }            
             }  
        }    
    }
    if (intRespuesta == true)
    {
        alert("Dato ingresado ya existe.");
    }    
    if(intRespuestaSumatoria == true)
        intRespuesta = true;
    return intRespuesta;       
}

function ValidarDatosDuplicadosSumatoria6Pct(gridViewName,textbox1,textbox2,textbox3,textbox4,textbox5,textbox6,valor,valColum)
{
    var intRespuesta = false;
    var intRespuestaSumatoria = false;
    var tableElement = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
    var textoElement = document.getElementById('ctl00_contentPlaceHolder1_' + valor);  
    var textoPct1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);  
    var textoPct2 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox2);  
    var textoPct3 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox3);  
    var textoPct4 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox4);
    var textoPct5 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox5);
    var textoPct6 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox6);
    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value)+parseFloat(textoPct4.value)+parseFloat(textoPct5.value)+parseFloat(textoPct6.value);
    
    if(parseFloat(sumaPct) > 100.00)
    {
        alert("La suma de % debe ser menor o igual a 100%.");
        intRespuestaSumatoria = true;
    }
    else
    {   
        if (tableElement != null )
        {   
            for (var i=1;i<tableElement.rows.length;i++)
            {                             
                var cell = tableElement.rows[i].cells[valColum];                                               
                var v1 = trim(cell.innerText);
                var v2 = trim(textoElement.value);                                                                   
                if (v1.toUpperCase() == v2.toUpperCase())
                {            
                    intRespuesta = true;
                }            
             }  
        }    
    }
    if (intRespuesta == true)
    {
        alert("Dato ingresado ya existe.");
    }    
    if(intRespuestaSumatoria == true)
        intRespuesta = true;
    return intRespuesta;       
}

function ValidarCostos(textboxDirecto1,textboxDirecto2,textboxDirecto3,textboxDirecto4,textboxDirecto5,textboxIndirecto1,textboxIndirecto2,textboxIndirecto3,textboxIndirecto4,textboxIndirecto5)
{
    var intRespuesta = false;
    intRespuesta = ValidarSumatoriaCostosDirectos(textboxDirecto1,textboxDirecto2,textboxDirecto3,textboxDirecto4,textboxDirecto5);
    if(!intRespuesta)
        intRespuesta = ValidarSumatoriaCostosIndirectos(textboxIndirecto1,textboxIndirecto2,textboxIndirecto3,textboxIndirecto4,textboxIndirecto5);
    return intRespuesta;
}

function ValidarSumatoriaCostosDirectos(textbox1,textbox2,textbox3,textbox4,textbox5)
{
    var intRespuestaSumatoria = false;
    var textoPct1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);  
    var textoPct2 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox2);  
    var textoPct3 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox3);  
    var textoPct4 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox4);
    var textoPct5 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox5);
    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value)+parseFloat(textoPct4.value)+parseFloat(textoPct5.value);
    if(parseFloat(sumaPct) > 100.00)
    {
        alert("Estructura de Costos:\nLa suma de % de Costos Directos debe ser menor o igual a 100%.");
        intRespuestaSumatoria = true;
    }
    return intRespuestaSumatoria;
}

function ValidarSumatoriaCostosIndirectos(textbox1,textbox2,textbox3,textbox4,textbox5)
{
    var intRespuestaSumatoria = false;
    var textoPct1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);  
    var textoPct2 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox2);  
    var textoPct3 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox3);  
    var textoPct4 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox4);
    var textoPct5 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox5);
    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value)+parseFloat(textoPct4.value)+parseFloat(textoPct5.value);
    if(parseFloat(sumaPct) > 100.00)
    {
        alert("Estructura de Costos:\nLa suma de % de Costos Indirectos debe ser menor o igual a 100%.");
        intRespuestaSumatoria = true;
    }
    return intRespuestaSumatoria;
}

function ValidarCostosUso(textboxDirecto1,textboxDirecto2,textboxDirecto3,textboxDirecto4,textboxDirecto5,textboxIndirecto1,textboxIndirecto2,textboxIndirecto3,textboxIndirecto4,textboxIndirecto5)
{
    var intRespuesta = false;
    intRespuesta = ValidarSumaCostosDirectosUso(textboxDirecto1,textboxDirecto2,textboxDirecto3,textboxDirecto4,textboxDirecto5);
    if(!intRespuesta)
        intRespuesta = ValidarSumaCostosIndirectosUso(textboxIndirecto1,textboxIndirecto2,textboxIndirecto3,textboxIndirecto4,textboxIndirecto5);
    return intRespuesta;
}

function ValidarSumaCostosDirectosUso(textbox1,textbox2,textbox3,textbox4,textbox5)
{
    var intRespuestaSumatoria = false;
    var textoPct1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);  
    var textoPct2 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox2);  
    var textoPct3 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox3);  
    var textoPct4 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox4);
    var textoPct5 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox5);

//esto debido a que quieren solo la suma de 3 campos ya no de los 5 campos
var sumaPct = parseFloat(textoPct1.value)+parseFloat(0)+parseFloat(0)+parseFloat(textoPct4.value)+parseFloat(textoPct5.value);

//    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value)+parseFloat(textoPct4.value)+parseFloat(textoPct5.value);

    if(parseFloat(sumaPct) > 100.00)
    {
        alert("Estructura de Costos:\nLa suma de % de Costos Directos (Materia prima, sueldos y salarios, depreciación) debe ser igual a 100%.");
        intRespuestaSumatoria = true;
    }
    if(parseFloat(sumaPct) < 100.00)
    {
        alert("Estructura de Costos:\nLa suma de % de Costos Directos (Materia prima, sueldos y salarios, depreciación) debe ser igual a 100%.");
        intRespuestaSumatoria = true;
    }
    
    return intRespuestaSumatoria;
}

function ValidarSumaCostosIndirectosUso(textbox1,textbox2,textbox3,textbox4,textbox5)
{
    var intRespuestaSumatoria = false;
    var textoPct1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);  
    var textoPct2 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox2);  
    var textoPct3 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox3);  
    var textoPct4 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox4);
    var textoPct5 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox5);
    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value)+parseFloat(textoPct4.value)+parseFloat(textoPct5.value);
    if(parseFloat(sumaPct) > 100.00)
    {
        alert("Estructura de Costos:\nLa suma de % de Costos Indirectos debe ser igual a 100%.");
        intRespuestaSumatoria = true;
    }
     if(parseFloat(sumaPct) < 100.00)
    {
        alert("Estructura de Costos:\nLa suma de % de Costos Indirectos debe ser igual a 100%.");
        intRespuestaSumatoria = true;
    }
    return intRespuestaSumatoria;
}

function ValidarDatosDuplicadosConFechas(gridViewName,valor,valColum, txtFechaInicioName, txtFechaFinName)
{
    var intRespuesta = false ;
    var txtFechaInicioElement = document.getElementById('ctl00_contentPlaceHolder1_' + txtFechaInicioName).value;
    var txtFechaFinElement = document.getElementById('ctl00_contentPlaceHolder1_' + txtFechaFinName).value;
    
     var dt1  = parseInt(txtFechaInicioElement.substring(0,2),10);
     var mon1 = parseInt(txtFechaInicioElement.substring(3,5),10);
     var yr1  = parseInt(txtFechaInicioElement.substring(6,10),10);
     var dt2  = parseInt(txtFechaFinElement.substring(0,2),10);
     var mon2 = parseInt(txtFechaFinElement.substring(3,5),10);
     var yr2  = parseInt(txtFechaFinElement.substring(6,10),10);
     var dateInicio = new Date(yr1, mon1, dt1);
     var dateFin = new Date(yr2, mon2, dt2);

     if(dateFin < dateInicio)
     {
         alert("La fecha de término ingresada debe ser mayor a la fecha de inicio.");
         intRespuesta = true;
     } 
     else
     {    
        var tableElement = document.getElementById('ctl00_contentPlaceHolder1_' + gridViewName);
        var textoElement = document.getElementById('ctl00_contentPlaceHolder1_' + valor);  

        if (tableElement != null )
        {
            for (var i=1;i<tableElement.rows.length;i++)
            {                             
                    var cell = tableElement.rows[i].cells[valColum];                                               
                    var v1 = trim(cell.innerText);
                    var v2 = trim(textoElement.value);                                                                   
                    if (v1.toUpperCase() == v2.toUpperCase())
                    {            
                    intRespuesta = true ;            
                    }            
             }       
        }    
        if (intRespuesta == true)
        {
        alert("Dato ingresado ya existe.");
        } 
    }   
    return intRespuesta ;       
}

function trim(cadena)
{
	for(i=0; i<cadena.length; )
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)
	{
		if(cadena.charAt(i)==" ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	return cadena	
}


function validarCampana2(tex1,tex2,opcion)
    {
     var txtBox1 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex1).value);
     var txtBox2 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex2).value);     
         
     var op = trim(opcion);
     var re = false;
     
     var opIngresa = false ;
     
     opIngresa = ValidarInputNumerico();
     
     if (opIngresa = true )
     {
     
     var  keyAscii = event.keyCode;
     
	if(keyAscii!=13)
	{
		var key = String.fromCharCode(event.keyCode); 
	 	var keyAj = key.toUpperCase();	 	    

        if (opcion == '1')
             {
                txtBox1 = txtBox1 + trim(keyAj); 
                if (txtBox1.length == '4')
                {       
                    if (parseFloat(txtBox1) >= parseFloat(txtBox2) )
                    {       
                        alert('Año Ingresado es Incorrecto.'); 
                        re = true;                    
                    }
                    else 
                    {
                        re = false;                    
                    }                
                }
             }    
     
         if (opcion == '2')
         {
            txtBox2 = txtBox2 + trim(keyAj);        
            if (txtBox2.length == '4')
            {
            if (parseFloat(txtBox2) <= parseFloat(txtBox1))
                {
                    alert('Año Ingresado es Incorrecto.');            
                    re = true;
                }
                else 
                {                    
                    re = false;
                }
            }
         }          
          
     }              
     
    }        
     return re ;     
    }

function validarCampana3(tex1,tex2,tex3,opcion)
    {
     var txtBox1 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex1).value);
     var txtBox2 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex2).value);
     var txtBox3 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex3).value);
         
     var op = trim(opcion);
     var re = false;
     
     var opIngresa = false ;
     
     opIngresa = ValidarInputNumerico();
     
     if (opIngresa = true )
     {
     
     var  keyAscii = event.keyCode;
     
	if(keyAscii!=13)
	{
		var key = String.fromCharCode(event.keyCode); 
	 	var keyAj = key.toUpperCase();	 	    

        if (opcion == '1')
             {
                txtBox1 = txtBox1 + trim(keyAj); 
                if (txtBox1.length == '4')
                {       
                    if (parseFloat(txtBox1) >= parseFloat(txtBox2) || parseFloat(txtBox1) >= parseFloat(txtBox3))
                    {       
                        alert('Año Ingresado es Incorrecto.'); 
                        re = true;                    
                    }
                    else 
                    {
                        re = false;                    
                    }                
                }
             }    
     
         if (opcion == '2')
         {
            txtBox2 = txtBox2 + trim(keyAj);        
            if (txtBox2.length == '4')
            {
            if (parseFloat(txtBox2) <= parseFloat(txtBox1) || parseFloat(txtBox2) >= parseFloat(txtBox3))
                {
                    alert('Año Ingresado es Incorrecto.');            
                    re = true;
                }
                else 
                {                    
                    re = false;
                }
            }
         }
        
    if (opcion == '3')
         {            
            txtBox3 = txtBox3 + trim(keyAj);        
            if (txtBox3.length == '4')
            {
            if (parseFloat(txtBox3) <= parseFloat(txtBox1) || parseFloat(txtBox3) <= parseFloat(txtBox2))
                {
                    alert('Año Ingresado es Incorrecto.');            
                    re = true;
                }
                else 
                {                    
                    re = false;
                }
            }
         }
          
     }              
     
    }        
     return re ;     
    }

//function validarAnio(tex1,tex2,tex3,tex4,opcion)
function validarAnio(tex1,tex2,tex4,opcion)
    {
     var txtBox1 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex1).value);
     var txtBox2 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex2).value);
//   var txtBox3 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex3).value);
     var txtBox4 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex4).value);
     var op = trim(opcion);
     var re = false;
     
     var opIngresa = false ;
     
     opIngresa = ValidarInputNumerico();
     
     if (opIngresa = true )
     {
     
     var  keyAscii = event.keyCode;
     
	if(keyAscii!=13)
	{
		var key = String.fromCharCode(event.keyCode); 
	 	var keyAj = key.toUpperCase();	 	    

        if (opcion == '1')
             {
                txtBox1 = txtBox1 + trim(keyAj); 
                if (txtBox1.length == '4')
                {       
                if (txtBox1 == txtBox2 || txtBox1 == txtBox4)
                {            
                    re = true;                    
                }
                else 
                {
                AsignarAnioMineria(txtBox1,opcion)                
                }
                
                }
             }    
     
         if (opcion == '2')
         {
            txtBox2 = txtBox2 + trim(keyAj);        
            if (txtBox2.length == '4')
            {
            if (txtBox1 == txtBox2 || txtBox2 == txtBox4)
                {            
                    re = true;
                }
                else 
                {
                AsignarAnioMineria(txtBox2,opcion)                
                }
            }
         }
        
    if (opcion == '4')
         {
            txtBox4 = txtBox4 + trim(keyAj);        
            if (txtBox4.length == '4')
            {
            if (txtBox1 == txtBox4 || txtBox2 == txtBox4)
                {            
                    re = true;
                }
                else 
                {
                AsignarAnioMineria(txtBox4,opcion)                
                }
            }
         }
          
     }              
     
    }        
     return re ;     
    }
    
    function AsignarAnioMineria(ctrTexbox,opcion)
    {    
        if (opcion=='1')
        {
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtLeyReservAnio1').value = ctrTexbox;
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtMinExploAnno1').value = ctrTexbox; 
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtMinUtilAnno1').value = ctrTexbox; 
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtLeyResCapInstal1').value = ctrTexbox;        
        }
        
        if (opcion=='2')
        {
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtLeyReservAnio2').value = ctrTexbox;
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtMinExploAnno2').value = ctrTexbox; 
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtMinUtilAnno2').value = ctrTexbox; 
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtLeyResCapInstal2').value = ctrTexbox;        
        }
        
        if (opcion=='4')
        {
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtLeyReservAnio4').value = ctrTexbox;
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtMinExploAnno4').value = ctrTexbox; 
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtMinUtilAnno4').value = ctrTexbox; 
        document.getElementById('ctl00_contentPlaceHolder1_' + 'txtLeyResCapInstal4').value = ctrTexbox;        
        }        
    }
        
    function ValidaMes(tex1)
    {
    var txtBox1 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex1).value);    
        var opIngresa = false ;
        var res = true;
        opIngresa = ValidarInputNumerico();    
        if (opIngresa = true)
         {                  
            var  keyAscii = event.keyCode;        
	        if(keyAscii!=13)
	        {	        
		        var key = String.fromCharCode(event.keyCode); 
	 	        var keyAj = key.toUpperCase();	 	    	 	    
	 	        txtBox1 = txtBox1 + trim(keyAj);	 	    	 	    
	 	        if(txtBox1<='12')
	 	        {	 	    	 	    
	 	        res = false;
	 	        }	 	    	 	    
	 	    }     
         }    
         return res
    }
    
    
    function ValidarInputDecimalUserControl(ctrTexbox) {  
    
var txtBox = trim(document.getElementById(ctrTexbox).value);
var resul = false ;
var resul2 = false ;

    for (i=0;i<txtBox.length;i++)
        {
        if (txtBox.charAt(i)==".")
            {
            resul = true;        
            }
        }                
        
        if (resul == true)
        {        
        resul2 = ValidarInputNumerico();
        }
        else
        {        
        resul2 = ValidaDecimal();
        }        
        return resul2;
 
}
    
    function HabilitaControl(ctrDd1,ctrDd2)
        {
        var ddlVal = trim(document.getElementById(ctrDd1).value);
        var ddlVal2 = document.getElementById(ctrDd2);
        if (ddlVal == '001')
        {        
        ddlVal2.disabled=false;
        }
        else
        {        
        ddlVal2.disabled=true;
        ddlVal2.value = '000';
        }
        return true;
        } 
        
function HabilitaControlTextBox(ctrDd1,ctrDd2)
{
var ddlVal = trim(document.getElementById(ctrDd1).value);
var ddlVal2 = document.getElementById(ctrDd2);
if (ddlVal == '002')
{        
ddlVal2.disabled=false;
}
else
{        
ddlVal2.disabled=true;
ddlVal2.value = '';
}
return true;
}        
        
function ValidarDatosDuplicadosFiltrosAux(ctrCombo,camp1,ctrTexbox,camp2)
{    
    var intRespuesta = false;    
//    //grilla
//    var GridElement1 = document.getElementById('ctl00_contentPlaceHolder1_' + ctrGrid);    
    //combo
    var ComboElement2 = document.getElementById('ctl00_contentPlaceHolder1_' + ctrCombo);    
    //columa01
    var Columna1 = trim(camp1);    
    //texbox
    var TextoElement3 = document.getElementById('ctl00_contentPlaceHolder1_' + ctrTexbox);      
    //columa02
    var Columna2 = trim(camp2);      
    
    //valor texto del combo
    var ValorTextCombo = ComboElement2.options[ComboElement2.selectedIndex].text;
    //valor del texbox
    var ValorTextoBox = trim(TextoElement3.value);           
    
    //grilla
    var GridElement1 = document.getElementById('ctl00_contentPlaceHolder1_ucInformacionDireccion_gvwAccionistas');                            
            
    if (GridElement1 != null )
    {                 
        for (var i=1;i<GridElement1.rows.length;i++)
        {   
            var cell1 = GridElement1.rows[i].cells[Columna1];                                               
            var cell2 = GridElement1.rows[i].cells[Columna2];                    
            
            var v1 = trim(cell1.innerText);
            var v2 = trim(cell2.innerText);                        
    
            
            if (v1.toUpperCase() == ValorTextCombo.toUpperCase() && v2.toUpperCase() == ValorTextoBox.toUpperCase())
            {   
                intRespuesta = true ;                
            }
        }      
    } 
    
    if (intRespuesta == false)
    {
        var GridElement2 = document.getElementById('ctl00_contentPlaceHolder1_ucInformacionDireccion_gvwDirectorio');    
        
        if (GridElement2 != null )
        {
            for (var i=1;i<GridElement2.rows.length;i++)
            {       
                var cell1 = GridElement2.rows[i].cells[Columna1];                                               
                var cell2 = GridElement2.rows[i].cells[Columna2];                    
                
                var v1 = trim(cell1.innerText);
                var v2 = trim(cell2.innerText);
                
                if (v1.toUpperCase() == ValorTextCombo.toUpperCase() && v2.toUpperCase() == ValorTextoBox.toUpperCase())
                {            
                    intRespuesta = true ;
                }            
            }
        }
    }
        
    if (intRespuesta == false)
    {
        var GridElement3 = document.getElementById('ctl00_contentPlaceHolder1_ucInformacionDireccion_gvwEjecutivo');            
        if (GridElement3 != null )
        {         
            for (var i=1;i<GridElement3.rows.length;i++)
            {       
                var cell1 = GridElement3.rows[i].cells[Columna1];                                               
                var cell2 = GridElement3.rows[i].cells[Columna2];                    
                
                var v1 = trim(cell1.innerText);
                var v2 = trim(cell2.innerText);
                if (v1.toUpperCase() == ValorTextCombo.toUpperCase() && v2.toUpperCase() == ValorTextoBox.toUpperCase())
                {            
                    intRespuesta = true ;
                }            
            }
        }
    }
       
    if (intRespuesta == true)
    {
        alert("Dato ingresado ya existe.");
    }    
    return intRespuesta ;       
}

function ValidarDatoMayorCero(textbox)
{
    var blnResultado = false;
    var textoIngreso1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);     
    
    if(parseFloat(textoIngreso1.value)>0.00)
        blnResultado = true;
    return blnResultado;
}

function ValidaMesV2(tex1,tex2)
    {
    var txtBox1 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex1).value);  
    
     //años
     var txtBox2 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex2).value);
       
        var opIngresa = false ;
        var res = true;
        opIngresa = ValidarInputNumerico();    
        if (opIngresa = true)
         {                  
            var  keyAscii = event.keyCode;        
	        if(keyAscii!=13)
	        {	        
		        var key = String.fromCharCode(event.keyCode); 
	 	        var keyAj = key.toUpperCase();	 	    	 	    
	 	        txtBox1 = txtBox1 + trim(keyAj);	 	    	 	    
	 	        if(txtBox1<='12')
	 	        {	 	    	 	    
	 	        res = false;
	 	        }	 	    	 	    
	 	    }     
         }    
         
         document.getElementById('ctl00_contentPlaceHolder1_' + tex2).value='';
         
         return res
    }
    
function validarIngresoPeriodos(tex1,tex2,tex3,tex4,opcion)
    {
     //años
     var txtBox1 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex1).value);
     var txtBox2 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex2).value);
     
     //meses
     var txtBox3 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex3).value);
     var txtBox4 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex4).value);
         
     var op = trim(opcion);
     var re = false;
     
     var opIngresa = false ;
     
     opIngresa = ValidarInputNumerico();
     
     if (opIngresa = true )
     {
     
     var  keyAscii = event.keyCode;
     
	if(keyAscii!=13)
	{
		var key = String.fromCharCode(event.keyCode); 
	 	var keyAj = key.toUpperCase();	 	    

        //periodo incial ingresado
        if (opcion == '1')
             {
                txtBox1 = txtBox1 + trim(keyAj); 
                if (txtBox1.length == '4')
                {       
                    if (parseFloat(txtBox1) > parseFloat(txtBox2))
                    {       
                        alert('Periodo Ingresado es Incorrecto.'); 
                        re = true;                    
                    }
                    else 
                    {
                        if (parseFloat(txtBox1) == parseFloat(txtBox2))
                            {   //validar meses de ingreso    
                                if (parseFloat(txtBox3) > parseFloat(txtBox4))
                                    {       
                                        alert('Periodo Ingresado es Incorrecto.'); 
                                        re = true;                    
                                    }
                                else
                                    {
                                        re = false;            
                                    }                                
                            }
                        else
                            {
                                re = false;    
                            }                                                
                    }                
                }
             }    
     
        //periodo final ingresado
         if (opcion == '2')
             {
                txtBox2 = txtBox2 + trim(keyAj); 
                if (txtBox2.length == '4')
                {                           
                    if (parseFloat(txtBox2) < parseFloat(txtBox1))
                    {       
                        alert('Periodo Ingresado es Incorrecto.'); 
                        re = true;                    
                    }
                    else 
                    {   
                        //llega                           
                        if (parseFloat(txtBox1) == parseFloat(txtBox2))
                            { 
                                if (parseFloat(txtBox3) > parseFloat(txtBox4))
                                    {       
                                        alert('Periodo Ingresado es Incorrecto.'); 
                                        re = true;                    
                                    }
                                else
                                    {
                                        re = false;      
                                        //Acumulador      
                                        
                                    }                                
                            }
                        else
                            {                                                        
                                re = false;    
                                //Acumulador      
                                
                            }                                                
                    }                
                }
             }    
          
     }              
     
    }        
     return re ;     
    }
    
    function validarIngresoPeriodosV2(tex1,tex2,tex3,tex4,hdn,opcion)
    {
     //años
     var txtBox1 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex1).value);
     var txtBox2 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex2).value);
     
     //meses
     var txtBox3 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex3).value);
     var txtBox4 = trim(document.getElementById('ctl00_contentPlaceHolder1_' + tex4).value);
         
     var op = trim(opcion);
     var re = false;
     
     var opIngresa = false ;
     
     opIngresa = ValidarInputNumerico();
     
     if (opIngresa = true )
     {
     
     var  keyAscii = event.keyCode;
     
	if(keyAscii!=13)
	{
		var key = String.fromCharCode(event.keyCode); 
	 	var keyAj = key.toUpperCase();	 	    

        //periodo incial ingresado
        if (opcion == '1')
             {
                txtBox1 = txtBox1 + trim(keyAj); 
                if (txtBox1.length == '4')
                {       
                    if (parseFloat(txtBox1) > parseFloat(txtBox2))
                    {       
                        alert('Periodo Ingresado es Incorrecto.'); 
                        re = true;                    
                    }
                    else 
                    {
                        if (parseFloat(txtBox1) == parseFloat(txtBox2))
                            {   //validar meses de ingreso    
                                if (parseFloat(txtBox3) > parseFloat(txtBox4))
                                    {       
                                        alert('Periodo Ingresado es Incorrecto.'); 
                                        re = true;                    
                                    }
                                else
                                    {
                                        re = false;       
                                         //Acumulador      
                                        document.getElementById('ctl00_contentPlaceHolder1_' + hdn).value= parseFloat(txtBox1)*12+parseFloat(txtBox3);     
                                    }                                
                            }
                        else
                            {
                                re = false;  
                                 //Acumulador      
                                document.getElementById('ctl00_contentPlaceHolder1_' + hdn).value= parseFloat(txtBox1)*12+parseFloat(txtBox3);  
                            }                                                
                    }                
                }
             }    
     
        //periodo final ingresado
         if (opcion == '2')
             {
                txtBox2 = txtBox2 + trim(keyAj); 
                if (txtBox2.length == '4')
                {                           
                    if (parseFloat(txtBox2) < parseFloat(txtBox1))
                    {       
                        alert('Periodo Ingresado es Incorrecto.'); 
                        re = true;                    
                    }
                    else 
                    {   
                        //llega                           
                        if (parseFloat(txtBox1) == parseFloat(txtBox2))
                            { 
                                if (parseFloat(txtBox3) > parseFloat(txtBox4))
                                    {       
                                        alert('Periodo Ingresado es Incorrecto.'); 
                                        re = true;                    
                                    }
                                else
                                    {
                                        re = false;      
                                        //Acumulador      
                                        document.getElementById('ctl00_contentPlaceHolder1_' + hdn).value= parseFloat(txtBox2)*12+parseFloat(txtBox4);
                                    }                                
                            }
                        else
                            {                                                        
                                re = false;    
                                //Acumulador      
                                document.getElementById('ctl00_contentPlaceHolder1_' + hdn).value= parseFloat(txtBox2)*12+parseFloat(txtBox4);
                            }                                                
                    }                
                }
             }    
          
     }              
     
    }        
     return re ;     
    }
    
    function ValidarSectorIndustria()
    {
    if(ValidarCostosUso('txtConMateriaPrima','txtConNacional','txtConImportada','txtConSaldoSalarios','txtConDepreciacion','txtConGastoGeneral','txtConEnergia','txtConSuministro','txtConSeguros','txtConSueldoSalIndi'))
    {        
        return false;
    }
    else
    {
        return true;//confirm('¿Deseas registrar los datos del sector?.');
    }
    }
    
    function ValidarSectorPesca()
    {
    if(ValidarCostosUsoPesca('txtCostosMatPrima','txtCostosCombustible','txtCostosMant','txtCostosManoObra','txtCostosOtros'))
    {        
        return false;
    }
    else
    {
        return true;//confirm('¿Deseas registrar los datos del sector?.');
    }
    }
    
    function ValidarCostosUsoPesca(textboxDirecto1,textboxDirecto2,textboxDirecto3,textboxDirecto4,textboxDirecto5)
    {
    var intRespuesta = false;
    intRespuesta = ValidarSumaCostosDirectosUsoPesca(textboxDirecto1,textboxDirecto2,textboxDirecto3,textboxDirecto4,textboxDirecto5);
    return intRespuesta;
    }

    function ValidarSumaCostosDirectosUsoPesca(textbox1,textbox2,textbox3,textbox4,textbox5)
    {
    var intRespuestaSumatoria = false;
    var textoPct1 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox1);  
    var textoPct2 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox2);  
    var textoPct3 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox3);  
    var textoPct4 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox4);
    var textoPct5 = document.getElementById('ctl00_contentPlaceHolder1_' + textbox5);

    //esto debido a que quieren solo la suma de 3 campos ya no de los 5 campos
    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value)+parseFloat(textoPct4.value)+parseFloat(textoPct5.value);
    //    var sumaPct = parseFloat(textoPct1.value)+parseFloat(textoPct2.value)+parseFloat(textoPct3.value)+parseFloat(textoPct4.value)+parseFloat(textoPct5.value);

        if(parseFloat(sumaPct) > 100.00)
        {
            alert("Estructura de Costos:\nLa suma de % de Costos Directos debe ser igual a 100%.");
            intRespuestaSumatoria = true;
        }
        if(parseFloat(sumaPct) < 100.00)
        {
            alert("Estructura de Costos:\nLa suma de % de Costos Directos debe ser igual a 100%.");
            intRespuestaSumatoria = true;
        }
        
        return intRespuestaSumatoria;
    }
function ValidarAnioConstitucion()
     {        
        var txtfecha = document.getElementById('ctl00_ContentPlaceHolder1_ucInformacionBasica_txtFecNacimientoCliente');
               
        if(txtfecha != null )
        {
            var fecha = txtfecha.value;
            date_now = new Date();
            var anio = date_now.getFullYear();
            var mes = date_now.getMonth();
            var dia = date_now.getDate();
            fechaControl = fecha.split("/");
            var diaControl = parseInt(fechaControl[0]);
            var MesControl = parseInt(fechaControl[1]);
            var AnioControl = parseInt(fechaControl[2]);
            if(anio >= AnioControl)
            {
                if((mes + 1) >= MesControl)
                {
                    if(dia < diaControl)
                    {
                        alert("Ingrese una fecha de nacimiento / constitución anterior o igual al día de hoy");
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
                else
                {
                    alert("Ingrese una fecha de nacimiento / constitución anterior o igual al día de hoy");
                    return false;
                }
            }
            else
            {
                alert("Ingrese una fecha de nacimiento / constitución anterior o igual al día de hoy");
                return false;
            } 
        }      
     }
     function Pegar(obj)
     {  
        var maxLength = document.getElementById(obj.id).getAttribute("MaxLength");        
        obj.value += window.clipboardData.getData("Text").substring(0, maxLength - obj.value.length);
        event.returnValue = false;
     }
     
     function PegarMultiline(obj, maxLength)
     {          
        obj.value += window.clipboardData.getData("Text").substring(0, maxLength - obj.value.length);        
        event.returnValue = false;
     }
//COmentado el 28/04/2010
//function ValidarSectorIndustria()
//{
//    if(ValidarCostos('txtConMateriaPrima','txtConNacional','txtConImportada','txtConSaldoSalarios','txtConDepreciacion','txtConGastoGeneral','txtConEnergia','txtConSuministro','txtConSeguros','txtConSueldoSalIndi',0))
//    {        
//        return false;
//    }
//    else
//    {
//        return true;//confirm('¿Deseas registrar los datos del sector?.');
//    }
//}



