
var _presionoEnter = false;

function _CerrarSesion() 
{
	BaseVistas.AJAXCerrarSesion(_CB_CC); 
}

function _CB_CC(res)
{}

/* Pasaje de Minutos a Descripcion */
function _CerrarComboMinutosOnfocusout() {
	var comboBox;
	var textBox;
	var buscadorTabla;
		
	buscadorTabla =  document.all['txtMinutos_buscadorTabla'];

	if (buscadorTabla.style.display == "none") {
		textBox = document.all['txtMinutos_seleccionTextBox'];
		comboBox = document.all['txtMinutos_listaComboBox'];
		comboBox.style.display = 'none'; 

		textBox.style.display = '';
		textBox.value = comboBox(comboBox.selectedIndex).innerText;    
		textBox.title = comboBox(comboBox.selectedIndex).innerText;
		
		// window.event.cancelBubble = true;
		// document.all.item("btnInsertar").focus();	
	}

}


function _CerrarComboAvanceOnfocusout() {
	var comboBox;
	var textBox;
	var buscadorTabla;
		
	buscadorTabla =  document.all['txtAvance_buscadorTabla'];

	if (buscadorTabla.style.display == "none") {
		textBox = document.all['txtAvance_seleccionTextBox'];
		comboBox = document.all['txtAvance_listaComboBox'];
		comboBox.style.display = 'none'; 

		textBox.style.display = '';
		textBox.value = comboBox(comboBox.selectedIndex).innerText;    
		textBox.title = comboBox(comboBox.selectedIndex).innerText;
		//document.all.item("txtdescripcion").focus();		
			}

}



////////////////////////////////////////////////////////////////////////
//  Guarda y Carga el estado del scroll de la vista de Período
////////////////////////////////////////////////////////////////////////

function GuardarScroll()
{
	try{
  document.Form1._ventanaScroll.value = _ventanaVistaPeriodo.scrollLeft;
  document.Form1._ventanaVDScroll.value = _ventanaVD.scrollTop;
  	}catch(e) {}
}

function CargarScroll()
{
	try {
	_ventanaVistaPeriodo.scrollLeft = document.Form1._ventanaScroll.value;
	_ventanaVD.scrollTop = document.Form1._ventanaVDScroll.value;    
	}catch(e) {}
}


	


function _ContinuarEjecucion() {
	try{
		var s = window.event.toElement.outerHTML;
		
		if ((window.event.toElement.id.indexOf("txtHoras") == -1) && window.event.toElement.id.indexOf("txtMinutos") == -1) {
			if (window.event.toElement.id.indexOf("_seleccionTextBox") != -1) return false;
		}
		
		if ((s.indexOf("btnIngresoGastos") != -1) ||
		(s.indexOf("btnReportes") != -1) ||
		(s.indexOf("btnIngresoHoras") != -1) ||
		(s.indexOf("btnInformacion") != -1) ||
		(s.indexOf("btnConsultaCliente") != -1) ||
		(s.indexOf("btnAutorizaciones") != -1) || 
		(s.indexOf("btnAnticipos") != -1) || 
		(s.indexOf("bloquear") != -1) || 
		(s.indexOf("tabBloque") != -1) ||
		(s.indexOf("calFecha") != -1) || 
		(s.indexOf("chkCargaRango") != -1) || 		
		(s.indexOf("Modificar") != -1) || 					
		(s.indexOf("chkOpcionesVista") != -1) || 				
		(s.indexOf("btnVistaPeriodica") != -1) || 				
		(s.indexOf("btnVistaDiaria") != -1) || 				
		(s.indexOf("radCargaRangoFinal") != -1) || 			
		(s.indexOf("radCargaRangoIncial") != -1) || 			
		(s.indexOf("radFiltro") != -1) || 				
		(s.indexOf("chkCronometro") != -1) || 		
		(s.indexOf("chkMoverRegistros") != -1) || 		
		(s.indexOf("CargarGastos") != -1) || 
		(s.indexOf("btnAvanceProyecto") != -1) || 
		(s.indexOf("btnCompletarDias") != -1) || 			
		(s.indexOf("CargareGastos") != -1)) 		 {
			window.cancelBubble = true;
			return false;
		}else {
			return true;
		}
	}catch(e) {return true;}	
}

/* Pasaje de Proyecto a Tarea */
function _CerrarComboTipoGastoOnfocusout() {
	var comboBox;
	var textBox;
	var buscadorTabla;
	var sugerencia;
	
	textBox = document.all['txtTipoGasto_seleccionTextBox'];
	comboBox = document.all['txtTipoGasto_listaComboBox'];
	buscadorTabla =  document.all['txtTipoGasto_buscadorTabla'];
	
	if (buscadorTabla.style.display == "none") {
		comboBox.style.display = 'none'; 
		textBox.style.display = '';
				
		textBox.value = comboBox(comboBox.selectedIndex).innerText + " - " + comboBox(comboBox.selectedIndex).value;      
		textBox.title = comboBox(comboBox.selectedIndex).innerText;
		
		if (document.all["AttrT" + comboBox.value].reqInfo == "1") {
			
			document.all["lblTipoInfo"].innerText = document.all["AttrT" + comboBox.value].tipoInfo ;
			document.all.item("txtTipoInfo_seleccionTextBox").style.display = ""; 
			document.all.item("txtTipoInfo_seleccionTextBox").style.backgroundColor = "whitesmoke";
			document.all.item("txtTipoInfo_seleccionTextBox").disabled = false;
			document.all.item("txtTipoInfo_seleccionTextBox").Habilitado = "true";
			document.all["lblDescripcion"].innerText = document.all["AttrT" + comboBox.value].leyendaCustom ;
		
		}
		
		if ((!_ContinuarEjecucion()) && (!_presionoEnter)) return;
		
		_PrepararComboTipoDoc(document.all["AttrT" + comboBox.value].usaTipoDoc);

	}
	primeraVes = 0;	
	
}


function OnKeyDownG(){
var comboBox;  

OnKeyDown();

comboBox = document.all['txtTipoGasto_listaComboBox'];

	if( window.event.keyCode==13 && (window.event.srcElement.className == "combo" || window.event.srcElement.className == "buscadorTexto")) 
	{		
		if (window.event.srcElement.id == "txtTipoGasto_listaComboBox") 
		{
			if	(document.all["AttrT" + comboBox.value].usaTipoDoc == "0") 
			{  	
				if (document.all["AttrT" + comboBox.value].reqInfo == "0") 
				{			
					document.all['txtMoneda_seleccionTextBox'].style.display = ''; 
					document.all['txtMoneda_seleccionTextBox'].title = ""; 
					document.all['txtMoneda_listaComboBox'].style.display = 'none'; 
					AbrirComboBox(document.all['txtMoneda_seleccionTextBox'], document.all['txtMoneda_listaComboBox']);
				}else
				{
					document.all["lblTipoInfo"].innerText = document.all["AttrT" + comboBox.value].tipoInfo ;
					document.all.item("txtTipoInfo_seleccionTextBox").style.display = ""; 
					document.all.item("txtTipoInfo_seleccionTextBox").style.backgroundColor = "whitesmoke";
					document.all.item("txtTipoInfo_seleccionTextBox").disabled = false;
					document.all.item("txtTipoInfo_seleccionTextBox").Habilitado = "true";
					document.all["lblDescripcion"].innerText = document.all["AttrT" + comboBox.value].leyendaCustom ;
					try{					
						document.all.item("txtTipoInfo_seleccionTextBox").focus();							
					}catch(e){}
				}		
			}
		}else
		{
			if (window.event.srcElement.id == "txtTipoDoc_listaComboBox") 
			{
				try{
					document.all.item("txtNroDoc_seleccionTextBox").focus();				
				}catch(e){}
			}else
			{
				if (window.event.srcElement.id == "txtMoneda_listaComboBox") 
				{
					try{
						document.all.item("txtImporte_seleccionTextBox").focus();				
					}catch(e){}
				}else
				{
					try {
						document.all.item("_cuerpo").focus();			
					}catch(e){}
				}
			}
		}
	}else
	{
		if (window.event.keyCode==13 && (window.event.srcElement.id == "txtNroDoc_seleccionTextBox")) 
		{
			try{
				document.all.item("txtTipoInfo_seleccionTextBox").focus();				
			}catch(e){}
		}
	}
}

// RSV 07/12/2008 Req. 1
function OnKeyDownRG(){
var comboBox;  

OnKeyDown();
if (window.event.keyCode==13 || window.event.keyCode==9)
{
comboBox = document.all['txtTipoGasto_listaComboBox'];
  
	if( (window.event.keyCode==13 || window.event.keyCode==9) && (window.event.srcElement.className == "combo" || window.event.srcElement.className == "buscadorTexto")) 
	{		
		if   (window.event.srcElement.id == "txtTipoGasto_listaComboBox") 
		{
				document.all.item("txtImporte_seleccionTextBox").focus();
				return;
		}
	
		if (window.event.srcElement.id == "txtMoneda_listaComboBox") 
		{
					
			if (document.all['txtMoneda_seleccionTextBox'].value  == "1") 
			{
				document.all['txtMonedaGasto_seleccionTextBox'].style.display = ''; 
				document.all['txtMonedaGasto_seleccionTextBox'].title = ""; 
				document.all['txtMonedaGasto_listaComboBox'].style.display = 'none'; 
				AbrirComboBox(document.all['txtMonedaGasto_seleccionTextBox'], document.all['txtMonedaGasto_listaComboBox']);
				return;
			}else
			{	
				document.all.item("txtTipoCambio_seleccionTextBox").focus();
				return;
			}
		}
		if (window.event.srcElement.id == "txtMonedaGasto_listaComboBox") 
		{
			if (document.all['txtMonedaGasto_seleccionTextBox'].value  == "1") 
			{
				document.all['txtTipoGasto_seleccionTextBox'].style.display = ''; 
				document.all['txtTipoGasto_seleccionTextBox'].title = ""; 
				document.all['txtTipoGasto_listaComboBox'].style.display = 'none'; 
				AbrirComboBox(document.all['txtTipoGasto_seleccionTextBox'], document.all['txtTipoGasto_listaComboBox']);
				return;
			}else
			{	
				document.all.item("txtTipoCambioGasto_seleccionTextBox").focus();
				return;
			}
		}
		
		if (window.event.srcElement.id == "txtProyecto_listaComboBox") 
		{
					document.all['txtMedioPago_seleccionTextBox'].style.display = ''; 
					document.all['txtMedioPago_seleccionTextBox'].title = ""; 
					document.all['txtMedioPago_listaComboBox'].style.display = 'none'; 
					AbrirComboBox(document.all['txtMedioPago_seleccionTextBox'], document.all['txtMedioPago_listaComboBox']);
					return;
		}else
		if (window.event.srcElement.id == "txtMedioPago_listaComboBox") 
		{
					document.all.item("txtNroAnticipo").focus();
					return;
		}else
			{
					try {
						document.all.item("_cuerpo").focus();			
					}catch(e){}
			}
	}else
	{
		if ((window.event.keyCode==13 || window.event.keyCode==9) && (window.event.srcElement.id == "txtTipoCambioGasto_seleccionTextBox"))
		{
				document.all['txtTipoGasto_seleccionTextBox'].style.display = ''; 
				document.all['txtTipoGasto_seleccionTextBox'].title = ""; 
				document.all['txtTipoGasto_listaComboBox'].style.display = 'none'; 
				AbrirComboBox(document.all['txtTipoGasto_seleccionTextBox'], document.all['txtTipoGasto_listaComboBox']);
			return;
		}		
		if ((window.event.keyCode==13 || window.event.keyCode==9) && (window.event.srcElement.id == "txtNroAnticipo") && (document.all.item("txtNroAnticipo").value == "" ))
		{
				document.all['txtMoneda_seleccionTextBox'].style.display = ''; 
				document.all['txtMoneda_seleccionTextBox'].title = ""; 
				document.all['txtMoneda_listaComboBox'].style.display = 'none'; 
				AbrirComboBox(document.all['txtMoneda_seleccionTextBox'], document.all['txtMoneda_listaComboBox']);
				return;
		}		
		if ((window.event.keyCode==13 || window.event.keyCode==9) && (window.event.srcElement.id == "txtTipoCambio_seleccionTextBox"))
		{
				document.all['txtMonedaGasto_seleccionTextBox'].style.display = ''; 
				document.all['txtMonedaGasto_seleccionTextBox'].title = ""; 
				document.all['txtMonedaGasto_listaComboBox'].style.display = 'none'; 
				AbrirComboBox(document.all['txtMonedaGasto_seleccionTextBox'], document.all['txtMonedaGasto_listaComboBox']);
				return;
		}		
	
		if  ((window.event.keyCode==13 || window.event.keyCode==9) &&  (window.event.srcElement.id == "txtFechaGasto")) 
			{
					document.all.item("chkFacturable").focus();
					return;
			}
		if  ((window.event.keyCode==13 || window.event.keyCode==9) &&  (window.event.srcElement.id == "chkFacturable")) 
			{
					document.all.item("chkComprobante").focus();
					return;
			}	
		if  ((window.event.keyCode==13 || window.event.keyCode==9) &&  (window.event.srcElement.id == "chkComprobante")) 
			{
					document.all.item("btnInsertar").focus();
					return;
			}		
		if  ((window.event.keyCode==13 || window.event.keyCode==9) &&  (window.event.srcElement.id == "txtImporte_seleccionTextBox")) 
			{
					document.all.item("txtDescripcion").focus();
					return;
			}	
		if  ((window.event.keyCode==9) &&  (window.event.srcElement.id == "txtDescripcion")) 
			{
					document.all.item("txtFechaGasto").focus();
					return;
			}
		
		{
			try{
				document.all.item("_cuerpo").focus();			
			}catch(e){}
		}
	}
}	
}




////////////////////////////////////////////////////////////////////////
//  Funciones 
////////////////////////////////////////////////////////////////////////

///////////////////////// REVIVIR SESION ///////////////////////////////

var _tiempoRevivir;

function RevivirSesion(){
	BaseVistas.AJAXRevivirSesion(_CB_RevivirSesion); 	
}

function _CB_RevivirSesion(res){	
	clearTimeout(_tiempoRevivir);
	SetRevivirSesion();
} 

function SetRevivirSesion()
{	
	//_tiempoRevivir = window.setTimeout('RevivirSesion()', (5 * 60000));
	_tiempoRevivir = window.setTimeout('RevivirSesion()', (6000));
}

/////////////////////////////////////////////////////////////////////////


function ValidarNuloHorasMinutos(argMensaje)
{	
	// var combo = document.getElementById("txtProyecto_listaComboBox");
		
	// if (combo(combo.selectedIndex).Tareas = "No") {
	//	document.getElementById("txtTarea").HabilitarValidadorVacio = 'False' 
		// var txtTareaCodigo = document.getElementById("txtTarea_listaComboBox").value;
	// }else {
	//	if (txtTareaCodigo == null || txtTareaCodigo == "") {
	//	document.getElementById("txtTarea").HabilitarValidadorVacio = 'True' 
	//	} 
    //    txtTareaNombre = Request.Form.Item("txtTarea:seleccionTextBox")
	//}
	
	if (document.getElementById("txtMinutos_seleccionTextBox").value == "0" && document.getElementById("txtHoras_seleccionTextBox").value == "0" )  {
		alert( argMensaje );					
	}else {
		if (document.getElementById("btnActualizar") == null) {
			if (Page_ClientValidate()) javascript:__doPostBack('btnInsertar','click');
		}else {
			if (Page_ClientValidate()) javascript:__doPostBack('btnActualizar','click');
		}
	}	
}

function ValidarNuloUnidad(argMensaje)
{	
	
	if (document.getElementById("txtUnidad_seleccionTextBox").value == "0" )  {
		alert( argMensaje );					
	}else {
		if (document.getElementById("btnActualizar") == null) {
			 if (Page_ClientValidate()) javascript:__doPostBack('btnInsertar','click');
		}else {
			if (Page_ClientValidate()) javascript:__doPostBack('btnActualizar','click');
		}
	}	
}

function ValidarNuloDesc(argMensaje)
{	
	
	if (document.getElementById("txtDescripcion").value == "" )  {
		alert( argMensaje );					
	}else {
	  	   if (document.getElementById("txtMinutos_seleccionTextBox").value == "0" && document.getElementById("txtHoras_seleccionTextBox").value == "0" )  {
			   alert('Horas Minutos debe de ser mayor que 0');					
		  }else { 
				if (document.getElementById("btnActualizar") == null) {
					if (Page_ClientValidate()) javascript:__doPostBack('btnInsertar','click');
				}else {
					if (Page_ClientValidate()) javascript:__doPostBack('btnActualizar','click');
					  }
			    }
	}	
}
function MuestroImgagen(argValor)
{	
	
	if (argValor == 'True')  {
		document.all['ImgRendGto'].style.display = ''; 	
				
	}else {
			document.all['ImgRendGto'].style.display = 'none';		
		  }	
}

function ValidoRemito()
{	
	alert("Es Necesario marcar un registro para poder ver el Remito");					
}

function ValidoResultados(argMensaje)
{	
	alert( argMensaje );					
}

 function ValidarNulo(argMensaje)
{	if (document.getElementById("txtTarea_seleccionTextBox").value == "")
	{
		alert( argMensaje );					
	}
	else {  
	
		if (document.getElementById("txtAvance_seleccionTextBox").value == "0")
			{
				alert( argMensaje );					
			}
		  // else { javascript:__doPostBack('btnInsertar','click');   }  
		 }
}
function ValidarNuloTarea(argMensaje)
 {	
	if (document.getElementById("txtTarea_seleccionTextBox").value == "")
	  {
		alert( argMensaje );					
	  } else {
		     javascript:__doPostBack('btnVisualizar','click');
		     }  
 }

function ValidarNuloDivision(argMensaje)
 {	
	if (document.getElementById("txtDivision_seleccionTextBox").value == "")
	  {
		alert( argMensaje );					
	  } else {
		     javascript:__doPostBack('btnVisualizar','click');
		     }  
 }



function ValidarNuloResponsable(argMensaje)
 {	
	if (document.getElementById("txtResponsable_seleccionTextBox").value == "")
	  {
		alert( argMensaje );					
	  } else {
		     javascript:__doPostBack('btnVisualizar','click');
		     }  
 }


function InStr(strSearch, charSearchFor)
{
    var i;
    for (i=0; i < Len(strSearch); i++)
    {
        if (charSearchFor == Mid(strSearch, i, 1))
        {
            return i;
        }
    }
    return -1;
} 


function Len(str)
{ 
    return String(str).length; 
}


function Mid(str, start, len)
{
    if (start < 0 || len < 0) return "";

    var iEnd, iLen = String(str).length;
    if (start + len > iLen) {
        iEnd = iLen;
    }else {
        iEnd = start + len;
    }
    return String(str).substring(start,iEnd);
}

// Información:
// Marca los estilos de los eventos mouseover y mouseout en las toolbars.
function Hover(tbl, idx, cls)
{
	var t, d;
	if (document.getElementById)
		t = document.getElementById(tbl);
	else
		t = document.all(tbl);
	if (t == null) return;
	if (t.getElementsByTagName)
		d = t.getElementsByTagName("TD");
	else
		d = t.all.tags("TD");
	if (d == null) return;
	if (d.length <= idx) return;
	d[idx].className = cls;
}

////////////////////////////////////////////////////////////////////////
//  Carga de unidades en el ingreso de horas.
////////////////////////////////////////////////////////////////////////

// Si se esta cargando en unidades se imprime la cantidad de horas y minutos 
// correspondiente a las unidades ingresadas.
function ActualizarHorasMinutos()
{
  var horas, minutos;    
  
  if (IsNumeric(document.all.item("txtUnidad_seleccionTextBox").value) && (document.all.item("txtUnidad_seleccionTextBox").value>0) ) 
  {
    horas = Div(document.all.item("txtUnidad_seleccionTextBox").value*txtUnidad.valorUnidad,60);
    minutos = Mod(document.all.item("txtUnidad_seleccionTextBox").value*txtUnidad.valorUnidad,60);

    if (horas < 10) 
    {
      horas = "0" + horas;
    }

    if (minutos < 10) 
    {
      minutos = "0" + minutos;
    }
  
    lblHorasMinutos.innerText = horas + ":" + minutos;

  }
}

function Mod(a, b) { return a-Math.floor(a/b)*b }

function Div(a, b) { return Math.floor(a/b) }

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   return IsNumber;
}
////// Levanto los reportes anteriores de BROCHOU
function LevantoReportes(argId)
{
  var URLReportesTec;
  URLReportesTec = "http://localhost/timebr/Reports.asp";
  TimeOutInicio();
  
  var result = window.showModalDialog(URLReportesTec + "?Id=" + argId, window, "dialogHeight:500px; dialogWidth:1000px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No");

  if (result != null) 
  {alert(result);}
}


function Ayuda()
{
  var URLAyuda;
  URLAyuda = "../Ayuda/Index.html";
  TimeOutInicio();
  
  var result = window.open(URLAyuda, "newWindow", "height=480,width=680,scrollbars=yes,resizable=yes,toolbars=no,status=no,menubar=yes,location=no");
    if (result != null) 
	{
	// alert(result);
	}
}


function AgruparGastos()
{
  var URLGastos;
     
   URLGastos = "Modales/AgruparGastos.aspx";
  
  TimeOutInicio();
  var result = window.showModalDialog(URLGastos, window, "dialogHeight:420px; dialogWidth:600px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No");

  if (result != null) 
  {alert(result);}
}

function DesAgruparGastos()
{
  var URLGastos;
  URLGastos = "Modales/DesAgruparGastos.aspx";
  TimeOutInicio();
  //var result = window.showModalDialog(URLGastos + "?Id=" + argIdHora, window, "dialogHeight:284px; dialogWidth:500px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No");
  var result = window.showModalDialog(URLGastos, window, "dialogHeight:420px; dialogWidth:600px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No");

  if (result != null) 
  {alert(result);}
}


///////////////////////////////////////////////////////////////

function _CargarRendicion(argId)
{
  var URLVerRend;
  URLVerRend = "Modales/VerRendicionGastos.aspx";
  TimeOutInicio();
  
  var result = window.showModalDialog(URLVerRend + "?Id=" + argId, window, "dialogHeight:420px; dialogWidth:640px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:Yes");

  if (result != null) 
  {alert(result);}
}


function _ImpRendicion(argId)
{
  var URLImpRend;
  URLImpRend = "Modales/ImpRendicionGastos.aspx";
  TimeOutInicio();
  
  if ( argId == null || argId == "" )
	{argId = document.getElementById("txtEditarRend").value;
	document.getElementById("txtEditarRend").value = "" ;
	}
    if ( argId == null || argId == "" )
	{argId =  document.getElementById("txtNroDoc_seleccionTextBox").value;}
  
  if ( argId == null || argId == "")
	{alert('Para Imprimir la Rendicion tiene que elegir un numero');
	 return;	
	}
	
  var result = window.showModalDialog(URLImpRend + "?Id=" + argId, window, "dialogHeight:460px; dialogWidth:640px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:Yes");

  if (result != null) 
  {alert(result);}
}



////////////////////////////////////////////////////////////////////////
//  Ingreso de gastos al ingresar horas
////////////////////////////////////////////////////////////////////////

function CargarGastos(argIdHora)
{
  var URLGastos;
  URLGastos = "Modales/GastosIngresarHoras.aspx";
  TimeOutInicio();
  //var result = window.showModalDialog(URLGastos + "?Id=" + argIdHora, window, "dialogHeight:284px; dialogWidth:500px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No");
  var result = window.showModalDialog(URLGastos + "?Id=" + argIdHora, window, "dialogHeight:320px; dialogWidth:500px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No");

  if (result != null) 
  {alert(result);}
}

function CerrarVentana()
{
    if (top.opener || parent.window.dialogArguments)
	   self.close();
}

////////////////////////////////////////////////////////////////////////
//  Control de navegación afuera del sitio
////////////////////////////////////////////////////////////////////////

/*
trap=false;
function AvisoDeNavegacion()
{
  alert("Se esta navegando afuera del sitio.");
  if (trap) {
       return  "There seems to be some modified and unprocessed content in the form that you were currently filling up. If you continue to navigate away from the page, any or all changes over there would be lost.";
  }
}
window.onbeforeunload = AvisoDeNavegacion;
*/

////////////////////////////////////////////////////////////////////////
//  Control de finalización del tiempo de sesión
////////////////////////////////////////////////////////////////////////

// Información:
// La ventana de advertencia se levantara <_timeOutAdvertencia> 
// milisegundos segundos antes de que culmine la sesión.

// Este código es el que utilizan las páginas aspx que tienen control de 
// tiempo de sesion. 
var timeR;
var _timeOutSesion;
var _timeOutAdvertencia = 60000; 
var _timeOut;

function TimeOutInicio()
{
	//_timeOutSesion = document.forms['Form1'].elements['_SesionTimeOutTiempo'].value * 60000;	
	//_timeOut = window.setTimeout('MostrarAdvertencia()', (_timeOutSesion -_timeOutAdvertencia));
}

function TimeOutFin()
{
	//clearTimeout(_timeOut);
}

function MostrarAdvertencia()
{		
}

// Este código es el que utiliza la página de Sesion.html 

var _miliSegundos = window.dialogArguments;
var _segundos;
var _intervalo;
var _tiempo = new Date();

function CuentaRegresiva(argX)
{
  _segundos = _miliSegundos / 1000;

  if (_segundos <= 60)
  {
    _tiempo.setMinutes(0);
   }
  _tiempo.setSeconds(_segundos);

  argX.value = (((_tiempo.getMinutes() <= 9)? "0" + _tiempo.getMinutes() :
  _tiempo.getMinutes()) + ":" + ((_tiempo.getSeconds() <= 9)? "0" +
  _tiempo.getSeconds() : _tiempo.getSeconds()));

  if (_segundos < 0)
  {
    Accion(false);
  }
}

function Accion(argX)
{
  (argX == true) ? window.returnValue = "renovar" : window.returnValue = "abandonar";
  window.close();
}


////////////////////////////////////////////////////////////////////////
//  Logo de Powerede by Magma
////////////////////////////////////////////////////////////////////////
 
function _PoweredByAbrir()
{		
  window.open("http://www.magmatools.com");
}
	
function _PoweredByOn()
{
  document.all.item("imgPoweredBy").src = "../imagenes/PoweredMagma.gif";
}

function _PoweredByOff()
{ 
	document.all.item("imgPoweredBy").src = "../imagenes/PoweredMagma_off.gif";
}

////////////////////////////////////////////////////////////////////////
//  PopUp para las opciones de la vista por período
////////////////////////////////////////////////////////////////////////

var oPopup = window.createPopup();

function AbrirSeleccion(argSeleccion)
{
  parent.oPopup.hide();
  parent.document.all.item("_SeleccionOpcion").value = argSeleccion;
  doPostBackPA(parent.document.all.item("_SeleccionValor").value,argSeleccion);  
}

function _MS(argId, argFuncion, argTipoRegistro, argControlPorDia,argMensaje)
{  
	var oPopupBody = oPopup.document.body;
	var popUp;
	var alto;
	
	if  (argControlPorDia == 'True') {
		alert( argMensaje );
		return;
	}
  
	parent.document.all.item("_SeleccionValor").value = argFuncion;

	/*0 es vacio, 1 es horas, 2 es gastos*/
	switch(argTipoRegistro)   
	{
		case "0" :
		{      
			popUp = _PopUpNuevo.innerHTML;
			alto = 22;		
  		}break;
		case "1" :
		{     
			popUp = _PopUpEditar.innerHTML;
			//alto = 61;		
			alto = 41;		
		}break;
		case "2" :
		{     
			popUp = _PopUpEditar.innerHTML;
			alto = 22;		
			//alto = 43;		
		}break;
		default :
		{   	
	    }
	}
    
	oPopupBody.innerHTML = popUp;  
	oPopupBody.innerHTML += document.scripts[0].outerHTML;
	oPopup.document.createStyleSheet("../Estilos.css");
	oPopup.show(event.x,event.y, 128, alto, document.body);
	oPopup.document.scripts(0).src = "../Scripts/Funciones.js";  
}


function doPostBackPA(eventTarget, eventArgument) {
		var theform;
   
    parent.document.all.item("__EVENTTARGET").value = eventTarget.split("$").join(":");
    parent.document.all.item("__EVENTARGUMENT").value = eventArgument;
		

    parent.document.all.item("Form1").submit();

	}

////////////////////////////////////////////////////////////////////////
//  PopUp para el Mensaje de Cargando...
////////////////////////////////////////////////////////////////////////

var _PopUpCagando = window.createPopup();
var _Cargando;

_Cargando = false;

function MensajeCargando()
{  
	if (_Cargando) {
		var oPopupBody = _PopUpCagando.document.body;		
		//_cuerpo.disabled = "TRUE";  
		oPopupBody.innerHTML = tabCargando.innerHTML;    
		_PopUpCagando.document.createStyleSheet("../Estilos.css");
		_PopUpCagando.show((document.body.offsetWidth / 2)-89,(document.body.offsetHeight /2)-20, 160, 40, document.body);  
	}
}





////////////////////////////////////////////////////////////////////////
//  Guarda y Carga el estado del scroll de Autorizacion de Horas
////////////////////////////////////////////////////////////////////////

function GuardarScrollAut()
{
  document.Form1._ventanaScrollAut.value = _ventanaAutHoras.scrollLeft;
}

function CargarScrollAut()
{
  _ventanaAutHoras.scrollLeft = document.Form1._ventanaScrollAut.value;
}


////////////////////////////////////////////////////////////////////////
//  Mostrar la ventana de mensajes
////////////////////////////////////////////////////////////////////////
var _MostrarMensaje
var _MostrarGuardarRegistros

_MostrarGuardarRegistros = false;
_MostrarMensaje  = true;

function GastosSinGuardarHoras() {
	parent.window.dialogArguments.document.all.item("_registrosSinGuardar2").value = document.all.item("_registrosSinGuardar2").value;  
	parent.window.dialogArguments.document.all.item("_registrosSinGuardar3").value = document.all.item("_registrosSinGuardar3").value;  		
}

function ControlRegistrosGuardados(argEvento)
{  
	var mensaje;
			
	if (document.all.item("_registrosSinGuardar1").value != "" || document.all.item("_registrosSinGuardar2").value != "") {
		if (document.all.item("_registrosSinGuardar1").value != "" && document.all.item("_registrosSinGuardar2").value != "") {
			mensaje = document.all.item("_registrosSinGuardar1").value + "chr(13)" + document.all.item("_registrosSinGuardar2").value }
		else {
			mensaje = document.all.item("_registrosSinGuardar1").value + document.all.item("_registrosSinGuardar2").value }		
			window.showModalDialog("Modales/Mensaje.aspx?mensaje1=" + mensaje + "&mensaje2=" + document.all.item("_registrosSinGuardar3").value + "&botones=1",_timeOutAdvertencia," dialogWidth:290px;dialogHeight:164px;edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No ");		
	} 

	switch(argEvento)
	{
		case "CerrarSesion" :
		{      
		__doPostBack('btnCerrarSesion','click');  
	}break;		  
	}  
	_MostrarMensaje = false;
}

function CalendarioSeleccion(){
	try{
		if ((window.event.srcElement.parentElement.parentElement.parentElement.parentElement.id == "calFecha") || 
			(window.event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.id == "_VD") || 
			(window.event.srcElement.parentElement.parentElement.parentElement.parentElement.id == "_VP"))
		{
			_MostrarGuardarRegistros = true;
		}
	}
	catch(e) {}
}

function OnKeyDown(){ 
	_presionoEnter = (window.event.keyCode==13) || (window.event.keyCode==9); 	
}

function OnKeyDownR() {
	OnKeyDown();
	if (_presionoEnter) {
		try{
			document.all.item("_cuerpo").focus();
		}catch(e){}
	}
}
	
function OnKeyDownA(){ 

OnKeyDown();

 if( window.event.keyCode==13 && (window.event.srcElement.className == "combo" || window.event.srcElement.className == "buscadorTexto")) 
 {	
	
		if (window.event.srcElement.id == "txtTipo_listaComboBox") 
		{
			document.all['txtMoneda_seleccionTextBox'].style.display = ''; 
			document.all['txtMoneda_seleccionTextBox'].title = ""; 
			document.all['txtMoneda_listaComboBox'].style.display = 'none';		
			AbrirComboBox(document.all['txtMoneda_seleccionTextBox'], document.all['txtMoneda_listaComboBox']);

		}else {
			if (window.event.srcElement.id == "txtMoneda_listaComboBox") 
			{
				try{
					document.all.item("txtImporte_seleccionTextBox").focus();				
				}catch(e){}
			}else{
					try{
  						document.all.item("_cuerpo").focus();			
					}catch(e){}
				 }
			   }
	} 
}

function ComboMoneda(){
	document.all['txtMoneda_seleccionTextBox'].style.display = ''; 
	document.all['txtMoneda_seleccionTextBox'].title = ""; 
	document.all['txtMoneda_listaComboBox'].style.display = 'none'; 
	AbrirComboBox(document.all['txtMoneda_seleccionTextBox'], document.all['txtMoneda_listaComboBox']);
}



function AntesDeSalir()
{
	var mensaje;

	}

////////////////////////////////////////////////////////////////////////
//  Foco y acción para la pantalla de login
////////////////////////////////////////////////////////////////////////

function EmpleadoCodigoFoco() 
{	
	try{
		document.all.item("txtEmpleadoCodigo").focus();
	}catch(e){}
}

function EmpleadoContrasenaFoco() 
{	
	if( window.event.keyCode==13)
	{
		try{
			document.all.item("txtEmpleadoContrasena").focus();
		}catch(e){}
	}
}

function IniciarSesion()
{
	if (window.event.keyCode==13) 
	{
		if (Page_ClientValidate()) javascript:__doPostBack('btnIniciarSesion','click');	
	}
}

////////////////////////////////////////////////////////////////////////
//  Para los reportes las funciones de lo option buttons
////////////////////////////////////////////////////////////////////////

function estadoCambiar(argOpcion)
{ 
	switch(argOpcion)   
	{
		case "0" :
		{      
			document.all.item('optEstado0').checked = true;
			document.all.item('optEstado1').checked = false;
			document.all.item('optEstado2').checked = false;
			document.all.item('optEstado3').checked = false;
  		}break;
		case "1" :
		{     
			document.all.item('optEstado0').checked = false;
			document.all.item('optEstado1').checked = true;
			document.all.item('optEstado2').checked = false;
			document.all.item('optEstado3').checked = false;
		}break;
		case "2" :
		{     
			document.all.item('optEstado0').checked = false;
			document.all.item('optEstado1').checked = false;
			document.all.item('optEstado2').checked = true;
			document.all.item('optEstado3').checked = false;
		}break;
		case "3" :
		{     
			document.all.item('optEstado0').checked = false;
			document.all.item('optEstado1').checked = false;
			document.all.item('optEstado2').checked = false;
			document.all.item('optEstado3').checked = true;
		}break;
		default :
		{       
		}
	}
}

function gruposCambiar(argOpcion)
{ 
	document.all.item('txtGrupoCategoria_seleccionTextBox').value = "";
	document.all.item('txtActividadEmpleado_seleccionTextBox').value = "";
	document.all.item('txtCategoria_seleccionTextBox').value = "";

	switch(argOpcion)   
	{
		// Categoria
		case "0" :
		{      
			document.all.item('optGrupos0').checked = true;
			document.all.item('optGrupos1').checked = false;
			document.all.item('optGrupos2').checked = false;
			
			document.all.item('txtGrupoCategoria_seleccionTextBox').style.backgroundColor = "gainsboro" 			
			document.all.item('txtGrupoCategoria_seleccionTextBox').disabled = true;
			document.all.item('txtActividadEmpleado_seleccionTextBox').style.backgroundColor = "gainsboro" 			
			document.all.item('txtActividadEmpleado_seleccionTextBox').disabled = true;
			document.all.item('txtCategoria_seleccionTextBox').style.backgroundColor = "whitesmoke" 			
			document.all.item('txtCategoria_seleccionTextBox').disabled = false;
  		}break;
  		// Grupo Categoria
		case "1" :
		{     
			document.all.item('optGrupos0').checked = false;
			document.all.item('optGrupos1').checked = true;
			document.all.item('optGrupos2').checked = false;
			
			document.all.item('txtGrupoCategoria_seleccionTextBox').style.backgroundColor = "whitesmoke" 			
			document.all.item('txtGrupoCategoria_seleccionTextBox').disabled = false;
			document.all.item('txtActividadEmpleado_seleccionTextBox').style.backgroundColor = "gainsboro" 			
			document.all.item('txtActividadEmpleado_seleccionTextBox').disabled = true;
			document.all.item('txtCategoria_seleccionTextBox').style.backgroundColor = "gainsboro" 			
			document.all.item('txtCategoria_seleccionTextBox').disabled = true;
		}break;
		// Activivdad Empleado
		case "2" :
		{     
			document.all.item('optGrupos0').checked = false;
			document.all.item('optGrupos1').checked = false;
			document.all.item('optGrupos2').checked = true;

			document.all.item('txtGrupoCategoria_seleccionTextBox').style.backgroundColor = "gainsboro" 						
			document.all.item('txtGrupoCategoria_seleccionTextBox').disabled = true;
			document.all.item('txtActividadEmpleado_seleccionTextBox').style.backgroundColor = "whitesmoke" 			
			document.all.item('txtActividadEmpleado_seleccionTextBox').disabled = false;
			document.all.item('txtCategoria_seleccionTextBox').style.backgroundColor = "gainsboro" 			
			document.all.item('txtCategoria_seleccionTextBox').disabled = true;
		}break;
		default :
		{       
		}
	}
}

////////////////////////////////////////////////////////////////////////
//  Para las Autorizacion las funciones de lo option buttons
////////////////////////////////////////////////////////////////////////

function CargoAutorizacion(argOpcion,ID)
{ 
  
	switch(argOpcion)   
	{
		case "P" :
		{      
			document.all.item('optAut0' + ID ).checked = true;
			document.all.item('optAut1' + ID).checked = false;
			document.all.item('optAut2' + ID).checked = false;
  		}break;
		case "S" :
		{     
			document.all.item('optAut0' + ID).checked = false;
			document.all.item('optAut1' + ID).checked = true;
			document.all.item('optAut2' + ID).checked = false;
		}break;
		case "N" :
		{     
			document.all.item('optAut0' + ID).checked = false;
			document.all.item('optAut1' + ID).checked = false;
			document.all.item('optAut2' + ID).checked = true;
			
		}break;
		default :
		{       
		}
	}
}

function CargarComentarioRechazo(argId)
{
  var URLComentario;
  URLComentario = "Modales/ComentarioRechazo.aspx";
  TimeOutInicio();
  var result = window.showModalDialog(URLComentario + "?Id=" + argId , window, "dialogHeight:178px; dialogWidth:500px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No");
  
}

function SelCambio(ID)
{ 

	if (document.all.item('optSel' + ID).checked = true )
	{
			document.all.item('optSel1' + ID).checked  = false;
			document.all.item('optSel' + ID).checked  = true;
	}
	else
		{     
			document.all.item('optSel1' + ID).checked  = true;
			document.all.item('optSel' + ID).checked  = false;
		}
}



function AutorizacionCambiar(argOpcion,ID)
{ 
	
	switch(argOpcion)   
	{
		case 0 :
		{      
			document.all.item('optAut0' + ID ).checked = true;
			document.all.item('optAut1' + ID).checked = false;
			document.all.item('optAut2' + ID).checked = false;
  		}break;
		case 1 :
		{     
			
			document.all.item('optAut0' + ID).checked = false;
			document.all.item('optAut1' + ID).checked = true;
			document.all.item('optAut2' + ID).checked = false;
		}break;
		case 2 :
		{     
			document.all.item('optAut0' + ID).checked = false;
			document.all.item('optAut1' + ID).checked = false;
			document.all.item('optAut2' + ID).checked = true;
			CargarComentarioRechazo(ID);			
		}break;
		default :
		{       
		}
	}
}



function AutorizacionCambiarGastos(argOpcion,ID)
{ 
	switch(argOpcion)   
	{
		case 0 :
		{								   
			document.all.item('optAutG0' + ID ).checked = true;
			document.all.item('optAutG1' + ID).checked = false;
			document.all.item('optAutG2' + ID).checked = false;
  		}break;
		case 1 :
		{     
		
			document.all.item('optAutG0' + ID).checked = false;
			document.all.item('optAutG1' + ID).checked = true;
			document.all.item('optAutG2' + ID).checked = false;
		}break;
		case 2 :
		{     
			document.all.item('optAutG0' + ID).checked = false;
			document.all.item('optAutG1' + ID).checked = false;
			document.all.item('optAutG2' + ID).checked = true;
			CargarComentarioRechazo(ID);			
		}break;
		default :
		{       
		}
	}
}

function AutorizacionCambiarRendGastos(argOpcion,ID)
{ 
	switch(argOpcion)   
	{
		case 0 :
		{								   
			document.all.item('optAutRG0' + ID ).checked = true;
			document.all.item('optAutRG1' + ID).checked = false;
			document.all.item('optAutRG2' + ID).checked = false;
  		}break;
		case 1 :
		{     
		
			document.all.item('optAutRG0' + ID).checked = false;
			document.all.item('optAutRG1' + ID).checked = true;
			document.all.item('optAutRG2' + ID).checked = false;
		}break;
		case 2 :
		{     
			document.all.item('optAutRG0' + ID).checked = false;
			document.all.item('optAutRG1' + ID).checked = false;
			document.all.item('optAutRG2' + ID).checked = true;
			CargarComentarioRechazo(ID);			
		}break;
		default :
		{       
		}
	}
}

function AutorizacionCambiarAnticipos(argOpcion,ID)
{ 
	switch(argOpcion)   
	{
		case 0 :
		{								   
			document.all.item('optAutA0' + ID ).checked = true;
			document.all.item('optAutA1' + ID).checked = false;
			document.all.item('optAutA2' + ID).checked = false;
  		}break;
		case 1 :
		{     
		
			document.all.item('optAutA0' + ID).checked = false;
			document.all.item('optAutA1' + ID).checked = true;
			document.all.item('optAutA2' + ID).checked = false;
		}break;
		case 2 :
		{     
			document.all.item('optAutA0' + ID).checked = false;
			document.all.item('optAutA1' + ID).checked = false;
			document.all.item('optAutA2' + ID).checked = true;
			CargarComentarioRechazo(ID);			
		}break;
		default :
		{       
		}
	}
}


function ConfiguraOptionButtons()
{
	
	if (document.all.item('optGrupos0').checked) {
		document.all.item('txtGrupoCategoria_seleccionTextBox').style.backgroundColor = "gainsboro" 			
		document.all.item('txtGrupoCategoria_seleccionTextBox').disabled = true;
		document.all.item('txtActividadEmpleado_seleccionTextBox').style.backgroundColor = "gainsboro" 			
		document.all.item('txtActividadEmpleado_seleccionTextBox').disabled = true;
		document.all.item('txtCategoria_seleccionTextBox').style.backgroundColor = "whitesmoke" 			
		document.all.item('txtCategoria_seleccionTextBox').disabled = false;
	}
	
	if (document.all.item('optGrupos1').checked) {
		document.all.item('txtGrupoCategoria_seleccionTextBox').style.backgroundColor = "whitesmoke" 			
		document.all.item('txtGrupoCategoria_seleccionTextBox').disabled = false;
		document.all.item('txtActividadEmpleado_seleccionTextBox').style.backgroundColor = "gainsboro" 			
		document.all.item('txtActividadEmpleado_seleccionTextBox').disabled = true;
		document.all.item('txtCategoria_seleccionTextBox').style.backgroundColor = "gainsboro" 			
		document.all.item('txtCategoria_seleccionTextBox').disabled = true;
	}
	
	if (document.all.item('optGrupos2').checked) {
		document.all.item('txtGrupoCategoria_seleccionTextBox').style.backgroundColor = "gainsboro" 						
		document.all.item('txtGrupoCategoria_seleccionTextBox').disabled = true;
		document.all.item('txtActividadEmpleado_seleccionTextBox').style.backgroundColor = "whitesmoke" 			
		document.all.item('txtActividadEmpleado_seleccionTextBox').disabled = false;
		document.all.item('txtCategoria_seleccionTextBox').style.backgroundColor = "gainsboro" 			
		document.all.item('txtCategoria_seleccionTextBox').disabled = true;
	}
}

////////////////////////////////////////////////////////////////////////
//  Posiciona el combo de clientes en activo al cargar la página la primera
//  vez
////////////////////////////////////////////////////////////////////////



//  Posiciona el combo de Tipo de Gasto

function _AbrirComboBoxTipoGasto() {	
	AbrirComboBox(document.all['txtTipoGasto_seleccionTextBox'], document.all['txtTipoGasto_listaComboBox']);
}

//  Posiciona el combo de Tarea
function _AbrirComboBoxTarea() {
	AbrirComboBox(document.all['txtTarea_seleccionTextBox'], document.all['txtTarea_listaComboBox']);
}

//  Posiciona el combo de Minutos
function _AbrirComboBoxMinutos() {
	AbrirComboBox(document.all['txtMinutos_seleccionTextBox'], document.all['txtMinutos_listaComboBox']);
}

//  Posiciona el combo de Division
function _AbrirComboBoxDivision() {
	AbrirComboBox(document.all['txtDivision_seleccionTextBox'], document.all['txtDivision_listaComboBox']);
}

//  Posiciona el combo de Responsable
function _AbrirComboBoxResponsable() {
	AbrirComboBox(document.all['txtResponsable_seleccionTextBox'], document.all['txtResponsable_listaComboBox']);
}



//  Posiciona el combo de Solicitudes de cambio
function _AbrirComboBoxSolicitudCambio() {
	AbrirComboBox(document.all['txtTipoSolicitud_seleccionTextBox'], document.all['txtTipoSolicitud_listaComboBox']);
}

//  Posiciona el combo En Avance

function _AbrirComboBoxAvance() {
	AbrirComboBox(document.all['txtAvance_seleccionTextBox'], document.all['txtAvance_listaComboBox']);
}

//  Posiciona el combo de Actividades

function _AbrirComboBoxActividad() {
	AbrirComboBox(document.all['txtActividad_seleccionTextBox'], document.all['txtActividad_listaComboBox']);
}

//  Posiciona el combo de Tipo de Documento

function _AbrirComboBoxTipoDoc() {
	AbrirComboBox(document.all['txtTipoDoc_seleccionTextBox'], document.all['txtTipoDoc_listaComboBox']);
}



/* Pasaje de Cliente a Proyecto */



function _PrepararComboTipoGasto() {
var comboTipoGasto;
var codigoTipo;

	document.all['txtTipoGasto_listaComboBox'].disabled = '';
	
	codigoTipo = "cboT"
	
	comboTipoGasto = "<select name='txtTipoGasto:listaComboBox' runat='server' id='txtTipoGasto_listaComboBox' onclick=\"CerrarComboBox('txtTipoGasto',document.all['txtTipoGasto_seleccionTextBox'], document.all['txtTipoGasto_listaComboBox'], document.all['txtTipoGasto_buscadorTabla']);\" onkeydown=\"AbrirBuscador(document.all['txtTipoGasto_buscadorTabla'],document.all['txtTipoGasto_buscadorTexto'],document.all['txtTipoGasto_sugerenciaTabla'], this);\" onfocusout=\"CerrarComboBox1('txtTipoGasto',document.all['txtTipoGasto_seleccionTextBox'], document.all['txtTipoGasto_listaComboBox'], document.all['txtTipoGasto_buscadorTabla']);\" class='combo' style='cursor:hand;width:180px;'>" + document.all[codigoTipo].innerHTML + "</SELECT>"; 
	CerrarComboBox1('txtProyecto',document.all['txtProyecto_seleccionTextBox'], document.all['txtProyecto_listaComboBox'], document.all['txtProyecto_buscadorTabla']);
	document.all['spantxtTipoGasto'].innerHTML = comboTipoGasto;

	document.all['txtTipoGasto'].ondblclick = "";
	document.all['txtTipoGasto_seleccionTextBox'].style.backgroundColor = "whitesmoke";
	document.all['txtTipoGasto_seleccionTextBox'].disabled = false;
	document.all['txtTipoGasto_seleccionTextBox'].Habilitado = false;
	document.all['txtTipoGasto_seleccionTextBox'].style.cursor = "hand";
	document.all['txtTipoGasto_seleccionTextBox'].onclick = _AbrirComboBoxTipoGasto;
									         
}




function _PrepararComboTipoDoc(argUsaTipoDoc) {

	switch(argUsaTipoDoc)   
	{
		case "0" :
		{      
			document.all['txtTipoDoc'].ondblclick = "El Tipo de Gasto no carga Tipo de Docuemntos.";
			document.all['txtTipoDoc_seleccionTextBox'].style.backgroundColor = "Gainsboro";
			document.all['txtTipoDoc_seleccionTextBox'].disabled = true;
			document.all['txtTipoDoc_seleccionTextBox'].value = "";			
			document.all['txtTipoDoc_seleccionTextBox'].innertext = "";			
			document.all['txtTipoDoc_seleccionTextBox'].style.cursor = "";
			document.all['txtTipoDoc_seleccionTextBox'].onclick = "";			
			document.all['txtTipoDoc_seleccionTextBox'].title = "El Tipo de Gasto " + document.all['txtTipoGasto_seleccionTextBox'].value + " no carga Tipo de Documentos.";			

			document.all.item("txtNroDoc_seleccionTextBox").style.backgroundColor = "Gainsboro";
			document.all.item("txtNroDoc_seleccionTextBox").disabled = true;
			document.all['txtNroDoc_seleccionTextBox'].innertext = "";			
			document.all.item('txtNroDoc_seleccionTextBox').value = "";
			document.all.item("txtNroDoc_seleccionTextBox").Habilitado = "False";

		}break;
		case "1" :
		{
			document.all['txtTipoDoc_seleccionTextBox'].style.display = ''; 
			document.all['txtTipoDoc_seleccionTextBox'].title = "";
			document.all['txtTipoDoc_listaComboBox'].disabled = '';
			document.all['txtTipoDoc_listaComboBox'].style.display = 'none'; 
			document.all.item("txtNroDoc_seleccionTextBox").style.display = ""; 
			document.all.item("txtNroDoc_seleccionTextBox").style.backgroundColor = "whitesmoke";
			document.all.item("txtNroDoc_seleccionTextBox").disabled = false;
			document.all.item("txtNroDoc_seleccionTextBox").Habilitado = "true";
			_HabilitoComboTipoDoc();
			AbrirComboBox(document.all['txtTipoDoc_seleccionTextBox'], document.all['txtTipoDoc_listaComboBox']);

		}break;
		default :
		{ 
		}
	}
}

function _HabilitoComboTipoDoc() {
	document.all['txtTipoDoc'].ondblclick = "";
	document.all['txtTipoDoc_seleccionTextBox'].style.backgroundColor = "whitesmoke";
	document.all['txtTipoDoc_seleccionTextBox'].disabled = false;
	document.all['txtTipoDoc_seleccionTextBox'].Habilitado = "true";
	document.all['txtTipoDoc_seleccionTextBox'].style.cursor = "hand";
	document.all['txtTipoDoc_seleccionTextBox'].onclick = _AbrirComboBoxTipoDoc;
	
}



function CargaRango() {
	//document.all['chkCargaRango'].style.display = ''; 	
			
}




function _CargarComboTipoGasto() {
	_PrepararComboTipoGasto();	
	document.all['txtTipoGasto_seleccionTextBox'].style.display = 'none'; 	
	try {
		document.all['txtTipoGasto_listaComboBox'].focus();  	
	}catch(e){}
}


function _CerrarBuscadorTipoGasto() {
	var buscadorTabla;
	var buscadorTextBox;
	var sugerenciaTabla;
		
	buscadorTextBox = document.all['txtTipoGasto_buscadorTexto']; 
	buscadorTabla =  document.all['txtTipoGasto_buscadorTabla'];
	sugerenciaTabla =  document.all['txtTipoGasto_sugerenciaTabla'];

	buscadorTabla.style.display = 'none'; 
	buscadorTextBox.value = '';
	sugerenciaTabla.style.display = 'none';  
	primeraVes = 1;
	_CerrarComboTipoGastoOnClick();
}

function _CerrarBuscadorTipoDoc() {
	var buscadorTabla;
	var buscadorTextBox;
	var sugerenciaTabla;
		
	buscadorTextBox = document.all['txtTipoDoc_buscadorTexto']; 
	buscadorTabla =  document.all['txtTipoDoc_buscadorTabla'];
	sugerenciaTabla =  document.all['txtTipoGasto_sugerenciaTabla'];

	buscadorTabla.style.display = 'none'; 
	sugerenciaTabla.style.display = 'none';  
	buscadorTextBox.value = '';
	primeraVes = 1;
	_CerrarComboTipoDocOnClick();
}



function FocoDescripcion() {
	if (window.event.srcElement.id == "txtDescripcion")	{
		
		// document.all['txtHoras_seleccionTextBox'].value = "";
		 try {
		  document.all['txtHoras_seleccionTextBox'].focus();
		 // Solo para Ledelfyl
		 //document.all['txtKmIni_seleccionTextBox'].focus();
		 
		 }catch(e){}
		 try {
		 document.all['txtUnidad_seleccionTextBox'].focus();
		 }catch(e){}
	}	
}

function FocoKmIni() {
	if (window.event.srcElement.id == "txtKmIni_seleccionTextBox")	{
		
		// document.all['txtHoras_seleccionTextBox'].value = "";
		 try {
		 document.all['txtKmFin_seleccionTextBox'].focus();
		 }catch(e){}
	}	
}

function FocoKmFin() {
	if (window.event.srcElement.id == "txtKmFin_seleccionTextBox")	{
		
		// document.all['txtHoras_seleccionTextBox'].value = "";
		 try {
		 var kmIni
		 var kmFin
		 kmIni = document.all['txtKmIni_seleccionTextBox'].value;
		 kmFin = document.all['txtKmFin_seleccionTextBox'].value;
		 document.all['txtKmSaldo_seleccionTextBox'].value = kmFin - kmIni;
		 document.all['txtVehiculo_seleccionTextBox'].focus();
		 }catch(e){}
	}	
}

function FocoVehiculo() {
	if (window.event.srcElement.id == "txtVehiculo_seleccionTextBox")	{
		
		// document.all['txtHoras_seleccionTextBox'].value = "";
		 try {
		 document.all['txtHoras_seleccionTextBox'].focus();
		 }catch(e){}
	}	
}


function FocoHoras() {
	if ( window.event.srcElement.id == "txtHoras_seleccionTextBox")	{
		 AbrirComboBox(document.all['txtMinutos_seleccionTextBox'], document.all['txtMinutos_listaComboBox']);
		document.all['txtMinutos_listaComboBox'].focus();
		document.all['txtMinutos_seleccionTextBox'].select();
		window.event.cancelBubble = true;
		return false;
	}	
}

function FocoIn() {
	//window.event.cancelBubble = true;
	return false;
}



function _CerrarComboTipoGastoOnClick() {
	var comboBox;
	var textBox;
	var buscadorTabla;
	var sugerencia;

	textBox = document.all['txtTipoGasto_seleccionTextBox'];
	comboBox = document.all['txtTipoGasto_listaComboBox'];
	buscadorTabla =  document.all['txtTipoGasto_buscadorTabla'];
		
	if (primeraVes == 1)
	{
		if (buscadorTabla.style.display == "none") {
			comboBox.style.display = 'none'; 
			textBox.style.display = '';
			
			sugerencia = _ObtenerSugerencia(comboBox);
			if (sugerencia != null) {
				textBox.value = sugerencia.text + " - " + sugerencia.value;				
				textBox.title = sugerencia.text;
			}else {
				textBox.value = comboBox(comboBox.selectedIndex).innerText + " - " + comboBox(comboBox.selectedIndex).value;    
				textBox.title = comboBox(comboBox.selectedIndex).innerText;
			}
			
			if (document.all["AttrT" + comboBox.value].reqInfo == "1") {
			
				document.all["lblTipoInfo"].innerText = document.all["AttrT" + comboBox.value].tipoInfo ;
				document.all.item("txtTipoInfo_seleccionTextBox").style.display = ""; 
				document.all.item("txtTipoInfo_seleccionTextBox").style.backgroundColor = "whitesmoke";
				document.all.item("txtTipoInfo_seleccionTextBox").disabled = false;
				document.all.item("txtTipoInfo_seleccionTextBox").Habilitado = "true";
				document.all["lblDescripcion"].innerText = document.all["AttrT" + comboBox.value].leyendaCustom;
				
			}else
				{
    			document.all["lblTipoInfo"].innerText = "Tipo Info."
				document.all.item("txtTipoInfo_seleccionTextBox").style.backgroundColor = "Gainsboro";
				document.all.item("txtTipoInfo_seleccionTextBox").disabled = true;
				document.all.item("txtTipoInfo_seleccionTextBox").Habilitado = "False";
				document.all.item("txtTipoInfo_seleccionTextBox").innerText = "";
				document.all["lblDescripcion"].innerText = "Descripción Max(1000)";
				}

			
				if ((!_ContinuarEjecucion()) && (!_presionoEnter)) return;
			
				if (primeraVes == 1) _PrepararComboTipoDoc(document.all["AttrT" + comboBox.value].usaTipoDoc);
		}  		
		primeraVes = 0;
	}
	else
	{primeraVes = 1;}
	//window.event.cancelBubble = true;
}

function _CerrarComboTipoDocOnClick() {
	var comboBox;
	var textBox;
	var buscadorTabla;
	
	textBox = document.all['txtTipoDoc_seleccionTextBox'];
	comboBox = document.all['txtTipoDoc_listaComboBox'];
	buscadorTabla =  document.all['txtTipoDoc_buscadorTabla'];
		
	if (primeraVes == 1)
	{
		if (buscadorTabla.style.display == "none") {
			comboBox.style.display = 'none'; 
			textBox.style.display = '';
			textBox.value = comboBox(comboBox.selectedIndex).innerText;    
			textBox.title = comboBox(comboBox.selectedIndex).innerText;
		}  		
		primeraVes = 0;
	}
	else
	{primeraVes = 1;}
	//window.event.cancelBubble = true;
}



function _CerrarComboTipoDocOnfocusout() {
var comboBox;
var textBox;
var buscadorTabla;
	
	textBox = document.all['txtTipoDoc_seleccionTextBox'];
	comboBox = document.all['txtTipoDoc_listaComboBox'];
	buscadorTabla =  document.all['txtTipoDoc_buscadorTabla'];
		
	if (buscadorTabla.style.display == "none") {
		comboBox.style.display = 'none'; 
		textBox.style.display = '';
		
		textBox.value = comboBox(comboBox.selectedIndex).innerText;    
		textBox.title = comboBox(comboBox.selectedIndex).innerText;	
		
	}
	
	}



function _HabilitarHorasFacturable(argUsaFacturable,argDefecto){

			/* switch(argUsaFacturable)   
			{
				case "Si" :
				{   
					document.all.item('chkHoraFacturable').disabled = false;  
					document.all.item('chkHoraFacturable').style.display = '';  
					document.all.item('chkHoraFacturable').style.visibility = '';  

				}break;
				case "No" :
				{
					document.all.item('chkHoraFacturable').disabled = true;  
					document.all.item('chkHoraFacturable').style.display = '';  
					document.all.item('chkHoraFacturable').style.visibility = '';  
				}break;
			}
			if (argUsaFacturable == "Si" &&  argDefecto == "S") 
			{
				document.all.item('chkHoraFacturable').checked = true;
			}*/
			
			switch(argUsaFacturable)   
			{
				case "False"  :
				{   
					document.all.item('chkHoraFacturable').disabled = true;  
					document.all.item('chkHoraFacturable').style.display = '';  
					document.all.item('chkHoraFacturable').style.visibility = '';  

				}break;
				case "True" :
				{
					document.all.item('chkHoraFacturable').disabled = false;  
					document.all.item('chkHoraFacturable').style.display = '';  
					document.all.item('chkHoraFacturable').style.visibility = '';  
				}break;
			}
			
			switch(argDefecto)   
			{
				case "S"  :
				{   
				document.all.item('chkHoraFacturable').checked = true;
				}break;
				case "N" :
				{
					document.all.item('chkHoraFacturable').checked = false;
				}break;
			}
				
			
}

function _HabilitarTarifaEspecial(argUsaTarifaEspecial,argDefecto){

			/* switch(argUsaTarifaEspecial)   
			{
				case "Si" :
				{   
					document.all.item('chkTarifaEspecial').disabled = false;  
					document.all.item('chkTarifaEspecial').style.display = '';  
					document.all.item('chkTarifaEspecial').style.visibility = '';  

				}break;
				case "No" :
				{
					document.all.item('chkTarifaEspecial').disabled = true;  
					document.all.item('chkTarifaEspecial').style.display = '';  
					document.all.item('chkTarifaEspecial').style.visibility = '';  
				}break;
			}*/
			
			switch(argUsaTarifaEspecial)   
			{
				case "False"  :
				{   
					document.all.item('chkTarifaEspecial').disabled = true;  
					document.all.item('chkTarifaEspecial').style.display = '';  
					document.all.item('chkTarifaEspecial').style.visibility = '';  

				}break;
				case "True" :
				{
					document.all.item('chkTarifaEspecial').disabled = false;  
					document.all.item('chkTarifaEspecial').style.display = '';  
					document.all.item('chkTarifaEspecial').style.visibility = '';  
				}break;
			}
			
			/* if (argDefecto == "T") 
				{
					document.all.item('chkTarifaEspecial').checked = true;
				}*/ 
				
				switch(argDefecto)   
			{
				case "T"  :
				{   
				document.all.item('chkTarifaEspecial').checked = true;
				}break;
				case "E" :
				{
					document.all.item('chkTarifaEspecial').checked = false;
				}break;
			}
				
			
}


function _HabilitarHorasExtras(argUsaExtra){

		// if (document.all.item('chkHoraExtra').value) != null) {
		if (document.getElementById('chkHoraExtra') != null) {
			switch(argUsaExtra)   
			{
				case "Si" :
				{   
					document.all.item('chkHoraExtra').disabled = false;  
					document.all.item('chkHoraExtra').style.display = '';  
					document.all.item('chkHoraExtra').style.visibility = '';  

				}break;
				case "No" :
				{
					document.all.item('chkHoraExtra').disabled = true;  
					document.all.item('chkHoraExtra').style.display = '';  
					document.all.item('chkHoraExtra').style.visibility = '';  
				}break;
			}
			switch(argUsaExtra)   
			{
				case "True" :
				{   
					document.all.item('chkHoraExtra').disabled = false;  
					document.all.item('chkHoraExtra').style.display = '';  
					document.all.item('chkHoraExtra').style.visibility = '';  

				}break;
				case "False" :
				{
					document.all.item('chkHoraExtra').disabled = true;  
					document.all.item('chkHoraExtra').style.display = '';  
					document.all.item('chkHoraExtra').style.visibility = '';  
				}break;
			}
		}
}

function _HabilitarHorasCompensar(argUsaCompensar){

			switch(argUsaCompensar)   
			{
				case "Si" :
				{   
					document.all.item('chkCompensar').disabled = false;  
					document.all.item('chkCompensar').style.display = '';  
					document.all.item('chkCompensar').style.visibility = '';  

				}break;
				case "No" :
				{
					document.all.item('chkCompensar').disabled = true;  
					document.all.item('chkCompensar').style.display = '';  
					document.all.item('chkCompensar').style.visibility = '';  
				}break;
			}
}
////////////////////////////////////////////////////////////////////////
//  Reportes
////////////////////////////////////////////////////////////////////////


function VisualizarReporte()
{
var URLReporte;
  URLReporte = "ReportesVisualizacion.aspx";
  TimeOutInicio();
   var result = window.open(URLReporte, "newWindow", "height=680,width=1200,scrollbars=yes,resizable=yes,toolbars=no,status=no,menubar=yes,location=no");
  if (result != null) 
  {
	// alert(result);
	}

}

function VisualizarRemito(argNroSerial)
{
  var URLReporte;
  URLReporte = "RemitosVisualizacion.aspx?NroSerial=" + argNroSerial;
  
  TimeOutInicio();
  var result = window.open(URLReporte, "newWindow", "height=480,width=800,scrollbars=yes,resizable=yes,toolbars=no,status=no,menubar=yes,location=no");
  if (result != null) 
  {
	//alert(result);
	}
}

var shell; 
function SetprintProperties() { 
		try { 
			shell = new ActiveXObject("WScript.Shell"); 
			// shell.SendKeys("%fu"); 
			window.setTimeout("javascript:shell.SendKeys('%fu');", 1000);
			window.setTimeout("javascript:SetPaperSize();", 1200); 
			window.setTimeout("javascript:setlandscape();", 2000); 
			// window.setTimeout("javascript:shell.sendKeys('%a{ENTER}');", 1000);   
		    // window.setTimeout("javascript:shell.SendKeys('%fv');", 1000);   

		} catch (e) { 
			alert('Please verify that your print settings have a landscape orientation and minimum margins.'); 
		} 
		} 
		
		function SetPaperSize() { 
			shell.sendKeys("%a{TAB}.2{TAB}0{TAB}0{TAB}0{ENTER}"); 
		} 
		
		function setlandscape() { 
			// shell.sendKeys("%fp"); 
			SetprintProperties();
			window.setTimeout("javascript:shell.SendKeys('%fp');", 2000);
			window.print(); 
			window.close();
		} 



function ImprimirReporte() {
		 window.print(); 
		// setlandscape();
}


function VisualizarReportesDinamicos(argIdSesion, argUsuario)
{
	var URLReporte;
	
	URLReporte = "../WebReports/Vistas/ReportSelect.aspx?idSesion=" + argIdSesion + "&usuario=" + argUsuario;
	var result = window.open(URLReporte, "newWindow", "height=480,width=640,scrollbars=yes,resizable=yes,toolbars=no,status=no,menubar=yes,location=no");  	
}


var __maximumvalue;
var __minimumvalue;
var __errormessage;
var __title;
var __eventoClickCargaPeriodo;
var __eventoClickCronometro;

function SetearValidador()
{
	var src = document.getElementById("txtHoras_seleccionTextBox").Validators[1];
	
	if (document.getElementById("chkCompensar").status) {
		__maximumvalue = src.maximumvalue;
		__minimumvalue = src.minimumvalue;
		__errormessage = src.errormessage;
		__title = src.title;
		
		src.maximumvalue = "744";
		src.minimumvalue = "0";
		src.errormessage = "El valor da las horas debe estar comprendido entre 0 y 744.";
		src.title = "El valor da las horas debe estar comprendido entre 0 y 744.";
		
		// Deshabilito la carga por periodo
		__eventoClickCargaPeriodo = document.getElementById("lblCargaRango").parentNode.parentNode.children(1).children(0).onclick;
		document.getElementById("lblCargaRango").parentNode.parentNode.children(1).children(0).onclick = Mensaje1;
		
		// Deshabilito el cronómetro
		__eventoClickCronometro = document.getElementById("lblCronometro").parentNode.parentNode.children(1).children(0).onclick;
		document.getElementById("lblCronometro").parentNode.parentNode.children(1).children(0).onclick = Mensaje2;
		
	}else {
		src.maximumvalue = __maximumvalue ;
		src.minimumvalue = __minimumvalue;
		src.errormessage = __errormessage;
		src.title = __title;	
		
		document.getElementById("lblCargaRango").parentNode.parentNode.children(1).children(0).onclick = __eventoClickCargaPeriodo;
		document.getElementById("lblCronometro").parentNode.parentNode.children(1).children(0).onclick = __eventoClickCronometro;
		
	}
}

function Mensaje1(){ alert("No es posible cargar un rango de horas a Compensar");}
function Mensaje2(){ alert("No es posible utilizar el cronómetro para cargar horas Compensadas");}



function _AbrirCalendarioMoverRegistro() {
	var URLCalendario;
	var fechaIni, fechaFin, cultura;
	
	URLCalendario = "Modales/Calendario.aspx";
	fechaSel = document.getElementById("_tdMoverRegistros").fechaSeleccionada;
	cultura = document.getElementById("_tdMoverRegistros").cultura;
	
  var result = window.showModalDialog(URLCalendario + "?FechaSeleccionada=" + fechaSel + "&Cultura=" + cultura, window, "dialogHeight:187px; dialogWidth:168px; edge:Raised; center:Yes; help:No; resizable:No; status:Yes; scroll:No");

  if (result != null) 
  {
	document.getElementById("txtMoverRegistrosFecha").value = result;
  }
}

function _AbrirCalendarioCopiarRegistro() {
	var URLCalendario;
	var fechaIni, fechaFin, cultura;
	
	URLCalendario = "Modales/Calendario.aspx";
	fechaSel = document.getElementById("_tdCopiarRegistros").fechaSeleccionada;
	cultura = document.getElementById("_tdCopiarRegistros").cultura;
	
  var result = window.showModalDialog(URLCalendario + "?FechaSeleccionada=" + fechaSel + "&Cultura=" + cultura + "&Libre=1", window, "dialogHeight:187px; dialogWidth:168px; edge:Raised; center:Yes; help:No; resizable:No; status:Yes; scroll:No");

  if (result != null) 
  {
	document.getElementById("txtCopiarRegistrosFecha").value = result;
  }
}

// RSV 07/12/2008 Req. 2 funcion que muestra el dialogo para cambiar la cantidad de horas a autorizar
function _ChangeHours(argId)
{	
	var URL;
		
	URL = "Modales/CambiarHsAut.aspx";
	
	var result = window.showModalDialog(URL + "?Id=" + argId, window, "dialogHeight:200px; dialogWidth:300px; edge:Raised; center:Yes; help:No; resizable:No; status:Yes; scroll:No");
	
	if (result != null) 
	{
		document.getElementById("hsAut" + argId).innerText = result;
	}	
}

// RSV 07/12/2008 Req. 1 Abre la lista para seleccionar una rendición para editar.
function _AbrirListaRendiciones() {
	var URLListaRend;
	
	URLListaRend = "Modales/ListaRendGastos.aspx";

	var result = window.showModalDialog(URLListaRend, window, "dialogHeight:380px; dialogWidth:620px; edge:Raised; center:Yes; help:No; resizable:No; status:Yes; scroll:No");

	if (result != null) 
	{
		document.getElementById("txtEditarRend").value = result;
	}
}

function _AbrirListaAnticipos() {
	var URLListaAntic;
	var nro;
	var moneda;
	var codigo;
	var nombre;
	var comboBox;
	var textBox;
		
	var splitTexto;
	URLListaAntic = "Modales/ListaRendAnticipos.aspx";

	var result = window.showModalDialog(URLListaAntic, window, "dialogHeight:380px; dialogWidth:620px; edge:Raised; center:Yes; help:No; resizable:No; status:Yes; scroll:No");

	if (result != null) 
	{
		
		splitTexto = result.split("|");
		nro = +splitTexto[0];
		moneda = splitTexto[1];
		splitTexto = moneda.split("-");
		codigo = +splitTexto[0];
		nombre = splitTexto[1];
			
		document.getElementById("txtNroAnticipo").value = nro;
		
		textBox = document.all['txtMoneda_seleccionTextBox'];
		comboBox = document.all['txtMoneda_listaComboBox'];
		
		comboBox.style.display = 'none'; 
		textBox.style.display = '';
		textBox.value = nombre + " - " + codigo; 
		textBox.title = nombre + " - " + codigo; 
			
		// splitTexto = textBox.value.split("-");
		// nombre = splitTexto[0];
		// codigo = splitTexto[1];
		document.all['txtMoneda_listaComboBox'].value 	= codigo 
		document.all['txtMoneda_seleccionTextBox'].value = nombre + " - " + codigo; 
		
		if (codigo  == "1") { 
			document.all['txtTipoCambio_seleccionTextBox'].value = "1"
			document.all['txtTipoCambio_seleccionTextBox'].title = "1"
			document.all['txtTipoCambio_seleccionTextBox'].style.backgroundColor = "Gainsboro";
			document.all['txtTipoCambio_seleccionTextBox'].disabled = true;
			}
		else {
				document.all['txtTipoCambio_seleccionTextBox'].value = ""
				document.all['txtTipoCambio_seleccionTextBox'].title = ""
				document.all['txtTipoCambio_seleccionTextBox'].style.backgroundColor = "whitesmoke";
				document.all['txtTipoCambio_seleccionTextBox'].disabled = false;
				_CargarTipoCambio()
			  }
	
			if (codigo  == "1") 
			{
				document.all['txtMonedaGasto_seleccionTextBox'].style.display = ''; 
				document.all['txtMonedaGasto_seleccionTextBox'].title = ""; 
				document.all['txtMonedaGasto_listaComboBox'].style.display = 'none'; 
				AbrirComboBox(document.all['txtMonedaGasto_seleccionTextBox'], document.all['txtMonedaGasto_listaComboBox']);
				return;
			}else
			{	
				document.all.item("txtTipoCambio_seleccionTextBox").focus();
				return;
			}
	}
}
