
function agregar_favoritos(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url="http://www.balnearioblancafort.com/"; 
      var titulo="Balneario Blancafort";
      window.external.AddFavorite(url,titulo);
   } else { 
      if(navigator.appName == "Netscape") 
         alert("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
   }
} 

/**********************************************************************
 * Promoció/noticia destacada
 **********************************************************************/
 
var intervaloEntrePromociones = 10

setInterval(
    function () {
        $('#promocionDestacada')
            .fadeOut(400, function () {
                $(this).load(
                    '/ajax/destacado.php',
                    {},
                    function () {
                        $(this).fadeIn(400)
                    }
                )
            })
    },
    intervaloEntrePromociones * 1000
)

var PCT = {}

PCT.displayFormErrors = function (errors) {
    var message = "Se ha encontrado errores al processar el formulario:"
    $.each(errors, function (i, error) { message += "\n- " + error })
    alert(message)
}

PCT.getStyle = function (url) {
    $('head').append(
        $(document.createElement('link'))
            .attr({
                rel: 'stylesheet',
                type: 'text/css',
                href: url
            }
        )
    )
}

PCT.getAnId = function (element) {
    if (element.id == '') element.id = 'id-' + parseInt(Math.random() * 10000000000)
    return element.id
}

$(document).ready(function () {
    var dateInputs = $('input.date')
    
    if (! dateInputs.length) return
    
    $.getScript("/resources/javascript/jscalendar/calendar.js", function () {
        $.getScript("/resources/javascript/jscalendar/lang/calendar-es.js", function () {
            $.getScript("/resources/javascript/jscalendar/calendar-setup.js", function () {
                dateInputs.each(function () {
                    var buttonId = PCT.getAnId(this) + '-button'
                    $(this).after(
                        $(document.createElement('img'))
                            .attr({
                                id: buttonId,
                                src: "/resources/images/common/main/inicio/calendario.gif",
                                alt: 'Calendario',
                                title: "Seleccionar la fecha del calendario"
                            })
                            .css({
                                cursor: 'pointer',
                                verticalAlign: 'middle',
                                margin: "0",
                                padding: '0 3px'
                            })
                    )
                    Calendar.setup({
                        inputField : PCT.getAnId(this),
                        ifFormat : "%d/%m/%Y",
                        button : buttonId
                    })
                })
            })
        })
    })
    PCT.getStyle("/resources/javascript/jscalendar/calendar-blue.css")
})
