//	Bloquea el botón atrás del navegador
function historial()
{
	if (history.forward(1))
		history.replace(history.forward(1));
	window.defaultStatus = "Central de Reservas Online para Agencias";
}
//	----------------------------------------------------------------------------------------------------
function init()
{
	window.document.getElementById("ECliente").focus();
}
function initFechasAspx()
{
	igdrp_getComboById("FechaEntrada").focus();
}
//	----------------------------------------------------------------------------------------------------
//	Sumar dias a una fecha
function finMes(nMes, nAno)
{
	var aFinMes = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);  
	
	return aFinMes[nMes - 1] + (((nMes == 2) && (nAno % 4) == 0)? 1: 0); 
} 

function padNmb(nStr, nLen, sChr)
{ 
    var sRes = String(nStr); 
	for (var i = 0; i < nLen - String(nStr).length; i++)	sRes = sChr + sRes; 
	return sRes; 
} 
	
function makeDateFormat(nDay, nMonth, nYear)
{ 
	var sRes; 
	sRes = padNmb(nDay, 2, "0") + "/" + padNmb(nMonth, 2, "0") + "/" + padNmb(nYear, 4, "0"); 
	return sRes; 
} 
   
function incDate(sFec0)
{ 
	var nDia = parseInt(sFec0.substr(0, 2), 10); 
	var nMes = parseInt(sFec0.substr(3, 2), 10); 
	var nAno = parseInt(sFec0.substr(6, 4), 10); 
	nDia += 1; 
	
	if (nDia > finMes(nMes, nAno))
	{ 
		nDia = 1; 
		nMes += 1; 
		if (nMes == 13)
		{ 
			nMes = 1; 
			nAno += 1; 
		} 
	} 
	return makeDateFormat(nDia, nMes, nAno); 
} 

function addToDate(sFec0, sInc)
{ 
	var nInc = Math.abs(parseInt(sInc)); 
	var sRes = sFec0; 
	if (parseInt(sInc) >= 0) 
		for (var i = 0; i < nInc; i++) sRes = incDate(sRes); 
			return sRes; 
} 
//	----------------------------------------------------------------------------------------------------

//	Calcula la fecha de salida
function ENumNoches_Blur(oEdit, text, oEvent)
{
	var fSalida = igedit_getById('LFechaSalida');
	var numNoches = igedit_getById('ENumNoches');
	var fEntrada = igdrp_getComboById('FechaEntrada');
	
	fSalida.setText(addToDate(fEntrada.getText(), text));
} 
//	----------------------------------------------------------------------------------------------------
function FechaEntrada_EditKeyDown(oDropDown, keyCode, oEvent)
{
	if (keyCode == 13)
		igedit_getById("ENumNoches").focus();
}
//	----------------------------------------------------------------------------------------------------
function FechaEntrada_OnBlur(oDropDown, oEvent)
{
	var fSalida = igedit_getById('LFechaSalida');
	var numNoches = igedit_getById('ENumNoches').getNumber();
	var fEntrada = igdrp_getComboById('FechaEntrada');
	
	fSalida.setText(addToDate(fEntrada.getText(), numNoches));
}
//	----------------------------------------------------------------------------------------------------
function DesmarcarTodosTipos()
{
	var tipos = igtbl_getGridById("GridHotel");
	
	for(var i = 0; i < tipos.Rows.length; i++)
		tipos.Rows.getRow(i).getCell(0).setValue(false);

}
//	----------------------------------------------------------------------------------------------------
function MarcarTodosTipos()
{
	var tipos = igtbl_getGridById("GridHotel");
	
	for (var i = 0; i < tipos.Rows.length; i++)
		tipos.Rows.getRow(i).getCell(0).setValue(true);
}
//	----------------------------------------------------------------------------------------------------
function ENombreHotel_KeyDown(oEdit, keyCode, oEvent)
{
	if (keyCode == 13)
		window.document.getElementById("CProvincia").focus();
}
