
//Formato de la fecha
// 1 = DD/MM/YYYY 
// 2 = MM/DD/YYYY	
// 3 = YYYY/MM/DD
// 4 = YYYY/DD/MM
var formato = 1;

//**********************************************************************************************
//	invierta una fecha dada retornando en formato YYYYMMDD
//  dFecIni = Fecha a invertir
//	nTipFormat = Formato en que biene la fecha
//				 1 = DD/MM/YYYY 
//				 2 = MM/DD/YYYY	
//				 3 = YYYY/MM/DD
//				 4 = YYYY/DD/MM

function invFecha(nTipFormat,dFecIni){
	var dFecIni = dFecIni.replace(/-/g,"/");					// reemplaza el - por /	
	
	// primera division fecha
	var nPosUno  = ponCero(dFecIni.substr(0,dFecIni.indexOf("/")));
	// 2º divicion fecha
	var nPosDos  = ponCero(dFecIni.substr(parseInt(dFecIni.indexOf("/")) + 1,parseInt(dFecIni.lastIndexOf("/")) - parseInt(dFecIni.indexOf("/")) - 1));
	// 3º divicion fecha
	var nPosTres = ponCero(dFecIni.substr(parseInt(dFecIni.lastIndexOf("/")) + 1));

	switch(nTipFormat){
		case 1 :	//	DD/MM/YYYY
			dReturnFecha = nPosTres + "" + nPosDos + "" + nPosUno;
			break;

		case 2 :	//	MM/DD/YYYY
			dReturnFecha = nPosTres + "" + nPosUno + "" +nPosDos;
			break;

		case 3 :	//	YYYY/MM/DD
			dReturnFecha = nPosUno + "" + nPosDos + "" +nPosTres;
			break;
	
		case 4 :	//	YYYY/DD/MM
			dReturnFecha = nPosUno + "" + nPosTres + "" +nPosDos;
			break;
	}
	
	return dReturnFecha;	// retorna la fecha 	
}

// Agrega un cero delante del strPon cuando tenga solo un caracter
function ponCero(strPon){
	if(parseInt(strPon.length) < 2)
		strPon = "0" + strPon;
	return strPon;
}

function comparaFecha(dFormat,dFecMenor, dFecMayor){
	dFecMenor = invFecha(dFormat,dFecMenor);
	dFecMayor = invFecha(dFormat,dFecMayor);

	if(dFecMenor > dFecMayor)
		return false;
	else
		return true;
}

function validaFecha( formulario ){
	var dFechaMenor = formulario.txt_fecha_entra.value;
	var dFechaMayor = formulario.txt_fecha_salida.value;

	if(comparaFecha( formato,dFechaMenor,dFechaMayor) == true)
		return true;
	else
		return false;
}

// ----- Fin  Validación


//---------------------------------------------enviar correo---------
var num=0;
function enviar_mail(form) {
var num=0;
for (i = 0; i < form.elements.length; i++) {
num=i+1;
	if ( (form.elements[i].type == "text" || form.elements[i].type =="textarea") && form.elements[i].value == "") {
		//alert('error');
		new Effect.Appear('error_'+num); form.elements[i].focus();
		return false; 
	}
	if ( (form.elements[i].type == "text" || form.elements[i].type =="textarea") && form.elements[i].value != "") {
		new Effect.Fade('error_'+num); form.elements[i].focus();
		 
	}

}
pms="txt_nomcomp="+$('txt_nomcomp').value+"&txt_nombre="+$('txt_nombre').value+"&txt_cargo="+$('txt_cargo').value+"&txt_correo="+$('txt_correo').value+"&txt_numtel="+$('txt_numtel').value+"&txt_mensaje="+$('txt_mensaje').value;
new Ajax.Updater('contenido_prin','send_mail.php?'+pms,{asynchronous:true,method:'post',onComplete: showResponse});	

}
//---------------------------------------------cargar_img---------
function cargar_img(x_img){
	if (navegador == "Microsoft Internet Explorer"){
		new Ajax.Updater('galery_img','load_img.php?id_img='+x_img,{asynchronous:true,method:'get'});
	}else{
	$('galery_img').style.display='none';
	$('galery_img').innerHTML="<img  src='"+x_img+"' width='267' height='190' border='0' alt='' onload=\"javascript:show_div();\"/>";}
	//$('ani_img').src=x_img;
	//alert("<img  src="+x_img+"' width='267' height='178' border='0' alt='' onload='show();'/>");
	
}
function show_div(){	
	new Effect.Appear('galery_img');
}
//----------------------------------------------------------------
function llamar_table_img(x_dir,x_div){
	new Ajax.Updater(x_div,'image_xml.php?sub_dir='+x_dir,{asynchronous:true,method:'get'});		
}
//---------------------------------------------cargar_menu---------
function mostrar_sub_menu(x_boolean,x_show){
	
	var div=[
			{name:'sub_conoz'},
			{name:'sub_acer_hot'}			
			];
	this.x_hide=div;
	if (x_boolean){
		new Effect.Appear(x_show);
		for (i=0;i<=this.x_hide.length;i++) {
			for (var j in this.x_hide[i]){
				if (this.x_hide[i][j] != x_show){
					$(this.x_hide[i][j]).style.display='none';
				}
			}
		} 
	}else{
		$(x_show).style.display='none'
	}
}
//---------------------------------------------------------------------
function mostrar_sub_huesped(x_show,x_div,x_seg_show){
	if (x_show){
		new Effect.Appear(x_div);
	}else{
		$(x_div).style.display='none'
		if (x_seg_show){
			$('sub_huesped').style.display='none';
			$('sub_event_corpo').style.display='none';
		}
	}
}
//---------------------------------------------------------------------

var numero = 0;

// Funciones comunes
function validar(){
	var num=0;
	var total=0;

	for (i = 0; i < $('reserva').elements.length; i++) {
		if ($('reserva').elements[i].type == "select"){		
			++num;			
			alert(num);
		}
	}	
}

function removeField(x_div) {
	
	$(x_div).style.display='none';
	span.parentNode.removeChild(span);
}
//-------------------------------------------------------------
function enviar_reserva(){
	new Ajax.Updater('prueba','send_reserva.php',{asynchronous:true,method:'post'});	
}
//------------------------------fecha-------------------------

var pong;
function makeArray(n){
  this.length = n;
  for (i=1;i<=n;i++){
    this[i]=0;
  }
  return this;
}

// standard date display function with y2k compatibility
function displayDate(x_page) {
  var this_month = new makeArray(12);
  this_month[0]  = "01";
  this_month[1]  = "02";
  this_month[2]  = "03";
  this_month[3]  = "04";
  this_month[4]  = "05";
  this_month[5]  = "06";
  this_month[6]  = "07";
  this_month[7]  = "08";
  this_month[8]  = "09";
  this_month[9]  = "10";
  this_month[10] = "11";
  this_month[11] = "12";

  var this_day_e = new makeArray(7);
  this_day_e[0]  = "Domingo";
  this_day_e[1]  = "Lunes";
  this_day_e[2]  = "Martes";
  this_day_e[3]  = "Miercoles";
  this_day_e[4]  = "Jueves";
  this_day_e[5]  = "Viernes";
  this_day_e[6]  = "Sabado";

  var today = new Date();
  var day   = today.getDate();
  var month = today.getMonth();
  var year  = today.getYear();
  var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
	if (x_page=="home"){
		return( " " + this_day_e[dia] + ", " + day + "/" + this_month[month] + "/" + year);
	}else if (x_page=="solicitud_evento"){
		return(day+"/"+this_month[month]+ "/" + year);
	}else if (x_page=="sugerencia"){
		return(day+"/"+this_month[month]+ "/" + year);
	}
}
//---------------------------------------------------------------------------------------
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-------------------------------------------------------------------------------------
function abrir_pop(x_htm,x_width,x_height,x_scroll){
window.open(x_htm,'','width='+x_width+', height='+x_height+', toolbar=0,scrollbars='+x_scroll+',location=0,statusbar=0,menubar=0,resizable=0, left=0,top=0');
}
function cerrar_meeting(){
	opener.document.location.href='../reserva/';
	close();
}
//------------------------------------------------------------------------------------
function descargar(x_file){
	new Ajax.Updater('download','download.php?id='+x_file,{asynchronous:true,method:'get'});	
}
//------------------------------------------------------------------------------------
function show_ubica(x_show,x_div){
	if (x_show){
		new Effect.Appear(x_div);
	}else{
		$(x_div).style.display='none';
	}
}
//---------------------------------------------------------------------------------
function load_select(x_id,x_div){
var inner_html="";
//-----------------------eventos sociales-----------------------
	if (x_id=="event_inn_social"){
		inner_html="<select name='txt_salon' id='txt_salon' style='width:110px'>";
			inner_html=inner_html+"<option value='JARDINES' selected='selected'>JARDINES</option>";	   
			inner_html=inner_html+"<option value='PISCINA'>PISCINA</option>";
			inner_html=inner_html+"<option value='GUAYACAN'>GUAYACAN</option>";
			inner_html=inner_html+" <option value='ALGARROBO'>ALGARROBO</option>";
			inner_html=inner_html+"<option value='BUCARE'>BUCARE</option>";
			inner_html=inner_html+"<option value='ROBLE'>ROBLE</option>";
		inner_html=inner_html+"</select>";
	}
//-----------------------eventos corporativo-----------------------	
	if (x_id=="event_inn_corporativo"){
		inner_html="<select name='txt_salon' id='txt_salon' style='width:110px'>";
			inner_html=inner_html+"<option value='BUCARE' selected='selected'>BUCARE</option>";	   
			inner_html=inner_html+"<option value='ROBLE'>ROBLE</option>";
			inner_html=inner_html+"<option value='NOGAL'>NOGAL</option>";
			inner_html=inner_html+" <option value='CEDRO'>CEDRO</option>";
			inner_html=inner_html+"<option value='CAOBO'>CAOBO</option>";
			inner_html=inner_html+"<option value='GUAYACAN'>GUAYACAN</option>";
			inner_html=inner_html+"<option value='SALÓN JARDIN'>SALÓN JARDIN</option>";
		inner_html=inner_html+"</select>";
	}
	if (x_id=="event_suites_corporativo"){
		inner_html="<select name='txt_salon' id='txt_salon' style='width:110px'>";
			inner_html=inner_html+"<option selected='selected' value='SAMANES'>SAMANES</option>";
			inner_html=inner_html+"<option value='CEIBA'>CEIBA</option>";
			inner_html=inner_html+"<option value='TERRAZA'>TERRAZA</option>";
		inner_html=inner_html+"</select>";		
	}
//-----------------------habitaciones en INN-----------------------		
	if (x_id=="sel_habita_inn"){
		inner_html="<select name='sel_habita_inn_suites' id='sel_habita_inn_suites'>";
			inner_html=inner_html+"<option selected='selected' value='CONFORT (sencilla)'>CONFORT (sencilla)</option>";
			inner_html=inner_html+"<option value='CONFORT (doble)'>CONFORT (doble)</option>";	   
			inner_html=inner_html+"<option value='CONFORT (triple)'>CONFORT (triple)</option>";
			inner_html=inner_html+"<option value='CLASSIC'>CLASSIC</option>";
			inner_html=inner_html+" <option value='PREMIUM KING'>PREMIUM KING</option>";
			inner_html=inner_html+"<option value='PREMIUM DOBLE'>PREMIUM DOBLE</option>";
			inner_html=inner_html+"<option value='PREMIUM DELUXE'>PREMIUM DELUXE</option>";
			inner_html=inner_html+"<option value='PREMIUM QUEEN'>PREMIUM QUEEN</option>";
			inner_html=inner_html+"<option value='DOBLE DELUXE'>DOBLE DELUXE</option>";
			inner_html=inner_html+"<option value='FAMILY SUITES'>FAMILY SUITES</option>";
			inner_html=inner_html+"<option value='SUITE GERENCIAL'>SUITE GERENCIAL</option>";
			inner_html=inner_html+"<option value='ROYAL SUITE'>ROYAL SUITE</option>";
			inner_html=inner_html+"<option value='RAND SUITE'>GRAND SUITE</option>";
			inner_html=inner_html+"<option value='MEETING SUITE'>MEETING SUITE</option>";
			inner_html=inner_html+"<option value='GRAND SUITE DELUXE'>GRAND SUITE DELUXE</option>";
		inner_html=inner_html+"</select>";
	}
	if (x_id=="sel_habita_suites"){
		inner_html="<select name='sel_habita_inn_suites' id='sel_habita_inn_suites' >";
			inner_html=inner_html+"<option selected='selected' value='JUNIOR SUITE (Sencilla ó Doble) 1 cama King'>JUNIOR SUITE (Sencilla &oacute; Doble)";
			inner_html=inner_html+"<option disabled='disabled'>&nbsp;&nbsp;&nbsp;CAMA KING</option>";
			inner_html=inner_html+"<option selected='selected' value='JUNIOR SUITE (Sencilla ó Doble) 2 camas dobles'>JUNIOR SUITE (Sencilla &oacute; Doble)</option>";
			inner_html=inner_html+"<option disabled='disabled'>&nbsp;&nbsp;&nbsp;CAMAS DOBLES</option>";
			inner_html=inner_html+"<option value='SUITE EJECUTIVA'>SUITE EJECUTIVA </option>";
			inner_html=inner_html+"<option disabled='disabled'>&nbsp;&nbsp;&nbsp;CAMA KING</option>";
			inner_html=inner_html+"<option value='SUITE EJECUTIVA(Sencilla ó Doble)'>SUITE EJECUTIVA (Sencilla &oacute; Doble)</option>";
			inner_html=inner_html+"<option disabled='disabled'>&nbsp;&nbsp;&nbsp;CAMAS DOBLES</option>";
			inner_html=inner_html+"<option value='MASTER SUITE (Sencilla ó Doble)'>MASTER SUITE (Sencilla &oacute; Doble)</option>";
			inner_html=inner_html+"<option disabled='disabled'>&nbsp;&nbsp;&nbsp;CAMA KING</option>";
		inner_html=inner_html+"</select>";
	}if (x_id=="sel_dis_corp_inn"){
		inner_html="<select name='txt_distribucion' id='txt_distribucion' style='width:114px' >";
			inner_html=inner_html+"<option selected='selected' value='Forma de Teatro'>Forma de Teatro</option>";
			inner_html=inner_html+"<option value='Forma de U'>Forma de U</option>";	   
			inner_html=inner_html+"<option value='Tipo Escuela'>Tipo Escuela</option>";
		inner_html=inner_html+"</select>";
		
	}if (x_id=="sel_dis_corp_suites"){
		inner_html="<select name='txt_distribucion' id='txt_distribucion' style='width:114px' >";
			inner_html=inner_html+"<option selected='selected' value='Forma de Teatro'>Forma de Teatro</option>";
			inner_html=inner_html+"<option value='Forma de U'>Forma de U</option>";	   
			inner_html=inner_html+"<option value='Tipo Escuela'>Tipo Escuela</option>";
			inner_html=inner_html+"<option value='Mesas Redondas'>Mesas Redondas</option>";
		inner_html=inner_html+"</select>";
		
	}
	if (x_id=="sel_tipo_even_corp"){
		inner_html="<select name='sel_txt_tipo_evento' id='sel_txt_tipo_evento' style='width:114px' onchange='ocultar(this.options[selectedIndex].value);' >";
			inner_html=inner_html+"<option selected='selected' value='Simposio'>Simposio</option>";
			inner_html=inner_html+"<option value='Conferencia'>Conferencia</option>";	   
			inner_html=inner_html+"<option value='Entrevista'>Entrevista</option>";
			inner_html=inner_html+"<option value='Taller'>Taller</option>";
			inner_html=inner_html+"<option value='Seminario'>Seminario</option>";
			inner_html=inner_html+"<option value='Otro'>Otro</option>";
		inner_html=inner_html+"</select>";		
	}
	if (x_id=="sel_tipo_even_social"){
		inner_html="<select name='sel_txt_tipo_evento' id='sel_txt_tipo_evento' style='width:114px' onchange='ocultar(this.options[selectedIndex].value);' >";
			inner_html=inner_html+"<option selected='selected' value='Fiesta'>Fiesta</option>";
			inner_html=inner_html+"<option value='Boda'>Boda</option>";	   
			inner_html=inner_html+"<option value='Bautizo'>Bautizo</option>";
			inner_html=inner_html+"<option value='Primera Comuni&oacute;n'>Primera Comuni&oacute;n</option>";
			inner_html=inner_html+"<option value='Cocktail'>Cocktail</option>";
			inner_html=inner_html+"<option value='Banquete'>Banquete</option>";
			inner_html=inner_html+"<option value='Otro'>Otro</option>";
		inner_html=inner_html+"</select>";		
	}



	$(x_div).innerHTML=inner_html;	
}
//-------------------------------------------------------
function remove_si_no(x_show,x_div){
	if (x_div=="audio"){
		if (x_show){		
			Element.hide('texto_cuantas');
			Element.hide('txt_cuantas');
		}else{
			Element.show('texto_cuantas');
			Element.show('txt_cuantas');			
		}
	}else if (x_div=="apoyo"){
		if (x_show){		
			Element.hide('material_apoyo');
			Element.hide('text_cuantas');
		}else{
			Element.show('material_apoyo');
			Element.show('text_cuantas');			
		}
	}else if (x_div=="evento_social"){
		if (x_show){		
			Element.hide('texto_cuantas');
			Element.hide('txt_cuantas');
		}else{
			Element.show('texto_cuantas');
			Element.show('txt_cuantas');			
		}
	}else if (x_div=="espe_tipo_event"){
		if (x_show){		
			Element.hide('texto_espe_tipo_event');
			Element.hide('txt_espe_tipo_evento');
		}else{
			Element.show('texto_espe_tipo_event');
			Element.show('txt_espe_tipo_evento');			
		}
	}else if (x_div=="evento_corp_hb"){
		if (x_show){		
			Element.hide('texto_cuantas_hb');
			Element.hide('txt_cuantas_hb');
		}else{
			Element.show('texto_cuantas_hb');
			Element.show('txt_cuantas_hb');			
		}
	}
	
}
//--------------------------------------------------------
function enviar_form(x_form,x_div,x_dir,form){	
	if (x_form == "form_reserva"){
		if(!validaFecha( $(x_form) )){
				alert("La fecha de salida no puede ser menor o igual a la de entrada.");
				return false;
		}
		if ($(x_form).txt_rif_ci_pas.value ==""){
			alert($(x_form).txt_rif_ci_pas.id);			
			return false;
		}else if ($(x_form).txt_fecha_entra.value ==""){
			alert("Debe especificar la fecha de entrada.");
			return false;
		}else if ($(x_form).txt_fecha_salida.value ==""){
			alert("Debe especificar la fecha de salida.");
			return false;		
/*		}else if ($(x_form).txt_fecha_entra.value >= $(x_form).txt_fecha_salida.value){
			alert("La fecha de salida no puede ser menor o igual a la de entrada.");
			return false;*/
		}else if ($(x_form).txt_titular_reserva.value ==""){
			alert("Debe especificar un titular de la reserva.");
			return false;
		}else if ($(x_form).txt_cont_ci.value ==""){
			alert("Debe especificar la C.I.");
			return false;		
		}else if ($(x_form).txt_cont_telf.value ==""){
			alert("Debe especificar un teléno de contacto.");
			return false;
		}else if ($(x_form).txt_cont_mail.value =="" || !es_email($(x_form).txt_cont_mail.value)){
			alert("Debe especificar un E-mail valido.");
			return false;				
		}
		var id_hotel="";
		if ($(x_form).txt_guaparp_suit_inn[0].checked){			
			id_hotel=$(x_form).txt_guaparp_suit_inn[0].value;
		}else if ($(x_form).txt_guaparp_suit_inn[1].checked){
			id_hotel=$(x_form).txt_guaparp_suit_inn[1].value;
		}		
		x_variables="x_opt="+x_div;
		x_variables=x_variables+'&id_hotel='+id_hotel;
		x_variables=x_variables+'&txt_tipo_reser='+$(x_form).txt_tipo_reser.value;
		x_variables=x_variables+'&txt_rif_ci_pas='+$(x_form).txt_sel_rif_ci_pas.value+"-"+$(x_form).txt_rif_ci_pas.value;
		x_variables=x_variables+'&txt_fech_solici='+$(x_form).txt_fech_solici.value;
		x_variables=x_variables+'&sel_habita_inn_suites='+$(x_form).sel_habita_inn_suites.value;
		x_variables=x_variables+'&txt_cantidad_perso='+$(x_form).txt_cantidad_perso.value;
		x_variables=x_variables+'&txt_cantidad_perso2='+$(x_form).txt_cantidad_perso2.value;
		x_variables=x_variables+'&txt_cantidad_habita='+$(x_form).txt_cantidad_habita.value;
		x_variables=x_variables+'&txt_fecha_entra='+$(x_form).txt_fecha_entra.value;
		x_variables=x_variables+'&txt_fecha_salida='+$(x_form).txt_fecha_salida.value;
		x_variables=x_variables+'&txt_titular_reserva='+$(x_form).txt_titular_reserva.value;		
		x_variables=x_variables+'&txt_cont_ci='+$(x_form).txt_cont_ci.value;
		x_variables=x_variables+'&txt_cont_telf='+$(x_form).txt_cont_telf.value;
		x_variables=x_variables+'&txt_cont_fax='+$(x_form).txt_cont_fax.value;
		x_variables=x_variables+'&txt_cont_mail='+$(x_form).txt_cont_mail.value;		
		x_variables=x_variables+'&txt_df_rif='+$(x_form).txt_df_rif.value;
		x_variables=x_variables+'&txt_df_rs='+$(x_form).txt_df_rs.value;
		x_variables=x_variables+'&txt_df_telf='+$(x_form).txt_df_telf.value;
		x_variables=x_variables+'&txt_df_dom_fiscal='+$(x_form).txt_df_dom_fiscal.value;
		x_variables=x_variables+'&txt_comentario='+$(x_form).txt_comentario.value;
		x_variables=x_variables+'&x_dir='+x_dir;
		
		$(x_div).innerHTML="<table border='0'><tr><td>Enviado formulario por favor espere.&nbsp;&nbsp;</td><td><img src='"+x_dir+"send_form/indicator.white.gif' /></td></tr></table>"
		new Ajax.Updater(x_div,x_dir+'send_form/?'+x_variables,{asynchronous:true,method:'get',onComplete:document.location.href=x_dir});	
		x_variables="";	
//-----------------------eventos sociales------------------------------		
	}else if (x_form == "form_solici_event_social"){
		var txt_tipo_event="";
		if ($(x_form).txt_rif_ci_pas.value =="" || !es_numero($(x_form).txt_rif_ci_pas.value)){
			alert($(x_form).txt_rif_ci_pas.id);
			return false;			
		}else if ($(x_form).txt_pers_contac.value ==""){
			alert("Debe especificar una persona de contacto.");
			return false;			
		}else if ($(x_form).txt_num_cel.value ==""){
			alert("Debe especificar un Telf. Celular.");
			return false;			
		}else if ($(x_form).txt_email.value =="" || !es_email($(x_form).txt_email.value)){
			alert("Debe especificar un E-mail valido.");
			return false;
		}else if ($(x_form).txt_fech_ini_event.value ==""){
			alert("Debe especificar la fecha de inicio del evento.");
			return false;			
		}else if ($(x_form).txt_fech_fin_event.value ==""){
			alert("Debe especificar la fecha de culminación del evento.");
			return false;						
		}else if ($(x_form).txt_cant_per.value ==""){
			alert("Debe especificar la cantidad de personas.");
			return false;			
		}else if ($(x_form).txt_hora_event.value ==""){
			alert("Debe especificar la hora del evento.");
			return false;			
		}else if ($(x_form).txt_nomb_evento.value ==""){
			alert("Debe especificar el nombre del evento.");
			return false;			
		}else if ($(x_form).sel_txt_tipo_evento.value =="Otro"){		
			if ($(x_form).txt_espe_tipo_event.value==""){
				alert("Debe especificar el tipo de Evento.");
				return false;
			}		
		}else if($(x_form).txt_per_res.value ==""){
			alert("Debe especificar el nombre de la persona responsable.");
			return false;						
		}else if ($(x_form).txt_df_rif.value ==""){
			alert("Debe especificar un Rif para los datos fiscales.");
			return false;
		}else if ($(x_form).txt_df_rs.value ==""){
			alert("Debe especificar la Razón Social.");
			return false;			
		}else if ($(x_form).txt_df_telf.value ==""){
			alert("Debe especificar un Nº de teléfono.");
			return false;
		}else if ($(x_form).txt_df_dom_fiscal.value ==""){
			alert("Debe especificar un Domicilio fiscal.");
			return false;
		}else if ($(x_form).txt_si_no[0].checked){
			if ($(x_form).txt_cuantas_hab.value ==""){
				alert("Debe especificar la cantidad de Habitaciones Requerias.");
				return false;
			}else{
				num_hab_reque=$(x_form).txt_cuantas_hab.value;
			}
		}
		x_opciones_presupuesto="";
		for (i = 0; i < form.elements.length; i++) {
			if (form.elements[i].type == "checkbox" && form.elements[i].checked){
				x_opciones_presupuesto=x_opciones_presupuesto+form.elements[i].value+", ";
			}
		}
		if ($(x_form).txt_punto_dulce.value != "Ninguno"){
			x_opciones_presupuesto=x_opciones_presupuesto+$(x_form).txt_punto_dulce.value;
		}
		if ($(x_form).sel_txt_tipo_evento.value =="Otro"){
			txt_tipo_event=$(x_form).txt_espe_tipo_event.value;
		}else{
			txt_tipo_event=$(x_form).sel_txt_tipo_evento.value;
		}		
			x_variables="x_opt="+x_div;
			x_variables=x_variables+'&tipo_persona='+$(x_form).txt_tipo_reser.value;
			x_variables=x_variables+'&rif_ci_pas='+$(x_form).txt_sel_rif_ci_pas.value+'-'+$(x_form).txt_rif_ci_pas.value;
			x_variables=x_variables+'&fecha_solicitud='+$(x_form).txt_fech_solici.value;
			x_variables=x_variables+'&persona_contac='+$(x_form).txt_pers_contac.value;
			x_variables=x_variables+'&num_cel='+$(x_form).txt_num_cel.value;
			x_variables=x_variables+'&num_ofi='+$(x_form).txt_num_ofi.value;
			x_variables=x_variables+'&num_casa='+$(x_form).txt_num_casa.value;
			x_variables=x_variables+'&num_fax='+$(x_form).txt_fax.value;
			x_variables=x_variables+'&email='+$(x_form).txt_email.value;
			x_variables=x_variables+'&nombre='+$(x_form).txt_nomb_evento.value;
			x_variables=x_variables+'&tipo_event='+txt_tipo_event;
			
			x_variables=x_variables+'&fech_ini_event='+$(x_form).txt_fech_ini_event.value;
			x_variables=x_variables+'&fech_fin_event='+$(x_form).txt_fech_fin_event.value;			
			x_variables=x_variables+'&distri_salon='+$(x_form).txt_distribucion.value;
			x_variables=x_variables+'&cant_per='+$(x_form).txt_cant_per.value;
			x_variables=x_variables+'&salon='+$(x_form).txt_salon.value;
			x_variables=x_variables+'&hora_evento='+$(x_form).txt_hora_event.value;
			x_variables=x_variables+'&opt_presupuesto='+x_opciones_presupuesto;
			x_variables=x_variables+'&perso_respon='+$(x_form).txt_per_res.value;
			x_variables=x_variables+'&num_hab='+$(x_form).txt_cuantas_hab.value;
			x_variables=x_variables+'&txt_otra_peti='+$(x_form).txt_otra_peti.value;
			//-----------
			x_variables=x_variables+'&txt_df_rif='+$(x_form).txt_df_rif.value;
			x_variables=x_variables+'&txt_df_rs='+$(x_form).txt_df_rs.value;
			x_variables=x_variables+'&txt_df_telf='+$(x_form).txt_df_telf.value;
			x_variables=x_variables+'&txt_df_dom_fiscal='+$(x_form).txt_df_dom_fiscal.value;			
			x_variables=x_variables+'&sugerencia='+$(x_form).txt_sugerencia.value;			
			$(x_div).innerHTML="<table border='0'><tr><td>Enviado formulario por favor espere.&nbsp;&nbsp;</td><td><img src='"+x_dir+"send_form/indicator.white.gif' /></td></tr></table>"			
			new Ajax.Updater(x_div,x_dir+'send_form/?'+x_variables,{asynchronous:true,method:'get',onComplete:document.location.href=x_dir});
			x_variables="";
//--------------------------eventos corporativos------------------------
	}else if (x_form == "form_event_corporativo"){		
		var txt_equipo_ad="";
		var txt_material_apoyo="";
		var txt_tipo_event="";
		var txt_hab_req="";
		if ($(x_form).txt_rif_ci_pas.value =="" || !es_numero($(x_form).txt_rif_ci_pas.value)){
			alert($(x_form).txt_rif_ci_pas.id);
			return false;			
		}else if ($(x_form).txt_pers_contac.value ==""){
			alert("Debe especificar una persona de contacto.");
			return false;			
		}else if ($(x_form).txt_num_cel.value ==""){
			alert("Debe especificar un Telf. Celular.");
			return false;			
		}else if ($(x_form).txt_email.value =="" || !es_email($(x_form).txt_email.value)){
			alert("Debe especificar un E-mail valido.");
			return false;
		}else if ($(x_form).txt_fech_ini_event.value ==""){
			alert("Debe especificar la fecha de inicio del evento.");
			return false;			
		}else if ($(x_form).txt_fech_fin_event.value ==""){
			alert("Debe especificar la fecha de culminación del evento.");
			return false;						
		}else if ($(x_form).txt_hora_event.value ==""){
			alert("Debe especificar la hora del evento.");
			return false;			
		}else if ($(x_form).txt_nomb_evento.value ==""){
			alert("Debe especificar el nombre del evento.");
			return false;
		}else if ($(x_form).sel_txt_tipo_evento.value =="Otro"){		
			if ($(x_form).txt_espe_tipo_event.value==""){
				alert("Debe especificar el tipo de Evento.");
				return false;
			}
		}else if($(x_form).txt_cant_persona.value =="" || !es_numero($(x_form).txt_cant_persona.value)){
				alert("Debe especificar la canatidad de personas.");
				return false;
		}else if($(x_form).txt_cant_salon.value =="" || !es_numero($(x_form).txt_cant_salon.value)){
				alert("Debe especificar la canatidad de Salones.");
				return false;		
		}else if($(x_form).txt_per_res.value ==""){
			alert("Debe especificar el nombre de la persona responsable.");
			return false;
		}else if ($(x_form).txt_df_rif.value ==""){
			alert("Debe especificar un Rif para los datos fiscales.");
			return false;
		}else if ($(x_form).txt_df_rs.value ==""){
			alert("Debe especificar la Razón Social.");
			return false;						
		}else if ($(x_form).txt_df_telf.value ==""){
			alert("Debe especificar un Nº de teléfono.");
			return false;
		}else if ($(x_form).txt_df_dom_fiscal.value ==""){
			alert("Debe especificar un Domicilio fiscal.");
			return false;			
		}
		if ($(x_form).txt_si_no[0].checked){
			if ($(x_form).txt_equipo_ad.value ==""){
				alert("Debe especificar los equipos audio visuales.");
				return false;
			}else{
				txt_equipo_ad=$(x_form).txt_equipo_ad.value;
			}			
		}
		if ($(x_form).txt_si_no_hb[0].checked){
			if ($(x_form).txt_cuantas_hab.value ==""){
				alert("Debe especificar la cantidad de Habitaciones Requerias.");
				return false;
			}else{
				txt_hab_req=$(x_form).txt_cuantas_hab.value;				
			}

		}
		if ($(x_form).txt_si_no_apoyo[0].checked){
			if ($(x_form).txt_material_apoyo.value ==""){
				alert("Debe especificar el material de apoyo.");
				return false;
			}else{
				txt_material_apoyo=$(x_form).txt_material_apoyo.value;				
			}

		}
		x_opciones_presupuesto="";
		for (i = 0; i < form.elements.length; i++) {
			if (form.elements[i].type == "checkbox" && form.elements[i].checked){
				x_opciones_presupuesto=x_opciones_presupuesto+form.elements[i].value+", ";
			}
		}
		if ($(x_form).guap_inn_suit[0].checked){
			x_id_hotel="Inn";			
		}else{
			x_id_hotel="Suites";
		}
		if ($(x_form).sel_txt_tipo_evento.value =="Otro"){
			txt_tipo_event=$(x_form).txt_espe_tipo_event.value;
		}else{
			txt_tipo_event=$(x_form).sel_txt_tipo_evento.value;
		}
		//alert(x_opciones_presupuesto);
			x_variables="x_opt="+x_div;
			x_variables=x_variables+"&id_hotel="+x_id_hotel;
			x_variables=x_variables+'&tipo_persona='+$(x_form).txt_tipo_reser.value;
			x_variables=x_variables+'&rif_ci_pas='+$(x_form).txt_sel_rif_ci_pas.value+'-'+$(x_form).txt_rif_ci_pas.value;
			x_variables=x_variables+'&fecha_solicitud='+$(x_form).txt_fech_solici.value;
			x_variables=x_variables+'&persona_contac='+$(x_form).txt_pers_contac.value;
			x_variables=x_variables+'&num_cel='+$(x_form).txt_num_cel.value;
			x_variables=x_variables+'&num_ofi='+$(x_form).txt_num_ofi.value;
			x_variables=x_variables+'&num_casa='+$(x_form).txt_num_casa.value;
			x_variables=x_variables+'&num_fax='+$(x_form).txt_fax.value;
			x_variables=x_variables+'&email='+$(x_form).txt_email.value;
			x_variables=x_variables+'&nombre='+$(x_form).txt_nomb_evento.value;
			x_variables=x_variables+'&tipo_event='+txt_tipo_event;
			x_variables=x_variables+'&fech_ini_event='+$(x_form).txt_fech_ini_event.value;
			x_variables=x_variables+'&fech_fin_event='+$(x_form).txt_fech_fin_event.value;			
			x_variables=x_variables+'&distri_salon='+$(x_form).txt_distribucion.value;
			x_variables=x_variables+'&cantidad_persona='+$(x_form).txt_cant_persona.value;
			x_variables=x_variables+'&cantidad_salon='+$(x_form).txt_cant_salon.value;
			x_variables=x_variables+'&hora_evento='+$(x_form).txt_hora_event.value;			
			x_variables=x_variables+'&opt_presupuesto='+x_opciones_presupuesto;			
			x_variables=x_variables+'&perso_respon='+$(x_form).txt_per_res.value;			
			x_variables=x_variables+'&equipo_ad='+txt_equipo_ad;
			x_variables=x_variables+'&material_apoyo='+txt_material_apoyo;
			x_variables=x_variables+'&hab_req='+txt_hab_req;
			//-----------
			x_variables=x_variables+'&txt_df_rif='+$(x_form).txt_df_rif.value;
			x_variables=x_variables+'&txt_df_rs='+$(x_form).txt_df_rs.value;
			x_variables=x_variables+'&txt_df_telf='+$(x_form).txt_df_telf.value;
			x_variables=x_variables+'&txt_df_dom_fiscal='+$(x_form).txt_df_dom_fiscal.value;			
			x_variables=x_variables+'&sugerencias='+$(x_form).txt_sugerencias.value;			
			$(x_div).innerHTML="<table border='0'><tr><td>Enviado formulario por favor espere.&nbsp;&nbsp;</td><td><img src='"+x_dir+"send_form/indicator.white.gif' /></td></tr></table>"
			new Ajax.Updater(x_div,x_dir+'send_form/?'+x_variables,{asynchronous:true,method:'get',onComplete:document.location.href=x_dir});
//----------------------sugerencia---------------------------------------		
	}else if (x_form == "form_sugerencia"){
		var x_opciones_sugerencia=""
		var num=0;
		for (i = 0; i < form.elements.length; i++) {
			if (form.elements[i].type == "radio" && form.elements[i].checked){
				x_opciones_sugerencia=x_opciones_sugerencia+form.elements[i].id+"="+form.elements[i].value+"&";
				++num;
			}
		}
		x_opciones_sugerencia=x_opciones_sugerencia+"comentario="+$(x_form).txt_sugerencia.value+"&fecha="+displayDate('sugerencia');
	$(x_div).innerHTML="<table border='0'><tr><td>Enviado formulario por favor espere.&nbsp;&nbsp;</td><td><img src='"+x_dir+"send_form/indicator.white.gif' /></td></tr></table>"
	new Ajax.Updater(x_div,x_dir+'send_form/?x_opt='+x_form+'&'+x_opciones_sugerencia,{asynchronous:true,method:'get',onComplete:document.location.href=x_dir});
	}else if (x_form == "form_contacto"){
		var x_variables="";
		for (i = 0; i < form.elements.length; i++) {
			if (form.elements[i].type == "text" || form.elements[i].type == "textarea"){
				if (form.elements[i].value ==""){
					alert(form.elements[i].name);
					form.elements[i].focus;
					return false
				}else{
					x_variables=x_variables+form.elements[i].id+"="+form.elements[i].value+"&";
				}
			}
		}
		$(x_div).innerHTML="<table border='0'><tr><td>Enviado formulario por favor espere.&nbsp;&nbsp;</td><td><img src='"+x_dir+"send_form/indicator.white.gif' /></td></tr></table>"		
		new Ajax.Updater(x_div,x_dir+'send_form/?x_opt='+x_form+'&'+x_variables,{asynchronous:true,method:'get',onComplete:document.location.href=x_dir});
	}else if (x_form == "form_login"){
		if($(x_form).txt_user.value==""){
			alert('Especifique un usuario.')
			return false;
		}else if($(x_form).txt_password.value==""){
			alert('Especifique una clave.')
			return false;			
		}
		form.submit();
	}
}
//----------------------------------------validar rif---------------------
function valida_rif(num) {
	var s = num;
	var filter=/^[0-9]*-[0-9]/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
		return true;
	else
		return false;
}
//----------------------------------------validar email---------------------
function es_email(email){
	var s = email;
	var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
	return true;
	else
	return false;
}
//----------------------------------------------------------------------------
function es_numero(num) {
	var s = num;
	var filter=/^[0-9]/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
	return true;
	else
	return false;
}

//----------------------------------------------------------------------------
function load_data(x_data_load,x_page,x_div,x_id_hotel){
	$(x_div).innerHTML="<div class='titulo'>Cargando . . . <img src='indicator.white.gif' /></div>";
	if (x_data_load=="reservaciones"){
		new Ajax.Updater(x_div,x_page+'?id_data='+x_data_load+'&id_hotel='+x_id_hotel,{asynchronous:true,method:'get'});		
	}else if (x_data_load=="opciones"){
		new Ajax.Updater(x_div,x_page,{asynchronous:true,method:'get'});		
	}else if (x_data_load=="evento_social"){
		new Ajax.Updater(x_div,x_page+'?id_data='+x_data_load,{asynchronous:true,method:'get'});
	}else if (x_data_load=="evento_corporativo"){
		new Ajax.Updater(x_div,x_page+'?id_data='+x_data_load+'&id_hotel='+x_id_hotel,{asynchronous:true,method:'get'});
	}else if (x_data_load=="sugerencias"){
		new Ajax.Updater(x_div,x_page+'?id_data='+x_data_load,{asynchronous:true,method:'get'});
	}else if (x_data_load=="update_tarifa_inn"){
		new Ajax.Updater(x_div,x_page+'?id_data='+x_data_load,{asynchronous:true,method:'get'});
	}else if (x_data_load=="update_tarifa_suites"){
		new Ajax.Updater(x_div,x_page+'?id_data='+x_data_load,{asynchronous:true,method:'get'});
	}
}
//----------------------
function check_read(x_id,x_table,x_div,x_user){	
	if ($('msn_read_'+x_id).innerHTML !="Leido"){		
	new Ajax.Updater(x_div,'update_read.php?id='+x_id+'&x_table='+x_table+'&user='+x_user,{asynchronous:true,method:'get',onComplete:$('msn_read_'+x_id).innerHTML="Leido"});
	}
}
//------------------------------
function otro(x_show){
	if (x_show=="otro_corpo"){
		$('otro_tipo_evento').style.display='block';
		$('tx_otro_tipo_evento').style.display='block';
	}else {
		$('otro_tipo_evento').style.display='none';
		$('tx_otro_tipo_evento').style.display='none';
	}				
}
function update_tarifa(x_div,x_form){
			var x_variables="";
	if (x_form=="tarifa_inn"){
		x_variables="x_opt="+x_form;
		x_variables=x_variables+'&confort_senc='+$(x_form).txt_confort_senc.value;
		x_variables=x_variables+'&confort_doble='+$(x_form).txt_confort_doble.value; 	
		x_variables=x_variables+'&confort_triple='+$(x_form).txt_confort_triple.value; 	
		x_variables=x_variables+'&clasica='+$(x_form).txt_clasica.value;  	
		x_variables=x_variables+'&premium_king='+$(x_form).txt_premium_king.value;  	
		x_variables=x_variables+'&premium_doble='+$(x_form).txt_premium_doble.value;  	 	
		x_variables=x_variables+'&premium_deluxe='+$(x_form).txt_premium_deluxe.value;
		x_variables=x_variables+'&premium_queen='+$(x_form).txt_premium_queen.value; 	
		x_variables=x_variables+'&doble_delux='+$(x_form).txt_doble_delux.value; 	
		x_variables=x_variables+'&family_suite='+$(x_form).txt_family_suite.value;
		x_variables=x_variables+'&suite_gerencial='+$(x_form).txt_suite_gerencial.value;
		x_variables=x_variables+'&royal_suite='+$(x_form).txt_royal_suite.value;
		x_variables=x_variables+'&grand_suite='+$(x_form).txt_grand_suite.value;
		x_variables=x_variables+'&meeting_suite='+$(x_form).txt_meeting_suite.value;
		x_variables=x_variables+'&grand_deluxe='+$(x_form).txt_grand_deluxe.value;		
		x_variables=x_variables+'&txt_per_ad='+$(x_form).txt_per_ad.value;
		
		$(x_div).innerHTML="<table border='0'><tr><td>Enviado formulario por favor espere.&nbsp;&nbsp;</td><td><img src='indicator.white.gif' /></td></tr></table>"
		new Ajax.Updater(x_div,'update_tarifa.php?'+x_variables,{asynchronous:true,method:'get',onComplete:load_data('opciones','opciones.php?nivel=admin','ajax')});	
	}else if (x_form=="tarifa_suites"){
		x_variables="x_opt="+x_form;
		x_variables=x_variables+'&junior_suite='+$(x_form).txt_junior_suite.value;
		x_variables=x_variables+'&junior_suite2='+$(x_form).txt_junior_suite2.value;
		x_variables=x_variables+'&suite_ejecutiva='+$(x_form).txt_suite_ejecutiva.value;
		x_variables=x_variables+'&suite_ejecutiva_doble='+$(x_form).txt_suite_ejecutiva_doble.value;
		x_variables=x_variables+'&master_suite='+$(x_form).txt_master_suite.value;
		x_variables=x_variables+'&txt_per_ad='+$(x_form).txt_per_ad.value;
		$(x_div).innerHTML="<table border='0'><tr><td>Enviado formulario por favor espere.&nbsp;&nbsp;</td><td><img src='indicator.white.gif' /></td></tr></table>"
		new Ajax.Updater(x_div,'update_tarifa.php?'+x_variables,{asynchronous:true,method:'get',onComplete:load_data('opciones','opciones.php?nivel=admin','ajax')});	
		
	}
	
}
//-----------------------------print--------------------------------
function print_document(x_htm,x_table,x_id_hotel,x_data_print,x_width,x_height){	
	//alert(x_htm+"?id_data="+x_table+"&id_hotel="+x_id_hotel+"&x_reg="+x_data_print);
	window.open(x_htm+"?id_data="+x_table+"&id_hotel="+x_id_hotel+"&x_reg="+x_data_print,'','width='+x_width+', height='+x_height+', toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0, left=0,top=0');	
	
}
