﻿
var addthis_config = {
    
    services_compact: 'facebook, twitter, google, stumbleupon, favorites, more'
    
}


function SetPage(pstrpage) {
    
    switch (pstrpage) {
        case "Inicio":


            Shadowbox.init({ skipSetup: true, overlayColor: '#000',
                overlayOpacity: '0.8'
            });
            SetPlayer();
            //SetMenu();
            SetTwitter();
            SetCalendar();
            QToolTip();
            //SetVideos();

            $('#SliderNews').bxSlider();

            $('ul#ListGallery').easyPaginate({
                step: 6
            });



            break; 
        default:

    }
}



function GetPage() {

}


function SetPlayer() {

    jwplayer("JWPlayer").setup({
        'flashplayer': 'Player/player.swf',
        'id': 'playerID',
        'width': '411',
        'height': '230',
        'playlistfile': 'Player/playlist.xml',
        'playlist.position': 'bottom',
        'playlist': 'bottom',
        'controlbar': 'top',
        'playlist.size': '220',
        'skin': 'Player/modieus.zip',
        'autostart': 'true',
        'repeat': 'list'
    });
}


function SetVideos() {

    jwplayer("JWPlayer").remove();

    var objWrapper = findObj('JWPlayer')
   

    var resp = _Default.GetVideos();
    

    objWrapper.innerHTML = resp.value
    setCaptify();
    Shadowbox.setup("a.Image", {
        gallery: "Videos",
        autoplayMovies: true
    });

    //	Basic carousel + timer
    $('#Videos').carouFredSel({

        auto: {
            duration: 500,
            pauseOnHover: 'resume',
            onPauseStart: function (percentage, duration) {
                $(this).trigger('configuration', ['width', function (value) {
                    $('#timer1').stop().animate({
                        width: value
                    }, {
                        duration: duration,
                        easing: 'linear'
                    });
                } ]);
            },
            onPauseEnd: function (percentage, duration) {
                $('#timer1').stop().width(0);
            },
            onPausePause: function (percentage, duration) {
                $('#timer1').stop();
            }
        }
    });


   
}


function QToolTip(strPosition) {


    $('a[title]').qtip(

				{
				    position: { my: 'bottom center', at: 'top center', viewport: $(window) },
				    hide: { fixed: true },
				    style: 'ui-tooltip-shadow'
				}


			);
}



function SetMenu() {
    $('.kwicks').kwicks({
        max: 140,
        spacing: 0
    });
}


function SetCalendar() {
    $('#datepicker').datepicker({
        beforeShowDay: highlightDays,
        onSelect: function (textoFecha, objDatepicker) {
            OpenBox("Events.aspx?Date=" + textoFecha, "Eventos para el dia: " + textoFecha, 300, 200, "iframe");
        }

    });

}



function SendMail() {

    $().message("Hemos recibido su mensaje, Muchas gracias");
    CloseBox();

}

function SendBooking() {
    $().message("Hemos recibido tu solicitud, muy pronto recibiras la respuesta, gracias.");
    CloseBox();
}



function AddMaillist() {


    var objMailList = findObj("txtMaillist")


    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

    if (objMailList.value != "") {


        if (reg.test(objMailList.value) == false) {

            alert('Debe escribir un Mail valido');
            objMailList.focus();
            objMailList.select()
        } else {


            var resp = _Default.AddMaillist(objMailList.value);


            switch (resp.value) {
                case 1:
                    $().message("Gracias por agregar su direccion, pronto recibira nuestras noticias en su mail.");                    
                    objMailList.disabled = true  
                    break;
                case 2:
                    $().message("Tu mail ya se encuentra en nuestra lista.");                    
                    objMailList.disabled = true 
                    break;
                case 0:
                    alert("No agregado")
                    break;
            }

           
        }
    } else {

        alert("Debe escribir un Mail")

    }
  

    
}


function GetEvent(pintID, iframe) {

    if (iframe) {
        Shadowbox.close();
        var strScript = "OpenBox('Event.aspx?ID=" + pintID + "', 'Informacion del Evento', 400, 400, 'iframe')"
        setTimeout(strScript, 500);
    } else {
        OpenBox("Event.aspx?ID=" + pintID, "Informacion del Evento", 400, 400, "iframe")       
    }


    
}


function NoEvents() {
    CloseBox();
    $().message("No hay eventos programados para esta fecha"); 
}





function SetTwitter() {
    $.Juitter.start({
        searchType: "fromUser", // needed, you can use "searchWord", "fromUser", "toUser"
        searchObject: "oliverochoa", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma.

        // The values below will overwrite the ones on the Juitter default configuration. 
        // They are optional here.
        // I'm changing here as a example only

        live: "live-180", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates.
        placeHolder: "Juitter", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
        loadMSG: "Cargando Tweets...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on 
        imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
        total: 3, // number of tweets to be show - max 100
        readMore: "Leer en twitter.", // read more message to be show after the tweet content
        nameUser: "image", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet 
        openExternalLinks: "newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow"
        filter: "sex->*BAD word*,porn->*BAD word*,fuck->*BAD word*,shit->*BAD word*"  // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,fuck"... Be aware that the tweets will still be showed, only the bad words will be removed
    });

}


function highlightDays(date) {




    for (var i = 0; i < dates.length; i++) {
        if (dates[i].getTime() == date.getTime()) {
            return [true, 'highlight'];
        }
    }
    return [true, ''];

}


function setCaptify() {

    $('img.captify').captify({
        // all of these options are... optional
        // ---
        // speed of the mouseover effect
        speedOver: 'fast',
        // speed of the mouseout effect
        speedOut: 'normal',
        // how long to delay the hiding of the caption after mouseout (ms)
        hideDelay: 200,
        // 'fade', 'slide', 'always-on'
        animation: 'slide',
        // text/html to be placed at the beginning of every caption
        prefix: '',
        // opacity of the caption on mouse over
        opacity: '0.7',
        // the name of the CSS class to apply to the caption box
        className: 'caption-bottom',
        // position of the caption (top or bottom)
        position: 'bottom',
        // caption span % of the image
        spanWidth: '100%'
    });

}



//______Utils______//
function BrowserCheck() {
    var b = navigator.appName
    if (b == "Netscape") this.b = "ns"
    else if (b == "Microsoft Internet Explorer") this.b = "ie"
    else this.b = b
    this.version = navigator.appVersion
    this.v = parseInt(this.version)
    this.ns = (this.b == "ns" && this.v >= 4)
    this.ns4 = (this.b == "ns" && this.v == 4)
    this.ns5 = (this.b == "ns" && this.v == 5)
    this.ie = (this.b == "ie" && this.v >= 4)
    this.ie4 = (this.version.indexOf('MSIE 4') > 0)
    this.ie5 = (this.version.indexOf('MSIE 5') > 0)
    this.min = (this.ns || this.ie)
}


function findObj(n, d) {
    var p, i, x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (n.substring(0, 6) == 'iFrame') {
        x = d.getElementById(n);
    } else {
        if (!(x = d[n]) && d.all) x = d.all[n];
        for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
        for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
        if (!x && d.getElementById) x = d.getElementById(n);
    }
    return x;
}



function focusObj(objName) { //v3.0
    var obj = MM_findObj(objName);
    obj.focus();
}

function getQuerystring(key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}

var monthNames = new makeArray(12);
monthNames[0] = "Enero";
monthNames[1] = "Febrero";
monthNames[2] = "Marzo";
monthNames[3] = "Abril";
monthNames[4] = "Mayo";
monthNames[5] = "Junio";
monthNames[6] = "Julio";
monthNames[7] = "Agosto";
monthNames[8] = "Septiembre";
monthNames[9] = "Octubre";
monthNames[10] = "Noviembre";
monthNames[11] = "Diciembre";

// Array of day names
var dayNames = new makeArray(7);
dayNames[0] = "Domingo";
dayNames[1] = "Lunes";
dayNames[2] = "Martes";
dayNames[3] = "Mi&eacute;rcoles";
dayNames[4] = "Jueves";
dayNames[5] = "Viernes";
dayNames[6] = "S&aacute;bado";

var now = new Date();
var year = now.getYear();

if (year < 2000) year = year + 1900;

function makeArray(len) {
    for (var i = 0; i < len; i++) this[i] = null;
    this.length = len;
}


function setDate() {
    var Date = findObj("DateRibbon")


    Date.innerHTML = dayNames[now.getDay()] + "    " + now.getDate() + " de " + monthNames[now.getMonth()] + "    " + " de " + year

}


function OpenBox(pstrContent, pstrTitle, pintWidth, pintHeight, pstrType) {
    // open a welcome message as soon as the window loads
  

    Shadowbox.open({
        content: pstrContent,
        player: pstrType,
        title: pstrTitle,
        height: pintHeight,
        width: pintWidth
    });
}


function CloseBox() {

    parent.Shadowbox.close();
}



