// source --> https://casalospedroches.es/wp-content/plugins/asesor-cookies-para-la-ley-en-espana/html/front/principal.js?ver=07489959500b90a119e51db5ec47e892 
/*!
 * jQuery Cookie Plugin v1.3.1
 * https://github.com/carhartl/jquery-cookie
 *
 * Copyright 2013 Klaus Hartl
 * Released under the MIT license
 */
 
(function (factory) {
   if (typeof define === 'function' && define.amd) {
      // AMD. Register as anonymous module.
      define(['jquery'], factory);
   } else {
      // Browser globals.
      factory(jQuery);
   }
}(function ($) {

   var pluses = /\+/g;

   function decode(s) {
      if (config.raw) {
         return s;
      }
      try {
         // If we can't decode the cookie, ignore it, it's unusable.
         return decodeURIComponent(s.replace(pluses, ' '));
      } catch(e) {}
   }

   function decodeAndParse(s) {
      if (s.indexOf('"') === 0) {
         // This is a quoted cookie as according to RFC2068, unescape...
         s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
      }

      s = decode(s);

      try {
         // If we can't parse the cookie, ignore it, it's unusable.
         return config.json ? JSON.parse(s) : s;
      } catch(e) {}
   }

   var config = $.cookie = function (key, value, options) {

      // Write
      if (value !== undefined) {
         options = $.extend({}, config.defaults, options);

         if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
         }

         value = config.json ? JSON.stringify(value) : String(value);

         return (document.cookie = [
            config.raw ? key : encodeURIComponent(key),
            '=',
            config.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path    ? '; path=' + options.path : '',
            options.domain  ? '; domain=' + options.domain : '',
            options.secure  ? '; secure' : ''
         ].join(''));
      }

      // Read

      var result = key ? undefined : {};

      // To prevent the for loop in the first place assign an empty array
      // in case there are no cookies at all. Also prevents odd result when
      // calling $.cookie().
      var cookies = document.cookie ? document.cookie.split('; ') : [];

      for (var i = 0, l = cookies.length; i < l; i++) {
         var parts = cookies[i].split('=');
         var name = decode(parts.shift());
         var cookie = parts.join('=');

         if (key && key === name) {
            result = decodeAndParse(cookie);
            break;
         }

         // Prevent storing a cookie that we couldn't decode.
         if (!key && (cookie = decodeAndParse(cookie)) !== undefined) {
            result[name] = cookie;
         }
      }

      return result;
   };

   config.defaults = {};

   $.removeCookie = function (key, options) {
      if ($.cookie(key) !== undefined) {
         // Must not alter options, thus extending a fresh object...
         $.cookie(key, '', $.extend({}, options, { expires: -1 }));
         return true;
      }
      return false;
   };

}));

/* ======================================================================================
   @author     Carlos Doral Pérez (http://webartesanal.com)
   @version    0.19
   @copyright  Copyright &copy; 2013-2014 Carlos Doral Pérez, All Rights Reserved
               License: GPLv2 or later
   ====================================================================================== */

//
//
//
var cdp_cookie = {

   // vars
   _id_cookie: 'cdp-cookies-plugin-wp',

   //
   // Compruebo si ya existe la cookie si es visitante nuevo.
   //
   // Modif: 08-ene-2014. Compruebo primero si existe la cookie antes del contenido de la misma
   //
   ya_existe_cookie: function _ya_existe_cookie() {
      if( jQuery.cookie( cdp_cookie._id_cookie ) != null )
         return jQuery.cookie( cdp_cookie._id_cookie ) == 'cdp';
      return false;
   },

   // Guardo cookie
   poner_cookie: function _poner_cookie() {
      return jQuery.cookie( cdp_cookie._id_cookie, 'cdp', { expires: 365, path: '/' } );
   },

   // Eliminar cookie
   eliminar: function _eliminar() {
      return jQuery.removeCookie( cdp_cookie._id_cookie );
   },

   // Inicializacion
   iniciar: function _iniciar() {
      // Solapa
      jQuery( '.cdp-cookies-solapa' ).click( function() {
         cdp_cookie.mostrar_aviso();
      } );

      // Aceptar
      jQuery( '.cdp-cookies-boton-cerrar' ).click( function() {
         cdp_cookie.poner_cookie();
         cdp_cookie.ocultar_aviso();
      } );
   },

   // Muestra aviso
   mostrar_aviso: function _mostrar_aviso( de_golpe ) {
      if( de_golpe )
      {
         jQuery( '.cdp-cookies-texto' ).attr( 'class', 'cdp-cookies-texto cdp-mostrar' );
         jQuery( '.cdp-cookies-solapa' ).attr( 'class', 'cdp-cookies-solapa cdp-ocultar' );
      }
      else
      {
         jQuery( '.cdp-cookies-texto' ).attr( 'class', 'cdp-cookies-texto cdp-animacion-arriba' );
         jQuery( '.cdp-cookies-solapa' ).attr( 'class', 'cdp-cookies-solapa cdp-animacion-abajo' );
      }
   },

   // Oculta aviso
   ocultar_aviso: function _ocultar_aviso( de_golpe ) {
      if( de_golpe )
      {
         jQuery( '.cdp-cookies-texto' ).attr( 'class', 'cdp-cookies-texto cdp-ocultar' );
         jQuery( '.cdp-cookies-solapa' ).attr( 'class', 'cdp-cookies-solapa cdp-mostrar' );
      }
      else
      {
         jQuery( '.cdp-cookies-texto' ).attr( 'class', 'cdp-cookies-texto cdp-animacion-abajo' );
         jQuery( '.cdp-cookies-solapa' ).attr( 'class', 'cdp-cookies-solapa cdp-animacion-arriba' );
      }
   },

   //
   comportamiento: function _comportamiento() {
      return cdp_cookies_info.comportamiento;
   }
};
 
//
//
//
jQuery( document ).ready( function( $ )
{
   // Inicialización
   cdp_cookie.iniciar();

   // Si ya hay cookie retorno
   if( cdp_cookie.ya_existe_cookie() )
      cdp_cookie.ocultar_aviso( true );
   else
      cdp_cookie.mostrar_aviso( true );
} );
// source --> https://casalospedroches.es/wp-content/plugins/booking-system/libraries/js/dop-prototypes.js?ver=2.9.9.6.8 
/*
* Title                   : DOP Prototypes (JavaScript class)
* Version                 : 1.0.3
* File                    : dop-prototypes.js
* File Version            : 1.0.3
* Created / Last Modified : 29 March 2016
* Author                  : Dot on Paper
* Copyright               : © 2014 Dot on Paper
* Website                 : http://www.dotonpaper.net
* Description             : List of general functions that we use at Dot on Paper.
* Licence                 : MIT
*/

var DOPPrototypes = new function(){
    /*
     * Private variables
     */
    var $ = jQuery.noConflict();

    /*
     * Public variables
     */
        
    /*
     * Constructor
     */
    this.__construct = function(){
    };
    
// Actions           

    /*
     * Make all parents & current item visible.
     * 
     * @param item (element): item for which all parens are going to be made visible
     * 
     * @return list of parents
     */
    this.doHiddenBuster = function(item){
        var parent = item.parent(),
        items = new Array();

        if (item.prop('tagName') !== undefined 
                && item.prop('tagName').toLowerCase() !== 'body'){
            items = this.doHiddenBuster(parent);
        }

        if (item.css('display') === 'none'){
            item.css('display', 'block');
            items.push(item);
        }

        return items;
    };
    
    /*
     * Hide all items from list. The list is returned by function doHiddenBuster().
     * 
     * @param items (Array): list of items to be hidden
     */
    this.undoHiddenBuster = function(items){    
        var i;

        for (i=0; i<items.length; i++){
            items[i].css('display', 'none');
        }
    };
    
    /*
     * Open a link.
     * 
     * @param url (String): link URL
     * @param target (String): link target (_blank, _parent, _self, _top)
     */
    this.openLink = function(url,
                             target){
        switch (target.toLowerCase()){
            case '_blank':
                window.open(url);
                break;
            case '_parent':
                parent.location.href = url;
                break;
            case '_top':
                top.location.href = url;
                break;
            default:    
                window.location = url;
        }
    };
    
    /*
     * Randomize the items of an array.
     * 
     * @param theArray (Array): the array to be mixed
     * 
     * return array with mixed items
     */
    this.randomizeArray = function(theArray){
        theArray.sort(function(){
            return 0.5-Math.random();
        });
        return theArray;
    };

    /*
     * Scroll vertically to position.
     * 
     * @param position (Number): position to scroll to
     * @param speed (Number): scroll speed 
     */  
    this.scrollToY = function(position,
                              speed){
        speed = speed !== undefined ? speed: 300;
        
        $('html').stop(true, true)
                 .animate({'scrollTop': position}, 
                          speed);
        $('body').stop(true, true)
                 .animate({'scrollTop': position}, 
                          speed);
    };
    
    /*
     * One finger navigation for touchscreen devices.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     */
    this.touchNavigation = function(parent,
                                    child){
        var prevX, 
        prevY, 
        currX, 
        currY, 
        touch, 
        childX, 
        childY;

        parent.bind('touchstart', function(e){
            touch = e.originalEvent.touches[0];
            prevX = touch.clientX;
            prevY = touch.clientY;
        });

        parent.bind('touchmove', function(e){                                
            touch = e.originalEvent.touches[0];
            currX = touch.clientX;
            currY = touch.clientY;
            childX = currX>prevX ? parseInt(child.css('margin-left'))+(currX-prevX):parseInt(child.css('margin-left'))-(prevX-currX);
            childY = currY>prevY ? parseInt(child.css('margin-top'))+(currY-prevY):parseInt(child.css('margin-top'))-(prevY-currY);

            if (childX < (-1)*(child.width()-parent.width())){
                childX = (-1)*(child.width()-parent.width());
            }
            else if (childX > 0){
                childX = 0;
            }
            else{                                    
                e.preventDefault();
            }

            if (childY < (-1)*(child.height()-parent.height())){
                childY = (-1)*(child.height()-parent.height());
            }
            else if (childY > 0){
                childY = 0;
            }
            else{                                    
                e.preventDefault();
            }

            prevX = currX;
            prevY = currY;

            if (parent.width() < child.width()){
                child.css('margin-left', childX);
            }

            if (parent.height() < child.height()){
                child.css('margin-top', childY);
            }
        });

        parent.bind('touchstart', function(e){
            if (!this.isChromeMobileBrowser()){
                e.preventDefault();
            }
        });
    };

// Browsers & devices

    /*
     * Check if operating system is Android.
     * 
     * @return true/false
     */
    this.isAndroid = function(){
        var isAndroid = false,
        agent = navigator.userAgent.toLowerCase();

        if (agent.indexOf('android') !== -1){
            isAndroid = true;
        }
        return isAndroid;
    };
    
    /*
     * Check if browser is Chrome on mobile..
     * 
     * @return true/false
     */
    this.isChromeMobileBrowser = function(){
        var isChromeMobile = false,
        agent = navigator.userAgent.toLowerCase();

        if ((agent.indexOf('chrome') !== -1 
                        || agent.indexOf('crios') !== -1) 
                && this.isTouchDevice()){
            isChromeMobile = true;
        }
        return isChromeMobile;
    };
    
    /*
     * Check if browser is IE8.
     * 
     * @return true/false
     */
    this.isIE8Browser = function(){
        var isIE8 = false,
        agent = navigator.userAgent.toLowerCase();

        if (agent.indexOf('msie 8') !== -1){
            isIE8 = true;
        }
        return isIE8;
    };
    
    /*
     * Check if browser is IE..
     * 
     * @return true/false
     */
    this.isIEBrowser = function(){
        var isIE = false,
        agent = navigator.userAgent.toLowerCase();

        if (agent.indexOf('msie') !== -1){
            isIE = true;
        }
        return isIE;
    };
    
    /*
     * Detect touchscreen devices.
     * 
     * @return true/false
     */
    this.isTouchDevice = function(){
        var os = navigator.platform;

        if (os.toLowerCase().indexOf('win') !== -1){
            return window.navigator.msMaxTouchPoints;
        }
        else {
            return 'ontouchstart' in document;
        }
    },

// Cookies
    
    /*
     * Delete cookie.
     * 
     * @param name (String): cookie name
     * @param path (String): cookie path
     * @param domain (String): cookie domain
     */
    this.deleteCookie = function(name,
                                 path,
                                 domain){
        if (this.getCookie(name)){
            document.cookie = name+'='+((path) ? ';path='+path:'')+((domain) ? ';domain='+domain:'')+';expires=Thu, 01-Jan-1970 00:00:01 GMT';
        }
    };
    
    /*
     * Get cookie.
     * 
     * @param name (String): cookie name
     */  
    this.getCookie = function(name){  
        var namePiece = name+"=",
        cookie = document.cookie.split(";"),
        i;

        for (i=0; i<cookie.length; i++){
            var cookiePiece = cookie[i];

            while (cookiePiece.charAt(0) === ' '){
                cookiePiece = cookiePiece.substring(1,cookiePiece .length);            
            } 

            if (cookiePiece.indexOf(namePiece) === 0){
                return unescape(cookiePiece.substring(namePiece.length, cookiePiece.length));
            } 
        }
        return null;
    };
    
    /*
     * Set cookie.
     * 
     * @param name (String): cookie name
     * @param value (String): cookie value
     * @param expire (String): the number of days after which the cookie will expire
     */
    this.setCookie = function(name,
                              value,
                              expire){
        var expirationDate = new Date();

        expirationDate.setDate(expirationDate.getDate()+expire);
        document.cookie = name+'='+escape(value)+((expire === null) ? '': ';expires='+expirationDate.toUTCString())+';javahere=yes;path=/';
    };

// Date & time
    
    /*
     * Converts time to AM/PM format.
     *
     * @param time (String): the time that will be converted (HH:MM)
     *
     * @return time to AM/PM format
     */
    this.getAMPM = function(time){
        var hour = parseInt(time.split(':')[0], 10),
        minutes = time.split(':')[1],
        result = '';

        if (hour === 0){
            result = '12';
        }
        else if (hour > 12){
            result = this.getLeadingZero(hour-12);
        }
        else{
            result = this.getLeadingZero(hour);
        }

        result += ':'+minutes+' '+(hour < 12 ? 'AM':'PM');

        return result;
    };
    
    /*
     * Returns difference between 2 dates.
     * 
     * @param date1 (Date): first date (JavaScript date)
     * @param date2 (Date): second date (JavaScript date)
     * @param type (String): diference type
     *                       "seconds"
     *                       "minutes"
     *                       "hours"
     *                       "days"
     * @param valueType (String): type of number returned
     *                            "float"
     *                            "integer"
     * @param noDecimals (Number): number of decimals returned with the float value (-1 to display all decimals)
     * 
     * @return dates diference
     */
    this.getDatesDifference = function(date1,
                                       date2,
                                       type,
                                       valueType,
                                       noDecimals){
        var y1 = date1.split('-')[0],
        m1 = date1.split('-')[1],
        d1 = date1.split('-')[2],
        y2 = date2.split('-')[0],
        m2 = date2.split('-')[1],
        d2 = date2.split('-')[2],
        time1 = (new Date(y1, m1-1, d1)).getTime(),
        time2 = (new Date(y2, m2-1, d2)).getTime(),
        diff = Math.abs(time1-time2);

        if (type === undefined){
            type = 'seconds';
        }

        if (valueType === undefined){
            valueType = 'float';
        }

        if (noDecimals === undefined){
            noDecimals = -1;
        }

        switch (type){
            case 'days':
                diff = diff/(1000*60*60*24);
                break;
            case 'hours':
                diff = diff/(1000*60*60);
                break;
            case 'minutes':
                diff = diff/(1000*60);
                break;
            default:
                diff = diff/(1000);
        }

        if (valueType === 'float'){
            return noDecimals === -1 ? diff:DOPPrototypes.getWithDecimals(diff, noDecimals);
        }
        else{
            return Math.ceil(diff);
        }
    };
    
    /*
     * Returns difference between 2 hours.
     * 
     * @param hour1 (Date): first hour (HH:MM, HH:MM:SS)
     * @param hour2 (Date): second hour (HH:MM, HH:MM:SS)
     * @param type (String): diference type
     *                       "seconds"
     *                       "minutes"
     *                       "hours"
     * @param valueType (String): type of number returned
     *                            "float"
     *                            "integer"
     * @param noDecimals (Number): number of decimals returned with the float value (-1 to display all decimals)
     * 
     * @return hours difference
     */
    this.getHoursDifference = function(hour1,
                                       hour2,
                                       type,
                                       valueType,
                                       noDecimals){
        var hours1 = parseInt(hour1.split(':')[0], 10),
        minutes1 = parseInt(hour1.split(':')[1], 10),
        seconds1 = hour1.split(':')[2] !== undefined ? parseInt(hour1.split(':')[2], 10):0,
        hours2 = parseInt(hour2.split(':')[0], 10),
        minutes2 = parseInt(hour2.split(':')[1], 10),
        seconds2 = hour2.split(':')[2] !== undefined ? parseInt(hour2.split(':')[2], 10):0,
        time1,
        time2,
        diff;

        if (type === undefined){
            type = 'seconds';
        }

        if (valueType === undefined){
            valueType = 'float';
        }

        if (noDecimals === undefined){
            noDecimals = -1;
        }

        switch (type){
            case 'hours':
                time1 = hours1+minutes1/60+seconds1/60/60;
                time2 = hours2+minutes2/60+seconds2/60/60;
                break;
            case 'minutes':
                time1 = hours1*60+minutes1+seconds1/60;
                time2 = hours2*60+minutes2+seconds2/60;
                break;
            default:
                time1 = hours1*60*60+minutes1*60+seconds1;
                time2 = hours2*60*60+minutes2*60+seconds2;
        }

        diff = Math.abs(time1-time2);

        if (valueType === 'float'){
            return noDecimals === -1 ? diff:DOPPrototypes.getWithDecimals(diff, noDecimals);
        }
        else{
            return Math.ceil(diff);
        }
    };
    
    /*
     * Returns next day.
     * 
     * @param date (Date): current date (YYYY-MM-DD)
     * 
     * @return next day (YYYY-MM-DD)
     */
    this.getNextDay = function(date){
        var nextDay = new Date(),
        parts = date.split('-');

        nextDay.setFullYear(parts[0], parts[1], parts[2]);
        nextDay.setTime(nextDay.getTime()+86400000);

        return nextDay.getFullYear()+'-'+DOPPrototypes.getLeadingZero(nextDay.getMonth())+'-'+DOPPrototypes.getLeadingZero(nextDay.getDate());
    };
    
    /*
     * Returns number of days between 2 dates.
     * 
     * @param date1 (Date): first date (YYYY-MM-DD)
     * @param date2 (Date): second date (YYYY-MM-DD)
     * 
     * @return number of days
     */
    this.getNoDays = function(date1,
                              date2){
        var y1 = date1.split('-')[0],
        m1 = date1.split('-')[1],
        d1 = date1.split('-')[2],
        y2 = date2.split('-')[0],
        m2 = date2.split('-')[1],
        d2 = date2.split('-')[2],
        time1 = (new Date(y1, m1-1, d1)).getTime(),
        time2 = (new Date(y2, m2-1, d2)).getTime(),
        diff = Math.abs(time1-time2);

        return Math.round(diff/(1000*60*60*24))+1;
    };
    
            /*
             * Returns the number of months between 2 dates.
             * 
             * @param date1 (Date): first date (YYYY-MM-DD)
             * @param date2 (Date): second date (YYYY-MM-DD)
             * 
             * @return the number of months 
             */
     this.getNoMonths = function(date1,
                                 date2){
        var firstMonth,
        lastMonth,
        m,
        month1,
        month2,
        noMonths = 0,
        y,
        year1,
        year2;

        date1 = date1 <= date2 ? date1:date2;
        month1 = parseInt(date1.split('-')[1], 10);
        year1 = parseInt(date1.split('-')[0], 10);
        month2 = parseInt(date2.split('-')[1], 10);
        year2 = parseInt(date2.split('-')[0], 10);

        for (y=year1; y<=year2; y++){
            firstMonth = y === year1 ? month1:1;
            lastMonth = y === year2 ? month2:12;

            for (m=firstMonth; m<=lastMonth; m++){
                noMonths++;
            }
        }

        return noMonths;
    };
                    
    /*
     * Returns previous day.
     * 
     * @param date (Date): current date (YYYY-MM-DD)
     * 
     * @return previous day (YYYY-MM-DD)
     */
    this.getPrevDay = function(date){
        var previousDay = new Date(),
        parts = date.split('-');

        previousDay.setFullYear(parts[0], parseInt(parts[1])-1, parts[2]);
        previousDay.setTime(previousDay.getTime()-86400000);

        return previousDay.getFullYear()+'-'+DOPPrototypes.getLeadingZero(previousDay.getMonth()+1)+'-'+DOPPrototypes.getLeadingZero(previousDay.getDate());                        
    };
                        
    /*
     * Returns previous time by hours, minutes, seconds.
     * 
     * @param time (String): time (HH, HH:MM, HH:MM:SS)
     * @param diff (Number): diference for previous time
     * @param diffBy (Number): diference by 
     *                         "hours"
     *                         "minutes"
     *                         "seconds"
     * 
     * @return previus hour (HH, HH:MM, HH:MM:SS)
     */
    this.getPrevTime = function(time,
                                diff,
                                diffBy){
        var timePieces = time.split(':'),
        hours = parseInt(timePieces[0], 10),
        minutes = timePieces[1] === undefined ? 0:parseInt(timePieces[1], 10),
        seconds = timePieces[2] === undefined ? 0:parseInt(timePieces[2], 10);

        switch (diffBy){
            case 'seconds':
                seconds = seconds-diff;

                if (seconds < 0){
                    seconds = 60+seconds;
                    minutes = minutes-1;

                    if (minutes < 0){
                        minutes = 60+minutes;
                        hours = hours-1 < 0 ? 0:hours-1;
                    }
                }
                break;
            case 'minutes':
                    minutes = minutes-diff;

                    if (minutes < 0){
                        minutes = 60+minutes;
                        hours = hours-1 < 0 ? 0:hours-1;
                    }
                break;
            default:
                hours = hours-diff < 0 ? 0:hours-diff;
        }

        return this.getLeadingZero(hours)+(timePieces[1] === undefined ? '':':'+this.getLeadingZero(minutes)+(timePieces[2] === undefined ? '':':'+this.getLeadingZero(seconds)));
    };
    
    /*
     * Returns today date.
     * 
     * @return today (YYYY-MM-DD)
     */
    this.getToday = function(){    
        var today = new Date();

        return today.getFullYear()+'-'+DOPPrototypes.getLeadingZero(today.getMonth()+1)+'-'+DOPPrototypes.getLeadingZero(today.getDate());
    };

    /*
     * Returns week day.
     * 
     * @param date (String): date for which the function get day of the week (YYYY-MM-DD)
     * 
     * @return week day index (0 for Sunday)
     */
    this.getWeekDay = function(date){    
        var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        year = date.split('-')[0],
        month = date.split('-')[1],
        day = date.split('-')[2],
        newDate = new Date(eval('"'+day+' '+months[parseInt(month, 10)-1]+', '+year+'"'));

        return newDate.getDay();
    };
    
// Domains & URLs                        
    
    /*
     * Parse a $_GET variable.
     * 
     * @param name (String): variable name
     * 
     * @return variable vaue or "undefined" if it doesn't exist
     */
    this.$_GET = function(name){
        var url = window.location.href.split('?')[1],
        variables = url !== undefined ? url.split('&'):[],
        i; 

        for (i=0; i<variables.length; i++){
            if (variables[i].indexOf(name) !== -1){
                return variables[i].split('=')[1];
                break;
            }
        }

        return undefined;
    };
    
    /*
     * Access-Control-Allow-Origin buster. Modifies URL to be the same as browser URL.
     * 
     * @param url (String): URL
     * 
     * @return modified URL
     */
    this.acaoBuster = function(url){
        var browserURL = window.location.href,
        pathPiece1 = '', pathPiece2 = '';

        if (this.getDomain(browserURL) === this.getDomain(url)){
            if (url.indexOf('https') !== -1 
                    || url.indexOf('http') !== -1){
                if (browserURL.indexOf('http://www.') !== -1){
                    pathPiece1 = 'http://www.';
                }
                else if (browserURL.indexOf('http://') !== -1){
                    pathPiece1 = 'http://';
                }
                else if (browserURL.indexOf('https://www.') !== -1){
                    pathPiece1 = 'https://www.';
                }
                else if (browserURL.indexOf('https://') !== -1){
                    pathPiece1 = 'https://';
                }

                if (url.indexOf('http://www.') !== -1){
                    pathPiece2 = url.split('http://www.')[1];
                }
                else if (url.indexOf('http://') !== -1){
                    pathPiece2 = url.split('http://')[1];
                }
                else if (url.indexOf('https://www.') !== -1){
                    pathPiece2 = url.split('https://www.')[1];
                }
                else if (url.indexOf('https://') !== -1){
                    pathPiece2 = url.split('https://')[1];
                }

                return pathPiece1+pathPiece2;
            }
            else{
                return url;
            }
        }
        else{
            return url;
        }
    };
    
    /*
     * Get current domain.
     *
     * @param url (String): the URL from which the domain will be extracted
     *
     * @return current domain
     */ 
    this.getDomain = function(url){
        var domain = url;

        /*
         * Remove white spaces from the begining of the URL.
         */
        domain = domain.replace(new RegExp(/^\s+/),"");

        /*
         * Remove white spaces from the end of the URL.
         */
        domain = domain.replace(new RegExp(/\s+$/),"");

        /*
         * If found , convert back slashes to forward slashes.
         */
        domain = domain.replace(new RegExp(/\\/g),"/");

        /*
         * If there, removes "http://", "https://" or "ftp://" from the begining.
         */
        domain = domain.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");

        /*
         * If there, removes 'www.' from the begining.
         */
        domain = domain.replace(new RegExp(/^www\./i),"");

        /*
         * Remove complete string from first forward slash on.
         */
        domain = domain.replace(new RegExp(/\/(.*)/),"");

        return domain;
    };
    
    /*
     * Check if current URL has a subdomain.
     *
     * @param url (String): URL that will be checked
     *
     * @return true/false
     */ 
    this.hasSubdomain = function(url){
        var subdomain;

        /*
         * Remove white spaces from the begining of the URL.
         */
        url = url.replace(new RegExp(/^\s+/),"");

        /*
         * Remove white spaces from the end of the URL.
         */
        url = url.replace(new RegExp(/\s+$/),"");

        /*
         * If found , convert back slashes to forward slashes.
         */
        url = url.replace(new RegExp(/\\/g),"/");

        /*
         * If there, removes 'http://', 'https://' or 'ftp://' from the begining.
         */
        url = url.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");

        /*
         * If there, removes 'www.' from the begining.
         */
        url = url.replace(new RegExp(/^www\./i),"");

        /*
         * Remove complete string from first forward slaash on.
         */
        url = url.replace(new RegExp(/\/(.*)/),""); // 

        if (url.match(new RegExp(/\.[a-z]{2,3}\.[a-z]{2}$/i))){
            /*
             * Remove ".??.??" or ".???.??" from end - e.g. ".CO.UK", ".COM.AU"
             */
            url = url.replace(new RegExp(/\.[a-z]{2,3}\.[a-z]{2}$/i),"");
        }
        else if (url.match(new RegExp(/\.[a-z]{2,4}$/i))){
            /*
             * Removes ".??" or ".???" or ".????" from end - e.g. ".US", ".COM", ".INFO"
             */
            url = url.replace(new RegExp(/\.[a-z]{2,4}$/i),"");
        }

        /*
         * Check to see if there is a dot "." left in the string.
         */
        subdomain = (url.match(new RegExp(/\./g))) ? true : false;

        return(subdomain);
    };

// Resize & position                        
    
    /*
     * Resize & position an item inside a parent.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): parent width
     * @param ph (Number): parent height
     * @param cw (Number): child width
     * @param ch (Number): child height
     * @param pos (String): set child position in parent (bottom, bottom-center, bottom-left, bottom-right, center, left, horizontal-center, middle-left, middle-right, right, top, top-center, top-left, top-right, vertical-center)
     * @param type (String): resize type
     *                       "fill" fill parent (child will be cropped)
     *                       "fit" child resize to fit in parent
     */
    this.rp = function(parent,
                       child,
                       pw,
                       ph,
                       cw,
                       ch,
                       pos,
                       type){
        var newW = 0,
        newH = 0;

        /*
         * Resize child.
         */
        if (cw <= pw 
                && ch <= ph){
            newW = cw;
            newH = ch;
        }
        else{
            switch (type){
                case 'fill':
                    newH = ph;
                    newW = (cw*ph)/ch;

                    if (newW < pw){
                        newW = pw;
                        newH = (ch*pw)/cw;
                    }
                    break;
                default:
                    newH = ph;
                    newW = (cw*ph)/ch;

                    if (newW > pw){
                        newW = pw;
                        newH = (ch*pw)/cw;
                    }
                    break;
            }
        }

        child.width(newW);
        child.height(newH);

        /*
         * Position child.
         */
        switch(pos.toLowerCase()){
            case 'bottom':
                this.rpBottom(parent, 
                              child, 
                              ph);
                break;
            case 'bottom-center':
                this.rpBottomCenter(parent, 
                                    child, 
                                    pw, 
                                    ph);
                break;
            case 'bottom-left':
                this.rpBottomLeft(parent, 
                                  child, 
                                  pw, 
                                  ph);
                break;
            case 'bottom-right':
                this.rpBottomRight(parent, 
                                   child, 
                                   pw, 
                                   ph);
                break;
            case 'center':
                this.rpCenter(parent, 
                              child, 
                              pw, 
                              ph);
                break;
            case 'left':
                this.rpLeft(parent, 
                            child, 
                            pw);
                break;
            case 'horizontal-center':
                this.rpCenterHorizontally(parent, 
                                          child, 
                                          pw);
                break;
            case 'middle-left':
                this.rpMiddleLeft(parent, 
                                  child, 
                                  pw, 
                                  ph);
                break;
            case 'middle-right':
                this.rpMiddleRight(parent, 
                                   child, 
                                   pw, 
                                   ph);
                break;
            case 'right':
                this.rpRight(parent, 
                             child, 
                             pw);
                break;
            case 'top':
                this.rpTop(parent, 
                           child, 
                           ph);
                break;
            case 'top-center':
                this.rpTopCenter(parent, 
                                 child, 
                                 pw, 
                                 ph);
                break;
            case 'top-left':
                this.rpTopLeft(parent, 
                               child, 
                               pw, 
                               ph);
                break;
            case 'top-right':
                this.rpTopRight(parent, 
                                child, 
                                pw, 
                                ph);
                break;
            case 'vertical-center':
                this.rpCenterVertically(parent, 
                                        child, 
                                        ph);
                break;
        }
    };
    
    /*
     * Position item on bottom.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpBottom = function(parent,
                             child,
                             ph){
        if (ph !== undefined){
            parent.height(ph);
        }
        child.css('margin-top', parent.height()-child.height());
    };
    
    /*
     * Position item on bottom-left.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpBottomCenter = function(parent,
                                   child,
                                   pw,
                                   ph){
        this.rpBottom(parent, 
                      child, 
                      ph);
        this.rpCenterHorizontally(parent, 
                                  child, 
                                  pw);
    };
    
    /*
     * Position item on bottom-left.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpBottomLeft = function(parent,
                                 child,
                                 pw,
                                 ph){
        this.rpBottom(parent, 
                      child, 
                      ph);
        this.rpLeft(parent, 
                    child, 
                    pw);
    };
    
    /*
     * Position item on bottom-left.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpBottomRight = function(parent,
                                  child,
                                  pw,
                                  ph){
        this.rpBottom(parent, 
                      child, 
                      ph);
        this.rpRight(parent, 
                     child, 
                     pw);
    };
    
    /*
     * Position item on center.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpCenter = function(parent,
                             child,
                             pw,
                             ph){
        this.rpCenterHorizontally(parent,
                                  child,
                                  pw);
        this.rpCenterVertically(parent, 
                                child, 
                                ph);
    };
    
    /*
     * Center item horizontally.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     */
    this.rpCenterHorizontally = function(parent,
                                         child,
                                         pw){
        if (pw !== undefined){
            parent.width(pw);
        }
        child.css('margin-left', (parent.width()-child.width())/2);
    };
    
    /*
     * Center item vertically.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpCenterVertically = function(parent,
                                       child,
                                       ph){
        if (ph !== undefined){
            parent.height(ph);
        }
        child.css('margin-top', (parent.height()-child.height())/2);
    };
    
    /*
     * Position item on left.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     */
    this.rpLeft = function(parent,
                           child,
                           pw){
        if (pw !== undefined){
            parent.width(pw);
        }
        child.css('margin-left', 0);
    };
    
    /*
     * Position item on middle-left.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpMiddleLeft = function(parent,
                                 child,
                                 pw,
                                 ph){
        this.rpCenterVertically(parent, 
                                child, 
                                ph);
        this.rpLeft(parent, 
                    child, 
                    pw);
    };
    
    /*
     * Position item on middle-right.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpMiddleRight = function(parent,
                                  child,
                                  pw,
                                  ph){
        this.rpCenterVertically(parent, 
                                child, 
                                ph);
        this.rpRight(parent, 
                     child, 
                     pw);
    };
    
    /*
     * Position item on right.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     */
    this.rpRight = function(parent,
                            child,
                            pw){
        if (pw !== undefined){
            parent.width(pw);
        }
        child.css('margin-left', parent.width()-child.width());
    };
    
    /*
     * Position item on top.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpTop = function(parent,
                          child,
                          ph){
        if (ph !== undefined){
            parent.height(ph);
        }
        child.css('margin-top', 0);
    };
    
    /*
     * Position item on top-center.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpTopCenter = function(parent,
                                child,
                                pw,
                                ph){
        this.rpTop(parent, 
                   child, 
                   ph);
        this.rpCenterHorizontally(parent, 
                                  child, 
                                  pw);
    };
    
    /*
     * Position item on top-left.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */
    this.rpTopLeft = function(parent,
                              child,
                              pw,
                              ph){
        this.rpTop(parent, 
                   child, 
                   ph);
        this.rpLeft(parent, 
                    child, 
                    pw);
    };
          
    /*
     * Position item on top-right.
     * 
     * @param parent (element): parent item
     * @param child (element): child item
     * @param pw (Number): width to which the parent is going to be set
     * @param ph (Number): height to which the parent is going to be set
     */  
    this.rpTopRight = function(parent,
                               child,
                               pw,
                               ph){
        this.rpTop(parent, 
                   child, 
                   ph);
        this.rpRight(parent, 
                     child, 
                     pw);
    };

// Strings & numbers
    
    /*
     * Clean an input from unwanted characters.
     * 
     * @param input (element): the input to be checked
     * @param allowedCharacters (String): the string of allowed characters
     * @param firstNotAllowed (String): the character which can't be on the first position
     * @param min (Number/String): the minimum value that is allowed in the input
     * 
     * @return clean string
     */ 
    this.cleanInput = function(input,
                               allowedCharacters,
                               firstNotAllowed,
                               min){
        var characters = input.val().split(''),
        returnStr = '', 
        i, 
        startIndex = 0;

        /*
         * Check first character.
         */
        if (characters.length > 1 
                && characters[0] === firstNotAllowed){
            startIndex = 1;
        }

        /*
         * Check characters.
         */
        for (i=startIndex; i<characters.length; i++){
            if (allowedCharacters.indexOf(characters[i]) !== -1){
                returnStr += characters[i];
            }
        }

        /*
         * Check the minimum value.
         */
        if (min > returnStr){
            returnStr = min;
        }

        input.val(returnStr);
    };
    
    /*
     * Adds a leading 0 if number smaller than 10.
     * 
     * @param no (Number): the number
     * 
     * @return number with leading 0 if needed
     */
    this.getLeadingZero = function(no){
        if (no < 10){
            return '0'+no;
        }
        else{
            return no;
        }
    };
    
    /*
     * Creates a string with random characters.
     * 
     * @param stringLength (Number): the length of the returned string
     * @param allowedCharacters (String): the string of allowed characters
     * 
     * @return random string
     */
    this.getRandomString = function(stringLength,
                                    allowedCharacters){
        var randomString = '',
        charactersPosition,
        i;

        allowedCharacters = allowedCharacters !== undefined ? allowedCharacters:'0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';

        for (i=0; i<stringLength; i++){
            charactersPosition = Math.floor(Math.random()*allowedCharacters.length);
            randomString += allowedCharacters.substring(charactersPosition, charactersPosition+1);
        }
        return randomString;
    };
    
    /*
     * Returns a part of a string followed by 3 dots.
     * 
     * @param str (String): the string
     * @param size (Number): the number of characters that will be displayed minus 3 dots
     * 
     * @return short string ...
     */
    this.getShortString = function(str,
                                   size){
        var newStr = new Array(),
        pieces = str.split(''), 
        i;

        if (pieces.length <= size){
            newStr.push(str);
        }
        else{
            for (i=0; i<size-3; i++){
                newStr.push(pieces[i]);
            }
            newStr.push('...');
        }

        return newStr.join('');
    };
    
    /*
     * Returns a number with a predefined number of decimals.
     * 
     * @param number (Number): the number
     * @param no (Number): the number of decimals
     * 
     * @return string with number and decimals
     */
    this.getWithDecimals = function(number,
                                    no){
        no = no === undefined ? 2:no;
        return parseInt(number) === number ? String(number):parseFloat(number).toFixed(no);
    };
    
    /*
     * Verify if a string contains allowed characters.
     * 
     * @param str (String): string to be checked
     * @param allowedCharacters (String): the string of allowed characters
     * 
     * @return true/false
     */
    this.validateCharacters = function(str,
                                       allowedCharacters){
        var characters = str.split(''), 
        i;

        for (i=0; i<characters.length; i++){
            if (allowedCharacters.indexOf(characters[i]) === -1){
                return false;
            }
        }
        return true;
    };
    
    /*
     * Email validation.
     * 
     * @param email (String): email to be checked
     * 
     * @return true/false
     */
    this.validEmail = function(email){
        var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,16}(?:\.[a-z]{2})?)$/i;

        if (filter.test(email)){
            return true;
        }
        return false;
    };
    
    /*
     * Remove slashes from string.
     * 
     * @param str (String): the string
     * 
     * @return string without slashes
     */
    this.stripSlashes = function(str){
        return (str + '').replace(/\\(.?)/g, function (s, n1){
            switch (n1){
                case '\\':
                    return '\\';
                case '0':
                    return '\u0000';
                case '':
                    return '';
                default:
                    return n1;
            }
        });
    };

// Styles
    
    /*
     * Convert RGB color to HEX.
     * 
     * @param rgb (String): RGB color
     * 
     * @return color HEX
     */
    this.getHEXfromRGB = function(rgb){
        var hexDigits = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');

        rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);

        return (isNaN(rgb[1]) ? '00':hexDigits[(rgb[1]-rgb[1]%16)/16]+hexDigits[rgb[1]%16])+
               (isNaN(rgb[2]) ? '00':hexDigits[(rgb[2]-rgb[2]%16)/16]+hexDigits[rgb[2]%16])+
               (isNaN(rgb[3]) ? '00':hexDigits[(rgb[3]-rgb[3]%16)/16]+hexDigits[rgb[3]%16]);
    };

    /*
     * Set text color depending on the background color.
     * 
     * @param bgColor(String): background color
     * 
     * return white/black
     */
    this.getIdealTextColor = function(bgColor){
        var rgb = /rgb\((\d+).*?(\d+).*?(\d+)\)/.exec(bgColor);

        if (rgb !== null){
            return parseInt(rgb[1], 10)+parseInt(rgb[2], 10)+parseInt(rgb[3], 10) < 3*256/2 ? 'white' : 'black';
        }
        else{
            return parseInt(bgColor.substring(0, 2), 16)+parseInt(bgColor.substring(2, 4), 16)+parseInt(bgColor.substring(4, 6), 16) < 3*256/2 ? 'white' : 'black';
        }
    };
    
    this.getCountries = function(){
        return [{"code":"+93","code2":"AF","name":"Afghanistan"},{"code":"+355","code2":"AL","name":"Albania"},{"code":"+213","code2":"DZ","name":"Algeria"},{"code":"+1 684","code2":"AS","name":"American Samoa"},{"code":"+376","code2":"AD","name":"Andorra"},{"code":"+244","code2":"AO","name":"Angola"},{"code":"+1 264","code2":"AI","name":"Anguilla"},{"code":"+672","code2":"AQ","name":"Antarctica"},{"code":"+1 268","code2":"AG","name":"Antigua and Barbuda"},{"code":"+54","code2":"AR","name":"Argentina"},{"code":"+374","code2":"AM","name":"Armenia"},{"code":"+297","code2":"AW","name":"Aruba"},{"code":"+61","code2":"AU","name":"Australia"},{"code":"+43","code2":"AT","name":"Austria"},{"code":"+994","code2":"AZ","name":"Azerbaijan"},{"code":"+1 242","code2":"BS","name":"Bahamas"},{"code":"+973","code2":"BH","name":"Bahrain"},{"code":"+880","code2":"BD","name":"Bangladesh"},{"code":"+1 246","code2":"BB","name":"Barbados"},{"code":"+375","code2":"BY","name":"Belarus"},{"code":"+32","code2":"BE","name":"Belgium"},{"code":"+501","code2":"BZ","name":"Belize"},{"code":"+229","code2":"BJ","name":"Benin"},{"code":"+1 441","code2":"BM","name":"Bermuda"},{"code":"+975","code2":"BT","name":"Bhutan"},{"code":"+591","code2":"BO","name":"Bolivia"},{"code":"+387","code2":"BA","name":"Bosnia and Herzegovina"},{"code":"+267","code2":"BW","name":"Botswana"},{"code":"+55","code2":"BR","name":"Brazil"},{"code":"+246","code2":"IO","name":"British Indian Ocean Territory"},{"code":"+1 284","code2":"VG","name":"British Virgin Islands"},{"code":"+673","code2":"BN","name":"Brunei"},{"code":"+359","code2":"BG","name":"Bulgaria"},{"code":"+226","code2":"BF","name":"Burkina Faso"},{"code":"+257","code2":"BI","name":"Burundi"},{"code":"+855","code2":"KH","name":"Cambodia"},{"code":"+237","code2":"CM","name":"Cameroon"},{"code":"+1","code2":"CA","name":"Canada"},{"code":"+238","code2":"CV","name":"Cape Verde"},{"code":"+ 345","code2":"KY","name":"Cayman Islands"},{"code":"+236","code2":"CF","name":"Central African Republic"},{"code":"+235","code2":"TD","name":"Chad"},{"code":"+56","code2":"CL","name":"Chile"},{"code":"+86","code2":"CN","name":"China"},{"code":"+61","code2":"CX","name":"Christmas Island"},{"code":"+61","code2":"CC","name":"Cocos-Keeling Islands"},{"code":"+57","code2":"CO","name":"Colombia"},{"code":"+269","code2":"KM","name":"Comoros"},{"code":"+242","code2":"CG","name":"Congo"},{"code":"+243","code2":"CD","name":"Congo, Dem. Rep. of (Zaire)"},{"code":"+682","code2":"CK","name":"Cook Islands"},{"code":"+506","code2":"CR","name":"Costa Rica"},{"code":"+385","code2":"HR","name":"Croatia"},{"code":"+53","code2":"CU","name":"Cuba"},{"code":"+357","code2":"CY","name":"Cyprus"},{"code":"+420","code2":"CZ","name":"Czech Republic"},{"code":"+45","code2":"DK","name":"Denmark"},{"code":"+253","code2":"DJ","name":"Djibouti"},{"code":"+1 767","code2":"DM","name":"Dominica"},{"code":"+1 809","code2":"DO","name":"Dominican Republic"},{"code":"+670","code2":"TL","name":"East Timor"},{"code":"+593","code2":"EC","name":"Ecuador"},{"code":"+20","code2":"EG","name":"Egypt"},{"code":"+503","code2":"SV","name":"El Salvador"},{"code":"+240","code2":"GQ","name":"Equatorial Guinea"},{"code":"+291","code2":"ER","name":"Eritrea"},{"code":"+372","code2":"EE","name":"Estonia"},{"code":"+251","code2":"ET","name":"Ethiopia"},{"code":"+500","code2":"FK","name":"Falkland Islands"},{"code":"+298","code2":"FO","name":"Faroe Islands"},{"code":"+679","code2":"FJ","name":"Fiji"},{"code":"+358","code2":"FI","name":"Finland"},{"code":"+33","code2":"FR","name":"France"},{"code":"+594","code2":"GF","name":"French Guiana"},{"code":"+689","code2":"PF","name":"French Polynesia"},{"code":"+241","code2":"GA","name":"Gabon"},{"code":"+220","code2":"GM","name":"Gambia"},{"code":"+995","code2":"GE","name":"Georgia"},{"code":"+49","code2":"DE","name":"Germany"},{"code":"+233","code2":"GH","name":"Ghana"},{"code":"+350","code2":"GI","name":"Gibraltar"},{"code":"+30","code2":"GR","name":"Greece"},{"code":"+299","code2":"GL","name":"Greenland"},{"code":"+1 473","code2":"GD","name":"Grenada"},{"code":"+590","code2":"GP","name":"Guadeloupe"},{"code":"+1 671","code2":"GU","name":"Guam"},{"code":"+502","code2":"GT","name":"Guatemala"},{"code":"+224","code2":"GN","name":"Guinea"},{"code":"+245","code2":"GW","name":"Guinea-Bissau"},{"code":"+595","code2":"GY","name":"Guyana"},{"code":"+509","code2":"HT","name":"Haiti"},{"code":"+379","code2":"VA","name":"Holy See(Vatican)"},{"code":"+504","code2":"HN","name":"Honduras"},{"code":"+852","code2":"HK","name":"Hong Kong SAR China"},{"code":"+36","code2":"HU","name":"Hungary"},{"code":"+354","code2":"IS","name":"Iceland"},{"code":"+91","code2":"IN","name":"India"},{"code":"+62","code2":"ID","name":"Indonesia"},{"code":"+98","code2":"IR","name":"Iran"},{"code":"+964","code2":"IQ","name":"Iraq"},{"code":"+353","code2":"IE","name":"Ireland"},{"code":"+972","code2":"IR","name":"Israel"},{"code":"+39","code2":"IT","name":"Italy"},{"code":"+225","code2":"CI","name":"Ivory Coast"},{"code":"+1 876","code2":"JM","name":"Jamaica"},{"code":"+81","code2":"JP","name":"Japan"},{"code":"+962","code2":"JO","name":"Jordan"},{"code":"+7","code2":"KZ","name":"Kazakhstan"},{"code":"+254","code2":"KE","name":"Kenya"},{"code":"+686","code2":"KI","name":"Kiribati"},{"code":"+965","code2":"KW","name":"Kuwait"},{"code":"+996","code2":"KG","name":"Kyrgyzstan"},{"code":"+856","code2":"LA","name":"Laos"},{"code":"+371","code2":"LV","name":"Latvia"},{"code":"+961","code2":"LB","name":"Lebanon"},{"code":"+266","code2":"LS","name":"Lesotho"},{"code":"+231","code2":"LR","name":"Liberia"},{"code":"+218","code2":"LY","name":"Libya"},{"code":"+423","code2":"LI","name":"Liechtenstein"},{"code":"+370","code2":"LT","name":"Lithuania"},{"code":"+352","code2":"LU","name":"Luxembourg"},{"code":"+853","code2":"MO","name":"Macau SAR China"},{"code":"+389","code2":"MK","name":"Macedonia"},{"code":"+261","code2":"MG","name":"Madagascar"},{"code":"+265","code2":"MW","name":"Malawi"},{"code":"+60","code2":"MY","name":"Malaysia"},{"code":"+960","code2":"MV","name":"Maldives"},{"code":"+223","code2":"ML","name":"Mali"},{"code":"+356","code2":"MT","name":"Malta"},{"code":"+692","code2":"MH","name":"Marshall Islands"},{"code":"+596","code2":"MQ","name":"Martinique"},{"code":"+222","code2":"MR","name":"Mauritania"},{"code":"+230","code2":"MU","name":"Mauritius"},{"code":"+262","code2":"YT","name":"Mayotte"},{"code":"+52","code2":"MX","name":"Mexico"},{"code":"+691","code2":"FM","name":"Micronesia"},{"code":"+373","code2":"MD","name":"Moldova"},{"code":"+377","code2":"MC","name":"Monaco"},{"code":"+976","code2":"MN","name":"Mongolia"},{"code":"+382","code2":"ME","name":"Montenegro"},{"code":"+1664","code2":"MS","name":"Montserrat"},{"code":"+212","code2":"MA","name":"Morocco"},{"code":"+258","code2":"MZ","name":"Mozambique"},{"code":"+95","code2":"MM","name":"Myanmar"},{"code":"+264","code2":"NA","name":"Namibia"},{"code":"+674","code2":"NR","name":"Nauru"},{"code":"+977","code2":"NP","name":"Nepal"},{"code":"+31","code2":"NL","name":"Netherlands"},{"code":"+599","code2":"AN","name":"Netherlands Antilles"},{"code":"+1 869","code2":"KN","name":"Nevis"},{"code":"+687","code2":"NC","name":"New Caledonia"},{"code":"+64","code2":"NZ","name":"New Zealand"},{"code":"+505","code2":"NI","name":"Nicaragua"},{"code":"+227","code2":"NE","name":"Niger"},{"code":"+234","code2":"NG","name":"Nigeria"},{"code":"+683","code2":"NU","name":"Niue"},{"code":"+672","code2":"NF","name":"Norfolk Island"},{"code":"+850","code2":"KP","name":"North Korea"},{"code":"+1 670","code2":"MP","name":"Northern Mariana Islands"},{"code":"+47","code2":"NO","name":"Norway"},{"code":"+968","code2":"OM","name":"Oman"},{"code":"+92","code2":"PK","name":"Pakistan"},{"code":"+680","code2":"PW","name":"Palau"},{"code":"+970","code2":"PS","name":"Palestinian Territory"},{"code":"+507","code2":"PA","name":"Panama"},{"code":"+675","code2":"PG","name":"Papua New Guinea"},{"code":"+595","code2":"PY","name":"Paraguay"},{"code":"+51","code2":"PE","name":"Peru"},{"code":"+63","code2":"PH","name":"Philippines"},{"code":"+64","code2":"PN","name":"Pitcairn Islands"},{"code":"+48","code2":"PL","name":"Poland"},{"code":"+351","code2":"PT","name":"Portugal"},{"code":"+1 787","code2":"PR","name":"Puerto Rico"},{"code":"+974","code2":"QA","name":"Qatar"},{"code":"+262","code2":"RE","name":"Reunion"},{"code":"+40","code2":"RO","name":"Romania"},{"code":"+7","code2":"RU","name":"Russia"},{"code":"+250","code2":"RW","name":"Rwanda"},{"code":"+685","code2":"WS","name":"Samoa"},{"code":"+378","code2":"SM","name":"San Marino"},{"code":"+966","code2":"SA","name":"Saudi Arabia"},{"code":"+221","code2":"SN","name":"Senegal"},{"code":"+381","code2":"RS","name":"Serbia"},{"code":"+248","code2":"SC","name":"Seychelles"},{"code":"+232","code2":"SL","name":"Sierra Leone"},{"code":"+65","code2":"SG","name":"Singapore"},{"code":"+421","code2":"SK","name":"Slovakia"},{"code":"+386","code2":"SI","name":"Slovenia"},{"code":"+677","code2":"SB","name":"Solomon Islands"},{"code":"+27","code2":"ZA","name":"South Africa"},{"code":"+500","code2":"GS","name":"South Georgia and the South Sandwich Islands"},{"code":"+82","code2":"KR","name":"South Korea"},{"code":"+34","code2":"ES","name":"Spain"},{"code":"+94","code2":"LK","name":"Sri Lanka"},{"code":"+249","code2":"SD","name":"Sudan"},{"code":"+597","code2":"SR","name":"Suriname"},{"code":"+268","code2":"SZ","name":"Swaziland"},{"code":"+46","code2":"SE","name":"Sweden"},{"code":"+41","code2":"CH","name":"Switzerland"},{"code":"+963","code2":"SY","name":"Syria"},{"code":"+886","code2":"TW","name":"Taiwan"},{"code":"+992","code2":"TJ","name":"Tajikistan"},{"code":"+255","code2":"TZ","name":"Tanzania"},{"code":"+66","code2":"TH","name":"Thailand"},{"code":"+670","code2":"TL","name":"Timor Leste"},{"code":"+228","code2":"TG","name":"Togo"},{"code":"+690","code2":"TK","name":"Tokelau"},{"code":"+676","code2":"TO","name":"Tonga"},{"code":"+1 868","code2":"TT","name":"Trinidad and Tobago"},{"code":"+216","code2":"TN","name":"Tunisia"},{"code":"+90","code2":"TR","name":"Turkey"},{"code":"+993","code2":"TM","name":"Turkmenistan"},{"code":"+1 649","code2":"TC","name":"Turks and Caicos Islands"},{"code":"+688","code2":"TV","name":"Tuvalu"},{"code":"+1 340","code2":"VI","name":"U.S. Virgin Islands"},{"code":"+256","code2":"UG","name":"Uganda"},{"code":"+380","code2":"UA","name":"Ukraine"},{"code":"+971","code2":"AE","name":"United Arab Emirates"},{"code":"+44","code2":"GB","name":"United Kingdom"},{"code":"+1","code2":"US","name":"United States"},{"code":"+598","code2":"UY","name":"Uruguay"},{"code":"+998","code2":"UZ","name":"Uzbekistan"},{"code":"+678","code2":"VU","name":"Vanuatu"},{"code":"+58","code2":"VE","name":"Venezuela"},{"code":"+84","code2":"VN","name":"Vietnam"},{"code":"+681","code2":"WF","name":"Wallis and Futuna"},{"code":"+967","code2":"YE","name":"Yemen"},{"code":"+260","code2":"ZM","name":"Zambia"},{"code":"+263","code2":"ZW","name":"Zimbabwe"}];
    };
    
    return this.__construct();
};
// source --> https://casalospedroches.es/wp-content/plugins/booking-system/assets/js/jquery.dop.frontend.BSPSearchWidget.js?ver=2.9.9.6.8 

/*
* Title                   : Pinpoint Booking System WordPress Plugin (PRO)
* Version                 : 2.1.1
* File                    : assets/js/jquery.dop.frontend.BSPSearch.js
* File Version            : 1.0.1
* Created / Last Modified : 25 August 2015
* Author                  : Dot on Paper
* Copyright               : © 2012 Dot on Paper
* Website                 : http://www.dotonpaper.net
* Description             : Front end search jQuery plugin.
*/

(function($){
    'use strict';
    
    $.fn.DOPBSPSearchWidget = function(options){
        /*
         * Private variables. 
         */
        var Data = {"availability": {"data": {"enabled": false,
                                              "max": 10,
                                              "min": 1},
                                     "text": {"title": "No. book items"}},
                    "currency": {"data": {"code": "USD",
                                          "position": "before",
                                          "sign": "$"},
                                 "text":{},         
                    "days": {"data": {"first": 1,
                                      "multipleSelect": true},
                             "text": {"names": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
                                      "shortNames": ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]}},
                    "hours": {"data": {"ampm": false,
                                       "definitions": [{"value": "00:00"},{"value": "01:00"},{"value": "02:00"},{"value": "03:00"},{"value": "04:00"},{"value": "05:00"},{"value": "06:00"},{"value": "07:00"},{"value": "08:00"},{"value": "09:00"},{"value": "10:00"},{"value": "11:00"},{"value": "12:00"},{"value": "13:00"},{"value": "14:00"},{"value": "15:00"},{"value": "16:00"},{"value": "17:00"},{"value": "18:00"},{"value": "19:00"},{"value": "20:00"},{"value": "21:00"},{"value": "22:00"},{"value": "23:00"}],
                                       "enabled": false,
                                       "multipleSelect": true},
                              "text": {}},
                    "ID": 0,
                    "REDIRECT_ID": 0,
                    "months": {"data": {},
                               "text": {"names": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
                                        "nextMonth": "Next month",
                                        "previousMonth": "Previous month",
                                        "shortNames": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]}},
                    "price": {"data": {"enabled": true,
                                       "max": 1000,
                                       "min": 0},
                              "text": {}},
                    "search": {"data": {"dateType": 1,
                                        "enabled": false,
                                        "language": 'en',
                                        "template": 'default'},
                               "text": {"checkIn": "Check in",
                                        "checkOut": "Check out",
                                        "hourEnd": "Finish at",
                                        "hourStart": "Start at",
                                        "title": "Search"}},  
                    "sort": {"data": {},
                             "text": {"name": "Name",
                                      "price": "Price",
                                      "title": "Sort by"}},
                    "URL": "",
                    "view": {"data": {"default": "list",
                                      "gridEnabled": false,
                                      "listEnabled": true,
                                      "mapEnabled": false,
                                      "results": 10},
                             "text": {"grid": "Grid view",
                                      "list": "List view",
                                      "map": "Map view"}}}},
                              
        ajaxRequestInProgress,
        ajaxURL = '',
        Container = this,
        ID = 0,
        REDIRECT_ID = 0,
        
// ***************************************************************************** Main methods.

// 1. Main methods.

        methods = {
            init:function(){
                /*
                 * Initialize jQuery plugin.
                 */
                return this.each(function(){
                    if (options){
                        $.extend(Data, options);
                    }

                    methods.parse();
                    $(window).bind('resize.DOPBSPSearchWidget', methods.rp);                          
                });
            },
            parse:function(){
                ajaxURL = prototypes.acaoBuster(Data['URL']);
                
                methods_availability.data = Data['availability']['data'];
                methods_availability.text = Data['availability']['text'];
                
                methods_currency.data = Data['currency']['data'];
                methods_currency.text = Data['currency']['text'];
                
                methods_days.data = Data['days']['data'];
                methods_days.text = Data['days']['text'];
                
                methods_hours.data = Data['hours']['data'];
                methods_hours.text = Data['hours']['text'];
                
                ID = Data['ID'];
                REDIRECT_ID = Data['REDIRECT_ID'];
                
                methods_months.data = Data['months']['data'];
                methods_months.text = Data['months']['text'];
                
                methods_price.data = Data['price']['data'];
                methods_price.text = Data['price']['text'];
                
                methods_search.data = Data['search']['data'];
                methods_search.text = Data['search']['text'];
                
                methods_sort.data = Data['sort']['data'];
                methods_sort.text = Data['sort']['text'];
                
                methods_view.data = Data['view']['data'];
                methods_view.text = Data['view']['text'];
                
                methods_components.init();
            },
            rp:function(){
                var containerW = parseInt($('#DOPBSPSearchWidget'+ID).parent().width()),
                    widgetClass = 'DOPBSPSearchWidget-360';
                
                if(containerW >= 360
                  && containerW <= 740) {
                    widgetClass = 'DOPBSPSearchWidget-360';
                } else if(containerW >= 740
                  && containerW <= 1000) {
                    widgetClass = 'DOPBSPSearchWidget-740';
                } else if(containerW >= 1000
                  && containerW <= 1230) {
                    widgetClass = 'DOPBSPSearchWidget-1000';
                } else if(containerW >= 1230) {
                    widgetClass = 'DOPBSPSearchWidget-1230';
                }
                
                $('#DOPBSPSearchWidget'+ID).removeClass('DOPBSPSearchWidget-360');
                $('#DOPBSPSearchWidget'+ID).removeClass('DOPBSPSearchWidget-740');
                $('#DOPBSPSearchWidget'+ID).removeClass('DOPBSPSearchWidget-1000');
                $('#DOPBSPSearchWidget'+ID).removeClass('DOPBSPSearchWidget-1230');
                $('#DOPBSPSearchWidget'+ID).addClass(widgetClass);
                
            }
        },
                
// 2. Components
        
        methods_components = {
            init:function(){
            /*
             * Initialize search components.
             */ 
                /*
                 * Initialize today date.
                 */
                methods_search.vars.todayDate = new Date();
                methods_search.vars.todayDay = methods_search.vars.todayDate.getDate();
                methods_search.vars.todayMonth = methods_search.vars.todayDate.getMonth()+1;
                methods_search.vars.todayYear = methods_search.vars.todayDate.getFullYear(); 
                
                /*
                 * Initialize map.
                 */
                if (methods_view.data['mapEnabled']){
                    methods_map.load();
                }
                
                /*
                 * Initialize sidebar.
                 */
                methods_sidebar.init();
                methods.rp();
                
                $('#DOPBSPSearchWidget-loader'+ID).remove();
                $(Container).removeClass('DOPBSPSearchWidget-hidden');
                
                methods_search.get();
            }
        },  
                
// 3. Currency
        
        methods_currency = {
            data:{},
            text:{},
            vars: {currencies: {}},
            
            init: function() {
                //methods_currency.parse();
            },
            
            parse: function(){
                var currencies = {};
                
                if (typeof methods_currency.data['currencies'] !== 'undefined') {
                    var currenciesJSON = methods_currency.data['currencies'].replace(new RegExp('"', 'g'), ""),
                        currenciesJSON = currenciesJSON.replace(new RegExp(';;;', 'g'), '"');
                
                        currencies = JSON.parse(currenciesJSON);
                }
            
                methods_currency.vars.currencies = currencies;
                
            },
            
            exchange: function(amount, currency_code, type){ 
                var currencies = methods_currency.vars.currencies;
                //methods_currency.data['sign']
                if (methods_currency.data['code'] !== currency_code) {
                    
                    for (var index in currencies){

                        if (currencies[index]['code'] === currency_code) {
                            
                            if (type === 'exchange') {
                                amount = parseInt(amount*currencies[index]['rate']);
                            } else {
                                amount = parseInt(amount*currencies[index]['inverse']);
                            }
                        }
                    }
                }
                
                return amount;
            }
            
        },   
   
// ***************************************************************************** Search methods.

// 4. Search
        
        methods_search = {
            data: {},
            text: {},
            vars: {todayDate: new Date(),
                   todayDay: new Date(),
                   todayMonth: new Date(),
                   todayYear: new Date()},
            
            init: function(){
                methods_days.init();
                
                if (methods_hours.data['enabled']){
                    methods_hours.init();
                }
                
                if (methods_availability.data['enabled']){
                    methods_availability.init();
                }
                
                methods_check_availability.init();
                
                if (methods_price.data['enabled']){
                    methods_price.init();
                }
                
                methods_sort.init();
                methods_view.init();
            },
            
            get:function(page){
                var $checkIn = $('#DOPBSPSearchWidget-check-in'+ID).val(),
                $checkOut = $('#DOPBSPSearchWidget-check-out'+ID).val(),
                $startHour = $('#DOPBSPSearchWidget-start-hour'+ID).val(),
                $endHour = $('#DOPBSPSearchWidget-end-hour'+ID).val(),
                checkIn = $checkIn === undefined ? '':$checkIn,
                checkOut = $checkOut === undefined || $checkOut === '' ? checkIn:$checkOut,
                startHour = $startHour === undefined ? '':$startHour,
                endHour = $endHour === undefined || $endHour === '' ? startHour:$endHour;
        
                page = page === undefined ? 1:page;
                
                if (ajaxRequestInProgress !== undefined){
                    ajaxRequestInProgress.abort();
                }
                $('#DOPBSPSearchWidget-results-loader'+ID).removeClass('DOPBSPSearchWidget-hidden');
                $('#DOPBSPSearchWidget-results'+ID).html('');
                
                ajaxRequestInProgress = $.post(ajaxURL, {action: 'dopbsp_search_results_get',
                                                         dopbsp_frontend_ajax_request: true,
                                                         id: ID,
                                                         language: methods_search.data['language'],
                                                         check_in: checkIn,
                                                         check_out: checkOut,
                                                         start_hour: startHour,
                                                         end_hour: endHour,
                                                         no_items: $('#DOPBSPSearchWidget-no-items'+ID).val() === undefined ? '':$('#DOPBSPSearchWidget-no-items'+ID).val(),
                                                         price_min: $('#DOPBSPSearchWidget-price-min-value'+ID).val() === undefined ? '':$('#DOPBSPSearchWidget-price-min-value'+ID).val(),
                                                         price_max: $('#DOPBSPSearchWidget-price-max-value'+ID).val() === undefined ? '':$('#DOPBSPSearchWidget-price-max-value'+ID).val(),
                                                         sort_by: $('#DOPBSPSearchWidget-sort-by'+ID).val() === undefined ? 'price':$('#DOPBSPSearchWidget-sort-by'+ID).val(),
                                                         sort_direction: $('#DOPBSPSearchWidget-sort-direction-value'+ID).val() === undefined ? 'ASC':$('#DOPBSPSearchWidget-sort-direction-value'+ID).val(),
                                                         view: $('#DOPBSPSearchWidget-view'+ID).val() === undefined ? 'list':$('#DOPBSPSearchWidget-view'+ID).val(),
                                                         results: methods_view.data['results'],
                                                         page: page}, function(data){
                        data = $.trim(data);
                        
                        switch ($('#DOPBSPSearchWidget-view'+ID).val()){
                            case 'map':
                                methods_map.display(data);
                                break;
                            default:
                                $('#DOPBSPSearchWidget-results-loader'+ID).addClass('DOPBSPSearchWidget-hidden');
                                $('#DOPBSPSearchWidget-results'+ID).html(data);
                                methods_search.events();
                        }
                });
            },
            
            events:function(){
                $('#DOPBSPSearchWidget-results'+ID+' .dopbsp-pagination li').unbind('click');
                $('#DOPBSPSearchWidget-results'+ID+' .dopbsp-pagination li').bind('click', function(){
                    if (!$(this).hasClass('selected')){
                        methods_search.get($(this).attr('class').split('dopbsp-page')[1]);
                    }
                });
            }
        },      
        
// 5. Sidebar
        
        methods_sidebar = {
            data:{},
            text:{},
            
            init:function(){
                methods_search.init();
                
                // $('.dopbsp-search-sidebar-form', Container).isotope({itemSelector: '.dopbsp-module', layoutMode: 'fitRows' });
            }
        },    
                
// 6. Months
        
        methods_months = {
            data:{},
            text:{}
        },
                
// 7. Days
        
        methods_days = {
            data:{},
            text:{},
            
            init:function(){
            /*
             * Initialize sidebar search days.
             */ 
                methods_days.events.init();
            },
            initDatepicker:function(id,
                                    altId,    
                                    minDate){
            /*
             * Initialize sidebar search datepicker.
             * 
             * @param id (String): input(text) field ID
             * @param aldId (String): alternative input(hidden) field ID
             * @param minDate (Number): start date from today
             */                            
                minDate = minDate === undefined ? 0:minDate;  

                $(id).datepicker('destroy');
                $(id).datepicker({altField: altId,
                                  altFormat: 'yy-mm-dd',
                                  beforeShow: function(input, inst){
                                    $('#ui-datepicker-div').removeClass('DOPBSPSearchWidget-datepicker')
                                                           .addClass('DOPBSPSearchWidget-datepicker');
                                  },
                                  dateFormat: methods_search.data['dateType'] === 1 ? 'MM dd, yy':'dd MM yy',
                                  dayNames: methods_days.text['names'],
                                  dayNamesMin: methods_days.text['shortNames'],
                                  firstDay: methods_days.data['first'],
                                  minDate: minDate,
                                  monthNames: methods_months.text['names'],
                                  monthNamesMin: methods_months.text['shortNames'],
                                  nextText: methods_months.text['nextMonth'],
                                  prevText: methods_months.text['previousMonth']});
                $('.ui-datepicker').removeClass('notranslate').addClass('notranslate');
            },
            validate:function(day){
            /*
             * Validate day format.
             * 
             * @param day (String): day format to be verified
             * 
             * @return true if format is "YYYY-MM-DD"
             */    
                var dayPieces = day.split('-');

                if (day === ''
                        || dayPieces.length !== 3
                        || dayPieces[0].length !== 4
                        || dayPieces[1].length !== 2
                        || dayPieces[2].length !== 2){
                    return false;
                }
                else{
                    return true;
                }
            },

            events: {
                init:function(){
                /*
                 * Initialize sidebar search days events.
                 */    
                    /*
                     * Initialize check in datepicker.
                     */
                    methods_days.initDatepicker('#DOPBSPSearchWidget-check-in-view'+ID,
                                                       '#DOPBSPSearchWidget-check-in'+ID);
                    methods_days.events.checkIn();

                    if (methods_days.data['multipleSelect']){
                        /*
                         * Initialize check out datepicker.
                         */
                        methods_days.initDatepicker('#DOPBSPSearchWidget-check-out-view'+ID,
                                                           '#DOPBSPSearchWidget-check-out'+ID);
                        methods_days.events.checkOut();
                    }
                },
                checkIn:function(){
                /*
                 * Initialize sidebar search days events when multiple days need to be selected.
                 */
                    /*
                     * Check in click event.
                     */
                    $('#DOPBSPSearchWidget-check-in-view'+ID).unbind('click');
                    $('#DOPBSPSearchWidget-check-in-view'+ID).bind('click', function(){
                        $(this).val('');
                        $('#DOPBSPSearchWidget-check-in'+ID).val('');

                    });

                    /*
                     * Check in blur event.
                     */
                    $('#DOPBSPSearchWidget-check-in-view'+ID).unbind('blur');
                    $('#DOPBSPSearchWidget-check-in-view'+ID).bind('blur', function(){  
                        var $this = $(this);

                        if ($this.val() === ''){
                            $this.val(methods_search.text['checkIn']);
                            $('#DOPBSPSearchWidget-check-in'+ID).val('');
                        }
                    });

                    /*
                     * Check in change event.
                     */
                    $('#DOPBSPSearchWidget-check-in-view'+ID).unbind('change');
                    $('#DOPBSPSearchWidget-check-in-view'+ID).bind('change', function(){
                        var ciDay = $('#DOPBSPSearchWidget-check-in'+ID).val(),
                        minDateValue;

                        if (methods_days.validate(ciDay)){
                            if (methods_days.data['multipleSelect']){
                                minDateValue = prototypes.getNoDays(prototypes.getToday(), ciDay)-1;

                                methods_days.initDatepicker('#DOPBSPSearchWidget-check-out-view'+ID,
                                                            '#DOPBSPSearchWidget-check-out'+ID,
                                                            minDateValue);

                                if (($('#DOPBSPSearchWidget-check-in'+ID).val() > $('#DOPBSPSearchWidget-check-out'+ID).val()
                                                && $('#DOPBSPSearchWidget-check-out'+ID).val() !== '')
                                        || $('#DOPBSPSearchWidget-check-out'+ID).val() === ''){
                                    setTimeout(function(){
                                        $('#DOPBSPSearchWidget-check-out-view'+ID).val('')
                                                                              .select();  
                                        $('#DOPBSPSearchWidget-check-out'+ID).val('');
                                    }, 100);
                                }
                                else{
                                    methods_search.get();
                                }
                            }
                            else{
                                methods_search.get();
                            }
                        }
                        else{
                            $('#DOPBSPSearchWidget-check-in-view'+ID).val(methods_search.text['checkIn']);
                            $('#DOPBSPSearchWidget-check-in'+ID).val('');
                        }
                    });
                },
                checkOut:function(){
                    /*
                     * Check out click event.
                     */
                    $('#DOPBSPSearchWidget-check-out-view'+ID).unbind('click');
                    $('#DOPBSPSearchWidget-check-out-view'+ID).bind('click', function(){  
                        $(this).val(''); 
                        $('#DOPBSPSearchWidget-check-out'+ID).val('');
                    });

                    /*
                     * Check out blur event.
                     */
                    $('#DOPBSPSearchWidget-check-out-view'+ID).unbind('blur');
                    $('#DOPBSPSearchWidget-check-out-view'+ID).bind('blur', function(){ 
                        var $this = $(this);

                        if ($this.val() === ''){
                            $this.val(methods_search.text['checkOut']);
                            $('#DOPBSPSearchWidget-check-out'+ID).val('');
                        }
                    });

                    /*
                     * Check out change event.
                     */
                    $('#DOPBSPSearchWidget-check-out-view'+ID).unbind('change');
                    $('#DOPBSPSearchWidget-check-out-view'+ID).bind('change', function(){
                        var coDay = $('#DOPBSPSearchWidget-check-out'+ID).val();
                        
                        if (methods_days.validate(coDay)){
                            if ($('#DOPBSPSearchWidget-check-in'+ID).val() !== ''){
                                methods_search.get();
                            }
                        }
                        else{
                            $('#DOPBSPSearchWidget-check-out-view'+ID).val(methods_search.text['checkOut']);
                            $('#DOPBSPSearchWidget-check-out'+ID).val('');
                        }
                    });
                }
            }
        },
                
// 8. Hours
        
        methods_hours = {
            data:{},
            text:{},
                
            init:function(){
                $('#DOPBSPSearchWidget-start-hour'+ID).DOPSelect();

                if (methods_hours.data['multipleSelect']){
                    $('#DOPBSPSearchWidget-end-hour'+ID).DOPSelect();
                }
                methods_hours.events();
            },
            set:function(){
                var HTML = new Array(),
                hours = methods_hours.data['definitions'],
                i,
                startHour = $('#DOPBSPSearchWidget-start-hour'+ID).val(),
                endHour = $('#DOPBSPSearchWidget-end-hour'+ID).val();

                HTML.push('<select id="DOPBSPSearchWidget-end-hour'+ID+'" class="dopbsp-small">');

                for (i=0; i<hours.length; i++){
                    if (startHour <= hours[i]['value']){
                        HTML.push('     <option value="'+hours[i]['value']+'"'+(endHour === hours[i]['value'] ? ' selected="selected"':'')+'>'+prototypes.getAMPM(hours[i]['value'])+'</option>');
                    }
                }
                HTML.push('</select>');

                $('#DOPSelect-DOPBSPSearchWidget-end-hour'+ID).replaceWith(HTML.join());
                $('#DOPBSPSearchWidget-end-hour'+ID).DOPSelect();
                methods_hours.events();
            },

            events:function(){
                $('#DOPBSPSearchWidget-start-hour'+ID).unbind('change');
                $('#DOPBSPSearchWidget-start-hour'+ID).bind('change',function(){
                    if (methods_hours.data['multipleSelect']){
                        methods_hours.set();
                    }
                    methods_search.get();
                });

                if (methods_hours.data['multipleSelect']){
                    $('#DOPBSPSearchWidget-end-hour'+ID).unbind('change');
                    $('#DOPBSPSearchWidget-end-hour'+ID).bind('change',function(){
                        if ($('#DOPBSPSearchWidget-start-hour'+ID).val() !== ''){
                            methods_search.get();
                        }
                    });
                }
            }
        },
                
// 9. No items.
        
        methods_availability = {
            data:{},
            text:{},
            
            init:function(){
                $('#DOPBSPSearchWidget-no-items'+ID).DOPSelect();
                methods_availability.events();
            },

            events:function(){
                $('#DOPBSPSearchWidget-no-items'+ID).unbind('change');
                $('#DOPBSPSearchWidget-no-items'+ID).bind('change',function(){
                    methods_search.get();
                });
            }
        },
                
// 11. Check Availability         
                
        methods_check_availability = {
            data:{},
            text:{},
            
            init:function(){
                $('#DOPBSPSearchWidget-check-availability'+ID).unbind('click');
                $('#DOPBSPSearchWidget-check-availability'+ID).bind('click', function(){
                    var $checkIn = $('#DOPBSPSearchWidget-check-in'+ID).val(),
                    $checkOut = $('#DOPBSPSearchWidget-check-out'+ID).val(),
                    $startHour = $('#DOPBSPSearchWidget-start-hour'+ID).val(),
                    $endHour = $('#DOPBSPSearchWidget-end-hour'+ID).val(),
                    checkIn = $checkIn === undefined ? '':$checkIn,
                    checkOut = $checkOut === undefined || $checkOut === '' ? checkIn:$checkOut,
                    startHour = $startHour === undefined ? '':$startHour,
                    endHour = $endHour === undefined || $endHour === '' ? startHour:$endHour,
                    no_items = $('#DOPBSPSearchWidget-no-items'+ID).val();
                    $('#DOPBSPSearchWidget-error'+ID).remove();
                    
                    $.post(ajaxURL, {action: 'dopbsp_search_widget_get',
                                     dopbsp_frontend_ajax_request: true,
                                     id: ID,
                                     redirect_id: REDIRECT_ID,
                                     language: methods_search.data['language'],
                                     check_in: checkIn,
                                     check_out: checkOut,
                                     start_hour: startHour,
                                     end_hour: endHour,
                                     no_items: no_items
                                     }, function(data){
                        data = $.trim(data);
                        
                        if(data === 'no_data') {
                            $('#DOPBSPSearchWidget-check-availability'+ID).parent().after('<div class="dopbsp-input-wrapper"><div id="DOPBSPSearchWidget-error'+ID+'" class="dopbsp-error">No services available, please choose other dates.</div></div>');
						} 
                        else {
                            window.location.href = data;
                        }
                    });
                });
            }
        },
                
                
                
// 12. Price         
                
        methods_price = {
            data:{},
            text:{},
            
            init:function(){
                $('#DOPBSPSearchWidget-price'+ID).slider({max: methods_price.data['max'],
                                                    min: methods_price.data['min'],
                                                    values: [methods_price.data['min'], methods_price.data['max']],
                                                    range: true,
                                                    step: 0.1,
                                                    create:function(event, ui){
                                                        $('#DOPBSPSearchWidget-price-min'+ID).html(methods_price.set(methods_price.data['min']));
                                                        $('#DOPBSPSearchWidget-price-max'+ID).html(methods_price.set(methods_price.data['max']));
                                                        
                                                        $('#DOPBSPSearchWidget-price-min-value'+ID).val(methods_price.data['min']);
                                                        $('#DOPBSPSearchWidget-price-max-value'+ID).val(methods_price.data['max']);
                                                    },
                                                    slide:function(event, ui){
                                                        $('#DOPBSPSearchWidget-price-min'+ID).html(methods_price.set(ui.values[0]));
                                                        $('#DOPBSPSearchWidget-price-max'+ID).html(methods_price.set(ui.values[1]));
                                                        
                                                        $('#DOPBSPSearchWidget-price-min-value'+ID).val(ui.values[0]);
                                                        $('#DOPBSPSearchWidget-price-max-value'+ID).val(ui.values[1]);
                                                    },
                                                    stop:function(event, ui){
                                                        methods_search.get();
                                                    }});
            },
            
            set:function(price){
            /*
             * Display price with currency in set format.
             * 
             * @param price (Number): price value
             * 
             * @return price with currency
             */ 
                var priceDisplayed = '';
                
                price = prototypes.getWithDecimals(Math.abs(price), 
                                                   2);
                                                   
                switch (methods_currency.data['position']){
                    case 'after':
                        priceDisplayed =  price+methods_currency.data['sign'];
                        break;
                    case 'after_with_space':
                        priceDisplayed =  price+' '+methods_currency.data['sign'];
                        break;
                    case 'before_with_space':
                        priceDisplayed =  methods_currency.data['sign']+' '+price;
                        break;
                    default:
                        priceDisplayed = methods_currency.data['sign']+price;
                }
                
                return priceDisplayed;
            }
        },   
                
// 13. Sort
        
        methods_sort = {
            data:{},
            text:{},
            
            init:function(){
                $('#DOPBSPSearchWidget-sort-by'+ID).DOPSelect();
                methods_sort.events();
            },

            events: function(){
                $('#DOPBSPSearchWidget-sort-by'+ID).unbind('change');
                $('#DOPBSPSearchWidget-sort-by'+ID).bind('change',function(){
                    methods_search.get();
                });

                $('#DOPBSPSearchWidget-sort-direction'+ID).unbind('click');
                $('#DOPBSPSearchWidget-sort-direction'+ID).bind('click',function(){
                    if ($(this).hasClass('dopbsp-asc')){
                        $(this).removeClass('dopbsp-asc')
                               .addClass('dopbsp-desc');
                        $('#DOPBSPSearchWidget-sort-direction-value'+ID).val('DESC');
                    }
                    else{
                        $(this).removeClass('dopbsp-desc')
                               .addClass('dopbsp-asc');
                        $('#DOPBSPSearchWidget-sort-direction-value'+ID).val('ASC');
                    }
                    methods_search.get();
                });
            }
        },
                
// 14. View
        
        methods_view = {
            data:{},
            text:{},
            
            init:function(){
                methods_view.events();
            },
            
            events:function(){
                if (methods_view.data['listEnabled']){
                    $('#DOPBSPSearchWidget-view-list'+ID).unbind('click');
                    $('#DOPBSPSearchWidget-view-list'+ID).bind('click',function(){
                        if (!$(this).hasClass('dopbsp-selected')){
                            methods_view.data['gridEnabled'] ? $('#DOPBSPSearchWidget-view-grid'+ID).removeClass('dopbsp-selected'):'';
                            methods_view.data['mapEnabled'] ? $('#DOPBSPSearchWidget-view-map'+ID).removeClass('dopbsp-selected'):'';
                            $(this).addClass('dopbsp-selected');
                            
                            $('#DOPBSPSearchWidget-view'+ID).val('list');
                            methods_search.get();
                        }
                    });
                }
                
                if (methods_view.data['gridEnabled']){
                    $('#DOPBSPSearchWidget-view-grid'+ID).unbind('click');
                    $('#DOPBSPSearchWidget-view-grid'+ID).bind('click',function(){
                        if (!$(this).hasClass('dopbsp-selected')){
                            methods_view.data['listEnabled'] ? $('#DOPBSPSearchWidget-view-list'+ID).removeClass('dopbsp-selected'):'';
                            methods_view.data['mapEnabled'] ? $('#DOPBSPSearchWidget-view-map'+ID).removeClass('dopbsp-selected'):'';
                            $(this).addClass('dopbsp-selected');
                            
                            $('#DOPBSPSearchWidget-view'+ID).val('grid');
                            methods_search.get();
                        }
                    });
                }
                
                if (methods_view.data['mapEnabled']){
                    $('#DOPBSPSearchWidget-view-map'+ID).unbind('click');
                    $('#DOPBSPSearchWidget-view-map'+ID).bind('click',function(){
                        if (!$(this).hasClass('dopbsp-selected')){
                            methods_view.data['listEnabled'] ? $('#DOPBSPSearchWidget-view-list'+ID).removeClass('dopbsp-selected'):'';
                            methods_view.data['gridEnabled'] ? $('#DOPBSPSearchWidget-view-grid'+ID).removeClass('dopbsp-selected'):'';
                            $(this).addClass('dopbsp-selected');
                            
                            $('#DOPBSPSearchWidget-view'+ID).val('map');
                            methods_search.get();
                        }
                    });
                }
            }
        },
                
// 15. Map
        
        methods_map = {
            vars:{locations: new Array(),
                  map: null},
            
            load:function(){
                if (typeof google !== 'object' 
                        || typeof google.maps !== 'object'){
                    var script = document.createElement('script');
                    
                    script.type = 'text/JavaScript';
                    script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&callback=DOPBSPSearchWidgetLoadInfobox';
                    
                    $('body').append(script);
                }
                else{
                    DOPBSPSearchWidgetLoadInfobox();
                }
            },
            
            display:function(data){
                var HTML = new Array();
                if (typeof google === 'object' 
                        && typeof google.maps === 'object'
                        && typeof InfoBox === 'function'){
                    methods_map.vars.locations = JSON.parse(data.split(';;;;;')[0]);
                    
                    HTML.push('<div id="DOPBSPSearchWidget-results-map'+ID+'" class="dopbsp-map"></div>');
                    HTML.push(data.split(';;;;;')[1]);
                    
                    $('#DOPBSPSearchWidget-results-loader'+ID).addClass('DOPBSPSearchWidget-hidden');
                    $('#DOPBSPSearchWidget-results'+ID).html(HTML.join(''));
                    
                    methods_search.events();
                    
                    setTimeout(function(){
                        google.maps.event.addDomListener(window, 'load', methods_map.init());
                    }, 100);
                }
                else{
                    setTimeout(function(){
                        methods_map.display();
                    }, 500);
                }
                
            },
            init:function(){
                var //$coordinates = $('#DOPBSP-location-coordinates').val(),
                //coordinates = $coordinates === undefined || $coordinates === '' || $coordinates === ' ' ? [0, 0]:JSON.parse($coordinates),
                options;
               // zoom = coordinates[0] === 0 && coordinates[1] === 0  ? 2:17;

                options = {center: new google.maps.LatLng(0, 0),
                           mapTypeId: google.maps.MapTypeId.ROADMAP,
                           zoom: 2};
                /*
                 * Create the map
                 */          
                methods_map.vars.map = new google.maps.Map(document.getElementById('DOPBSPSearchWidget-results-map'+ID), options);

//                DOPBSPLocationMapMarker.set(map,
//                                            coordinates);
                methods_map.set();
            },
            set:function(){
                var bounds = new google.maps.LatLngBounds(),
                coordinates,
                icon = new google.maps.MarkerImage(Data['pluginURL']+'templates/'+methods_search.data['template']+'/images/marker.png',
                                                   new google.maps.Size(36, 52),
                                                   new google.maps.Point(1, 0),
                                                   new google.maps.Point(18, 52)),
                i,
                locations = methods_map.vars.locations,
                markers = new Array(),
                position = new Array(),
                shadow = new google.maps.MarkerImage(Data['pluginURL']+'templates/'+methods_search.data['template']+'/images/marker.png',
                                                     new google.maps.Size(36, 52),
                                                     new google.maps.Point(1, 0),
                                                     new google.maps.Point(18, 52)),
                shape = {coord: [0, 0, 36, 0, 36, 52, 0, 52],
                         type: 'poly'};
                     
                for (i=0; i<locations.length; i++){
                    coordinates = JSON.parse(locations[i]['coordinates']);
                    position = new google.maps.LatLng(coordinates[0], coordinates[1]);
                    bounds.extend(position);
                    
                    markers[i] = new google.maps.Marker({animation: null,
                                                         clickable: true,
                                                         draggable: false,
                                                         icon: icon,
                                                         map: methods_map.vars.map,
                                                         position: position,
                                                         shadow: shadow,
                                                         shape: shape});

                    markers[i].info = new InfoBox({alignBottom: true,
                                                   boxClass: 'dopbsp-infobox',
                                                   closeBoxMargin: '0px',
                                                   closeBoxURL: Data['pluginURL']+'templates/'+methods_search.data['template']+'/images/close.png',
                                                   disableAutoPan: false,
                                                   content: methods_map.get(locations[i]['calendars'], i),
                                                   isHidden: false,
                                                   infoBoxClearance: new google.maps.Size(20, 20),
                                                   pixelOffset: new google.maps.Size(-190, -60),
                                                   position: position});
                                               
                    markers[i].index = i;
                                               
                    google.maps.event.addListener(markers[i], 'click', function(){
                        var index = this.index;
                        
                        for (i=0; i<locations.length; i++){
                            markers[i].info.close();
                        }
                        this.info.open(methods_map.vars.map, this);
                        
                        setTimeout(function(){
                            methods_map.events(index);
                        }, 100);
                    });
                }
                methods_map.vars.map.fitBounds(bounds);
            },
            
            get:function(calendars,
                         index){
                var HTML = new Array(),
                i;
                
                HTML.push('<ul class="dopbsp-locations" id="DOPBSPSearchWidget-locations-'+ID+'-'+index+'">');
                
                for (i=0; i<calendars.length; i++){
                    HTML.push('<li>');
                    HTML.push('     <div class="dopbsp-image">');
                    HTML.push('         <a href="'+calendars[i]['link']+'" target="_self" style="background-image: url('+calendars[i]['image']+');">');
                    HTML.push('             <img src="'+calendars[i]['image']+'" alt="'+calendars[i]['name']+'" title="'+calendars[i]['name']+'" />');
                    HTML.push('         </a>');
                    HTML.push('     </div>');
                    HTML.push('     <div class="dopbsp-content">');
                    HTML.push('         <h3>');
                    HTML.push('             <a href="'+calendars[i]['link']+'" target="_self">'+calendars[i]['name']+'</a>');
                    HTML.push('         </h3>');
                    HTML.push('         <div class="dopbsp-address">'+(calendars[i]['address_alt'] === '' ? calendars[i]['address']:calendars[i]['address_alt'])+'</div>');
                    HTML.push('         <div class="dopbsp-price-wrapper">'+calendars[i]['price']+'</div>');
                    HTML.push('     </div>');
                    HTML.push('</li>');
                }
                HTML.push('</ul>');
                
                if (calendars.length > 1){
                    HTML.push('<div class="dopbsp-navigation" id="DOPBSPSearchWidget-locations-navigation-'+ID+'-'+index+'">');
                    HTML.push('     <a href="javascript:void(0)" class="dopbsp-prev dopbsp-disabled"></a>');
                    HTML.push('     <a href="javascript:void(0)" class="dopbsp-next"></a>');
                    HTML.push('</div>');
                }
                
                return HTML.join('');
            },
            
            events:function(i){
                $('#DOPBSPSearchWidget-locations-navigation-'+ID+'-'+i+' .dopbsp-prev').unbind('click');
                $('#DOPBSPSearchWidget-locations-navigation-'+ID+'-'+i+' .dopbsp-prev').bind('click', function(){
                    var $this = $(this),
                    id = $this.parent().attr('id').split('DOPBSPSearchWidget-locations-navigation-')[1],
                    $li = $('#DOPBSPSearchWidget-locations-'+id+' li:first-child');
                    
                    if (!$this.hasClass('dopbsp-disabled')){
                        $('#DOPBSPSearchWidget-locations-navigation-'+ID+'-'+i+' .dopbsp-next').removeClass('dopbsp-disabled');
                        $li.css('margin-top', parseInt($li.css('margin-top'))+($li.height()+parseInt($li.css('margin-bottom'))));
                        
                        setTimeout(function(){
                            if (parseInt($li.css('margin-top')) >= 0){
                                $this.addClass('dopbsp-disabled');
                            }
                        }, 150);
                    }
                });
                
                $('#DOPBSPSearchWidget-locations-navigation-'+ID+'-'+i+' .dopbsp-next').unbind('click');
                $('#DOPBSPSearchWidget-locations-navigation-'+ID+'-'+i+' .dopbsp-next').bind('click', function(){
                    var $this = $(this),
                    id = $this.parent().attr('id').split('DOPBSPSearchWidget-locations-navigation-')[1],
                    $li = $('#DOPBSPSearchWidget-locations-'+id+' li:first-child'),
                    locations = methods_map.vars.locations;
                    
                    if (!$this.hasClass('dopbsp-disabled')){
                        $('#DOPBSPSearchWidget-locations-navigation-'+ID+'-'+i+' .dopbsp-prev').removeClass('dopbsp-disabled');
                        $li.css('margin-top', parseInt($li.css('margin-top'))-($li.height()+parseInt($li.css('margin-bottom'))));
                        
                        setTimeout(function(){
                            if (-1*parseInt($li.css('margin-top')) >= ($li.height()+parseInt($li.css('margin-bottom')))*(locations.length-1)){
                                $this.addClass('dopbsp-disabled');
                            }
                        }, 150);
                    }
                });
            }
        },

// ***************************************************************************** Prototypes
        
// 14. Prototypes

        prototypes = {
// Actions                  
            doHiddenBuster:function(item){
            /*
             * Make all parents & current item visible.
             * 
             * @param item (element): item for which all parens are going to be made visible
             * 
             * @return list of parents
             */
                var parent = item.parent(),
                items = new Array();

                if (item.prop('tagName') !== undefined 
                        && item.prop('tagName').toLowerCase() !== 'body'){
                    items = prototypes.doHiddenBuster(parent);
                }

                if (item.css('display') === 'none'){
                    item.css('display', 'block');
                    items.push(item);
                }

                return items;
            },
            undoHiddenBuster:function(items){
            /*
             * Hide all items from list. The list is returned by function doHiddenBuster().
             * 
             * @param items (Array): list of items to be hidden
             */    
                var i;

                for (i=0; i<items.length; i++){
                    items[i].css('display', 'none');
                }
            },
            openLink:function(url,
                              target){
            /*
             * Open a link.
             * 
             * @param url (String): link URL
             * @param target (String): link target (_blank, _parent, _self, _top)
             */
                switch (target.toLowerCase()){
                    case '_blank':
                        window.open(url);
                        break;
                    case '_parent':
                        parent.location.href = url;
                        break;
                    case '_top':
                        top.location.href = url;
                        break;
                    default:    
                        window.location = url;
                }
            },
            randomizeArray:function(theArray){
            /*
             * Randomize the items of an array.
             * 
             * @param theArray (Array): the array to be mixed
             * 
             * return array with mixed items
             */
                theArray.sort(function(){
                    return 0.5-Math.random();
                });
                return theArray;
            },
            scrollToY:function(position,
                               speed){
            /*
             * Scroll vertically to position.
             * 
             * @param position (Number): position to scroll to
             * @param speed (Number): scroll speed 
             */  
                speed = speed !== undefined ? speed: 300;

                $('html').stop(true, true)
                         .animate({'scrollTop': position}, 
                                  speed);
                $('body').stop(true, true)
                         .animate({'scrollTop': position}, 
                                  speed);
            },
            touchNavigation:function(parent,
                                     child){
            /*
             * One finger navigation for touchscreen devices.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             */
                var prevX, 
                prevY, 
                currX, 
                currY, 
                touch, 
                childX, 
                childY;

                parent.bind('touchstart', function(e){
                    touch = e.originalEvent.touches[0];
                    prevX = touch.clientX;
                    prevY = touch.clientY;
                });

                parent.bind('touchmove', function(e){                                
                    touch = e.originalEvent.touches[0];
                    currX = touch.clientX;
                    currY = touch.clientY;
                    childX = currX>prevX ? parseInt(child.css('margin-left'))+(currX-prevX):parseInt(child.css('margin-left'))-(prevX-currX);
                    childY = currY>prevY ? parseInt(child.css('margin-top'))+(currY-prevY):parseInt(child.css('margin-top'))-(prevY-currY);

                    if (childX < (-1)*(child.width()-parent.width())){
                        childX = (-1)*(child.width()-parent.width());
                    }
                    else if (childX > 0){
                        childX = 0;
                    }
                    else{                                    
                        e.preventDefault();
                    }

                    if (childY < (-1)*(child.height()-parent.height())){
                        childY = (-1)*(child.height()-parent.height());
                    }
                    else if (childY > 0){
                        childY = 0;
                    }
                    else{                                    
                        e.preventDefault();
                    }

                    prevX = currX;
                    prevY = currY;

                    if (parent.width() < child.width()){
                        child.css('margin-left', childX);
                    }

                    if (parent.height() < child.height()){
                        child.css('margin-top', childY);
                    }
                });

                parent.bind('touchstart', function(e){
                    if (!prototypes.isChromeMobileBrowser()){
                        e.preventDefault();
                    }
                });
            },

// Browsers & devices
            isAndroid:function(){
            /*
             * Check if operating system is Android.
             * 
             * @return true/false
             */
                var isAndroid = false,
                agent = navigator.userAgent.toLowerCase();

                if (agent.indexOf('android') !== -1){
                    isAndroid = true;
                }
                return isAndroid;
            },
            isChromeMobileBrowser:function(){
            /*
             * Check if browser is Chrome on mobile..
             * 
             * @return true/false
             */
                var isChromeMobile = false,
                agent = navigator.userAgent.toLowerCase();

                if ((agent.indexOf('chrome') !== -1 
                                || agent.indexOf('crios') !== -1) 
                        && prototypes.isTouchDevice()){
                    isChromeMobile = true;
                }
                return isChromeMobile;
            },
            isIE8Browser:function(){
            /*
             * Check if browser is IE8.
             * 
             * @return true/false
             */
                var isIE8 = false,
                agent = navigator.userAgent.toLowerCase();

                if (agent.indexOf('msie 8') !== -1){
                    isIE8 = true;
                }
                return isIE8;
            },
            isIEBrowser:function(){
            /*
             * Check if browser is IE..
             * 
             * @return true/false
             */
                var isIE = false,
                agent = navigator.userAgent.toLowerCase();

                if (agent.indexOf('msie') !== -1){
                    isIE = true;
                }
                return isIE;
            },
            isTouchDevice:function(){
            /*
             * Detect touchscreen devices.
             * 
             * @return true/false
             */
                var os = navigator.platform;

                if (os.toLowerCase().indexOf('win') !== -1){
                    return window.navigator.msMaxTouchPoints;
                }
                else {
                    return 'ontouchstart' in document;
                }
            },

// Cookies
            deleteCookie:function(name,
                                  path,
                                  domain){
            /*
             * Delete cookie.
             * 
             * @param name (String): cookie name
             * @param path (String): cookie path
             * @param domain (String): cookie domain
             */
                if (prototypes.getCookie(name)){
                    document.cookie = name+'='+((path) ? ';path='+path:'')+((domain) ? ';domain='+domain:'')+';expires=Thu, 01-Jan-1970 00:00:01 GMT';
                }
            },
            getCookie:function(name){
            /*
             * Get cookie.
             * 
             * @param name (String): cookie name
             */    
                var namePiece = name+"=",
                cookie = document.cookie.split(";"),
                i;

                for (i=0; i<cookie.length; i++){
                    var cookiePiece = cookie[i];

                    while (cookiePiece.charAt(0) === ' '){
                        cookiePiece = cookiePiece.substring(1, cookiePiece.length);            
                    } 

                    if (cookiePiece.indexOf(namePiece) === 0){
                        return unescape(cookiePiece.substring(namePiece.length, cookiePiece.length));
                    } 
                }
                return null;
            },
            setCookie:function(name,
                               value,
                               expire){
            /*
             * Set cookie.
             * 
             * @param name (String): cookie name
             * @param value (String): cookie value
             * @param expire (String): the number of days after which the cookie will expire
             */
                var expirationDate = new Date();

                expirationDate.setDate(expirationDate.getDate()+expire);
                document.cookie = name+'='+escape(value)+((expire === null) ? '': ';expires='+expirationDate.toUTCString())+';javahere=yes;path=/';
            },

// Date & time          
            getAMPM:function(time){
            /*
             * Converts time to AM/PM format.
             *
             * @param time (String): the time that will be converted (HH:MM)
             *
             * @return time to AM/PM format
             */
                var hour = parseInt(time.split(':')[0], 10),
                minutes = time.split(':')[1],
                result = '';

                if (hour === 0){
                    result = '12';
                }
                else if (hour > 12){
                    result = prototypes.getLeadingZero(hour-12);
                }
                else{
                    result = prototypes.getLeadingZero(hour);
                }

                result += ':'+minutes+' '+(hour < 12 ? 'AM':'PM');

                return result;
            },
            getDatesDifference:function(date1,
                                        date2,
                                        type,
                                        valueType,
                                        noDecimals){
            /*
             * Returns difference between 2 dates.
             * 
             * @param date1 (Date): first date (YYYY-MM-DD)
             * @param date2 (Date): second date (YYYY-MM-DD)
             * @param type (String): diference type
             *                       "seconds"
             *                       "minutes"
             *                       "hours"
             *                       "days"
             * @param valueType (String): type of number returned
             *                            "float"
             *                            "integer"
             * @param noDecimals (Number): number of decimals returned with the float value (-1 to display all decimals)
             * 
             * @return dates diference
             */
                var y1 = date1.split('-')[0],
                m1 = date1.split('-')[1],
                d1 = date1.split('-')[2],
                y2 = date2.split('-')[0],
                m2 = date2.split('-')[1],
                d2 = date2.split('-')[2],
                time1 = (new Date(y1, m1-1, d1)).getTime(),
                time2 = (new Date(y2, m2-1, d2)).getTime(),
                diff = Math.abs(time1-time2);
        
                if (type === undefined){
                    type = 'seconds';
                }
                
                if (valueType === undefined){
                    valueType = 'float';
                }
                
                if (noDecimals === undefined){
                    noDecimals = -1;
                }
                
                switch (type){
                    case 'days':
                        diff = diff/(1000*60*60*24);
                        break;
                    case 'hours':
                        diff = diff/(1000*60*60);
                        break;
                    case 'minutes':
                        diff = diff/(1000*60);
                        break;
                    default:
                        diff = diff/(1000);
                }
                
                if (valueType === 'float'){
                    return noDecimals === -1 ? diff:prototypes.getWithDecimals(diff, noDecimals);
                }
                else{
                    return Math.ceil(diff);
                }
            },
            getHoursDifference:function(hour1,
                                        hour2,
                                        type,
                                        valueType,
                                        noDecimals){
            /*
             * Returns difference between 2 hours.
             * 
             * @param hour1 (Date): first hour (HH:MM, HH:MM:SS)
             * @param hour2 (Date): second hour (HH:MM, HH:MM:SS)
             * @param type (String): diference type
             *                       "seconds"
             *                       "minutes"
             *                       "hours"
             * @param valueType (String): type of number returned
             *                            "float"
             *                            "integer"
             * @param noDecimals (Number): number of decimals returned with the float value (-1 to display all decimals)
             * 
             * @return hours difference
             */
                var hours1 = parseInt(hour1.split(':')[0], 10),
                minutes1 = parseInt(hour1.split(':')[1], 10),
                seconds1 = hour1.split(':')[2] !== undefined ? parseInt(hour1.split(':')[2], 10):0,
                hours2 = parseInt(hour2.split(':')[0], 10),
                minutes2 = parseInt(hour2.split(':')[1], 10),
                seconds2 = hour2.split(':')[2] !== undefined ? parseInt(hour2.split(':')[2], 10):0,
                time1,
                time2,
                diff;
        
                if (type === undefined){
                    type = 'seconds';
                }
                
                if (valueType === undefined){
                    valueType = 'float';
                }
                
                if (noDecimals === undefined){
                    noDecimals = -1;
                }
                
                switch (type){
                    case 'hours':
                        time1 = hours1+minutes1/60+seconds1/60/60;
                        time2 = hours2+minutes2/60+seconds2/60/60;
                        break;
                    case 'minutes':
                        time1 = hours1*60+minutes1+seconds1/60;
                        time2 = hours2*60+minutes2+seconds2/60;
                        break;
                    default:
                        time1 = hours1*60*60+minutes1*60+seconds1;
                        time2 = hours2*60*60+minutes2*60+seconds2;
                }
                
                diff = Math.abs(time1-time2);
                
                if (valueType === 'float'){
                    return noDecimals === -1 ? diff:prototypes.getWithDecimals(diff, noDecimals);
                }
                else{
                    return Math.ceil(diff);
                }
            },
            getNextDay:function(date){
            /*
             * Returns next day.
             * 
             * @param date (Date): current date (YYYY-MM-DD)
             * 
             * @return next day (YYYY-MM-DD)
             */
                var nextDay = new Date(),
                parts = date.split('-');

                nextDay.setFullYear(parts[0], parts[1], parts[2]);
                nextDay.setTime(nextDay.getTime()+86400000);

                return nextDay.getFullYear()+'-'+prototypes.getLeadingZero(nextDay.getMonth())+'-'+prototypes.getLeadingZero(nextDay.getDate());
            },
            getNoDays:function(date1,
                               date2){
            /*
             * Returns number of days between 2 dates.
             * 
             * @param date1 (Date): first date (YYYY-MM-DD)
             * @param date2 (Date): second date (YYYY-MM-DD)
             * 
             * @return number of days
             */
                var y1 = date1.split('-')[0],
                m1 = date1.split('-')[1],
                d1 = date1.split('-')[2],
                y2 = date2.split('-')[0],
                m2 = date2.split('-')[1],
                d2 = date2.split('-')[2],
                time1 = (new Date(y1, m1-1, d1)).getTime(),
                time2 = (new Date(y2, m2-1, d2)).getTime(),
                diff = Math.abs(time1-time2);
        
                return Math.round(diff/(1000*60*60*24))+1;
            },
            getPrevDay:function(date){
            /*
             * Returns previous day.
             * 
             * @param date (Date): current date (YYYY-MM-DD)
             * 
             * @return previous day (YYYY-MM-DD)
             */
                var previousDay = new Date(),
                parts = date.split('-');

                previousDay.setFullYear(parts[0],
                                        parseInt(parts[1])-1, 
                                        parts[2]);
                previousDay.setTime(previousDay.getTime()-86400000);

                return previousDay.getFullYear()+'-'+prototypes.getLeadingZero(previousDay.getMonth()+1)+'-'+prototypes.getLeadingZero(previousDay.getDate());                        
            },
            getPrevTime:function(time,
                                 diff,
                                 diffBy){
            /*
             * Returns previous time by hours, minutes, seconds.
             * 
             * @param time (String): time (HH, HH:MM, HH:MM:SS)
             * @param diff (Number): diference for previous time
             * @param diffBy (Number): diference by 
             *                         "hours"
             *                         "minutes"
             *                         "seconds"
             * 
             * @return previus hour (HH, HH:MM, HH:MM:SS)
             */
                var timePieces = time.split(':'),
                hours = parseInt(timePieces[0], 10),
                minutes = timePieces[1] === undefined ? 0:parseInt(timePieces[1], 10),
                seconds = timePieces[2] === undefined ? 0:parseInt(timePieces[2], 10);

                switch (diffBy){
                    case 'seconds':
                        seconds = seconds-diff;

                        if (seconds < 0){
                            seconds = 60+seconds;
                            minutes = minutes-1;

                            if (minutes < 0){
                                minutes = 60+minutes;
                                hours = hours-1 < 0 ? 0:hours-1;
                            }
                        }
                        break;
                    case 'minutes':
                            minutes = minutes-diff;

                            if (minutes < 0){
                                minutes = 60+minutes;
                                hours = hours-1 < 0 ? 0:hours-1;
                            }
                        break;
                    default:
                        hours = hours-diff < 0 ? 0:hours-diff;
                }

                return prototypes.getLeadingZero(hours)+(timePieces[1] === undefined ? '':':'+prototypes.getLeadingZero(minutes)+(timePieces[2] === undefined ? '':':'+prototypes.getLeadingZero(seconds)));
            },
            getToday:function(){
            /*
             * Returns today date.
             * 
             * @return today (YYYY-MM-DD)
             */    
                var today = new Date();
              
                return today.getFullYear()+'-'+prototypes.getLeadingZero(today.getMonth()+1)+'-'+prototypes.getLeadingZero(today.getDate());
            },
            getWeekDay:function(date){
            /*
             * Returns week day.
             * 
             * @param date (String): date for which the function get day of the week (YYYY-MM-DD)
             * 
             * @return week day index (0 for Sunday)
             */    
                var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
                year = date.split('-')[0],
                month = date.split('-')[1],
                day = date.split('-')[2],
                newDate = new Date(eval('"'+day+' '+months[parseInt(month, 10)-1]+', '+year+'"'));

                return newDate.getDay();
            },

// Domains & URLs                        
            $_GET:function(name){
            /*
             * Parse a $_GET variable.
             * 
             * @param name (String): variable name
             * 
             * @return variable vaue or "undefined" if it doesn't exist
             */
                var url = window.location.href.split('?')[1],
                variables = url !== undefined ? url.split('&'):[],
                i; 

                for (i=0; i<variables.length; i++){
                    if (variables[i].indexOf(name) !== -1){
                        return variables[i].split('=')[1];
                        break;
                    }
                }

                return undefined;
            },
            acaoBuster:function(url){
            /*
             * Access-Control-Allow-Origin buster. Modifies URL to be the same as browser URL.
             * 
             * @param url (String): URL
             * 
             * @return modified URL
             */
                var browserURL = window.location.href,
                pathPiece1 = '', pathPiece2 = '';

                if (prototypes.getDomain(browserURL) === prototypes.getDomain(url)){
                    if (url.indexOf('https') !== -1 
                            || url.indexOf('http') !== -1){
                        if (browserURL.indexOf('http://www.') !== -1){
                            pathPiece1 = 'http://www.';
                        }
                        else if (browserURL.indexOf('http://') !== -1){
                            pathPiece1 = 'http://';
                        }
                        else if (browserURL.indexOf('https://www.') !== -1){
                            pathPiece1 = 'https://www.';
                        }
                        else if (browserURL.indexOf('https://') !== -1){
                            pathPiece1 = 'https://';
                        }

                        if (url.indexOf('http://www.') !== -1){
                            pathPiece2 = url.split('http://www.')[1];
                        }
                        else if (url.indexOf('http://') !== -1){
                            pathPiece2 = url.split('http://')[1];
                        }
                        else if (url.indexOf('https://www.') !== -1){
                            pathPiece2 = url.split('https://www.')[1];
                        }
                        else if (url.indexOf('https://') !== -1){
                            pathPiece2 = url.split('https://')[1];
                        }

                        return pathPiece1+pathPiece2;
                    }
                    else{
                        return url;
                    }
                }
                else{
                    return url;
                }
            },
            getDomain:function(url){
            /*
             * Get current domain.
             *
             * @param url (String): the URL from which the domain will be extracted
             *
             * @return current domain
             */ 
                var domain = url;

                /*
                 * Remove white spaces from the begining of the URL.
                 */
                domain = domain.replace(new RegExp(/^\s+/),"");

                /*
                 * Remove white spaces from the end of the URL.
                 */
                domain = domain.replace(new RegExp(/\s+$/),"");

                /*
                 * If found , convert back slashes to forward slashes.
                 */
                domain = domain.replace(new RegExp(/\\/g),"/");

                /*
                 * If there, removes "http://", "https://" or "ftp://" from the begining.
                 */
                domain = domain.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");

                /*
                 * If there, removes 'www.' from the begining.
                 */
                domain = domain.replace(new RegExp(/^www\./i),"");

                /*
                 * Remove complete string from first forward slash on.
                 */
                domain = domain.replace(new RegExp(/\/(.*)/),"");

                return domain;
            },
            hasSubdomain:function(url){
            /*
             * Check if current URL has a subdomain.
             *
             * @param url (String): URL that will be checked
             *
             * @return true/false
             */ 
                var subdomain;

                /*
                 * Remove white spaces from the begining of the URL.
                 */
                url = url.replace(new RegExp(/^\s+/),"");

                /*
                 * Remove white spaces from the end of the URL.
                 */
                url = url.replace(new RegExp(/\s+$/),"");

                /*
                 * If found , convert back slashes to forward slashes.
                 */
                url = url.replace(new RegExp(/\\/g),"/");

                /*
                 * If there, removes 'http://', 'https://' or 'ftp://' from the begining.
                 */
                url = url.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),"");

                /*
                 * If there, removes 'www.' from the begining.
                 */
                url = url.replace(new RegExp(/^www\./i),"");

                /*
                 * Remove complete string from first forward slaash on.
                 */
                url = url.replace(new RegExp(/\/(.*)/),""); // 

                if (url.match(new RegExp(/\.[a-z]{2,3}\.[a-z]{2}$/i))){
                    /*
                     * Remove ".??.??" or ".???.??" from end - e.g. ".CO.UK", ".COM.AU"
                     */
                    url = url.replace(new RegExp(/\.[a-z]{2,3}\.[a-z]{2}$/i),"");
                }
                else if (url.match(new RegExp(/\.[a-z]{2,4}$/i))){
                    /*
                     * Removes ".??" or ".???" or ".????" from end - e.g. ".US", ".COM", ".INFO"
                     */
                    url = url.replace(new RegExp(/\.[a-z]{2,4}$/i),"");
                }

                /*
                 * Check to see if there is a dot "." left in the string.
                 */
                subdomain = (url.match(new RegExp(/\./g))) ? true : false;

                return(subdomain);
            },

// Resize & position                        
            rp:function(parent,
                        child,
                        pw,
                        ph,
                        cw,
                        ch,
                        pos,
                        type){
            /*
             * Resize & position an item inside a parent.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): parent width
             * @param ph (Number): parent height
             * @param cw (Number): child width
             * @param ch (Number): child height
             * @param pos (String): set child position in parent (bottom, bottom-center, bottom-left, bottom-right, center, left, horizontal-center, middle-left, middle-right, right, top, top-center, top-left, top-right, vertical-center)
             * @param type (String): resize type
             *                       "fill" fill parent (child will be cropped)
             *                       "fit" child resize to fit in parent
             */
                var newW = 0,
                newH = 0;

                /*
                 * Resize child.
                 */
                if (cw <= pw 
                        && ch <= ph){
                    newW = cw;
                    newH = ch;
                }
                else{
                    switch (type){
                        case 'fill':
                            newH = ph;
                            newW = (cw*ph)/ch;

                            if (newW < pw){
                                newW = pw;
                                newH = (ch*pw)/cw;
                            }
                            break;
                        default:
                            newH = ph;
                            newW = (cw*ph)/ch;

                            if (newW > pw){
                                newW = pw;
                                newH = (ch*pw)/cw;
                            }
                            break;
                    }
                }

                child.width(newW);
                child.height(newH);

                /*
                 * Position child.
                 */
                switch(pos.toLowerCase()){
                    case 'bottom':
                        prototypes.rpBottom(parent,
                                            child, 
                                            ph);
                        break;
                    case 'bottom-center':
                        prototypes.rpBottomCenter(parent, 
                                                  child, 
                                                  pw, 
                                                  ph);
                        break;
                    case 'bottom-left':
                        prototypes.rpBottomLeft(parent, 
                                                child, 
                                                pw, 
                                                ph);
                        break;
                    case 'bottom-right':
                        prototypes.rpBottomRight(parent,
                                                 child, 
                                                 pw, 
                                                 ph);
                        break;
                    case 'center':
                        prototypes.rpCenter(parent, 
                                            child, 
                                            pw, 
                                            ph);
                        break;
                    case 'left':
                        prototypes.rpLeft(parent, 
                                          child, 
                                          pw);
                        break;
                    case 'horizontal-center':
                        prototypes.rpCenterHorizontally(parent, 
                                                        child, 
                                                        pw);
                        break;
                    case 'middle-left':
                        prototypes.rpMiddleLeft(parent, 
                                                child, 
                                                pw, 
                                                ph);
                        break;
                    case 'middle-right':
                        prototypes.rpMiddleRight(parent, 
                                                 child, 
                                                 pw, 
                                                 ph);
                        break;
                    case 'right':
                        prototypes.rpRight(parent, 
                                           child, 
                                           pw);
                        break;
                    case 'top':
                        prototypes.rpTop(parent, 
                                         child, 
                                         ph);
                        break;
                    case 'top-center':
                        prototypes.rpTopCenter(parent, 
                                               child, 
                                               pw, 
                                               ph);
                        break;
                    case 'top-left':
                        prototypes.rpTopLeft(parent, 
                                             child, 
                                             pw, 
                                             ph);
                        break;
                    case 'top-right':
                        prototypes.rpTopRight(parent, 
                                              child,
                                              pw, 
                                              ph);
                        break;
                    case 'vertical-center':
                        prototypes.rpCenterVertically(parent, 
                                                      child, 
                                                      ph);
                        break;
                }
            },
            rpBottom:function(parent,
                              child,
                              ph){
            /*
             * Position item on bottom.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param ph (Number): height to which the parent is going to be set
             */
                if (ph !== undefined){
                    parent.height(ph);
                }
                child.css('margin-top', parent.height()-child.height());
            },
            rpBottomCenter:function(parent,
                                    child,
                                    pw,
                                    ph){
            /*
             * Position item on bottom-left.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpBottom(parent, 
                                    child, 
                                    ph);
                prototypes.rpCenterHorizontally(parent, 
                                                child, 
                                                pw);
            },
            rpBottomLeft:function(parent,
                                  child,
                                  pw,
                                  ph){
            /*
             * Position item on bottom-left.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpBottom(parent, 
                                    child, 
                                    ph);
                prototypes.rpLeft(parent, 
                                  child, 
                                  pw);
            },
            rpBottomRight:function(parent,
                                   child,
                                   pw,
                                   ph){
            /*
             * Position item on bottom-left.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpBottom(parent, 
                                    child, 
                                    ph);
                prototypes.rpRight(parent, 
                                   child, 
                                   pw);
            },
            rpCenter:function(parent,
                              child,
                              pw,
                              ph){
            /*
             * Position item on center.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpCenterHorizontally(parent, 
                                                child, 
                                                pw);
                prototypes.rpCenterVertically(parent, 
                                              child, 
                                              ph);
            },
            rpCenterHorizontally:function(parent,
                                          child,
                                          pw){
            /*
             * Center item horizontally.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             */
                if (pw !== undefined){
                    parent.width(pw);
                }
                child.css('margin-left', (parent.width()-child.width())/2);
            },
            rpCenterVertically:function(parent,
                                        child,
                                        ph){
            /*
             * Center item vertically.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param ph (Number): height to which the parent is going to be set
             */
                if (ph !== undefined){
                    parent.height(ph);
                }
                child.css('margin-top', (parent.height()-child.height())/2);
            },
            rpLeft:function(parent,
                            child,
                            pw){
            /*
             * Position item on left.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             */
                if (pw !== undefined){
                    parent.width(pw);
                }
                child.css('margin-left', 0);
            },
            rpMiddleLeft:function(parent,
                                  child,
                                  pw,
                                  ph){
            /*
             * Position item on middle-left.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpCenterVertically(parent,
                                              child, 
                                              ph);
                prototypes.rpLeft(parent,
                                  child, 
                                  pw);
            },
            rpMiddleRight:function(parent,
                                   child,
                                   pw,
                                   ph){
            /*
             * Position item on middle-right.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpCenterVertically(parent,
                                              child, 
                                              ph);
                prototypes.rpRight(parent, 
                                   child, 
                                   pw);
            },
            rpRight:function(parent,
                             child,
                             pw){
            /*
             * Position item on right.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             */
                if (pw !== undefined){
                    parent.width(pw);
                }
                child.css('margin-left', parent.width()-child.width());
            },
            rpTop:function(parent,
                           child,
                           ph){
            /*
             * Position item on top.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param ph (Number): height to which the parent is going to be set
             */
                if (ph !== undefined){
                    parent.height(ph);
                }
                child.css('margin-top', 0);
            },
            rpTopCenter:function(parent,
                                 child,
                                 pw,
                                 ph){
            /*
             * Position item on top-center.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpTop(parent, 
                                 child, 
                                 ph);
                prototypes.rpCenterHorizontally(parent, 
                                                child, 
                                                pw);
            },
            rpTopLeft:function(parent,
                               child,
                               pw,
                               ph){
            /*
             * Position item on top-left.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpTop(parent, 
                                 child, 
                                 ph);
                prototypes.rpLeft(parent, 
                                  child, 
                                  pw);
            },
            rpTopRight:function(parent,
                                child,
                                pw,
                                ph){
            /*
             * Position item on top-right.
             * 
             * @param parent (element): parent item
             * @param child (element): child item
             * @param pw (Number): width to which the parent is going to be set
             * @param ph (Number): height to which the parent is going to be set
             */
                prototypes.rpTop(parent, 
                                 child, 
                                 ph);
                prototypes.rpRight(parent, 
                                   child, 
                                   pw);
            },

// Strings & numbers
            cleanInput:function(input,
                                allowedCharacters,
                                firstNotAllowed,
                                min){
            /*
             * Clean an input from unwanted characters.
             * 
             * @param input (element): the input to be checked
             * @param allowedCharacters (String): the string of allowed characters
             * @param firstNotAllowed (String): the character which can't be on the first position
             * @param min (Number/String): the minimum value that is allowed in the input
             * 
             * @return clean string
             */ 
                var characters = input.val().split(''),
                returnStr = '', 
                i, 
                startIndex = 0;

                /*
                 * Check first character.
                 */
                if (characters.length > 1
                        && characters[0] === firstNotAllowed){
                    startIndex = 1;
                }

                /*
                 * Check characters.
                 */
                for (i=startIndex; i<characters.length; i++){
                    if (allowedCharacters.indexOf(characters[i]) !== -1){
                        returnStr += characters[i];
                    }
                }

                /*
                 * Check the minimum value.
                 */
                if (min > returnStr){
                    returnStr = min;
                }

                input.val(returnStr);
            },
            getLeadingZero:function(no){
            /*
             * Adds a leading 0 if number smaller than 10.
             * 
             * @param no (Number): the number
             * 
             * @return number with leading 0 if needed
             */
                if (no < 10){
                    return '0'+no;
                }
                else{
                    return no;
                }
            },
            getRandomString:function(stringLength,
                                     allowedCharacters){
            /*
             * Creates a string with random characters.
             * 
             * @param stringLength (Number): the length of the returned string
             * @param allowedCharacters (String): the string of allowed characters
             * 
             * @return random string
             */
                var randomString = '',
                charactersPosition,
                i;

                allowedCharacters = allowedCharacters !== undefined ? allowedCharacters:'0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';

                for (i=0; i<stringLength; i++){
                    charactersPosition = Math.floor(Math.random()*allowedCharacters.length);
                    randomString += allowedCharacters.substring(charactersPosition, charactersPosition+1);
                }
                return randomString;
            },
            getShortString:function(str,
                                    size){
            /*
             * Returns a part of a string followed by 3 dots.
             * 
             * @param str (String): the string
             * @param size (Number): the number of characters that will be displayed minus 3 dots
             * 
             * @return short string ...
             */
                var newStr = new Array(),
                pieces = str.split(''), i;

                if (pieces.length <= size){
                    newStr.push(str);
                }
                else{
                    for (i=0; i<size-3; i++){
                        newStr.push(pieces[i]);
                    }
                    newStr.push('...');
                }

                return newStr.join('');
            },
            getWithDecimals:function(number,
                                     no){
            /*
             * Returns a number with a predefined number of decimals.
             * 
             * @param number (Number): the number
             * @param no (Number): the number of decimals
             * 
             * @return string with number and decimals
             */
                no = no === undefined ? 2:no;
                return parseInt(number) === number ? String(number):parseFloat(number).toFixed(no);
            },
            validateCharacters:function(str,
                                        allowedCharacters){
            /*
             * Verify if a string contains allowed characters.
             * 
             * @param str (String): string to be checked
             * @param allowedCharacters (String): the string of allowed characters
             * 
             * @return true/false
             */
                var characters = str.split(''), i;

                for (i=0; i<characters.length; i++){
                    if (allowedCharacters.indexOf(characters[i]) === -1){
                        return false;
                    }
                }
                return true;
            },
            validEmail:function(email){
            /*
             * Email validation.
             * 
             * @param email (String): email to be checked
             * 
             * @return true/false
             */
                var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,16}(?:\.[a-z]{2})?)$/i;

                if (filter.test(email)){
                    return true;
                }
                return false;
            },
            stripSlashes:function(str){
            /*
             * Remove slashes from string.
             * 
             * @param str (String): the string
             * 
             * @return string without slashes
             */
                return (str + '').replace(/\\(.?)/g, function (s, n1){
                    switch (n1){
                        case '\\':
                            return '\\';
                        case '0':
                            return '\u0000';
                        case '':
                            return '';
                        default:
                            return n1;
                    }
                });
            },

// Styles
            getHEXfromRGB:function(rgb){
            /*
             * Convert RGB color to HEX.
             * 
             * @param rgb (String): RGB color
             * 
             * @return color HEX
             */
                var hexDigits = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');

                rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);

                return (isNaN(rgb[1]) ? '00':hexDigits[(rgb[1]-rgb[1]%16)/16]+hexDigits[rgb[1]%16])+
                       (isNaN(rgb[2]) ? '00':hexDigits[(rgb[2]-rgb[2]%16)/16]+hexDigits[rgb[2]%16])+
                       (isNaN(rgb[3]) ? '00':hexDigits[(rgb[3]-rgb[3]%16)/16]+hexDigits[rgb[3]%16]);
            },
            getIdealTextColor:function(bgColor){
            /*
             * Set text color depending on the background color.
             * 
             * @param bgColor(String): background color
             * 
             * return white/black
             */
                var rgb = /rgb\((\d+).*?(\d+).*?(\d+)\)/.exec(bgColor);

                if (rgb !== null){
                    return parseInt(rgb[1], 10)+parseInt(rgb[2], 10)+parseInt(rgb[3], 10) < 3*256/2 ? 'white' : 'black';
                }
                else{
                    return parseInt(bgColor.substring(0, 2), 16)+parseInt(bgColor.substring(2, 4), 16)+parseInt(bgColor.substring(4, 6), 16) < 3*256/2 ? 'white' : 'black';
                }
            }
        };
        
        return methods.init.apply(this);
    };
})(jQuery);

function DOPBSPSearchWidgetLoadInfobox(){
    var script = document.createElement('script');
                    
    script.type = 'text/JavaScript';
    script.src = 'http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox_packed.js';
    
    jQuery('body').append(script);
    
    return true;
};
// source --> https://casalospedroches.es/wp-content/plugins/elementor/assets/lib/font-awesome/js/v4-shims.min.js?ver=4.0.9 
/*!
 * Font Awesome Free 5.15.1 by @fontawesome - https://fontawesome.com
 * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
 */
(function(){var l,a;l=this,a=function(){"use strict";var l={},a={};try{"undefined"!=typeof window&&(l=window),"undefined"!=typeof document&&(a=document)}catch(l){}var e=(l.navigator||{}).userAgent,r=void 0===e?"":e,n=l,o=a,u=(n.document,!!o.documentElement&&!!o.head&&"function"==typeof o.addEventListener&&o.createElement,~r.indexOf("MSIE")||r.indexOf("Trident/"),"___FONT_AWESOME___"),t=function(){try{return"production"===process.env.NODE_ENV}catch(l){return!1}}();var f=n||{};f[u]||(f[u]={}),f[u].styles||(f[u].styles={}),f[u].hooks||(f[u].hooks={}),f[u].shims||(f[u].shims=[]);var i=f[u],s=[["glass",null,"glass-martini"],["meetup","fab",null],["star-o","far","star"],["remove",null,"times"],["close",null,"times"],["gear",null,"cog"],["trash-o","far","trash-alt"],["file-o","far","file"],["clock-o","far","clock"],["arrow-circle-o-down","far","arrow-alt-circle-down"],["arrow-circle-o-up","far","arrow-alt-circle-up"],["play-circle-o","far","play-circle"],["repeat",null,"redo"],["rotate-right",null,"redo"],["refresh",null,"sync"],["list-alt","far",null],["dedent",null,"outdent"],["video-camera",null,"video"],["picture-o","far","image"],["photo","far","image"],["image","far","image"],["pencil",null,"pencil-alt"],["map-marker",null,"map-marker-alt"],["pencil-square-o","far","edit"],["share-square-o","far","share-square"],["check-square-o","far","check-square"],["arrows",null,"arrows-alt"],["times-circle-o","far","times-circle"],["check-circle-o","far","check-circle"],["mail-forward",null,"share"],["expand",null,"expand-alt"],["compress",null,"compress-alt"],["eye","far",null],["eye-slash","far",null],["warning",null,"exclamation-triangle"],["calendar",null,"calendar-alt"],["arrows-v",null,"arrows-alt-v"],["arrows-h",null,"arrows-alt-h"],["bar-chart","far","chart-bar"],["bar-chart-o","far","chart-bar"],["twitter-square","fab",null],["facebook-square","fab",null],["gears",null,"cogs"],["thumbs-o-up","far","thumbs-up"],["thumbs-o-down","far","thumbs-down"],["heart-o","far","heart"],["sign-out",null,"sign-out-alt"],["linkedin-square","fab","linkedin"],["thumb-tack",null,"thumbtack"],["external-link",null,"external-link-alt"],["sign-in",null,"sign-in-alt"],["github-square","fab",null],["lemon-o","far","lemon"],["square-o","far","square"],["bookmark-o","far","bookmark"],["twitter","fab",null],["facebook","fab","facebook-f"],["facebook-f","fab","facebook-f"],["github","fab",null],["credit-card","far",null],["feed",null,"rss"],["hdd-o","far","hdd"],["hand-o-right","far","hand-point-right"],["hand-o-left","far","hand-point-left"],["hand-o-up","far","hand-point-up"],["hand-o-down","far","hand-point-down"],["arrows-alt",null,"expand-arrows-alt"],["group",null,"users"],["chain",null,"link"],["scissors",null,"cut"],["files-o","far","copy"],["floppy-o","far","save"],["navicon",null,"bars"],["reorder",null,"bars"],["pinterest","fab",null],["pinterest-square","fab",null],["google-plus-square","fab",null],["google-plus","fab","google-plus-g"],["money","far","money-bill-alt"],["unsorted",null,"sort"],["sort-desc",null,"sort-down"],["sort-asc",null,"sort-up"],["linkedin","fab","linkedin-in"],["rotate-left",null,"undo"],["legal",null,"gavel"],["tachometer",null,"tachometer-alt"],["dashboard",null,"tachometer-alt"],["comment-o","far","comment"],["comments-o","far","comments"],["flash",null,"bolt"],["clipboard","far",null],["paste","far","clipboard"],["lightbulb-o","far","lightbulb"],["exchange",null,"exchange-alt"],["cloud-download",null,"cloud-download-alt"],["cloud-upload",null,"cloud-upload-alt"],["bell-o","far","bell"],["cutlery",null,"utensils"],["file-text-o","far","file-alt"],["building-o","far","building"],["hospital-o","far","hospital"],["tablet",null,"tablet-alt"],["mobile",null,"mobile-alt"],["mobile-phone",null,"mobile-alt"],["circle-o","far","circle"],["mail-reply",null,"reply"],["github-alt","fab",null],["folder-o","far","folder"],["folder-open-o","far","folder-open"],["smile-o","far","smile"],["frown-o","far","frown"],["meh-o","far","meh"],["keyboard-o","far","keyboard"],["flag-o","far","flag"],["mail-reply-all",null,"reply-all"],["star-half-o","far","star-half"],["star-half-empty","far","star-half"],["star-half-full","far","star-half"],["code-fork",null,"code-branch"],["chain-broken",null,"unlink"],["shield",null,"shield-alt"],["calendar-o","far","calendar"],["maxcdn","fab",null],["html5","fab",null],["css3","fab",null],["ticket",null,"ticket-alt"],["minus-square-o","far","minus-square"],["level-up",null,"level-up-alt"],["level-down",null,"level-down-alt"],["pencil-square",null,"pen-square"],["external-link-square",null,"external-link-square-alt"],["compass","far",null],["caret-square-o-down","far","caret-square-down"],["toggle-down","far","caret-square-down"],["caret-square-o-up","far","caret-square-up"],["toggle-up","far","caret-square-up"],["caret-square-o-right","far","caret-square-right"],["toggle-right","far","caret-square-right"],["eur",null,"euro-sign"],["euro",null,"euro-sign"],["gbp",null,"pound-sign"],["usd",null,"dollar-sign"],["dollar",null,"dollar-sign"],["inr",null,"rupee-sign"],["rupee",null,"rupee-sign"],["jpy",null,"yen-sign"],["cny",null,"yen-sign"],["rmb",null,"yen-sign"],["yen",null,"yen-sign"],["rub",null,"ruble-sign"],["ruble",null,"ruble-sign"],["rouble",null,"ruble-sign"],["krw",null,"won-sign"],["won",null,"won-sign"],["btc","fab",null],["bitcoin","fab","btc"],["file-text",null,"file-alt"],["sort-alpha-asc",null,"sort-alpha-down"],["sort-alpha-desc",null,"sort-alpha-down-alt"],["sort-amount-asc",null,"sort-amount-down"],["sort-amount-desc",null,"sort-amount-down-alt"],["sort-numeric-asc",null,"sort-numeric-down"],["sort-numeric-desc",null,"sort-numeric-down-alt"],["youtube-square","fab",null],["youtube","fab",null],["xing","fab",null],["xing-square","fab",null],["youtube-play","fab","youtube"],["dropbox","fab",null],["stack-overflow","fab",null],["instagram","fab",null],["flickr","fab",null],["adn","fab",null],["bitbucket","fab",null],["bitbucket-square","fab","bitbucket"],["tumblr","fab",null],["tumblr-square","fab",null],["long-arrow-down",null,"long-arrow-alt-down"],["long-arrow-up",null,"long-arrow-alt-up"],["long-arrow-left",null,"long-arrow-alt-left"],["long-arrow-right",null,"long-arrow-alt-right"],["apple","fab",null],["windows","fab",null],["android","fab",null],["linux","fab",null],["dribbble","fab",null],["skype","fab",null],["foursquare","fab",null],["trello","fab",null],["gratipay","fab",null],["gittip","fab","gratipay"],["sun-o","far","sun"],["moon-o","far","moon"],["vk","fab",null],["weibo","fab",null],["renren","fab",null],["pagelines","fab",null],["stack-exchange","fab",null],["arrow-circle-o-right","far","arrow-alt-circle-right"],["arrow-circle-o-left","far","arrow-alt-circle-left"],["caret-square-o-left","far","caret-square-left"],["toggle-left","far","caret-square-left"],["dot-circle-o","far","dot-circle"],["vimeo-square","fab",null],["try",null,"lira-sign"],["turkish-lira",null,"lira-sign"],["plus-square-o","far","plus-square"],["slack","fab",null],["wordpress","fab",null],["openid","fab",null],["institution",null,"university"],["bank",null,"university"],["mortar-board",null,"graduation-cap"],["yahoo","fab",null],["google","fab",null],["reddit","fab",null],["reddit-square","fab",null],["stumbleupon-circle","fab",null],["stumbleupon","fab",null],["delicious","fab",null],["digg","fab",null],["pied-piper-pp","fab",null],["pied-piper-alt","fab",null],["drupal","fab",null],["joomla","fab",null],["spoon",null,"utensil-spoon"],["behance","fab",null],["behance-square","fab",null],["steam","fab",null],["steam-square","fab",null],["automobile",null,"car"],["envelope-o","far","envelope"],["spotify","fab",null],["deviantart","fab",null],["soundcloud","fab",null],["file-pdf-o","far","file-pdf"],["file-word-o","far","file-word"],["file-excel-o","far","file-excel"],["file-powerpoint-o","far","file-powerpoint"],["file-image-o","far","file-image"],["file-photo-o","far","file-image"],["file-picture-o","far","file-image"],["file-archive-o","far","file-archive"],["file-zip-o","far","file-archive"],["file-audio-o","far","file-audio"],["file-sound-o","far","file-audio"],["file-video-o","far","file-video"],["file-movie-o","far","file-video"],["file-code-o","far","file-code"],["vine","fab",null],["codepen","fab",null],["jsfiddle","fab",null],["life-ring","far",null],["life-bouy","far","life-ring"],["life-buoy","far","life-ring"],["life-saver","far","life-ring"],["support","far","life-ring"],["circle-o-notch",null,"circle-notch"],["rebel","fab",null],["ra","fab","rebel"],["resistance","fab","rebel"],["empire","fab",null],["ge","fab","empire"],["git-square","fab",null],["git","fab",null],["hacker-news","fab",null],["y-combinator-square","fab","hacker-news"],["yc-square","fab","hacker-news"],["tencent-weibo","fab",null],["qq","fab",null],["weixin","fab",null],["wechat","fab","weixin"],["send",null,"paper-plane"],["paper-plane-o","far","paper-plane"],["send-o","far","paper-plane"],["circle-thin","far","circle"],["header",null,"heading"],["sliders",null,"sliders-h"],["futbol-o","far","futbol"],["soccer-ball-o","far","futbol"],["slideshare","fab",null],["twitch","fab",null],["yelp","fab",null],["newspaper-o","far","newspaper"],["paypal","fab",null],["google-wallet","fab",null],["cc-visa","fab",null],["cc-mastercard","fab",null],["cc-discover","fab",null],["cc-amex","fab",null],["cc-paypal","fab",null],["cc-stripe","fab",null],["bell-slash-o","far","bell-slash"],["trash",null,"trash-alt"],["copyright","far",null],["eyedropper",null,"eye-dropper"],["area-chart",null,"chart-area"],["pie-chart",null,"chart-pie"],["line-chart",null,"chart-line"],["lastfm","fab",null],["lastfm-square","fab",null],["ioxhost","fab",null],["angellist","fab",null],["cc","far","closed-captioning"],["ils",null,"shekel-sign"],["shekel",null,"shekel-sign"],["sheqel",null,"shekel-sign"],["meanpath","fab","font-awesome"],["buysellads","fab",null],["connectdevelop","fab",null],["dashcube","fab",null],["forumbee","fab",null],["leanpub","fab",null],["sellsy","fab",null],["shirtsinbulk","fab",null],["simplybuilt","fab",null],["skyatlas","fab",null],["diamond","far","gem"],["intersex",null,"transgender"],["facebook-official","fab","facebook"],["pinterest-p","fab",null],["whatsapp","fab",null],["hotel",null,"bed"],["viacoin","fab",null],["medium","fab",null],["y-combinator","fab",null],["yc","fab","y-combinator"],["optin-monster","fab",null],["opencart","fab",null],["expeditedssl","fab",null],["battery-4",null,"battery-full"],["battery",null,"battery-full"],["battery-3",null,"battery-three-quarters"],["battery-2",null,"battery-half"],["battery-1",null,"battery-quarter"],["battery-0",null,"battery-empty"],["object-group","far",null],["object-ungroup","far",null],["sticky-note-o","far","sticky-note"],["cc-jcb","fab",null],["cc-diners-club","fab",null],["clone","far",null],["hourglass-o","far","hourglass"],["hourglass-1",null,"hourglass-start"],["hourglass-2",null,"hourglass-half"],["hourglass-3",null,"hourglass-end"],["hand-rock-o","far","hand-rock"],["hand-grab-o","far","hand-rock"],["hand-paper-o","far","hand-paper"],["hand-stop-o","far","hand-paper"],["hand-scissors-o","far","hand-scissors"],["hand-lizard-o","far","hand-lizard"],["hand-spock-o","far","hand-spock"],["hand-pointer-o","far","hand-pointer"],["hand-peace-o","far","hand-peace"],["registered","far",null],["creative-commons","fab",null],["gg","fab",null],["gg-circle","fab",null],["tripadvisor","fab",null],["odnoklassniki","fab",null],["odnoklassniki-square","fab",null],["get-pocket","fab",null],["wikipedia-w","fab",null],["safari","fab",null],["chrome","fab",null],["firefox","fab",null],["opera","fab",null],["internet-explorer","fab",null],["television",null,"tv"],["contao","fab",null],["500px","fab",null],["amazon","fab",null],["calendar-plus-o","far","calendar-plus"],["calendar-minus-o","far","calendar-minus"],["calendar-times-o","far","calendar-times"],["calendar-check-o","far","calendar-check"],["map-o","far","map"],["commenting",null,"comment-dots"],["commenting-o","far","comment-dots"],["houzz","fab",null],["vimeo","fab","vimeo-v"],["black-tie","fab",null],["fonticons","fab",null],["reddit-alien","fab",null],["edge","fab",null],["credit-card-alt",null,"credit-card"],["codiepie","fab",null],["modx","fab",null],["fort-awesome","fab",null],["usb","fab",null],["product-hunt","fab",null],["mixcloud","fab",null],["scribd","fab",null],["pause-circle-o","far","pause-circle"],["stop-circle-o","far","stop-circle"],["bluetooth","fab",null],["bluetooth-b","fab",null],["gitlab","fab",null],["wpbeginner","fab",null],["wpforms","fab",null],["envira","fab",null],["wheelchair-alt","fab","accessible-icon"],["question-circle-o","far","question-circle"],["volume-control-phone",null,"phone-volume"],["asl-interpreting",null,"american-sign-language-interpreting"],["deafness",null,"deaf"],["hard-of-hearing",null,"deaf"],["glide","fab",null],["glide-g","fab",null],["signing",null,"sign-language"],["viadeo","fab",null],["viadeo-square","fab",null],["snapchat","fab",null],["snapchat-ghost","fab",null],["snapchat-square","fab",null],["pied-piper","fab",null],["first-order","fab",null],["yoast","fab",null],["themeisle","fab",null],["google-plus-official","fab","google-plus"],["google-plus-circle","fab","google-plus"],["font-awesome","fab",null],["fa","fab","font-awesome"],["handshake-o","far","handshake"],["envelope-open-o","far","envelope-open"],["linode","fab",null],["address-book-o","far","address-book"],["vcard",null,"address-card"],["address-card-o","far","address-card"],["vcard-o","far","address-card"],["user-circle-o","far","user-circle"],["user-o","far","user"],["id-badge","far",null],["drivers-license",null,"id-card"],["id-card-o","far","id-card"],["drivers-license-o","far","id-card"],["quora","fab",null],["free-code-camp","fab",null],["telegram","fab",null],["thermometer-4",null,"thermometer-full"],["thermometer",null,"thermometer-full"],["thermometer-3",null,"thermometer-three-quarters"],["thermometer-2",null,"thermometer-half"],["thermometer-1",null,"thermometer-quarter"],["thermometer-0",null,"thermometer-empty"],["bathtub",null,"bath"],["s15",null,"bath"],["window-maximize","far",null],["window-restore","far",null],["times-rectangle",null,"window-close"],["window-close-o","far","window-close"],["times-rectangle-o","far","window-close"],["bandcamp","fab",null],["grav","fab",null],["etsy","fab",null],["imdb","fab",null],["ravelry","fab",null],["eercast","fab","sellcast"],["snowflake-o","far","snowflake"],["superpowers","fab",null],["wpexplorer","fab",null],["cab",null,"taxi"]];return function(l){try{l()}catch(l){if(!t)throw l}}(function(){var l;"function"==typeof i.hooks.addShims?i.hooks.addShims(s):(l=i.shims).push.apply(l,s)}),s},"object"==typeof exports&&"undefined"!=typeof module?module.exports=a():"function"==typeof define&&define.amd?define(a):l["fontawesome-free-shims"]=a();})();
// source --> https://casalospedroches.es/wp-content/plugins/google-analyticator/external-tracking.min.js?ver=6.5.7 
jQuery(document).ready(function(){jQuery("a").each(function(){var e=jQuery(this);var t=e.attr("href");if(t==undefined||t=="")return;var n=t.replace("http://","").replace("https://","");var r=t.split(".").reverse();var i=r[0].toLowerCase();var r=t.split("/").reverse();var s=r[2];var o=false;if(typeof analyticsFileTypes!="undefined"){if(jQuery.inArray(i,analyticsFileTypes)!=-1){o=true;e.click(function(){if(analyticsEventTracking=="enabled"){if(analyticsSnippet=="enabled"){_gaq.push(["_trackEvent","Downloads",i.toUpperCase(),t])}else{ga("send","event","Downloads",i.toUpperCase(),t)}}else{if(analyticsSnippet=="enabled"){_gaq.push(["_trackPageview",analyticsDownloadsPrefix+n])}else{ga("send","pageview",analyticsDownloadsPrefix+n)}}})}}if(t.match(/^http/)&&!t.match(document.domain)&&o==false){e.click(function(){if(analyticsEventTracking=="enabled"){if(analyticsSnippet=="enabled"){_gaq.push(["_trackEvent","Outbound Traffic",t.match(/:\/\/(.[^/]+)/)[1],t])}else{ga("send","event","Outbound Traffic",t.match(/:\/\/(.[^/]+)/)[1],t)}}else if(analyticsSnippet=="enabled"){_gaq.push(["_trackPageview",analyticsOutboundPrefix+n])}else{ga("send","pageview",analyticsOutboundPrefix+n)}})}})});