var rand = parseInt(Math.random()*999999);
// JavaScript Document
	function Ajax(){
		var xmlhttp = false;
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		catch(E){
				xmlhttp = false;
			}
		}		
		if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
//
function cerrarDIVTarifas(){
	document.getElementById('tarifasDIV').style.visibility = "hidden";
	}
function cerrarDIVHab(){
	document.getElementById('habitacionDIV').style.visibility = "hidden";
	}
	
function obtenerTarifa(obj){
	var str = obj.value;
	    str = str.length;
	if(str >= 3){
		document.getElementById('tarifasDIV').style.visibility = "visible";
		var http = Ajax();
		var url = 'ajax/buscarTarifas.php?valor='+obj.value+'&rand='+rand;
		   http.open("GET",url,true);
			http.onreadystatechange=function(){
				if(http.readyState==4){
					document.getElementById('tarifasDIV').innerHTML = http.responseText;					
					}
				else{
					document.getElementById('tarifasDIV').innerHTML = "Cargar...";
					}
				}
			http.send(null);
		}
	}
	// ----------------
function pasaValor(valor, id_tarifa){	
	document.getElementById('tarifa').value = valor;
	document.getElementById('id_tarifa').value = id_tarifa;
	}
function pasaValorHab(valor, id_habitacion){	
	document.getElementById('tipo_habitacion').value = valor;
	document.getElementById('id_habitacion').value = id_habitacion;
	}	
	// ------------
	
function tipoHabitacion(obj){	
	var str = obj.value;
	    str = str.length;
	if(str >= 2){
		document.getElementById('habitacionDIV').style.visibility = "visible";
		var http = Ajax();
		var url = 'ajax/buscarHabitacion.php?valor='+obj.value+'&rand='+rand;
		   http.open("GET",url,true);
			http.onreadystatechange=function(){
				if(http.readyState==4){
					document.getElementById('habitacionDIV').innerHTML = http.responseText;					
					}
				else{
					document.getElementById('habitacionDIV').innerHTML = "Cargar...";
					}
				}
			http.send(null);
		}
	}
function calculaNumNoches(obj){
//	validamos las fechas por si estan ocupadas
	var fecha_ini = document.getElementById('fecha_entrada').value;
	var fecha_fin = document.getElementById('fecha_salida').value;
	var id_hotel =  document.getElementById('id_hotel').value;
if(fecha_ini !='' && fecha_fin != ''){
	var http = Ajax();
	var url = 'ajax/validarFechaCalendario.php?fecha_ini='+fecha_ini+'&fecha_fin='+fecha_fin+'&id_hotel='+id_hotel+'&rand='+rand;
		http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){
				//
				//alert(http.responseText);
			}
			else{
				//
				}
		}
		http.send(null);	
}

	if(fecha_ini != '' && fecha_fin != ''){
		var http = Ajax();
		var url = 'ajax/obtenerNumNoches.php?fecha_ini='+fecha_ini+'&fecha_fin='+fecha_fin+'&rand='+rand;
		    http.open("GET",url,true);
			http.onreadystatechange=function(){
				if(http.readyState==4){
					
					document.getElementById(obj.name).value = http.responseText;
					}
				else{
					document.getElementById(obj.name).value = 'Cargando...';
					}
				}
			http.send(null);
		}
	}	
// -------	
function Permisosreservaciones(){
	alert("No hay permisos");
	}
	
// -----
// -----
function AsignarHab(){  
   var hab = document.getElementById('numHab2').value;
   var hab3 = document.getElementById('numHab3').value;
   var id_h = document.getElementById('id_hotel').value;
   
	var chk1 = document.getElementById('chkHab1');
	var chk2 = document.getElementById('chkHab2');
	var chk3 = document.getElementById('chkHab3');
	
	
   
	
   if(id_h==""){return;}   
   if(document.getElementById('numhab').value==""){return;}
     
   if(chk1.checked==true && chk2.checked==true){
	   cargarSelectTarifas(id_h, 'tarifasDIV3');
	     if(document.getElementById('numhab2').value==""){return;}
         document.getElementById('hab3').style.display = "block";
         document.getElementById('chkHab3').checked = true;		 
	var url = 'ajax/cargarSelectTarifas3.php?id_hotel='+id_h+'&rand='+rand;
		var ht = Ajax();
		    ht.open("GET",url,true);
			ht.onreadystatechange=function(){
				if(ht.readyState==4){
					document.getElementById('tarifasDIV3').innerHTML = ht.responseText;
					}
				else{
					document.getElementById('tarifasDIV3').innerHTML = "Cargando...";
					}
				}
			ht.send(null);
   }
   else if(chk1.checked==true && chk2.checked==true && chk3.checked==true){
   alert("Numero Maximo de Campos");
   }
   else{	        
        document.getElementById('hab2').style.display = "block";
		document.getElementById('chkHab3').checked = false;
		document.getElementById('chkHab2').checked = true;
	cargarSelectTarifas(id_h, 'tarifasDIV2');
	var url = 'ajax/cargarSelectTarifas2.php?id_hotel='+id_h+'&rand='+rand;
		var ht = Ajax();
		    ht.open("GET",url,true);
			ht.onreadystatechange=function(){
				if(ht.readyState==4){
					document.getElementById('tarifasDIV2').innerHTML = ht.responseText;
					}
				else{
					document.getElementById('tarifasDIV2').innerHTML = "Cargando...";
					}
				}
			ht.send(null);
    }
}
// --------
function EliminarHab(){
	// CHECK
	var chk1 = document.getElementById('chkHab1');
	var chk2 = document.getElementById('chkHab2');
	var chk3 = document.getElementById('chkHab3');
   // INPUTS   
   var hab2 = document.getElementById('numHab2').value;
   var hab3 = document.getElementById('numHab3').value;   
   var id_h = document.getElementById('id_hotel');
   // TR
   var tr2 = document.getElementById('hab2');
   var tr3 = document.getElementById('hab3');  
   
   if(chk1.checked==true && chk2.checked==true && chk3.checked==true){
	   tr3.style.display = "none";
	   chk3.checked = false;
	   document.getElementById('numHab3').value = "";
	   }
else if(chk1.checked==true && chk2.checked==true){
	   tr2.style.display = "none";
	   chk2.checked = false;
	   document.getElementById('numHab2').value = "";
	}	  
}
// --------
function reservaciones(agente){
var fecha = new Date();
	var m = new String(fecha.getMonth()+1)
	var dia = new String();
	var mes = new String();
	var dia = new String(fecha.getDate());
		
    if(m.length==1){mes = '0'+m;}else{mes = m;}
	if(dia.length==1){dia = '0'+dia;}else{dia = dia;}
	
	var fechaHoy = dia+"/"+mes+"/"+(fecha.getFullYear());//fecha.getDate()+"/"+dia+"/"+fecha.getYear();

alert(fechaHoy);

	var des = "";
		des += "<table border='0' class='reservacion' width='100%'><tr><td>CAPTURA RESERVACION</td><td><h5><a href='index.php' class='volver'>volver</a></h5></td></tr><tr><td colspan='2' align='center'><div align='center' style='border: 0px solid red;'><table border='0' class='resInterna' width='90%' style='border-bottom: 0px'><tr><td colspan='3' bgcolor='#87C7E9'>DATOS DEL HOTEL</td></tr><tr><td colspan='7'>&nbsp;</td></tr><tr><td rowspan='8'></td><td>Id Hotel:</td><td><input type='text' name='id_hotel' id='id_hotel' onblur='buscarHotel(this)' class='reserva' onkeypress=\"moverFocus(event, 'nombre' )\" /></td><td rowspan='8'>&nbsp;&nbsp;</td><td>Ubicación:</td><td wdth='290'><div id='ubicacionDIV'></div></td><td rowspan='8'>&nbsp;</td></tr><tr><td>Nombre Hotel:</td><td><div id='nom_hotelDIV'></div></td><td colspan='2' width='290'>Descripcion:</td></tr></tr><tr><td>Pais:</td><td><div id='paisDIV'></div></td><td colspan='2'><div id='descripcionDIV'></div></td></tr><tr><td>Ciuda / Estado:</td><td><div id='ciudad_estadoDIV'></div></td></tr><tr><td></td><td></td></table></div><table border='0' class='resInterna' width='90%'><tr><td colspan='2' bgcolor='#87C7E9'>DATOS RESERVACION</td></tr><tr><td colspan='7'>&nbsp;</td></tr><tr><td rowspan='8'></td><td>Nombre de Huesped:</td><td><input type='text' name='nombre' id='nombre' class='reserva' /></td><td rowspan='8'>&nbsp;&nbsp;</td><td>Noches:</td><td><input type='text' name='noches' id='noches' size='4' onclick=\"calculaNumNoches(document.getElementById('noches'))\" class='reserva' /><img src='images/calcular.gif' alt='Calcular' onclick=\"calculaNumNoches(document.getElementById('noches'))\"></td><td rowspan='8'>&nbsp;</td></tr><tr><td>Fecha Entrada:</td><td><input type='text' name='fecha_entrada' id='fecha_entrada' class='reserva'  /><img src='images/cal.gif' alt='calendario' onclick=\"show_calendar('fecha_entrada', '"+fechaHoy+"')\" /></td>";

        des += "<td colspan='2'>Habitaciones";
        des += "<table border='0' width='100%' class='tableta' id='tabletas'>";
        des += "<tr><td>No</td><td>Tarifa</td><td>Tipo</td><td>Costo</td></tr>";


        des += "<tr><td><input type='text' name='numHab' id='numHab' class='resDato' style='width: 15px;' maxlength='2' /></td><td><div id='tarifasDIV'></div></td><td><div id='habitacionDIV'></div></td><td><div id='costoTarifa1'></div></td></tr>";
        des += "<tr id='hab2'><td><input type='text' name='numHab2' id='numHab2' class='resDato' style='width: 15px;' maxlength='2' /></td><td><div id='tarifasDIV2'></div></td><td><div id='habitacionDIV2'></div></td><td><div id='costoTarifa2'></div></td></tr>";
        des += "<tr id='hab3'><td><input type='text' name='numHab3' id='numHab3' class='resDato' style='width: 15px;' maxlength='2' /></td><td><div id='tarifasDIV3'></div></td><td><div id='habitacionDIV3'></div></td><td><div id='costoTarifa3'></div></td></tr>";
        // aqui se crearan los campos dinamic

        // ---------
        des += "<tr><td><img src='images/accept.gif' alt='Asignar' border='0' onclick='AsignarHab()' />[ + ]</td><td><img src='images/cancela.gif' alt='Eliminar' border='0' onclick='EliminarHab()' />[ - ]<input type='checkbox' name='chkHab3' id='chkHab3' class='chkValid' /><input type='checkbox' name='chkHab2' id='chkHab2' class='chkValid' /><input type='checkbox' name='chkHab1' id='chkHab1' checked class='chkValid' /></td></tr>";
        des += "</table>";
        des += "<div id='TOL'></div><div id='TAF'></div>";


//		des += "<input type='text' name='num_habitaciones' id='num_habitaciones' size='4' class='reserva' />";
		des += "</td></tr><tr><td>Fecha Salida:</td><td><input type='text' name='fecha_salida' id='fecha_salida' class='reserva' onblur=\"calculaNumNoches(document.getElementById('noches'))\" /><img src='images/cal.gif' alt='calendario'  onclick=\"show_calendar('fecha_salida', '"+fechaHoy+"')\" ></td><td>";
        des += "</td></tr><tr><td>Fecha Limite:</td><td><input type='text' name='fecha_limite' id='fecha_limite' class='reserva' onclick=\"calculaNumNoches(document.getElementById('noches'))\" /><img src='images/cal.gif' alt='calendario'  onclick=\"show_calendar('fecha_limite', '"+fechaHoy+"')\" ></td><td>&nbsp;</td><td></td></tr><tr><td>Como Garantiza</td><td><form name='forma'><input type='radio' name='card' id='card' value='1' onclick=\"CreaVentana('Datos de Tarjeta de Credito / Debito','capaT',1)\" />Tarjeta&nbsp;&nbsp;<input type='radio' name='card' id='card' value='2' onclick=\"CreaVentana('Datos de Tarjeta de Credito / Debito','capaT',2)\" />Cupon&nbsp;&nbsp;&nbsp;<input type='radio' name='card' id='card' value='3' checked />Otro</td></form><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td><div id='garantizado'></div></td></tr></table></td></tr><tr><td colspan='2' style='padding:2px; font-size: 1px;'>&nbsp;</td><tr><tr><td colspan='2' align='center'><table border='0' class='resInterna' width='90%'><tr><td colspan='3' bgcolor='#87C7E9'>DATOS DEL CLIENTE</td></tr><tr><td colspan='7'>&nbsp;</td></tr><tr><td>&nbsp;</td><td>QUIEN RESERVA</td><td colspan='5'><input type='text' name='nom_reserva' id='nom_reserva' class='reserva' /></td></tr><tr><td rowspan='8'></td><td>Num Cliente:</td><td><input type='text' name='num_cliente' id='num_cliente' onblur='buscaCliente(this,1)' class='reserva' /></td><td rowspan='4'>&nbsp;&nbsp;</td><td colspan='2'></td><td rowspan='8'>&nbsp;</td></tr><tr><td>Nombre Cliente:</td><td><input type='text' name='nom_cliente' id='nom_cliente' class='reserva' onkeypress='ObtenerCliente(this)' /><img src='images/lupa.png' onclick='buscaCliente(nom_cliente,2)' alt='lupa' width='20'><div id='DIVCliente'></div></td><td colspan='2' width='250' rowspan='3'><div id='direccionDIV'></div></td></tr><tr><td>Telefonos:</td><td><input type='text' name='telefonos' id='telefonos' class='resDato' /></td></tr><tr><td>Direccion:</td><td><textarea name='direccion' id='direccion' class='resDatotxt' ></textarea></td></tr></table></td></tr><tr><td colspan='2' style='padding:2px; font-size: 1px;'>&nbsp;</td></tr><tr><td colspan='2' style='padding:2px; font-size: 1px;' align='center'><table border='0' class='resInterna' width='90%'><tr><td colspan='3' bgcolor='#DEDDBE'>DATOS PARTICULARES</td></tr><tr><td colspan='7'>&nbsp;</td></tr><tr><td rowspan='8'></td><td>Observaciones:</td><td colspan='3'><textarea name='observaciones' id='observaciones' class='observaciones' class='reserva'></textarea></td><td wdth='290'><div id='ubicacionDIV'></div></td><td rowspan='8'>&nbsp;</td></tr><tr><td>Motivo:</td><td>";

        des += "<select name='motivo'>"
		des += "<option value='0'>Seleccionar Motivo</option>";
		des += "<option value='1'>Boletín Turístico</option>";
		des += "<option value='2'>Convenio Tarifas Netas</option>";
		des += "<option value='3'>Convenio Tarifas Comerciales</option>";
		des += "<option value='4'>Entretenedor Convenio T. Comercial</option>";
		des += "<option value='5'>Periodico</option>";
		des += "<option value='6'>Outlet</option>";
		des += "<option value='7'>Internet Anuncio</option>";
		des += "<option value='8'>Mercado de convenciones</option>";
		des += "<option value='9'>turistampa</option>";
		des += "<option value='10'>Sección amarilla</option>";
		des += "<option value='11'>HSBC</option>";
		des += "<option value='12'>Bancomer</option>";
		des += "<option value='13'>Banamex</option>";
		des += "<option value='14'>VTP mexicana</option>";
		des += "<option value='15'>Aeromar</option>";
		des += "<option value='16'>Ta planer</option>";
		des += "<option value='17'>Directorio Turístico de Mexico</option>";
		des += "<option value='18'>Agenda Grupo Carso</option>";
		des += "<option value='19'>Agenda SAT</option>";
		des += "<option value='20'>UNITEC</option>";
		des += "<option value='21'>Wal-Mart</option>";
		des += "<option value='22'>Amexco</option>";
		des += "<option value='23'>Internet Pagina</option>";
		des += "<option value='24'>Telemarketing</option>";
		des += "<option value='25'>Ninguno</option>";
		des += "<option value='26'>Otro</option>";
		des += "</select>";
		
		des += "</td></tr></tr><tr></tr><td></td><td></td></table></td></tr><tr><td colspan='2'>&nbsp;</td></tr><tr><td colspan='2' align='right'><input type='submit' name='CargarReserva' id='CargarReserva' value='Cargar Reserva' class='envios' onclick='enviar()' /></td></tr></table>";
		
	document.getElementById('iconos').innerHTML = "<b>RESERVACION</b> generar Nueva \n"+des;	
	}	
	// #############
	
/////
function ObtenerCliente(obj){


      var cliente = document.getElementById(obj.name);
      var tamano = cliente.value;
          tamano = tamano.length;
      var http = Ajax();
      var url = "ajax/ObtenerCliente.php?cliente="+obj.value+"&rand="+rand;
          if(tamano>3){
                 document.getElementById('DIVCliente').style.display = "block";
                 http.open("GET",url,true);
                 http.onreadystatechange=function(){
                   if(http.readyState==4){
                     document.getElementById('DIVCliente').innerHTML = http.responseText;
                   }  else{
                     //
                   }
                 }
               http.send(null);
          }
}
//
function pasaValorCliente(cliente){
      document.getElementById('nom_cliente').value = cliente;
      document.getElementById('DIVCliente').style.display = "none";
}
// ----------
function CreaVentana(titulo, DIV, tipo){
	document.getElementById('capaT').style.visibility = "visible";
	
	
	if(tipo == 1){
   var des = "";
		des += "<p class='regC'><span class='dato'>Num Tarjeta:</span> <input type='text' name='numTarjeta' id='numTarjeta' class='resDato' onkeypress='validar(event)'  onclick='quitarBorde(this)' /><img src='images/lupa.jpg' alt='buscar' onclick='obtenerNumTarjeta()'></p>";		
		des += "<p class='regC'><span class='dato'>Banco:</span><input type='text' name='bancoCard' id='bancoCard' class='resDato' style='width: 150px;' onclick='quitarBorde(this)' /></p>";		
		des += "<p class='regC'><span class='dato'>Fecha Vigencia:</span> <input type='text' name='fechaCard' id='fechaCard' class='resDato' style='width: 70px;' onclick='quitarBorde(this)' />Formato [mes/año]</p>";
		des += "<p class='regC'><span class='dato'>CODIGO:</span> <input type='text' name='codCard' id='codCard' class='resDato' style='width: 30px;' onclick='quitarBorde(this)' /></p>";
		des += "<p class='regC'><span class='dato'>Tarjetahabiente:</span> <input type='text' name='propietarioCard' id='propietarioCard' class='resDato' onclick='quitarBorde(this)' /></p>";
		//des += "<p class='regC'><span class='dato'>Activa:</span> <input type='checkbox' name='activaCard' id='activaCard' /> (si la Tarjeta esta actualmente activa)</p>";
		des += "<p class='regC'><span class='dato'>Tarjeta Existente:</span> <input type='checkbox' name='existenet' id='existenet' /> (marque si ya existen en la Base de Datos)</p>";
		des += "<p class='regC'><input type='hidden' name='idCard' id='idCard' /></p>";	
		des += "<p class='regC' style='text-align: center;'><input type='button' name='Limpiar' id='Limpiar' value='Limpiar' class='BtnCard' onclick='LimpiarCard()' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' name='AgregarCard' id='AgregarCard' value='Agregar' class='BtnCard' onclick='AsignarCard()' /></p>";
	
	}	
	else{
   var des = "";
		des += "<p class='regC'><span class='dato'>Cupon:</span> <input type='text' name='cupoCard' id='cupoCard' class='resDato' onclick='quitarBorde(this)'  /></p>";				
		des += "<p class='regC' style='text-align: center;'><input type='button' name='AgregarCard' id='AgregarCard' value='Agregar' class='BtnCard' onclick='AsignarCupon()' /></p>";		
		}
  var msgWindow = '';
  // ---
  msgWindow += '<div class="cajaarriba">';
  msgWindow += '<div class="cajaabajo">';
  msgWindow += '<div class="contenidoWIN">';
  msgWindow += '<div class="titulo">';
  msgWindow += '<span class="icon"><img src="js/icon.gif" /></span>';
  msgWindow += '<div class="texto">'+titulo+'</div>';
  msgWindow += '<span class="icon_x"><img src="js/icon_cerrar.gif" onclick=cerrarVentana("'+DIV+'") /></span>';
  msgWindow += '</div>';
  msgWindow += des;
  msgWindow += '<!-- -->';
  msgWindow += '</div></div></div>';
  
  document.getElementById(DIV).innerHTML = msgWindow;    
}
// ventana de modificaciones
function CreaVentanaModificaciones(titulo, DIV, id){
	
	var fecha = new Date();
	var m = new String(fecha.getMonth()+1)
	var dia = new String();
    var mes = new String();

    if(m.length==1){
		mes = '0'+m;
		}
	else{
		mes = m;
		}
	var fechaHoy = fecha.getDate()+"/"+mes+"/"+(fecha.getFullYear());//fecha.getDate()+"/"+dia+"/"+fecha.getYear();    

	document.getElementById('capaT').style.visibility = "visible";
	
   var http = Ajax();
   var url = "ajax/obtenerDatosReserva.php?id="+id+"&rand="+rand;
   var des = "";
   var msgWindow = '';
   var array = new String;
   	http.open("GET",url,true);
	http.onreadystatechange=function(){
		if(http.readyState==4){
			array = http.responseText;
		var data = array.split("|");									
			des += "<table border='0' width='100%'><tr><td>ID</td><td>RESERVA CLIENTE</td><td>ID HOTEL</td><td>NOMBRE HOTEL</td></tr>";
							  des += "<tr><td>"+data[0]+"<input type='hidden' name='id' id='id' value='"+data[0]+"' /></td><td>"+data[1]+"</td><td><input type='text' name='id_hotel' id='id_hotel' value='"+data[3]+"' class='resDato' style='width: 20px;' /><img src='images/lupa.jpg' alt='buscar Hotel' /></td><td><input type='text' name='nomHotel' id='nomHotel' value='"+data[4]+"' class='resDato'/></td></tr>";
		    des += "<tr><td colspan='4'>&nbsp;</td></tr>";
			des += "<tr><td>OPERADOR</td><td>"+data[6]+"</td><td>Fecha de Captura</td><td>"+data[8]+"</td></tr>";
			des += "<tr><td>HUESPED</td><td><input type='text' name='huesped' id='huesped' value='"+data[7]+"' class='resDato' /></td><td>Fecha Entrada</td><td><input type='text' name='fecha_entrada' id='fecha_entrada' value='"+data[9]+"' class='resDato' style='width: 120px;' /><img src='images/cal.gif' alt='calendario' onclick=\"show_calendar('fecha_entrada', '"+fechaHoy+"')\"  /></td></tr>";
			des += "<tr><td>Garantiza</td><td>"+data[13]+"</td><td>Fecha Salida</td><td><input type='text' name='fecha_salida' id='fecha_salida' value='"+data[10]+"' class='resDato' style='width: 120px;' /><img src='images/cal.gif' alt='calendario'  onclick=\"show_calendar('fecha_salida', '"+fechaHoy+"')\" /></td></tr>";
			des += "<tr><td>Reserva</td><td><input type='text' name='reserva' id='reserva' value='"+data[17]+"' class='resDato' /></td><td>Fecha Limite</td><td><input type='text' name='fecha_limite' id='fecha_limite' value='"+data[11]+"' class='resDato' style='width: 120px;' /><img src='images/cal.gif' alt='calendario'  onclick=\"show_calendar('fecha_limite', '"+fechaHoy+"')\" /></td></tr>";
			des += "<tr><td>Observaciones</td><td><textarea name='observaciones' id='observaciones' style='width: 350px; height: 80px; border: 1px solid #C9D0D3; color: #666666; font-size: 11px; font-family: Verdana;'>"+data[18]+"</textarea></td><td valign='top'>Noches</td><td valign='top'><input type='text' name='noches' id='noches' value='"+data[12]+"' class='resDato' style='width: 20px;' /><img src='images/calcular.gif' alt='Calcular' onclick=\"calculaNumNoches(document.getElementById('noches'))\"></td></tr>";
			des += "<tr><td colspan='4'>&nbsp;</td></tr>";
			des += "<tr><td colspan='4' align='center'><input type='button' name='Aceptar' id='Aceptar' value='Aceptar' class='BtnCard' onclick='ModificarReservaDatos()'/> </td></tr>";
			des += "</table>";			
  // ---
  msgWindow += '<div class="cajaarriba" style="margin-top: 10%; left: 20%; width: 900px;">';
  msgWindow += '<div class="cajaabajo">';
  msgWindow += '<div class="contenidoWIN">';
  msgWindow += '<div class="titulo">';
  msgWindow += '<span class="icon"><img src="js/accept.gif" /></span>';
  msgWindow += '<div class="texto">'+titulo+'</div>';
  msgWindow += '<span class="icon_x"><img src="js/icon_cerrar.gif" onclick=cerrarVentana("'+DIV+'") /></span>';
  msgWindow += '</div>';
  msgWindow += des;
  msgWindow += '<!-- -->';
  msgWindow += '</div></div></div>';
  document.getElementById(DIV).innerHTML = msgWindow;
		}
		else{
			//
		}
	}
	http.send(null); 
}
//
function ModificarReservaDatos(){
	var id = document.getElementById('id').value;
	var id_hotel = document.getElementById('id_hotel').value;
	var huesped  = document.getElementById('huesped').value;
	var fecha_entrada = document.getElementById('fecha_entrada').value;
	var fecha_salida = document.getElementById('fecha_salida').value;
	var fecha_limite = document.getElementById('fecha_limite').value;
	var reserva = document.getElementById('reserva').value;
	var observaciones = document.getElementById('observaciones').value;
	var noches = document.getElementById('noches').value;
	
	if(confirm("Los datos seran modificados")){
		var datos = '?id='+id+'&id_hotel='+id_hotel+'&huesped='+huesped+'&fecha_entrada='+fecha_entrada+'&fecha_salida='+fecha_salida+'&fecha_limite='+fecha_limite+'&reserva='+reserva+'&observaciones='+observaciones+'&noches='+noches+'&rand='+rand;
		var url = "actualizarDatosReserva.php"+datos;
		location.href = url;
		}
	}
	// quitar bordo de los datos
function quitarBorde(obj){
	document.getElementById(obj.name).style.borderColor = "#C9D0D3";
	}
//       
function AsignarCupon(){	
	var cupon = document.getElementById('cupoCard').value;
	if(cupon==''){document.getElementById('cupoCard').style.borderColor = "#FF0000"; return;}
if(confirm("El cupon es correcto?")){
		 
			   var http = Ajax();			   			   
			   var url = "ajax/variableSession.php?sesion=cupon&id_cupon="+cupon+"&rand="+rand;
			       http.open("GET",url,true);
				   http.onreadystatechange=function(){
					   if(http.readyState==4){
						  // alert(http.responseText+"------");
						  document.getElementById('capaT').innerHTML = "";
						  document.getElementById('capaT').style.visibility = "visible";
						  document.getElementById('garantizado').innerHTML = "Cupon";
						  document.getElementById('garantizado').style.backgroundColor = "#B9D6D9";
						   }
						else{
							//
							}
					   }
					http.send(null);		      
		}else{
             alert("validar");
			}
			
			
	}
//
function LimpiarCard(){
	document.getElementById('numTarjeta').value = "";
	document.getElementById('bancoCard').value = "";
	document.getElementById('fechaCard').value = "";
	document.getElementById('codCard').value = "";
	document.getElementById('propietarioCard').value = "";
   //	document.getElementById('activaCard').checked = false;  // false no esta checkeada
	document.getElementById('existenet').checked = false;
	}
// 
function AsignarCard(){
	// validando los campos de la tarjeta
	var num = document.getElementById('numTarjeta').value;
	var banco = document.getElementById('bancoCard').value;
	var fecha = document.getElementById('fechaCard').value;
	var cod = document.getElementById('codCard').value;
	var propietario = document.getElementById('propietarioCard').value;
   //	var activa = document.getElementById('activaCard').checked;  // false no esta checkeada

	if(num==''){document.getElementById('numTarjeta').style.borderColor = "#FF0000"; return;}
	if(banco==''){document.getElementById('bancoCard').style.borderColor = "#FF0000"; return;}
	if(fecha==''){document.getElementById('fechaCard').style.borderColor = "#FF0000"; return;}
	if(cod==''){document.getElementById('codCard').style.borderColor = "#FF0000"; return;}
	if(propietario==''){document.getElementById('propietarioCard').style.borderColor = "#FF0000"; return;}
	//if(!activa){alert("La tarjeta debera estar Activa"); return;}

	if(confirm("Los datos de la Tarjeta Son Correctos?")){
		   if(document.getElementById('existenet').checked){
			   // generamos la coockie sin insertar el registro
			   var http = Ajax();
			   var id = document.getElementById('idCard').value;
			   var url = "ajax/variableSession.php?id="+id+"&rand="+rand;
			       http.open("GET",url,true);
				   http.onreadystatechange=function(){
					   if(http.readyState==4){
						  // alert(http.responseText+"------");
						  document.getElementById('capaT').innerHTML = "";
						  document.getElementById('capaT').style.visibility = "hidden";
						  document.getElementById('garantizado').innerHTML = "Tarjeta de credio";
						  document.getElementById('garantizado').style.backgroundColor = "#B9D6D9";
						   }
						else{
							//
							}
					   }
					http.send(null);
			   }
			 else{
				 //alert("no existe hay que insertar el registro");
				var h = Ajax();			    
			    var url = "ajax/insertarTarjeta.php?banco="+banco+"&num_tarjeta="+num+"&fecha_vigencia="+fecha+"&nom_propietario="+propietario+"&cod_seguridad="+cod+"&rand="+rand;
			       h.open("GET",url,true);
				   h.onreadystatechange=function(){
					   if(h.readyState==4){						
						  document.getElementById('capaT').innerHTML = "";
						  document.getElementById('capaT').style.visibility = "hidden";
						  document.getElementById('garantizado').innerHTML = "Tarjeta de credio";
						  document.getElementById('garantizado').style.backgroundColor = "#B9D6D9";
						   }
						else{
							//
							}
					   }
					h.send(null);
					
				 }
		      
		}else{
//
			}
	}
// #####################################
	function validar(e) {
  		tecla = (document.all) ? e.keyCode : e.which;
  		if (tecla==13){
			obtenerNumTarjeta();
			}
}
// #########################
function obtenerNumTarjeta(){
	
	var numTarjeta = document.getElementById('numTarjeta').value;
	var http = Ajax();
	var url = "ajax/ObtenerNumTarjeta.php?num="+numTarjeta+"&rand="+rand;	
	var array = new String;
	var idCard;

		http.open("GET",url,true);
		http.onreadystatechange=function(){			
			if(http.readyState==4){			
				var array = http.responseText;
				var data = array.split("|");
				   if(data[0]=='0'){
					   alert("No existe Registro");
					   }
				  else{
					  document.getElementById('idCard').value = data[1]; 
					  document.getElementById('bancoCard').value = data[2];
					  document.getElementById('fechaCard').value = data[3];
					  document.getElementById('propietarioCard').value = data[4];
					  document.getElementById('codCard').value = data[5];
					  //if(data[7]=='1'){ document.getElementById('activaCard').checked = true; }else{document.getElementById('activaCard').checked = false;}
					  if(data[7]=='1'){ document.getElementById('existente').checked = true; }else{document.getElementById('existente').checked = false;}					  
					  }					  

				}
			else{
				//
				}
			}
		http.send(null);		
	}
// #####################################
function cerrarVentana(DIV){
	document.getElementById(DIV).innerHTML = '';
	document.getElementById(DIV).style.visibility = "hidden";
	document.forma.card[2].checked = true;	
}	
//
function enviar(){


	var NO = document.getElementById('nombre').value;
	var FE = document.getElementById('fecha_entrada').value;
	var FS = document.getElementById('fecha_salida').value;
	var FL = document.getElementById('fecha_limite').value;
	var NOC = document.getElementById('noches').value;
	var NC = document.getElementById('num_cliente').value;
	var IH = document.getElementById('id_hotel').value;
	var OB = document.getElementById('observaciones').value;
	var MO = document.getElementById('motivo').value;
	var NR = document.getElementById('nom_reserva').value;
	var chk1 = document.getElementById('chkHab1').checked;
	var chk2 = document.getElementById('chkHab2').checked;
	var chk3 = document.getElementById('chkHab3').checked;
	// datos EXTRAS CLIENTES
	var telefonoCli = document.getElementById('telefonos').value;
	var direccionCli = document.getElementById('direccion').value;
	// TARIFAS
	var chk1 = document.getElementById('chkHab1');
	var chk2 = document.getElementById('chkHab2');
	var chk3 = document.getElementById('chkHab3');
	
	if(chk1.checked==true && chk2.checked==false && chk3.checked==false){
		var numHab = document.getElementById('numHab').value;
		var idTari = document.getElementById('id_tarifa1').value;
		var tipoHab = document.getElementById('tipo_habitacion1').value;		
		tarifas = "&numHab0="+numHab+"&idTari="+idTari+"&tipoHab="+tipoHab;
		}
else if(chk1.checked==true && chk2.checked==true && chk3.checked==false){
		var numHab = document.getElementById('numHab').value;
		var idTari = document.getElementById('id_tarifa1').value;
		var tipoHab = document.getElementById('tipo_habitacion1').value;	
		//--
		var numHab2 = document.getElementById('numHab2').value;
		var idTari2 = document.getElementById('id_tarifa2').value;
		var tipoHab2 = document.getElementById('tipo_habitacion2').value;
		
		tarifas = "&numHab0="+numHab+"&idTari="+idTari+"&tipoHab="+tipoHab+"&numHab1="+numHab2+"&idTari2="+idTari2+"&tipoHab2="+tipoHab2;
		}
else if(chk1.checked==true && chk2.checked==true && chk3.checked==true){
		var numHab = document.getElementById('numHab').value;
		var idTari = document.getElementById('id_tarifa1').value;
		var tipoHab = document.getElementById('tipo_habitacion1').value;	
		//--
		var numHab2 = document.getElementById('numHab2').value;
		var idTari2 = document.getElementById('id_tarifa2').value;
		var tipoHab2 = document.getElementById('tipo_habitacion2').value;
		//--
		var numHab3 = document.getElementById('numHab3').value;
		var idTari3 = document.getElementById('id_tarifa3').value;
		var tipoHab3 = document.getElementById('tipo_habitacion3').value;
		
		tarifas = "&numHab0="+numHab+"&idTari="+idTari+"&tipoHab="+tipoHab+"&numHab1="+numHab2+"&idTari2="+idTari2+"&tipoHab2="+tipoHab2+"&numHab2="+numHab3+"&idTari3="+idTari3+"&tipoHab3="+tipoHab3;
	}	
	var datos = '&nombre='+NO+'&fecha_entrada='+FE+'&fecha_salida='+FS+"&fecha_limite="+FL+"&noches="+NOC+"&num_cliente="+NC+"&id_hotel="+IH+"&observaciones="+OB+"&motivo="+MO+"&nom_reserva="+NR+"&telefonoCli="+telefonoCli+"&direccionCli="+direccionCli+"&chk1="+chk1.checked+"&chk2="+chk2.checked+"&chk3="+chk3.checked+tarifas;
	
	location.href = "cargarReserva.php?rand="+rand+datos;
	}
//
function calculaFechaLimite(){
	var FE = document.getElementById('fecha_entrada');
	var FS = document.getElementById('fecha_salida');
	var FL = document.getElementById('fecha_limite');
	if(FE.value == ""){
		FE.focus();
		return;
		}
	if(FS.value == ""){
		FS.focus();
		return;
		}
	 FL.value = FE.value;	
	}
// buscar cliente
function buscaCliente(obj,tipo){
	var http = Ajax();
	var url = 'ajax/buscarCliente.php?valor='+obj.value+'&tipo='+tipo+'&rand='+rand;
	var array = new String;
		http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){				
				    array = http.responseText;	
				var nombre = array.split("|");

					document.getElementById('num_cliente').value = nombre[0];
	                document.getElementById('nom_cliente').value = nombre[1];
				//    document.getElementById('responsableDIV').innerHTML = nombre[2];
				//	document.getElementById('cargoDIV').innerHTML = nombre[3];
				//	document.getElementById('telefonosDIV').innerHTML = nombre[4];
				//	document.getElementById('emailsDIV').innerHTML = nombre[5];
				//	document.getElementById('direccionDIV').innerHTML = nombre[6];
				}
			else{//
				}
			}
		http.send(null);
	}
//
function buscarHotel(obj, DIV){
document.getElementById(DIV).style.display = "block";
document.getElementById('muestra').checked = true;

	var http = Ajax();
	var url = 'ajax/buscarHotel.php?valor='+obj.value+'&rand='+rand;
	var array = new String;
		http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){
				    array = http.responseText;
				var nombre = array.split("|");
				
					document.getElementById('nom_hotelDIV').innerHTML = nombre[0];
	                document.getElementById('paisDIV').innerHTML = nombre[1];
				    document.getElementById('ciudad_estadoDIV').innerHTML = nombre[2];
					document.getElementById('ubicacionDIV').innerHTML = nombre[3];
					document.getElementById('descripcionDIV').innerHTML = nombre[4];
				
					// envalua el hotel para generar un nuevo evento AJAX

					if(nombre[5] == 1){
						cargarSelectTarifas(obj.value, 'tarifasDIV');
						}
		
				}
			else{
				//
				}
			}
		http.send(null);
		
	}
// ################################
function buscarCliente(obj, DIV){
	var http = Ajax();
	var url = 'ajax/buscarDatosCliente.php?valor='+obj.value+'&rand='+rand;
	var array = new String;
		http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){
				    array = http.responseText;
				var nombre = array.split("|");		
					document.getElementById('nomReserva').value = nombre[0];
	                document.getElementById('dirCliente').value = nombre[1];
				    document.getElementById('ciudadCliente').value = nombre[2];
					document.getElementById('telefonoCliente').value = nombre[3];
					document.getElementById('empresa').value = nombre[4];
				}
			else{
				//
				}
			}
		http.send(null);
	}	
// ################################
	// funcion para cargar el select de tarifas
	function cargarSelectTarifas(id_hotel, DIV){		
		var url = 'ajax/cargarSelectTarifas.php?id_hotel='+id_hotel+'&rand='+rand;
		var ht = Ajax();
		    ht.open("GET",url,true);
			ht.onreadystatechange=function(){
				if(ht.readyState==4){
					document.getElementById(DIV).innerHTML = ht.responseText;
					}
				else{
					document.getElementById(DIV).innerHTML = "Cargando...";
					}
				}
			ht.send(null);
		}

//
	function cargarTipoHabitacion(id_hotel,id_habitacion){
		var url = 'ajax/cargarSelectHabitaciones.php?id_hotel='+id_hotel+'&id_tarifa='+id_habitacion.value+'&hab=1&divCosto=1&rand='+rand;
		var ht = Ajax();
		    ht.open("GET",url,true);
			ht.onreadystatechange=function(){
				if(ht.readyState==4){
					document.getElementById('habitacionDIV').innerHTML = ht.responseText;
					}
				else{
					document.getElementById('habitacionDIV').innerHTML = "Cargando...";
					}
				}
			ht.send(null);
		}
//
	function cargarTipoHabitacion2(id_hotel,id_habitacion){
		var url = 'ajax/cargarSelectHabitaciones.php?id_hotel='+id_hotel+'&id_tarifa='+id_habitacion.value+'&hab=2&divCosto=2&rand='+rand;
		var ht = Ajax();
		    ht.open("GET",url,true);
			ht.onreadystatechange=function(){
				if(ht.readyState==4){
					document.getElementById('habitacionDIV2').innerHTML = ht.responseText;
					}
				else{
					document.getElementById('habitacionDIV2').innerHTML = "Cargando...";
					}
				}
			ht.send(null);
		}
//
	function cargarTipoHabitacion3(id_hotel,id_habitacion){
		var url = 'ajax/cargarSelectHabitaciones.php?id_hotel='+id_hotel+'&id_tarifa='+id_habitacion.value+'&hab=3&divCosto=3&rand='+rand;
		var ht = Ajax();
		    ht.open("GET",url,true);
			ht.onreadystatechange=function(){
				if(ht.readyState==4){
					document.getElementById('habitacionDIV3').innerHTML = ht.responseText;
					}
				else{
					document.getElementById('habitacionDIV3').innerHTML = "Cargando...";
					}
				}
			ht.send(null);
		}
// -----------
function reportes(){
	var fecha = new Date();
	var m = new String(fecha.getMonth()+1)
	var dia = new String();
    if(m.length==1){
		mes = '0'+m;
		}
	else{
		mes = m;
		}

	var fechaHoy = fecha.getDate()+"/"+mes+"/"+(fecha.getFullYear());//fecha.getDate()+"/"+dia+"/"+fecha.getYear();

	var des = "";
		des += "<br />Fecha Inicial: <input type='text' name='fecha_inicial' id='fecha_inicial' class='input_fecha' onclick='despinta(this)' /><img src='images/cal.gif' alt='calendario' onclick=\"show_calendar('fecha_inicial', '"+fechaHoy+"')\"><br />";
		des += "<br />Fecha Final: <input type='text' name='fecha_final' id='fecha_final' class='input_fecha' onclick='despinta(this)' />";
		des += "<img src='images/cal.gif' alt='calendario'  onclick=\"show_calendar('fecha_final', '"+fechaHoy+"')\"><br />";	
		des += "<br /><input type='radio' name='tipo_radio' id='tipo_radio' value='1' style='float:left;' onclick='muestraCampo(1)'><div class='tipo'>por HOTEL</div>";
		des += "<input type='text' name='hotel_seleccion' id='hotel_seleccion' class='input_fecha' style='display: none; float: left; width: 300px;' onkeypress='obtenHotel(this)'>";
		des += "<div id='resultHoteles'></div>";
		des += "<br /><input type='radio' name='tipo_radio' id='tipo_radio' value='2' style='float:left; clear: both;' onclick='muestraCampo(2)'><div class='tipo'>por SEGMENTO</div>";
		des += "<input type='text' name='segmento_seleccion' id='segmento_seleccion' style='display: none;' >";
		des += "<br /><input type='button' name='Consultar' id='Consultar' value='Consultar' class='consultar' onclick='Consultar()' />";		
		des += "<div id='vistaConsulta'></div><input type='hidden' name='parametro' id='parametro'>";
		
	document.getElementById('iconos').innerHTML = "<b>REPORTES</b> cuartos noche por Hotel \n"+des;
	}
// 
function muestraCampo(campo){
	if(campo==1){
	  document.getElementById('hotel_seleccion').style.display = "block";
	  document.getElementById('hotel_seleccion').value = "";
	  document.getElementById('segmento_seleccion').style.display = "none";
	  hotel_seleccion.focus();
	}else{
	  document.getElementById('hotel_seleccion').style.display = "none";
	  document.getElementById('segmento_seleccion').style.display = "block";
	  segmento_seleccion.focus();
	  document.getElementById('resultHoteles').style.display = "none";
	}
}
// 
function obtenHotel(obj){
	 if(obj.value.length > 3){
		 var http = Ajax();
		 var rand = parseInt(Math.random()*999999);
		 var url = "cargarHotelcampo.php?valor="+obj.value+"&rand="+rand;
		 	http.open("GET",url,true);
			http.onreadystatechange=function(){
				if(http.readyState==4){
					//document.getElementById(obj.name).value = http.responseText;
					document.getElementById('resultHoteles').style.display = "block";
					document.getElementById('resultHoteles').innerHTML = http.responseText;
					}
                else{
					document.getElementById('resultHoteles').innerHTML = "Buscando...";
					}
				}
			http.send(null);
		}else{
					document.getElementById('resultHoteles').innerHTML = "";
			}
	 }
// primer consulta
function Consultar(){
	var fecha1 = document.getElementById('fecha_inicial');
	var fecha2 = document.getElementById('fecha_final');
	if(fecha1.value==''){
		fecha1.style.backgroundColor='#BD7A5E';
		return 0;
		}
	if(fecha2.value==''){
		fecha2.style.backgroundColor='#BD7A5E';
		return 0;
		}
	ObtenerConsulta();
	}
// 
function despinta(obj){
	document.getElementById(obj.name).style.backgroundColor = '#FFF';
	}
// 
function ObtenerConsulta(){
	var fecha1 = document.getElementById('fecha_inicial').value;
	var fecha2 = document.getElementById('fecha_final').value;
	var opcion = document.getElementById('tipo_radio').checked;
	var parametro = document.getElementById('parametro').value;
	if(opcion){var valor = 1;}else{var valor=2;}
	var http = Ajax();
	var rand = parseInt(Math.random()*999999);
	var url = 'ReporteNochesporHotel.php?tipo='+valor+'&fecha1='+fecha1+"&fecha2="+fecha2+"&parametro="+parametro+"&rand="+rand;
		http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){
				document.getElementById('vistaConsulta').innerHTML = http.responseText;
				}
			else{
				document.getElementById('vistaConsulta').innerHTML = "Cargando...";
				}
			}
		http.send(null);
	}
//

function convertirExcel(tipo, fecha1, fecha2, parametro){
	location.href = "convertirExcel.php?tipo="+tipo+"&fecha1="+fecha1+"&fecha2="+fecha2+"&parametro="+parametro;
	}
//
function pasarNombre(nombre, id){
	document.getElementById('hotel_seleccion').value = nombre;
	document.getElementById('parametro').value = id;
	}
//
function muestraResCar(filtro){
	var http = Ajax();
    var rand = parseInt(Math.random()*999999);
	var url = "ConsultaReservas.php?filtro="+filtro+"&rand="+rand;
	    http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){
				document.getElementById('iconOpt').innerHTML = http.responseText;
				}
			else{
				document.getElementById('iconOpt').innerHTML = "Cargando...";
				}
			}
		http.send(null);
	}
//---------
function cambiaOpt(opt){                 
//	document.getElementById('hoy').style.backgroundColor = '#FF0000';
muestraResCar(opt);
	}
	// ######################################
function ConsultaReservas(tipo){
	var http = Ajax();
	var url = "obtenerReservas.php?tipo="+tipo+"&rand="+rand;
	    http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){
				document.getElementById('menuOPT2').innerHTML = http.responseText;
				}
			else{
				document.getElementById('menuOPT2').innerHTML = "Cargando...";
				}
			}
		http.send(null);
	}
	// ######################################
function muestraTodas(){
	var menu = "";	    
		menu += "<a href='#' onclick='ConsultaReservas(1)'><img src='images/cargada.jpg' alt='' border='0' /></a>";
		menu += "<a href='#' onclick='ConsultaReservas(2)'><img src='images/cancelada.jpg' alt='' border='0' /></a>";
		menu += "<a href='#' onclick='ConsultaReservas(3)'><img src='images/modificada.jpg' alt='' border='0' /></a>";
		menu += "<a href='#' onclick='ConsultaReservas(4)'><img src='images/eliminada.jpg' alt='' border='0' /></a>";
		menu += "<a href='#' onclick='ConsultaReservas(5)'><img src='images/rechazada.jpg' alt='' border='0' /></a>";
		menu += "<a href='#' onclick='ConsultaReservas(6)'><img src='images/negada.jpg' alt='' border='0' /></a>";
		menu += "<div id='menuOPT2'>";
		menu += "</div>";
	
	
	document.getElementById('reservas_Cargadas').innerHTML = menu;
	}
//
// ######################
//  CANCELAR RESERVA
// ######################
function CreaVentanaCancelar(titulo, DIV, id){
	
	document.getElementById('capaT').style.visibility = "visible";
	
   var http = Ajax();
   var url = "ajax/obtenerDatosReserva.php?id="+id+"&rand="+rand;
   var des = "";
   var msgWindow = '';
   var array = new String;
   	http.open("GET",url,true);
	http.onreadystatechange=function(){
		if(http.readyState==4){
			array = http.responseText;
		var data = array.split("|");									
			des += "<table border='0' width='100%'><input type='hidden' name='id_hotel' id='id_hotel' value='"+data[3]+"' /><tr><td>ID</td><td>RESERVA CLIENTE</td></tr>";
							  des += "<tr><td>"+data[0]+"<input type='hidden' name='id' id='id' value='"+data[0]+"' /></td><td>"+data[1].toUpperCase()+"</td></tr>";
		    des += "<tr><td colspan='4'>&nbsp;</td></tr>";
			des += "<tr><td>OPERADOR</td><td>"+data[6]+"</td></tr>";
			des += "<tr><td>Observaciones</td><td><textarea name='observaciones' id='observaciones' style='width: 350px; height: 80px; border: 1px solid #C9D0D3; color: #666666; font-size: 11px; font-family: Verdana;'></textarea></td></tr>";
			des += "<tr><td colspan='4'>&nbsp;</td></tr>";
			des += "<tr><td colspan='4' align='center'><input type='button' name='Aceptar' id='Aceptar' value='Aceptar' class='BtnCard' onclick='CancelarReservacion()'/> </td></tr>";
			des += "</table>";			
  // ---
  msgWindow += '<div class="cajaarriba" style="margin-top: 10%; left: 20%; width: 700px;">';
  msgWindow += '<div class="cajaabajo">';
  msgWindow += '<div class="contenidoWIN">';
  msgWindow += '<div class="titulo">';
  msgWindow += '<span class="icon"><img src="js/accept.gif" /></span>';
  msgWindow += '<div class="texto">'+titulo+'</div>';
  msgWindow += '<span class="icon_x"><img src="js/icon_cerrar.gif" onclick=cerrarVentana("'+DIV+'") /></span>';
  msgWindow += '</div>';
  msgWindow += des;
  msgWindow += '<!-- -->';
  msgWindow += '</div></div></div>';
  document.getElementById(DIV).innerHTML = msgWindow;
		}
		else{
			//
		}
	}
	http.send(null); 
}
function CancelarReservacion(){
	var id = document.getElementById('id').value;
	var id_hotel = document.getElementById('id_hotel').value;
	var observaciones = document.getElementById('observaciones').value;
if(confirm("realmente desea cancelar la orden")){
		var http = Ajax();
		var url = "cancelarOrden.php?id="+id+"&id_hotel="+id_hotel+"&observaciones="+observaciones+"&rand="+rand;
			http.open("GET",url,true);
			http.onreadystatechange=function(){
				if(http.readyState==4){
					alert("La orden se ha cancelado");
					location.href = "index.php";
					}
				else{
					// cargando cancel
					}
				}
			http.send(null);
		}
	else{
		//
		}
	}
	function cancelarReserva(id,id_hotel){
	//CreaVentanaCancelar('Cancelar reserva', 'capaT', id);
	location.href = "reservacionesCancelacion.php?id="+id;
	}
// ######################
//  ELIMINAR RESERVA
// ######################
function eliminarReserva(id,id_hotel){
	if(confirm("realmente desea Eliminar la orden")){
		var http = Ajax();
		var url = "eliminarOrden.php?id="+id+"&id_hotel="+id_hotel+"&rand="+rand;
			http.open("GET",url,true);
			http.onreadystatechange=function(){
				if(http.readyState==4){
					alert("La orden se ha Eliminado");
					location.href = "index.php";
					}
				else{
					// cargando cancel
					}
				}
			http.send(null);
		}
	else{
		//
		}
	}
// ######################
//  ACTUALLIZA RESERVA
// ######################
function modificarReserva(id){
	  location.href = "reservacionesModificacion.php?id="+id;
	  //CreaVentanaModificaciones('Modifcar reserva', 'capaT', id);
	}		
function mostrarCatalogo(){
	var tipo = document.getElementById('catalogo').value;
	if(tipo==0){
		alert("Seleccione un Catalogo");
		return;
		}
	var h = Ajax();
	var url = "cargarCatalogo.php?tipo="+tipo+"&rand="+rand;
		h.open("GET",url,true);
		h.onreadystatechange=function(){
			if(h.readyState==4){
				document.getElementById('catalogoDIV').innerHTML = h.responseText;
				}
			else{
				document.getElementById('catalogoDIV').innerHTML = "Cargando...";
				}
			}
		h.send(null);
	}	
// ###############################
function agregarRegistro(){
	var opt = document.getElementById('catalogo').value;
	if(opt==0){
		alert("Seleccione Catalogo");
		return false;
		}
		var http = Ajax();
		var rand = Math.random()*9999999;
		var url = 'ajax/construyeContenido.php?opt='+opt+'&rand='+rand;
		http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){
				if(http.status==200){
					document.getElementById('catalogoDIV').innerHTML = http.responseText;
					}
				}
			}
		http.send(null);			
	}
//
function cancelar(){
	document.getElementById('catalogoDIV').innerHTML = '';
	}
// #############################
function siguiente(tipo,pagina){
	var h = Ajax();
	var url = "cargarCatalogo.php?tipo="+tipo+"&pagina="+pagina+"&rand="+rand;
		h.open("GET",url,true);
		h.onreadystatechange=function(){
			if(h.readyState==4){
				document.getElementById('catalogoDIV').innerHTML = h.responseText;
				}
			else{
				document.getElementById('catalogoDIV').innerHTML = "Cargando...";
				}
			}
		h.send(null);	
	}
// #############################
function atras(tipo,pagina){
	var h = Ajax();
	var url = "cargarCatalogo.php?tipo="+tipo+"&pagina="+pagina+"&rand="+rand;
		h.open("GET",url,true);
		h.onreadystatechange=function(){
			if(h.readyState==4){
				document.getElementById('catalogoDIV').innerHTML = h.responseText;
				}
			else{
				document.getElementById('catalogoDIV').innerHTML = "Cargando...";
				}
			}
		h.send(null);	
	}
	
//
function buscarReserva(){
	var clave = document.getElementById('claveRes').value;
	if(clave==''){
		document.getElementById('claveRes').style.backgroundColor = "#E0A854";
		return false;
		}
	var http = Ajax();
	var rand = Math.random()*9999999;
	var url = 'ajax/buscarReservaClave.php?clave='+clave+'&rand='+rand;
		http.open("GET",url,true);
		http.onreadystatechange=function(){
			if(http.readyState==4){
				  document.getElementById('datosResDIV').innerHTML = http.responseText;
				}
			else{
				  // .
				}
			}
		http.send(null);
	}