//variable gral para llamadas servicio
var ReservarGralURL = 'https://' + window.location.host + '/';//"localhost:39373+localhost:18991/';//'http://localhost:18991/';//'http://desreservar.dinatur.com.es/'; //'http://testreservar.dinatur.com.es/'; //' 'https://reservar.dinatur.com.es/';
var ScrollMapa = 0;//400
var ScrollServicios = 0;//350
var ScrollMsgResticciones = 0; //238
var EntradaOSalida = ""
var EntradaSet = true;
var SalidaSet = true;
var ClickEntrada = false;
var ClickSalida = false;
var ErrorFechas = false;
//pagina 0
btnPulsado = '';
tamBlq = 100;
TipVista = 'l';
blqRedViejo = '';
DivBloqViejo = '';
DivListViejo = '';
idViejo = '';
tipo = '';
idBtn = '';
LblTxt = '';
CantidadCeldas = 12; //Hace referencia a bootstrap ; 12 -- 6 -- 4 -- 3
var ContadorLoader = 0;
var FechaDestinoFIni = false;
var FechaDestinoFFin = false;
var FechaTDestinoFIni = false;
var FechaTDestinoFFin = false;
var IntervalEfectBtnOferta;
var ArrObjDisponibilidadFecha = '';//Se guarda las fechas de una habitacion , guarda Disponibilidad (cantidad), abierto...
var ActivarCalendarioDispo = true; //Bloquea la funcion CargarCalendarioDisponibilidad
var ActivarLoaderVariable = true;
var MensajesAdvertenciaArray = new Array();
var NoMasValidaciones = true;
//funciones genericas
//FIN funciones genericas
jQuery(document).on("click", ".CentrarCalendario", function () {
var viewportwidth = jQuery(window).width();
var viewportheight = jQuery(window).height();
if ((viewportwidth < 479) && !(viewportheight < 479)) {
var datepickerwidth = jQuery("#ui-datepicker-div").width();
var leftpos = (viewportwidth - datepickerwidth) / 2;
jQuery("#ui-datepicker-div").css({
left: leftpos,
position: 'absolute'
});
}
});
function CambiarImagen(ObjImg, imagen) {
var dato = document.getElementById(ObjImg);
dato.src = imagen;
}
function VerServicios(DivDestino, seleccion) {//visible o no
//primero todo a NO visibles y luego activo el que toque con salvado de la variable de sesion
var div1 = document.getElementById('DivInstalaciones');
var div2 = document.getElementById('DivServicios');
var div3 = document.getElementById('DivEntorno');
var div4 = document.getElementById(DivDestino);
div1.style.display = "none";
div2.style.display = "none";
div3.style.display = "none";
div4.style.display = "block";
//ahroa los botones
var boton1 = document.getElementById('TableInstalaciones1');
var boton2 = document.getElementById('TableServicios1');
var boton3 = document.getElementById('TableEntorno1');
//MenuNormalAncho
boton1.className = "MenuNormalAncho";
boton2.className = "MenuNormalAncho";
boton3.className = "MenuNormalAncho";
var boton1 = document.getElementById('TableInstalaciones2');
var boton2 = document.getElementById('TableServicios2');
var boton3 = document.getElementById('TableEntorno2');
boton1.className = "MenuCampoAncho";
boton2.className = "MenuCampoAncho";
boton3.className = "MenuCampoAncho";
if (seleccion == 2) {
var boton1 = document.getElementById('TableServicios1');
boton1.className = "MenuNormalAncho activo";
var boton1 = document.getElementById('TableServicios2');
boton1.className = "MenuCampoAncho activo";
}
if (seleccion == 1) {
var boton1 = document.getElementById('TableInstalaciones1');
boton1.className = "MenuNormalAncho activo";
var boton1 = document.getElementById('TableInstalaciones2');
boton1.className = "MenuCampoAncho activo";
}
if (seleccion == 3) {
var boton1 = document.getElementById('TableEntorno1');
boton1.className = "MenuNormalAncho activo";
var boton1 = document.getElementById('TableEntorno2');
boton1.className = "MenuCampoAncho activo";
}
var datos = {};
datos['Menu2Select'] = seleccion;
jQuery.ajax({
url: 'SessionServicio.php?Menu2Select=' + seleccion,
type: 'POST',
cache: false,
data: { Menu2Select: seleccion },
processData: false,
contentType: false,
success: function (data) {
//var divResultado = document.getElementById(destino);
//divResultado.innerHTML = data;
//alert('Load was performed.' + data); //no hacer nada si ha ido todo ok
}
});
}
function CerrarMsgBox(divdestino) {
jQuery('[id='+ divdestino + ']').remove();//se necesitas asi por el multi click al añadir al carrito que podia provocar mas de un mensaje y si no eliminamos solo uno
jQuery('[id=Inner' + divdestino + ']').remove();
}
function ReloadPag(Pag) {
document.location = Pag;
}
function Extensor(elemento) {
var dato = document.getElementById(elemento);
if (dato.style.display == "block") {
dato.style.display = "none";
}
else {
dato.style.display = "block";
}
}
function GetFile(event) {//esto funciona PERO no lo usaremos por ahora
var selectedFile = event.target.files[0];
var reader = new FileReader();
reader.onload = function (event) {
imgtag.src = event.target.result;
return event.target.result;
};
reader.readAsDataURL(selectedFile);
}
function CheckValidate(formulario) {
var formDatos = document.getElementById(formulario);
formDatos.checkValidity();
}
function ActivarDesactivar(imagenA, imgon, imgoff, hidImgA, texto) {
var imagen = document.getElementById(imagenA);
var hidImg = document.getElementById(hidImgA);
var Dattexto = document.getElementById(texto);
if (hidImg.value == "0") //oculta visualizar
{
imagen.src = "Imagenes/" + imgon;
hidImg.value = "1";
Dattexto.innerHTML = "Visible";
}
else {
imagen.src = "Imagenes/" + imgoff;
hidImg.value = "0";
Dattexto.innerHTML = "NO Visible";
}
}
function ValidaFecha(fecha, CaracControl) {
if (fecha) //nos envia algo
{
var fechaInvert;
dtCh = CaracControl;
var pos1 = fecha.indexOf(dtCh);
var pos2 = fecha.indexOf(dtCh, pos1 + 1);
var strYear = fecha.substring(0, pos1);
var strMonth = fecha.substring(pos1 + 1, pos2);
var strDay = fecha.substring(pos2 + 1);
fechaInvert = strDay + CaracControl + strMonth + CaracControl + strYear;
if ((validaFechaDDMMAAAA(fecha, CaracControl)) || (validaFechaDDMMAAAA(fechaInvert, CaracControl))) {
return true;
}
else {
return false;
}
}
}
function validaFechaDDMMAAAA(fecha, dtCh) {
var minYear = 1900;
var maxYear = 2100;
function isInteger(s) {
var i;
for (i = 0; i < s.length; i++) {
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
return true;
}
function stripCharsInBag(s, bag) {
var i;
var returnString = "";
for (i = 0; i < s.length; i++) {
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function daysInFebruary(year) {
return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31;
if (i == 4 || i == 6 || i == 9 || i == 11) { this[i] = 30 }
if (i == 2) { this[i] = 29; }
}
return this
}
function isDate(dtStr) {
if (dtStr) //esta definido algo
{
var daysInMonth = DaysArray(12);
var pos1 = dtStr.indexOf(dtCh);
var pos2 = dtStr.indexOf(dtCh, pos1 + 1);
var strDay = dtStr.substring(0, pos1);
var strMonth = dtStr.substring(pos1 + 1, pos2);
var strYear = dtStr.substring(pos2 + 1);
strYr = strYear;
if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1);
if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1);
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0) == "0" && strYr.length > 1) strYr = strYr.substring(1);
}
month = parseInt(strMonth);
day = parseInt(strDay);
year = parseInt(strYr);
if (pos1 == -1 || pos2 == -1) {
return false;
}
if (strMonth.length < 1 || month < 1 || month > 12) {
return false;
}
if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {
return false;
}
if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {
return false;
}
if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {
return false;
}
return true;
}
}
if (isDate(fecha)) {
return true;
} else {
return false;
}
}
function SelecCalTempDia(fecha, Objeto, HidValor) {
var TxtResult = document.getElementById('DivCalPeriodoSelect');
if (ValidaFecha(DiaIniSelect, "-")) {
if (DiaIniSelect <= fecha) {
DiaFinSelect = fecha;
AddPeriodo();
TxtResult.innerHTML = "";
}
}
else {
DiaIniSelect = fecha;
TxtResult.innerHTML = 'Inicio Periodo Selección:' + DiaIniSelect + ''
}
//deselccionar el anterior
if (ObjetoTemporadaDia) {
ObjetoTemporadaDia.className = "";
}
Objeto.className = Objeto.className + " Select";
ObjetoTemporadaDia = Objeto;
}
function ModalConfirmarCal(div1, div2) {
var VerDiv = document.getElementById(div1);
if (VerDiv) {
VerDiv.style.display = "block";
}
var VerDiv = document.getElementById(div2);
if (VerDiv) {
VerDiv.style.display = "block";
}
}
//function PopUpPensador() {
// texto = '
';
// jQuery('body').append(texto);
//}
function PopUpPensadorBlock(DivBlock, DivDatos) {
var DivPopUpDatosCal = document.getElementById(DivBlock);
var DivPopUpDatosCalGrabar = document.getElementById(DivDatos);
if ((DivPopUpDatosCal) && (DivPopUpDatosCalGrabar)) {
DivPopUpDatosCal.style.display = "block";
DivPopUpDatosCalGrabar.style.display = "block";
DivPopUpDatosCalGrabar.innerHTML = "";
}
}
function CancelarPopUp(DivModal1, DivModal2) {
jQuery('#DivPopUpDatosXX').remove();
jQuery('#DivPopUpDatosInnerXX').remove();
}
function SubmitAjaxFrom(formulario, DivOK, DivError) {
var formObj = document.getElementById(formulario);
var formURL = formObj.action;
var formData = jQuery(formObj).serialize();//new FormData('#' + formulario);
PopUpPensador();
jQuery.ajax({
url: formURL,
type: 'POST',
data: formData,
success: function (data, textStatus, jqXHR) {
var dato = document.getElementById(DivOK);
if (dato) {
dato.innerHTML = data;
AsignarColorPick('TxtColorTemporadaEdicion');//asegurandonos de que el color pick se asigna al calendario, puede que haya que poner un control para que esto SOLO se haga en llamadas a calendario
}
},
error: function (jqXHR, textStatus, errorThrown) {
var dato = document.getElementById(DivError);
if (dato) {
dato.innerHTML = data;
}
}
});
}
function DesHacerSelecPeriodo() {
RegistroTempDia = RegistroTempHistDia; //una vuelta atras
RefrescarCalendario();
}
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function CambiarTipoPoli(dato) {
if ((dato.value == "MIN") || (dato.value == "MAX")) {
divVisible = document.getElementById("DivPoliEspeTipoValores");
divOculto = document.getElementById("DivPoliEspeTipoRegimenes");
divVisible.style.display = "block";
divOculto.style.display = "none";
}
else // regimenes
{
divVisible = document.getElementById("DivPoliEspeTipoRegimenes");
divOculto = document.getElementById("DivPoliEspeTipoValores");
divVisible.style.display = "block";
divOculto.style.display = "none";
}
}
function VerCal(Campo) {
var fecha = '#' + Campo;
jQuery(fecha).datepicker('show');
}
function PopUpPensador(TiempoCierre) {
var texto = '';
document.body.innerHTML = texto + document.body.innerHTML;
//estos DIV DEBEN existir
var DivPopUpDatosCal = document.getElementById('DivPopUpPensador');
var DivPopUpDatosCalGrabar = document.getElementById('DivPopUpInnerPensador');
if ((DivPopUpDatosCal) && (DivPopUpDatosCalGrabar)) {
DivPopUpDatosCal.style.display = "block";
DivPopUpDatosCal.style.zIndex = 100000;
DivPopUpDatosCalGrabar.style.display = "block";
DivPopUpDatosCalGrabar.style.zIndex = 200000;
DivPopUpDatosCalGrabar.innerHTML = "";
}
if (isNumber(TiempoCierre))
{
setTimeout(function () { CancelarPopUpPensador(); }, TiempoCierre);
}
}
function CancelarPopUpPensador() {
var DivPopUpDatosCal = document.getElementById('DivPopUpPensador');
var DivPopUpDatosCalGrabar = document.getElementById('DivPopUpInnerPensador');
if ((DivPopUpDatosCal) && (DivPopUpDatosCalGrabar)) {
DivPopUpDatosCal.style.display = "none";
DivPopUpDatosCalGrabar.style.display = "none";
}
}
function RecuperarTextoIdioma(ID)
{
if (typeof (Texto) == 'undefined') {
Texto = new Array();
}
if (!Texto[ID]) {
RecogerFrase(ID);
}
return Texto[ID];
}
function MsgBoxArray(MensajeArr)
{
var Mensaje = '';
var HayMensaje = false;
for (b in MensajeArr) {
Mensaje = Mensaje + MensajeArr[b] + ' ';
HayMensaje = true;
}
if (HayMensaje) {
MsgBox(Mensaje);
}
}
function MsgBox(mensaje) {
if (typeof (Texto) == 'undefined') {
Texto = new Array();
}
if (!Texto[16]) RecuperarTextoIdioma(16);
if (!Texto[52]) RecuperarTextoIdioma(52);//TODO: hacer que en master se cargen los textos
if ((!Texto[16]) || (!Texto[52])) {
setTimeout(function () { MsgBox(mensaje); }, 200);
}
else {
setTimeout(function () {
jQuery('body').append('
');
ScrollActivo = false;
setTimeout(function () { CentrarDiv('InnerDivMsgJava') }, 200);
}, 200);//parece que no carga todo bien y hay que esperar
}
}
function MsgBoxImg(mensaje, Img) {
if (!Texto) var Texto = new Array();
if (!Texto[16]) Texto[16] = RecuperarTextoIdioma(16);
if (!Texto[52]) Texto[52] = RecuperarTextoIdioma(52);//TODO: hacer que en master se cargen los textos
setTimeout(function () {
jQuery('body').append('
');
ScrollActivo = false;
setTimeout(function () { CentrarDiv('InnerDivMsgJava') }, 100);
}, 200);
//parece que no carga todo bien y hay que esperar
}
function MsgBoxIFrame(mensaje, IFrame, Ancho) {
if (isNumber(Ancho)) {
if (Ancho < 300) Ancho = 300;
}
setTimeout(function () {
jQuery('body').append('
' + IFrame + '
');
ScrollActivo = false;
setTimeout(function () { CentrarDiv('InnerDivMsgJava') }, 100);
}, 200);
//parece que no carga todo bien y hay que esperar
}
///cuando sale un msgbox y cuando pulsas acept hace lo que haya en func
function MsgBoxFunc(mensaje, Func) {
if (!Texto) var Texto = new Array();
if (!Texto[16]) Texto[16] = RecuperarTextoIdioma(16);
if (!Texto[52]) Texto[52] = RecuperarTextoIdioma(52);//TODO: hacer que en master se cargen los textos
setTimeout(function () {
jQuery('body').append('
');
ScrollActivo = false;
setTimeout(function () { CentrarDiv('InnerDivMsgJava') }, 100);
}, 200);
//parece que no carga todo bien y hay que esperar
}
///Msg con operaciones en ok y en cancel, indicando ancho y alto
function MsgBoxOkCancelFull(mensaje, FuncOk, FuncCancel, Ancho, Alto) {
if (FuncCancel) {
if (FuncCancel.length < 2)
FuncCancel = "CerrarMsgBox('DivMsgJavaOKCAN')";
}
else {
FuncCancel = "CerrarMsgBox('DivMsgJavaOKCAN')";
}
if (Ancho) {
if (Ancho < 1)
Ancho = "";
else
if (Ancho < 460) Ancho = 460;
Ancho = "width:" + Ancho + "px;";
}
else {
Ancho = "width: 460px;";
}
if (Alto) {
if (Alto < 1)
Alto = "";
else
Alto = "height:" + Alto + "px;";
}
else {
Alto = "min-height: 100px;";
}
if (!Texto) var Texto = new Array();
if (!Texto[16]) Texto[16] = RecuperarTextoIdioma(16);
if (!Texto[52]) Texto[52] = RecuperarTextoIdioma(52);//TODO: hacer que en master se cargen los textos
jQuery('body').append('
' + mensaje + '
' + Texto[16] + '
');
setTimeout(function () { CentrarDiv('InnerDivMsgJavaOKCAN') }, 100);//parece que no carga todo bien y hay que esperar un poco
}
function ShowModal(DivDestino,DivCentrar)
{
DivDestino = document.getElementById(DivDestino);
if (DivDestino)
{
DivDestino.style.display = "block";
setTimeout(function () { CentrarDiv(DivCentrar) }, 100);
}
}
function HideModal(DivDestino)
{
DivDestino = document.getElementById(DivDestino);
if (DivDestino) {
DivDestino.style.display = "none";
}
}
function CentrarDiv(DivResultado) {
DivDato = document.getElementById(DivResultado);
if (DivDato) {
DivDato.style.position = 'absolute' //absolute';//Safari
var w = ((navigator.userAgent.indexOf('AppleWebKit/') > -1) || (navigator.userAgent.indexOf('Safari/') > -1)) ? window.innerWidth : jQuery(window).width();//window.innerWidth;
//var h = ((navigator.userAgent.indexOf('AppleWebKit/') > -1) || (navigator.userAgent.indexOf('Safari/') > -1)) ? window.innerHeight : jQuery(window).height();//window.innerHeight;
h = jQuery(window).height();
//alert(w + '::' + jQuery(window).width() + ' ::' + window.innerWidth);
var ancho = jQuery(DivDato).width();// DivDato.clientWidth;
var alto = jQuery(DivDato).height();// DivDato.clientHeight;
posx = (w / 2) - (ancho / 2);
posy = (h / 2) - (alto / 2);
if (posx < 0) posx = 0;
if (posy < 0) posy = 0;
posy += (jQuery(document).scrollTop());
DivDato.style.top = parseInt(posy) + 'px';
DivDato.style.left = parseInt(posx) + 'px';
//control de altura
if (alto > h)
{
DivDato.style.height = h + 'px';
DivDato.style.top = '0px';
DivDato.style.overflowY = 'auto';
DivDato.style.overflowX = 'none';
}
}
}
function BodyScrollCarrito() {
var ScrollTop = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
DivHabitacionesScroll = document.getElementById('DivHabitacionesStart');
Posicion = ScrollTop;
if (DivHabitacionesScroll && !IsMovil() && !IsTablet())
{
DivHabitacionesScroll = jQuery('#DivHabitacionesStart');//si no se hace asi no funciona bien en todas las paginas, da errores en pag 3,...
//de aki cogemos la posicion original del carrito
var pos = DivHabitacionesScroll.position();
Posicion = ScrollTop - pos.top;
if (Posicion > 0)
{
DivHabitaciones = document.getElementById('DivHabitaciones');
if (!DivHabitaciones) DivHabitaciones = document.getElementById('DivMsgCarrito');//msg de alerta sin nada en el carro
if (DivHabitaciones) {
DivHabitaciones.style.top = Posicion + "px";
}
}
else
{
DivHabitaciones = document.getElementById('DivHabitaciones');
if (!DivHabitaciones) DivHabitaciones = document.getElementById('DivMsgCarrito');//msg de alerta sin nada en el carro
if (DivHabitaciones) {
DivHabitaciones.style.top = "0px";
}
}
}
}
function BodyScrollCarritoExtra() {
BodyScrollCarrito();
}
function isEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function SubmitAjaxFromGDisp(formulario, DivOK, DivError, Fecha) {
var formObj = document.getElementById(formulario);
if (formObj) {
var formURL = formObj.action;
var formData = jQuery(formObj).serialize();//new FormData('#' + formulario);
PopUpPensador();
jQuery.ajax({
url: formURL + '?Fecha=' + Fecha,
type: 'POST',
data: formData,
success: function (data, textStatus, jqXHR) {
var dato = document.getElementById(DivOK);
if (dato) {
dato.innerHTML = data;
}
CancelarPopUpPensador();
},
error: function (jqXHR, textStatus, errorThrown) {
var dato = document.getElementById(DivError);
if (dato) {
dato.innerHTML = data;
}
CancelarPopUpPensador();
}
});
}
}
function getFormObj(formId) {
var formObj = {};
var inputs = jQuery('#' + formId).serializeArray();
jQuery.each(inputs, function (i, input) {
formObj[input.name] = input.value;
});
return formObj;
}
function ChangeFormElement(formId, elementname, value) {
var formObj = {};
var inputs = jQuery('#' + formId).serializeArray();
jQuery.each(inputs, function (i, input) {
if (input.name == elementname) {
input.value = value;
}
});
return formObj;
}
function isDate(txtDate) {
var currVal = txtDate;
if (currVal == '')
return false;
var rxDatePattern = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/; //Declare Regex
var dtArray = currVal.match(rxDatePattern); // is format OK?
if (dtArray == null)
return false;
//Checks for mm/dd/yyyy format.
dtMonth = dtArray[3];
dtDay = dtArray[5];
dtYear = dtArray[1];
if (dtMonth < 1 || dtMonth > 12)
return false;
else if (dtDay < 1 || dtDay > 31)
return false;
else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31)
return false;
else if (dtMonth == 2) {
var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0));
if (dtDay > 29 || (dtDay == 29 && !isleap))
return false;
}
return true;
}
function EsDate(txtDate) {
var currVal = txtDate;
if (currVal == '')
return false;
var rxDatePattern = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/; //Declare Regex
var dtArray = currVal.match(rxDatePattern); // is format OK?
if (dtArray == null)//no es año mes dia
{
rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
// /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/; //provemos con dia mes año
dtArray = currVal.match(rxDatePattern); // is format OK?
if (dtArray == null) {
return false;
}
else {
//Checks for mm/dd/yyyy format.
dtMonth = dtArray[3];
dtDay = dtArray[1];
dtYear = dtArray[5];
}
}
else {
//Checks for mm/dd/yyyy format.
dtMonth = dtArray[3];
dtDay = dtArray[5];
dtYear = dtArray[1];
}
if (dtMonth < 1 || dtMonth > 12)
return false;
else if (dtDay < 1 || dtDay > 31)
return false;
else if ((dtMonth == 4 || dtMonth == 6 || dtMonth == 9 || dtMonth == 11) && dtDay == 31)
return false;
else if (dtMonth == 2) {
var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0));
if (dtDay > 29 || (dtDay == 29 && !isleap))
return false;
}
return true;
}
function isTime(valor) {
var rxDatePattern = /^(\d{1,2})(:)(\d{1,2})$/; //Declare Regex
var dtArray = valor.match(rxDatePattern); // is format OK?
if (dtArray == null)
return false;
return true;
}
function CambiarPagDispo(Pag) {
jQuery.ajax({
url: Pag,
type: 'POST',
data: '',
success: function (data, textStatus, jqXHR) {
document.location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}
function CambiarPag(Pag) {
document.location = Pag;
}
function ConvertDate(txtDate) {
var currVal = txtDate;
if (currVal == '')
return false;
var rxDatePattern = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/; //Declare Regex
var dtArray = currVal.match(rxDatePattern); // is format OK?
var rxDatePattern2 = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/; //Declare Regex
var dtArray2 = currVal.match(rxDatePattern2); // is format OK?
if ((dtArray == null) && (dtArray2 == null))
return false;
//Checks for mm/dd/yyyy format.
if (dtArray) {
dtMonth = dtArray[3];
dtDay = dtArray[5];
dtYear = dtArray[1];
}
else {
dtMonth = dtArray2[3];
dtDay = dtArray2[1];
dtYear = dtArray2[5];
}
t = new Date(dtYear + '-' + dtMonth + '-' + dtDay);
return t;
}
function ForzarClick(Boton) {
Boton = document.getElementById(Boton);
if (Boton) {
Boton.click();
}
}
function vistaBloq() {
quitarDesplegables();
eliminarTemporales();
cant = 1;
TipVista = 'b';
jQuery('#DivLstHotel span').children('br').remove();
cantBloq = jQuery('.BloqueHotel').length;
NumBlq = 0;
totCol = 1;// num de columnas -1
if (cantBloq > 4) totCol = 2;
jQuery('.BloqueHotel').each(function (i, item) {
if (cantBloq <= 4)
tamBlq = 49;
else
tamBlq = 32;
jQuery(this).css('width', tamBlq + '%');
if (NumBlq == 0) {
NumBlq = totCol;
} else {
if (cantBloq <= 4)
jQuery(this).css('margin-left', '2%');
else
jQuery(this).css('margin-left', '2%');
NumBlq--;
}
// Boton de reservar
txt = jQuery(this).find(".GrupBtnHotels div:last >span").text();
DivTxt = txt.split(' ');
if (DivTxt.length > 1) {
jQuery(this).find('.GrupBtnHotels div:last >span').addClass('TxtReser').removeClass('TxtModReser');//switchClass('TxtModReser', 'TxtReser');
} else {
jQuery(this).find('.GrupBtnHotels div:last >span').addClass('TxtModReser').removeClass('TxtReser');//.switchClass('TxtReser', 'TxtModReser');
jQuery(this).find('.GrupBtnHotels div:last >span').addClass('EstiloTextoNormal').removeClass('EstiloTextoGrande');//.switchClass('EstiloTextoGrande', 'EstiloTextoNormal');
}
// Texto de servicio e instalaciones
jQuery(this).find('.GrupBtnHotels > div:first > span').css('text-align', 'right').css('margin-top', '7px');
jQuery(this).find('.sliderHotel').addClass('sliderHotelBloq');
jQuery(this).find('.sliderHotelBloq').removeClass('sliderHotel');
jQuery(this).find('.cndHotel').addClass('cndHotelBloq');
jQuery(this).find('.cndHotelBloq').removeClass('cndHotel');
jQuery(this).find('.sliderServi').css('display', 'none');
HidHotelLinea = document.getElementById('HidHotelLinea');
if (HidHotelLinea) {
if (parseInt(HidHotelLinea.value) < 5) {
jQuery(this).find('.sliderServi').css('display', 'block');
jQuery(this).find('.sliderServi').css('width', '140px');
}
}
});
}
function vistaList()
{
quitarDesplegables(); eliminarTemporales();
TipVista = 'l';
jQuery('.BloqueHotel').each(function (i, item) {
jQuery(this).css('width', '100%');
// Boton de reservar
txt = jQuery(this).find(".GrupBtnHotels div:last >span").text();
DivTxt = txt.split(' ');
if (DivTxt.length > 1) {
jQuery(this).find('.GrupBtnHotels div:last >span').addClass('TxtModReser').removeClass('TxtReser');//.switchClass('TxtReser', 'TxtModReser');
} else {
jQuery(this).find('.GrupBtnHotels div:last >span').addClass('TxtReser').removeClass('TxtModReser'); //switchClass('TxtModReser', 'TxtReser');
jQuery(this).find('.GrupBtnHotels div:last >span').addClass('EstiloTextoGrande').removeClass('EstiloTextoNormal');//.switchClass('EstiloTextoNormal', 'EstiloTextoGrande');
}
//Texto de servicio e instalaciones
jQuery(this).find('.GrupBtnHotels > :first > span').css('text-align', 'right').css('margin-top', '13px');
jQuery(this).css('margin-left', '0%');
jQuery(this).find('.sliderHotelBloq').addClass('sliderHotel');
jQuery(this).find('.sliderHotel').removeClass('sliderHotelBloq');
jQuery(this).find('.cndHotelBloq').addClass('cndHotel');
jQuery(this).find('.cndHotel').removeClass('cndHotelBloq');
jQuery(this).find('.sliderServi').css('display', 'block');//falta "activarlos"
jQuery(this).find('.sliderServi').css('width', '100px');
});
RevertirDiv();
}
function CerrarPanel(id, LblTexto, blqRed, DivList, DivBloq, latitud, longitud, valido, direccion, TxtLongitud, TxtLatitud) {
quitarDesplegables();
if (idViejo != id) {
if (TipVista == 'b') Rellenar = DivBloq; else Rellenar = DivList;
jQuery('#' + Rellenar).css('min-height', 'auto');
// Para Cuando pulsamos en google maps
if (latitud > 0 || latitud == 0) {
jQuery('#' + Rellenar).show();
jQuery('#' + Rellenar).css('min-height', '300px');
tipo = 'map';
jQuery('#' + id).css('background-color', '#00b050').css({ '-webkit-transform': 'rotate(180deg)', '-moz-transform': 'rotate(180deg)', 'transform': 'rotate(180deg)' });
idBtn = id;
LblTxt = LblTexto;
IniciarMapaGoogleRetardo(latitud, longitud, Rellenar, valido);
if (latitud == 0) {
geocodeRetardo(direccion, Rellenar, 'TxtLatitud', 'TxtLongitud', true);
}
} else { // Para cuando pulsamos en servicios e instalaciones
if (TipVista == 'l') {
jQuery('#' + DivList).show(1000);
var alto = jQuery('#' + DivList + ' > table ').height();
jQuery('#' + DivList + ' > .TxtDescripcion').css('height', alto + 'px');
} else {
var contenido = jQuery('#' + DivList + ' > table,#' + DivList + ' > div').clone(true);
jQuery('#' + DivBloq).append(contenido);
jQuery('#' + DivBloq).show(1000);
var alto = jQuery('#' + DivBloq + ' > table ').height();
//jQuery('#' + DivBloq + ' > .TxtDescripcion').css('height', alto + 'px');
jQuery('#' + DivBloq + ' > .TxtDescripcion').css('height', '200px');
}
jQuery('#' + LblTexto).text(TxtOcultar);
jQuery('#' + id).css('background-color', '#00b050');
tipo = 'servicio';
idBtn = id;
LblTxt = LblTexto;
}
idViejo = id;
blqRedViejo = blqRed;
DivBloqViejo = DivBloq;
DivListViejo = DivList;
} else {
eliminarTemporales();
}
}
function quitarDesplegables() {
jQuery('#' + DivBloqViejo).hide(1000);
jQuery('#' + DivListViejo).hide(1000);
if (TipVista == 'b')
jQuery('#' + DivBloqViejo).empty();
if (tipo == "map") { jQuery('#' + idBtn).css('background-color', '#E60026').css({ '-webkit-transform': 'rotate(0deg)', '-moz-transform': 'rotate(0deg)', 'transform': 'rotate(0deg)' }); tipo = ''; }
if (tipo == "servicio") {
jQuery('#' + idBtn).css('background-color', '#3399FF'); tipo = '';
jQuery('#' + LblTxt).text(TxtVisualizar);
}
}
function eliminarTemporales() {
idViejo = '';
blqRedViejo = '';
DivBloqViejo = '';
DivListViejo = '';
}
function ConvertirDiv(blqRed) {
jQuery('#' + blqRed).css('width', '100%');
jQuery('#' + blqRed + ' > div:first').css('width', tamBlq + '%').css('float', 'left');
jQuery('#' + blqRed + ' > div:eq(1),#' + blqRed + ' > div:eq(2)').css('width', (98 - tamBlq) + '%').css('float', 'left');
//Centrar el mapa de Google
jQuery('#' + blqRed + '> div.Gmaps, #' + blqRed + '> div.MostrarServicios ').css('float', 'right');
jQuery('#' + blqRed + '> div.Gmaps').css('min-height', jQuery('#' + blqRed).height());
blqRedViejo = blqRed;
}
function RevertirDiv() {
if (blqRedViejo != '') {
jQuery('#' + blqRedViejo).css('width', tamBlq + '%');
jQuery('#' + blqRedViejo + ' > div:first').css('width', '').css('float', '');
jQuery('#' + blqRedViejo + ' > div:eq(1),#' + blqRedViejo + ' > div:eq(2)').css('width', '100%').css('float', '');
jQuery('#' + blqRedViejo + ' > .Gmaps,#' + blqRedViejo + '> .MostrarServicios').css('margin-left', '');
jQuery('#' + blqRedViejo + '> div.Gmaps').css('min-height', '250px');
}
blqRedViejo = '';
}
function ActivarLoader(Tiempo) {
PnlInternoPensando = document.getElementById('loadingDiv');
if (PnlInternoPensando) {
PnlInternoPensando.style.display = 'block';
}
if (Tiempo)
{
setTimeout(function () {
DesActivarLoader();
},Tiempo);
}
}
function DesActivarLoader() {
PnlInternoPensando = document.getElementById('loadingDiv');
if (PnlInternoPensando) {
PnlInternoPensando.style.display = 'none';
}
}
function DesactivarLoaderControlado()
{
ContadorLoader -= 1;
if (ContadorLoader <= 0)
{
DesActivarLoader();
ContadorLoader = 0;
}
}
function ActivarLoaderControlado(Tiempo)
{
ContadorLoader += 1;
ActivarLoader(Tiempo);
}
function CheckCantOcupas(Boton,Idioma,BtnAccion)
{
Boton.style.display = 'none';
document.getElementById('BtnMsgOkCancelOKPlaceHolderProd').style.display = 'block';
//get todos los obj con clase CantidadProd sumar y si el valor es mayor que 0 OK, sino mensaje fallo'
//HidRangoSeleccion
Objetos = jQuery("[id*='HidRangoSeleccionProd']");//document.getElementsByClassName("CantidadProd");
var cont = 0;
var Cantidad = 0
while(cont < Objetos.length)
{
Cantidad = Cantidad + parseInt(Objetos[cont].value);
cont++;
}
if (Cantidad < 1) {
//RecuperarTextoIdioma(646);//, Idioma, MsgBox)
MsgBox(RecuperarTextoIdioma(646));
return false;
}
ForzarClick(BtnAccion);
}
/*
* recoge la frase en el idioma que toca
*/
function RecogerFrase(Id)
{
HidIdioma = document.getElementById('HidIdioma');
if (HidIdioma) {
jQuery.ajax({
type: 'GET',
url: ReservarGralURL + 'ServicioPortal.aspx?Funcion=RecogerTextos&Ids=' + Id + '&Idioma=' + HidIdioma.value,
contentType: 'application/json; utf-8',
dataType: 'jsonp',
success: function (data) {
try {
if (typeof (Texto) == 'undefined') {
Texto = new Array();
}
if (data.NewDataSet.Table.length == undefined)//solo uno?
{
Texto[data.NewDataSet.Table.id] = data.NewDataSet.Table.nombre;
}
else {
for (var indice in data.NewDataSet.Table) {
Texto[data.NewDataSet.Table[indice].id] = data.NewDataSet.Table[indice].nombre;
}
}
} catch (e) {
}
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
}
});
}
}
function LlamarServicio(funcionServicio, DatosSerializados, funcionRespuesta) {
//var envio = DatosSerializados.serializeArray();
jQuery.ajax({
type: 'POST',
url: 'ServiciosMotor.asmx/' + funcionServicio,
data: "{ " + DatosSerializados + " }",
contentType: 'application/json; utf-8',
dataType: 'json',
success: function (data) {
if (data.d != null) {
if (typeof funcionRespuesta == 'function') {
funcionRespuesta(data);
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
//log.console(jqXHR.responseText);
}
});
}
function OcultarMostrar(tPnlOcultar, tPnlMostrar, tBtnOcultar, tBtnMostrar) {
PnlOcultar = document.getElementById(tPnlOcultar);
PnlMostrar = document.getElementById(tPnlMostrar);
BtnOcultar = document.getElementById(tBtnOcultar);
BtnMostrar = document.getElementById(tBtnMostrar);
HidSelectorActivo = document.getElementById('HidSelectorActivo');
if ((PnlMostrar) && (PnlOcultar)) {
PnlOcultar.style.position = "absolute"
PnlOcultar.style.top = "-20000px";
if (BtnOcultar) BtnOcultar.setAttribute("class", BtnOcultar.getAttribute("class").replace("activo", ""));
PnlMostrar.style.position = ""
PnlMostrar.style.top = "";
if (BtnMostrar) BtnMostrar.setAttribute("class", BtnMostrar.getAttribute("class").replace("activo", "") + " activo");
if (HidSelectorActivo) HidSelectorActivo.value = PnlMostrar.id;
}
else {
setTimeout(function () {
OcultarMostrar(tPnlOcultar, tPnlMostrar, tBtnOcultar, tBtnMostrar);
}, 200);
}
return false;
}
function EjecutarScript(DivBase) {
if (document.getElementById(DivBase)) {
jQuery(document).ready(function () {
jQuery('#' + DivBase).find('script').each(function (i) { eval(jQuery(this).text()); })
});
}
}
function RecogerDesplegar(BtnMostrar, Estado, Destino) {
//Estado = document.getElementById(Estado);
Destino = document.getElementById(Destino);
if (Destino) {
jQuery(Destino).toggle('show');
}
return false;
}
function CambiarCss(Destion,Class)
{
if (jQuery('#' + Destion).hasClass(Class)) jQuery('#' + Destion).removeClass(Class);
else jQuery('#' + Destion).addClass(Class);
}
function RegistrarFecha(Origen, Destino,FIni,FFin,TFIni,TFFin) {
//Destino = document.getElementById(Destino);
//Origen = document.getElementById(Origen);
//if ((Destino) && (Origen)) {
// Destino.value = Origen.value;
//}
////actualizamos fechas si es necesario
//FIni = document.getElementById(FIni);
//FFin = document.getElementById(FFin);
//if ((FIni) && (FFin))
//{
// FechaDestinoFIni = FIni;
// FechaDestinoFFin = FFin;
// FechaTDestinoFIni = document.getElementById(TFIni);
// FechaTDestinoFFin = document.getElementById(TFFin);
// //que lo haga el servicio y evitamos problemas de conversion de fechas en diferentes navegadores y regiones
// LlamarServicioGralEx(ReservarGralURL + 'ServicioPortal.aspx?Funcion=AjusteFechas&FIni=' + FIni.value + "&FFin=" + FFin.value + "&Origen=" + Origen.value, AjusteFechas);
//}
}
function LlamarServicioGralEx(Llamada, funcionRespuesta, FuncionFinal,NResult,NResult2) {
try {
jQuery.ajax({
type: 'GET',
url: Llamada,
contentType: 'application/json; utf-8',
dataType: 'jsonp',
success: function (data) {
if (typeof funcionRespuesta == 'function') {
if ((NResult) && (NResult2)) {
funcionRespuesta(data, NResult, NResult2);
}
else
if (NResult) {
funcionRespuesta(data, NResult);
}
else {
funcionRespuesta(data);
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
//poner algo
console.log(errorThrown)
}
});
} catch (err) {
console.log(err);
}
}
function AjusteFechas(Datos)
{
if ((FechaDestinoFIni) && (FechaDestinoFFin) && (FechaTDestinoFIni) && (FechaTDestinoFFin)) {
//que lo haga el servicio y evitamos problemas de conversion de fechas en diferentes navegadores y regiones
if (Datos != undefined)
{
if (((FechaDestinoFIni.value != Datos.FIni) && (EsDate(FechaDestinoFIni.value))) || ((FechaDestinoFFin.value != Datos.FFin) && (EsDate(FechaDestinoFFin.value))))
{
//alerta de cambio de fecha por maximo de dias o por fini > ffin
if (typeof HideModal == 'function') {
HideModal('loadingDiv');
rxDatePattern = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;//la fecha viene en formato dd/mm/yyyy
FIni = FechaDestinoFIni.value.match(rxDatePattern);
FFin = FechaDestinoFFin.value.match(rxDatePattern);
var diff = Math.floor((Date.parse(FFin[5] + "/" + FFin[3] + "/" + FFin[1]) - Date.parse(FIni[5] + "/" + FIni[3] + "/" + FIni[1])) / 86400000);
if (isNumber(diff)) {
if (diff >= 59) MsgBox(RecuperarTextoIdioma(619));//solo se lanza el msj la primera vez
}
}
}
FechaDestinoFIni.value = Datos.FIni;
FechaDestinoFFin.value = Datos.FFin;
FechaTDestinoFIni.value = Datos.FIni;
FechaTDestinoFFin.value = Datos.FFin;
}
if (typeof RedireccionarBuscador == 'function') RedireccionarBuscador();//esto es para el portal deberia estar en el general del portal
}
}
function PonerCartelMostrarAvisoOferta() {
CajaOferta = jQuery("input[id$='PnlBtnOferta']");
if (CajaOferta.length > 0) {
CajaOferta.after('
' + Texto[1032] + '
');
IntervalEfectBtnOferta = setInterval(function () {
CajaOferta = jQuery("input[id$='PnlBtnOferta']");
if (CajaOferta.hasClass('EfectoCambio'))
{
CajaOferta.removeClass('EfectoCambio');
}else
{
CajaOferta.addClass('EfectoCambio');
}
}, 5000);
CajaOferta.on('click', BtnOfertasEfectoCambio);
setTimeout(function () { jQuery('.MsjOfertas').removeClass("OcultarOfertasMsj") }, 500);
setTimeout(function () { jQuery('.MsjOfertas').addClass("OcultarOfertasMsj") }, 5500);
}
}
function BtnOfertasEfectoCambio()
{
clearInterval(IntervalEfectBtnOferta);
CajaOferta.removeClass('EfectoCambio');
}
function PonerColoresDisponibilidad(date) {
//añadimos un cambio para el hotel sant joan que NO quiere el amarillo, o rojo o verde
if (document.getElementById('HidIdHotelN')) IdHotel = document.getElementById('HidIdHotelN').value;
else IdHotel = 0;
Hoy = new Date();
for (var i in ArrObjDisponibilidadFecha.Table) {
FechaTemp = new Date(ArrObjDisponibilidadFecha.Table[i].fecha)
if ((Hoy.getDate() > date.getDate()) && (Hoy.getMonth() == date.getMonth()) && (Hoy.getYear() == date.getYear())) {//compara solo dia para evitar horas no hace falta porque va mes a mes
DispoClass = 'BeforeToday';
return [false, DispoClass, ''];
}
else {
if ((date.getMonth() == FechaTemp.getMonth()) && (date.getDate() == FechaTemp.getDate())) {
// console.log(date + ' --- ' + FechaTemp + ';;;' + date.getMonth() + ' -- ' + FechaTemp.getMonth() + ';;;' + date.getDate() + '--' + FechaTemp.getDate());
DispoClass = '';
MinNoches = '';
if (ArrObjDisponibilidadFecha.Table[i].cierre == 0 && ArrObjDisponibilidadFecha.Table[i].disponible > 0) {
if ((ArrObjDisponibilidadFecha.Table[i].disponible <= 2) && (IdHotel != 587) && (IdHotel != 174)) {//el id del hotel especial es 587
DispoClass = 'HayPocaDisponibilidad';
}
else
DispoClass = 'HayDisponibilidad';
}
else {
DispoClass = 'NoHayDisponibilidad';
}
// Miramos el minimo de noches
if (ArrObjDisponibilidadFecha.Table[i].minimo == 2) {
DispoClass += ' MinNoches2';
} else if (ArrObjDisponibilidadFecha.Table[i].minimo == 3) {
DispoClass += ' MinNoches3';
} else if (ArrObjDisponibilidadFecha.Table[i].minimo > 3) {
DispoClass += ' MinNochesMas3';
}
delete (ArrObjDisponibilidadFecha.Table[i]);
return [false, DispoClass, ''];
}
}
}
return [false, '', ''];
}
//Pone los colores y la disponibilidad de la habitacion
function CargarCalendarioDisponibilidad(IdContenedor, IdHab, FechaIni, CantidadMeses, Canal, FuncionServicio) {
//2015/12/1
if (ActivarCalendarioDispo) {
FechaTemp = new Date(FechaIni);
ActivarLoaderVariable = false;
ActivarCalendarioDispo = false;
DatosSerializados = '&FIni=' + FechaIni + '&IdHab=' + IdHab + '&CantMes=' + CantidadMeses + '&IdCanal=' + Canal;
if (!FuncionServicio) FuncionServicio = 'GetDisponibilidadHabFIniCantMes';
jQuery.ajax({
type: 'POST',
url: ReservarGralURL + 'ServicioPortal.aspx?Funcion=' + FuncionServicio + DatosSerializados,
contentType: 'application/json; utf-8',
dataType: 'jsonp',
success: function (data) {
ArrObjDisponibilidadFecha = data.NewDataSet;
FechaIniCalendario = new Date(ArrObjDisponibilidadFecha.Table[0].fecha);
FechaIniCalendario = FechaIniCalendario.getDate() + '/' + (FechaIniCalendario.getMonth() + 1) + '/' + FechaIniCalendario.getFullYear();
Refrescar = false;
if (jQuery("#" + IdContenedor).hasClass('hasDatepicker')) Refrescar = true;
jQuery("#" + IdContenedor).datepicker({
beforeShowDay: PonerColoresDisponibilidad,
minDate: 'today',
defaultDate: FechaIniCalendario,
onChangeMonthYear: function (year, month, widget) {
CargarCalendarioDisponibilidad(widget.id, this.dataset.id, '1/' + month + '/' + year, 1, 0);
}
});
if (Refrescar) jQuery("#" + IdContenedor).datepicker("refresh");
jQuery("#" + IdContenedor + ">div>table>tbody").click(function () { BootstrapOpenModal("ModalCalendar"); LimpiarInputFecha("#BtnBuscarFIni"); })
ActivarCalendarioDispo = true;
setTimeout(function () { ActivarLoaderVariable = true; }, 200);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
ActivarCalendarioDispo = true;
}
});
}
else {
setTimeout(function () { CargarCalendarioDisponibilidad(IdContenedor, IdHab, FechaIni, CantidadMeses, Canal, FuncionServicio); }, 200);
ActivarCalendarioDispo = true;//nos aseguramos que no se generara un bucle
}
}
function VerMensagePopUp(TextoAdvertencia,id)
{
var Procesar = 1;
if (typeof (MensajesAdvertenciaArray[id]) != 'undefined')//chekeamos que el mensaje no haya salido ya
{
if (MensajesAdvertenciaArray[id] == 0)
{
MensajesAdvertenciaArray[id] = 1;
}
else {
Procesar = 0;
}
}
if (Procesar == 1) {
var texto = '
';
texto += '
';
texto += '
';
texto += '
';
texto += '
';
texto += '
';
texto += '
';
texto += '
';
texto += '
';
texto = texto.replace("@Texto", TextoAdvertencia);
jQuery('#DivMesajeAdvertenciaPadre').append(texto);
MensajesAdvertenciaArray[id] = 1;//marcamos para no repetirlo
setTimeout(function () { jQuery('#DivMesajeAdvertencia' + id).toggle(); }, 100);//visualizamos con efecto fade
setTimeout(function () { OcultarMensagePopUp(id); }, 10000);
}
}
function OcultarMensagePopUp(id) {
jQuery('#DivMesajeAdvertencia' + id).toggle();//ocultamos con efecto fade
setTimeout(function () {
jQuery('#DivMesajeAdvertencia' + id).remove();
MensajesAdvertenciaArray[id] = 0;
},500);
}
function stopEvent(e) {
if (!e) e = window.event;
if (e.stopPropagation) {
e.stopPropagation();
} else {
e.cancelBubble = true;
}
}
function IsMovil()
{
IdMovil = document.getElementById('IsMovil');
if(jQuery(IdMovil).css('display')=='block')
return true;
return false;
}
function IsTablet()
{
IdTablet = document.getElementById('IsTablet');
if (jQuery(IdTablet).css('display') == 'block')
return true;
return false;
}
function myTrim(x) {
return x.replace(/^\s+|\s+$/gm, '');
}
function ChekeoExpRegular(DatoCheck)
{
Formula = myTrim(DatoCheck.dataset.checkformula);
Valor = myTrim(DatoCheck.value);
if ((Valor.length > 0) && (Formula.length > 0))//si hay valor y hay formula
{
var ExpRegular = new RegExp(Formula);
Resultado = ExpRegular.test(Valor);
if (Resultado) return true;
else return false;
}
return true;
}
RevisionValidos=function(BntOk,DivBuscar,Grupo,BloquearBoton)
{
DivBuscar = DivBuscar || 'body';
NoMasValidaciones = true;
if (Grupo != null) {
jQuery(' [data-checkear*=S]').each(function () {
if (typeof (this.dataset.grupovalidador) != 'undefined') {
if (this.dataset.grupovalidador == Grupo) {
if (NoMasValidaciones)
if (ComprobarValidacionRequerido(this) == false) {
NoMasValidaciones = false;
}
}
}
});
}
else {
jQuery(' [data-checkear*=S]').each(function () {
if (NoMasValidaciones)
if (ComprobarValidacionRequerido(this) == false) {
NoMasValidaciones = false;
}
});
}
if (NoMasValidaciones) {
ForzarClick(BntOk);
if (BloquearBoton)
{
Boton = document.getElementById(BntOk);
if (Boton)
{
Boton.onclick = "";
Boton.disabled = true;
}
}
}
return NoMasValidaciones;
}
ComprobarValidacionRequerido = function (Obj) {
if (Obj.dataset.controlrel == "#DropPais") {
if (jQuery(Obj.dataset.controlrel).val() == 1001) {
Obj.dataset.checkrequerido = 'S';
} else {
Obj.dataset.checkrequerido = 'N';
}
}
if (Obj.dataset.checkrequerido == 'S')
{
Txt = myTrim(Obj.value);
if (Txt.length == 0) {
MostrarMsgValidador(Obj.id);
return false
}
}
if (typeof Obj.dataset.checkiguala != 'undefined')
{
div = document.getElementById(Obj.dataset.checkiguala);
if(div.value!=Obj.value)
{
MostrarMsgValidador(Obj.id);
return false
}
}
if (typeof Obj.dataset.checkformula != 'undefined')
{
if(ChekeoExpRegular(Obj)==false)
{
MostrarMsgValidador(Obj.id);
return false
}
}
//MostrarMsgValidador(Obj.id);
return true;
}
//La cantidad es las veces q se llama a si misma
MostrarMsgValidador=function(IdObj,Cant)
{
Cant = Cant || 0;
Obj = document.getElementById( IdObj);
if(Obj)
{
Tipo = 0;
if (typeof Obj.dataset.mensajeerror != 'undefined') {
Msg = Obj.dataset.mensajeerror;
} else if (typeof jQuery(Obj).parent().data("mensajeerror") != 'undefined') {
Msg = jQuery(Obj).parent().data("mensajeerror");
Tipo = 1;
}
if (typeof Obj.dataset.tipo != 'undefined') Tipo = parseInt(Obj.dataset.tipo);
if(jQuery(Obj).prev().data("controlerror")=='ok')
{
jQuery(Obj).prev().removeClass('ErrorActive').addClass('ErrorActive');
jQuery(Obj).bind("click", OcultarMsgValido);
}
else
{
div = jQuery('', { 'class': 'MsgError ErrorActive', 'style': '', 'data-controlerror': 'ok', 'id': jQuery(Obj).attr('id') + 'Error', 'data-tipo': Tipo });
jQuery(div).html(Msg);
jQuery(Obj).before(div);
jQuery(Obj).bind("click", OcultarMsgValido);
CentrarMsgValido(div, IdObj);
}
ScrollSuave(jQuery(Obj).prev().attr('id'),80);
}
else {
Cant++;
if (Cant < 6) setTimeout(function () { MostrarMsgValidador(IdObj, Cant); },400);
}
}
OcultarMsgValido=function(Obj)
{
jQuery(this).prev().removeClass('ErrorActive')
jQuery(this).unbind("click");
}
CentrarMsgValido=function(ObjCentrar,IdObjReferencia)
{
if(jQuery(ObjCentrar).data("tipo")==1 )
jQuery(ObjCentrar).css('margin-top', '-' + (ObjCentrar.outerHeight() + 20) + 'px');
else if (jQuery(ObjCentrar).data("tipo") == 2) // Si
{
jQuery(ObjCentrar).css('margin-top', '-' + (ObjCentrar.outerHeight() + 20) + 'px');
jQuery(ObjCentrar).css('left', jQuery('#' + IdObjReferencia).offset().left + 'px');
}
else
jQuery(ObjCentrar).css('top', '-' + ObjCentrar.outerHeight() + 'px');
}
function LimpiarInputFecha(Input) {
ClickEntrada = false;
ClickSalida = false;
if (Input == "#BtnBuscarFIni") {
SeleccionarBtnFecha("#BtnEntrada", "#BtnSalida");
} else if (Input == "#BtnBuscarFFin") {
SeleccionarBtnFecha("#BtnSalida", "#BtnEntrada");
}
}
Date.prototype.addHours = function (h) {
this.setTime(this.getTime() + (h * 60 * 60 * 1000));
return this;
}
function LimpiarInputFecha(Input) {
ClickEntrada = false;
ClickSalida = false;
if (Input == "#BtnBuscarFIni") {
SeleccionarBtnFecha("#BtnEntrada", "#BtnSalida");
} else if (Input == "#BtnBuscarFFin") {
SeleccionarBtnFecha("#BtnSalida", "#BtnEntrada");
}
}
function SeleccionarBtnFecha(InputSelec, InputNoSelec) {
if (InputSelec == "#BtnEntrada") {
EntradaOSalida = "#BtnBuscarFIni";
} else if (InputSelec == "#BtnSalida") {
EntradaOSalida = "#BtnBuscarFFin";
}
jQuery(InputSelec).removeClass("BtnNoSelec");
jQuery(InputSelec).addClass("BtnSelec");
jQuery(InputNoSelec).addClass("BtnNoSelec");
jQuery(InputNoSelec).removeClass("BtnSelec");
}
function CerrarCal() {
var FIni = "";
var FFin = "";
if (jQuery("#BtnBuscarFIni").val() == "") {
FFin = jQuery("#BtnBuscarFFin").val();
FIni = sumaFecha(-1, FFin);
jQuery("#BtnBuscarFIni").val(FIni);
jQuery("#LblFechaEntrada").text(FIni);
} else if (jQuery("#BtnBuscarFFin").val() == "") {
FIni = jQuery("#BtnBuscarFIni").val();
FFin = sumaFecha(1, FIni);
jQuery("#BtnBuscarFFin").val(FFin);
jQuery("#LblFechaSalida").text(FFin);
}
jQuery('#ModalCalendar').modal('hide');
jQuery("#DivBtnBuscar").hide();
jQuery("#TxtDatePicker").datepicker('refresh');
jQuery(".modal-content").removeClass("ModalMovil");
}
function sumaFecha(d, fecha) {
var Fecha = new Date();
var sFecha = fecha || (Fecha.getDate() + "/" + (Fecha.getMonth() + 1) + "/" + Fecha.getFullYear());
var sep = sFecha.indexOf('/') != -1 ? '/' : '-';
var aFecha = sFecha.split(sep);
var fecha = aFecha[2] + '/' + aFecha[1] + '/' + aFecha[0];
fecha = new Date(fecha);
fecha.setDate(fecha.getDate() + parseInt(d));
var anno = fecha.getFullYear();
var mes = fecha.getMonth() + 1;
var dia = fecha.getDate();
mes = (mes < 10) ? ("0" + mes) : mes;
dia = (dia < 10) ? ("0" + dia) : dia;
var fechaFinal = dia + sep + mes + sep + anno;
return (fechaFinal);
}
function OcultarMostrarForm(DivOcultar, DivMostrar) {
jQuery("#" + DivOcultar).hide();
jQuery("#" + DivMostrar).show();
}
Date.prototype.addHours = function (h) {
this.setTime(this.getTime() + (h * 60 * 60 * 1000));
return this;
}
function BloquearBoton(Obj, BtnClick) {
if (Obj) {
//deshabilitamos el boton y pulsamos el boton
Boton = document.getElementById(BtnClick);
if (Boton) {
Boton.style.display = "block";
}
Obj.style.display = "none";
}
}
function CheckCuponValido(CodigoCupon, IdHotel ,FIni , FFin ,Idioma , RespuestaCupon, RespuestaCuponMovil)
{
CodigoCuponT = jQuery('#' + CodigoCupon).val();
var DatosSerializados = '&IdHotel=' + IdHotel + '&Idioma=' + Idioma + '&FIni=' + FIni + '&FFin=' + FFin + '&Codigo=' + CodigoCuponT;
var ServicioPortal = 'ServicioPortal.aspx?Funcion=';
LlamarServicioGralEx(ReservarGralURL + ServicioPortal + "CheckCupoValido" + DatosSerializados, ResultadoCupon, null, RespuestaCupon, RespuestaCuponMovil);
}
function ResultadoCupon(datos, RespuestaCupon, RespuestaCuponMovil)
{
if (typeof(datos.resultado) != 'undefined')
{
ImgBtnCheck = document.getElementById('PnlImgCheckCupon');
ImgBtnCheckMovil = document.getElementById('PnlImgCheckCuponMovil');
if (ImgBtnCheck)
{
ImgBtnCheck.className = "NoVisible";
}
if (ImgBtnCheckMovil) {
ImgBtnCheckMovil.className = "NoVisible";
}
RespuestaCuponT = document.getElementById(RespuestaCupon);
if (RespuestaCuponT)
{
jQuery(RespuestaCuponT).html(datos.resultado);
}
RespuestaCuponMovilT = document.getElementById(RespuestaCuponMovil);
if (RespuestaCuponMovilT) {
jQuery(RespuestaCuponMovilT).html(datos.resultado);
}
if (datos.resultado == "OK")
{
if (ImgBtnCheck) {
ImgBtnCheck.className = "ImgCheckCuponValido";
}
if (ImgBtnCheckMovil) {
ImgBtnCheckMovil.className = "ImgCheckCuponValido";
}
ForzarClick('BtnActivarBusqueda');//como fue todo bien renovamos busquedas para renovar precios
}
}
}