(function() {
var init = function() {
addStyleSheet('https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css', function(){ });
addScript('https://code.jquery.com/jquery-1.12.4.js', function(){ });
if (window.jQuery) {
if (typeof jQuery.fn.datepicker !== "undefined" ){ /* SI TIENE JQUERY y datepicker*/
cargarLiberiasDate=1;
} else {
if (window.jQuery.ui) { /*SI TIENE EL UI*/
cargarFuncionesForm(1);
} else {
cargarLiberiasDate=1;
}
}
} else {
addScript('https://book.carrental.systems/js/jquery.min.js', function(){ });
cargarLiberiasDate=1;
}
if(cargarLiberiasDate == 1) {
addScript("https://code.jquery.com/ui/1.12.1/jquery-ui.js", function(){
cargarFuncionesForm(1);
});
}
};
var addScript = function(url, callback) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = "text/javascript";
script.src = url;
if (script.readyState) { // IE, incl. IE9
script.onreadystatechange = function() {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;
callback();
}
};
} else {
script.onload = function(){
callback();
};
}
head.appendChild(script);
};
var addStyleSheet = function(url) {
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.type = "text/css";
link.rel = "stylesheet";
link.href = url;
head.appendChild(link);
};
var cargarFuncionesForm = function(version) {
if ( $('#rentayatescancun').length > 0 ) {
addStyleSheet('https://book.carrental.systems//css/widget.css');
$('#rentayatescancun').html('
');
$.datepicker.regional[ "es" ] = {
dayNamesMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"],
monthNamesShort:["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
monthNames: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
closeText: "Cerrar",
currentText: "Hoy",
};
$.datepicker.regional[ "en" ] = {
dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
monthNamesShort:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
closeText: "Done",
currentText: "Today",
};
$.datepicker.setDefaults($.datepicker.regional["es"]);
$(".formWidgetArca #fechaRecoger").datepicker({
changeMonth: true,
changeYear: true,
numberOfMonths: 2,
showButtonPanel: true,
dateFormat: "yy-mm-dd",
minDate: 0,
showAnim: "slideDown",
altField: ".formWidgetArca #fhInicio",
altFormat: "yy-mm-dd",
duration: "fast",
onSelect: function( selectedDate, e) {
startDate = new Date(selectedDate);
var masdias= "";
var day_s = startDate.getDay();
if(day_s == 4){
masdias = (86400000 * 3);
}else{
masdias = (86400000 * 2);
}
fhNueva = new Date(Date.parse($(this).datepicker("getDate")) + masdias); //86400000 equivale a 1 dia
fhpick = new Date(Date.parse($(this).datepicker("getDate"))+ 86400000); //86400000 equivale a 1 dia
$(".formWidgetArca #fechaDejar").datepicker( "setDate", fhNueva );
$(".formWidgetArca #fechaDejar").datepicker(
'option', 'minDate', fhpick
);
}
});
$(".formWidgetArca #fechaDejar").datepicker({
changeMonth: true,
changeYear: true,
numberOfMonths: 2,
showButtonPanel: true,
dateFormat: "yy-mm-dd",
minDate: 0,
showAnim: "slideDown",
altField: ".formWidgetArca #fechaDejar",
altFormat: "yy-mm-dd",
duration: "fast",
});
$(".formWidgetArca #fechaDejar").datepicker('option', 'minDate', (new Date(Date.parse($("#fechaRecoger").datepicker("getDate"))+ 86400000)));
document.getElementById("form-paso-1").addEventListener("submit", function(){
document.getElementById("mcr_btnSubmitWidget").disabled = true;
});
$("#url_real_widget").val(window.location);
} else {
if('rentayatescancun' != "") {
console.log("ALERTA WIDGET:El contenedor indicado para el cotizador no existe!")
}
}
}
setTimeout(function() { //aparece despues de unos segundos
init();
},0);
})();