﻿$(document).ready(function () {

    // This is the simplified img hover script
    $('img[hvr]').hover(function () {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hvr'));
        $(this).attr('hvr', currentImg);
    }, function () {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hvr'));
        $(this).attr('hvr', currentImg);
    });

    // This adds a watermark to the textbox using the ToolTip attribute for <asp:TextBox or the Title attribute on input.
    $("input[title]").each(function () {
        if ($(this).attr('title') != '') {
            $(this).val($(this).attr('title'));
            $(this).addClass("water");
        }
    }).focus(function () {
        if ($(this).val() == $(this).attr('title')) {
            $(this).val("");
            $(this).removeClass("water");
        }
    }).blur(function () {
        if ($.trim($(this).val()) == "") {
            $(this).val($(this).attr('title'));
            $(this).addClass("water");
        }
    });

    $(function () {
        $('a[href*="target=blank"]').attr('target', '_blank').each(function () {
            var href = $(this).attr('href').replace('target=blank', '');

            if (href.indexOf("?") == href.length - 1) {
                href = href.substring(0, href.length - 1);
            }

            $(this).attr('href', href);
        });
    });

    $(function () {
        $('a[href="/give/donation/default.aspx"]').attr('target', '_blank');
    });

    // Autocreate captions for images.
    $("img[longdesc]").each(function () {

        $(this).wrap('<div class="autoImage" />');
        $(this).after('<div class="autoImageCaption">' + $(this).attr('longdesc') + '</div>');
        $(this).parent().attr('style', $(this).attr('style') || '').attr('class', $(this).attr('class') || '');
        $(this).removeAttr("style").removeAttr("class");

    });

    if (typeof DDscrollMenu == 'function') {
        if (document.getElementsByTagName("body")[0].className == "main")
            DDscrollMenu("navigation", document.getElementById("mp_text_block").offsetHeight + 6, 363, -4);
        else
            DDscrollMenu("navigation", 228, 130, -4);
    };
});


/******************************************************
*OpenPopup('url','height','width');return false
*******************************************************/
var win = null;
function OpenPopUp(URL) {




    switch (URL) {
        case "https://www.baptist-health.com/give/donation/":
            h = "550";
            w = "782";
            break
        case "":
            h = "300";
            w = "200";
            break
        case "/newsletter/popup.asp":
            h = "400";
            w = "400";
            break
        default:
            h = "400";
            w = "400";
    }




    var settings;
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,resizable';
    win = window.open(URL, 'BH', settings);
    if (!win) {
        alert("NOTE: Please disable any Pop-up Blockers and click \'OK\' to continue...")
    }
    else
        win.focus();
}
function NewWindow(url, w, h, scroll) {
    var settings;
    var sbars = (scroll) ? 'yes' : 'no';
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + sbars + ',resizable';
    win = window.open(url, 'BH', settings);

    if (win)
        win.focus();
    return !win; //if succussful href on calling link will be cancelled
}

var winNews = null;
function OpenNews() {
    var settings;
    var h = "400";
    var w = "450";
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,resizable';
    winNews = window.open('/newsletter/popup.asp', 'NEWS', settings);

    if (winNews) {
        winNews.focus();
    }
}

// hold-overs from old site
function openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}

function gotosite(site) {
    if (site != "") {
        location.href = site;
    }
}
