var pgInit = {}; pgInit.vars = { promotions: '[{"id":"24","title":" Early 2021","description":"# teaser about Early 2021 promo","linkLabel":"Pulse para m\u00e1s informaci\u00f3n","link":"10","bookBtn":"https:\/\/secure.guestcentric.org\/api\/bg\/book.php?apikey=591d21de4ea53d42eb93d30a6d2b06ee&l=es&nrNights=2&preselect=promo24&startDay=2025-05-03","image":"https:\/\/secure.guestcentric.org\/bin\/c67809f2acbb4784\/thumb-screenshot-2020-02-07-at-14.09.051.png"},{"id":"18","title":"Advance booking days = 4 days (-95%)","description":"# Teaser Advance booking days = 4 days (-95%)","linkLabel":"Pulse para m\u00e1s informaci\u00f3n","link":"10","bookBtn":"https:\/\/secure.guestcentric.org\/api\/bg\/book.php?apikey=591d21de4ea53d42eb93d30a6d2b06ee&l=es&nrNights=2&preselect=promo18&startDay=2025-05-05","image":""},{"id":"4","title":"Custom promotion - hide from the BE","description":"Teaser custom promotion","linkLabel":"Pulse para m\u00e1s informaci\u00f3n","link":"10","bookBtn":"https:\/\/secure.guestcentric.org\/api\/bg\/book.php?apikey=591d21de4ea53d42eb93d30a6d2b06ee&l=es&nrNights=2&preselect=promo4&startDay=","image":""}]', displayTime: 10, transitionTime: 1.5, frameworkPath: 'https://secure.guestcentric.org/js/yui/build/' }; /** * promotions gadget javascript file * @fileOverview * @author marco.lopes * @version 1.0 * @since 2008-10-28 */ (function() { if(!pgInit.vars.frameworkPath) { alert("framework path for the weather gadget not found!"); return; } //creating gadget info var gadget = {gadget: "promotionGadget", status: "waiting", start: init}; //check for Guestcentric Gadgets Stack if(!window.gcGadgetStack) { //registering gcGadgetStack gadget.status = "loading"; window.gcGadgetStack = [gadget]; gadget.start(); } else if(gcGadgetStack[gcGadgetStack.length-1].status === "loaded") { //registering gcGadgetStack gadget.status = "loading"; gcGadgetStack.push(gadget); gadget.start(); } else { //adding gadget to Guestcentric Gadgets Stack gcGadgetStack.push(gadget); } var G; //framework object /** * load necessary YUI modules * @param {Function} callback function to execute after loading the modules */ function loadYUIModules(callback) { //loading necessary files new YAHOO.util.YUILoader( { require: ["dom", "animation", "event", "json"], loadOptional: true, base: pgInit.vars.frameworkPath, onSuccess: function() { callback(); }, onFailure: function() { changeGadgetStatus(); } }).insert(); } //END OF loadYUIModules /** * changes the gadget status */ function changeGadgetStatus() { //changing the gadget status for(var i=0, li=gcGadgetStack.length; i 1) { randIndex = parseInt(Math.random() * promotions.length, 10); while(randIndex === this.oldIndex) { randIndex = parseInt(Math.random() * promotions.length, 10); } this.oldIndex = randIndex; } return promotions[randIndex]; }; /** * Get template opcaity value */ this.getOpacity = function(node) { return G.getStyle(node, "opacity"); }; // set the widget opacity this.opacity = this.getOpacity(node) || 1; //build promotion this.build(); //establish timer G.later(this.interval * 1000, this, this.refresh); }; //END OF PromotionsGadget /** * creates the framework interface * @return the necessary methods * @type Object */ function getInterface() { var D = YAHOO.util.Dom; var E = YAHOO.util.Event; var frameworkInterface = { /** * gets a node by id * @param {String} id node id * @return html node * @type Object */ byId: function(id) { return D.get(id); }, /** * gets nodes by class * @param {String} class name * @param {String} tagName type of tag that holds the class * @param {String|Object} rootNode id of search start node * @return array of html nodes * @type Array */ byClass: function(cssClass, tag, startNode) { return D.getElementsByClassName(cssClass, tag, startNode); }, /** * creates a node with the specified settings * @param {Object} nodeType node tag type (div, span...) * @param {Object} settings node settings (id, className...) * @return the created node * @type html node */ createNode: function(nodeType, settings) { var node = document.createElement(nodeType); for(var s in settings) { node[s] = settings[s]; } return node; }, /** * appends a node * @param {Object} newNode * @param {Object} referenceNode parent node * @return status or domNode */ inject: function(newNode, referenceNode) { if(!newNode || !referenceNode) { return false; } return G.byId(referenceNode).appendChild(newNode); }, /** * set node css style (inline) * @param {Object} node dom node * @param {String} property css property * @param {String|Boolean} value property target value */ setStyle: function(node, property, value) { return YAHOO.util.Dom.setStyle(node, property, value); }, /** * get node css style * @param {Object} node dom node * @param {String} property css property */ getStyle: function(node, property) { return YAHOO.util.Dom.getStyle(node, property); }, /** * detects on dom ready event * @param {Function} callback function * @param {Object} args callback arguments * @param {Boolean} callback run scope * @return status * @type Boolean */ onDOMReady: function(callback, args, scope) { return E.onDOMReady(callback, args, scope); }, /** * add an event to a node * @param {Object} node domNode * @param {String} event trigger * @param {Function} callback function to execute * @param {Object} args arguments * @param {Boolean} scope run in args */ addEvent: function(node, event, callback, args, scope) { return YAHOO.util.Event.addListener(node, event, callback, args, scope); }, /** * parses a string and trasforms it into an object * @param {String} jsonString the json string * @return the resultant json object * @type Object */ parseJSON: function(jsonString) { return YAHOO.lang.JSON.parse(jsonString); }, /** * create an animation * @param {Object} node * @param {Int} time in seconds * @param {Object} obj Animation object * @param {Function} callback function to execute after the animation * @param {Object} scope object where the callback will run */ anim: function(node, time, obj, callback, scope) { var anim = new YAHOO.util.Anim(node, obj, time, YAHOO.util.Easing.easeOut); if(typeof callback == 'function') { var f = function() { anim.onComplete.unsubscribe(f); callback.call(scope, anim); }; anim.onComplete.subscribe(f, anim, true); } return anim.animate(); }, /** * fades in a node * @param {Object} node dom node to fade * @param {Int} time in seconds * @param {Function} callback function to execute after fade * @param {Object} scope object where the callback will run */ fadeIn: function(node, time, callback, scope) { return G.anim(node, time, { opacity: { to: scope.opacity} }, callback, scope); }, /** * fades out a node * @param {Object} node dom node to fade * @param {Int} time in seconds * @param {Function} callback function to execute after fade * @param {Object} scope object where the callback will run */ fadeOut: function(node, time, callback, scope) { return G.anim(node, time, { opacity: { to: 0} }, callback, scope); }, /** * executes a function with a certain delay * @param {Int} time in miliseconds * @param {Object} obj object where the callback function will run * @param {Object} callback function to be executed * @param {Object} args arguments to the callback function */ later: function(time, obj, callback, args) { return YAHOO.lang.later(time, obj, callback, args, true); } }; return frameworkInterface; } //END OF getInterface //check for Guestcentric Gadgets Stack if(!window.gcGadgetStack) { //registering gcGadgetStack gadget.status = "loading"; window.gcGadgetStack = [gadget]; window.gcGadgetStack[0].start(); } else if(gcGadgetStack[gcGadgetStack.length-1].status === "loaded") { //registering gcGadgetStack gadget.status = "loading"; gcGadgetStack.push(gadget); gadget.start(); } else { //adding gadget to Guestcentric Gadgets Stack gcGadgetStack.push(gadget); } })(); window.vars = [];