﻿$(document).ready(function() {
    responseEnd(null, null);
});

var FQD; //Global variable for the fully qualified domain
var showPromoPulse = true;

function responseEnd(sender, eventArgs) {
    //FontEFX
    runFontEFX();

    //Set Css
    setCSS();

    //Load Fancy Box
    //loadfancyBox();

    //Color Box
    $(".lightboxImg").colorbox({ maxWidth: "95%", maxHeight: "95%", transition: "elastic", opacity: 0 });

    //Buttons
    setHoverBtns();

    //Ajax-AddThis
    loadAjaxAddThis();

    //Masonry
    $('#helpfulReferralWrapper').masonry({ singleMode: true });

//    //Handle Scheduler
//    var urlPath = window.location.pathname.toLowerCase();
//    if (urlPath.indexOf("watermans_events") != -1) {
//        SetSchedulerLateNightSpans();
//    }
}

//function SetSchedulerLateNightSpans() {
//    try {
//        $("div[isLateNight]").each(function (index) {
//            var daysToSpan = $(this).attr("isLateNight");
//            var hideSunday = $(this).attr("hideSunday");
//            var apptSpanWidth = $(".rsWrap").width();
//            $(this).width(apptSpanWidth * daysToSpan);
//            if (hideSunday == "true")
//                $(this).hide();
//        });
//        $("div[hideCarrot]").find(".rsArrowRight").hide();
//    } catch (err) { }
//}

function loadAjaxAddThis() {
    $('.ajaxAddThis').each(function () {
        var thisId = $(this).attr('id');
        var tbx = document.getElementById(thisId);
        tbx.innerHTML += '<a class="addthis_button_facebook_like" fb:like :layout="button_count" title="Like this on Facebook"></a>';
        tbx.innerHTML += '<a class="addthis_button_tweet" title="Send this to Twitter"></a>';
        addthis.toolbox("#" + thisId);
    });
}

function loadfancyBox() {
    $(".lightboxImg").fancybox({
        'titleShow': true,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'autoScale': true,
        'scrolling': 'no'
    });

    $(".bannerVideo").fancybox({
        'titleShow': true,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'autoScale': true,
        'scrolling': 'no'
    });
}

function runFontEFX() {
    $('.title h1, .titleLink h1 a, .menuDirItem .text a, .fontEFX').FontEffect({
        outline         :true,
        outlineColor1   :"#ffffff",
        outlineColor2   :"", 
        outlineWeight   :1, 
        mirror          :false,
        mirrorColor     :"",
        mirrorOffset    :-10,
        mirrorHeight    :50,
        mirrorDetail    :1,
        mirrorTLength   :50,
        mirrorTStart    :0.2,
        shadow          :false,
        shadowColor     :"#000000",
        shadowOffsetTop :2,     
        shadowOffsetLeft:2,     
        shadowBlur      :1,     
        shadowOpacity   :0.1,   
        gradient        :false, 
        gradientColor   :"",    
        gradientPosition:20,    
        gradientLength  :50,    
        gradientSteps   :20,    
        hideText        :false
    });
}

function startNaviPromoPulse() {
    $(".naviPromoPulse").css("display", "block");
    $(".naviPromoPulse").pulse({ opacity: [0, 1] }, {
        duration: 1000, // duration of EACH individual animation
        times: 9999999, // Will go three times through the pulse array [0,1]
        easing: 'linear', // easing function for each individual animation
        complete: function () { }
    });
}

function runBgRotator() {
    $('#bg-banner').cycle({ fx: 'fade', speed: 700, timeout: 6000 });
}

function setCSS() {
    $(".contentBlock .text p:last-child").css("margin-bottom", "0px");
    $("ul.iconLinks li:first-child, ul.textLinks li:first-child").css("padding-left", "0px");
    $("ul.iconLinks li:last-child, ul.textLinks li:last-child").css("border", "none");
    $("ul.iconLinks li:last-child, ul.textLinks li:last-child").css("padding-right", "0px");
    $(".eventItem:last-child, .l_Item:last-child").css("margin-bottom", "0px");
}

function CamWindowOpen(title, navurl) {
    var w = window.radopen(navurl, "CamWindow");
    w._titleIconElement.style.background = "transparent url('" + w.get_iconUrl() + "') no-repeat scroll 0px 0px";
    w.set_title(title);
    w.SetSize(416, 359);
}

function MenuForceClose(sender, args) {
    args.get_item().focus();
    if (sender.get_focusedItem().get_childListElement() == null) {
        sender.close();
    } else { return; }
}

function conditionalPostback(sender, args) {

}

function RowDblClick(sender, args) {

}

function ReloadPage() {
    location.reload(true);
}

function CloseToolTip(toolTipCtrl) {
    var toolTip = $find(toolTipCtrl);
    toolTip.hide();
}

var backgroungIndex;
var backgroungCount = 5;
function switchBackground() {

    if (backgroungIndex == null)
        backgroungIndex = backgroungCount + 1;

    backgroungIndex--;

    if (backgroungIndex == 0)
        backgroungIndex = backgroungCount;

    $('#body-wrapper').css("background-image", "url(/images/backgrounds/bg-banner-" + backgroungIndex + ".jpg)");
}
