﻿
$(function() {

    var regex = new RegExp('^/[0-9]+');
    var loc = location.pathname.toLowerCase(); // current location
    loc = loc.replace(regex, "");

    var path = loc.substring(0, loc.lastIndexOf("/") + 1); // current location
    var section = loc.substring(0, loc.lastIndexOf("/mymorrisby/") + 12);
    // hide the 'back to home' link if on the home page

    if ((path == "/")) {
        if ((loc == "/") || (loc == "/default.aspx")) {
            $(".homeTab a").addClass("current");
            $(".backhome").addClass("hidden");
        }
    } else {

        // search the links for a match with the current pathname
        if (!(loc.match("/mymorrisby/"))) {
            $(".primaryNav a[href*=" + path + "]").each(function() {
                $(this).addClass("current")
                //$(this).attr("href", "javascript:void(0);")
            });
        }
        // search the links for a match with the current pathname
        $("a[href*=" + loc + "]").each(function() {

            $(this).addClass("current")
            //$(this).attr("href", "javascript:void(0);")

        });

        //        // search the links for a match with the current section
        //        $(".primaryNav a[href*=" + section + "]").each(function() {
        //            $(this).addClass("current")
        //            //$(this).attr("href", "javascript:void(0);")

        //        });
    };

    if (loc.match("/mymorrisby/")) {
        $("body").addClass("MyMorrisby");
        $("#GoHomeNav").addClass("hidden");
        $("#mainNav").addClass("hidden");
        $("#BackToMainSite").removeClass("hidden");
        $("#MyMorrisbyNav").removeClass("hidden");
    }

    else if (loc.match("/individuals/")) {
        $("body").addClass("Individuals");
    }

    else if (loc.match("/professional/")) {
        $("body").addClass("Professional");
    }

    else {
        $("body").addClass("Default");
    }
});

$(document).ready(function() {
    // PNG fixer
$('#header-logo').supersleight({ shim: '/Resources/images/blank.gif', apply_positioning: true });
//    $('#footer').supersleight({ shim: '/Resources/images/blank.gif', apply_positioning: true });

    $('#Intro_Links.keepAtTop').floatBox();

    
    // functionality
    // sitefunctions.textresize();
    sitefunctions.initFancyBits();

    // The stuff below is depracated - use a wrapper to determine the tooltip style!!
    $('abbr[title]').createTooltips();
    $('input[title], .valSummary a[title]').createTooltips({ skin: 'green', position: 'rightMiddle' });
    $('#fontsizer a[title]').createTooltips({ skin: 'grey', position: 'bottomLeft' });
    $('.footerlink a.fancyTooltip[title]').createTooltips({ skin: 'grey', position: 'bottomRight' });
    $('.sectionlinks a.fancyTooltip[title]').createTooltips({ skin: 'grey', position: 'bottomRight' });
    $('.sidebarBox a.fancyTooltip[title], #tabs-nav .vertical a.fancyTooltip[title]').createTooltips({ skin: 'grey', position: 'leftMiddle' });
    $('#UserSummary a.fancyTooltip[title]').createTooltips({ skin: 'grey', position: 'topMiddle' });
    $('#versionInfo .fancyTooltip[title]').createTooltips({ skin: 'grey', position: 'topMiddle', showdelay: '2000' });

    $('.toolTips-LeftTop a.fancyTooltip[title]').createTooltips({ position: 'leftTop' });
    $('.toolTips-Left a.fancyTooltip[title]').createTooltips({ position: 'leftMiddle'});
    $('.toolTips-LeftBottom a.fancyTooltip[title]').createTooltips({ position: 'leftBottom' });

    $('.toolTips-RightTop a.fancyTooltip[title]').createTooltips({ position: 'rightTop' });
    $('.toolTips-Right a.fancyTooltip[title]').createTooltips({ position: 'rightMiddle' });
    $('.toolTips-RightBottom a.fancyTooltip[title]').createTooltips({ position: 'rightBottom' });

    $('.toolTips-TopLeft a.fancyTooltip[title]').createTooltips({ position: 'topLeft' });
    $('.toolTips-Top a.fancyTooltip[title]').createTooltips({ position: 'topMiddle' });
    $('.toolTips-TopRight a.fancyTooltip[title]').createTooltips({ position: 'topRight' });

    $('.toolTips-BottomLeft a.fancyTooltip[title]').createTooltips({ position: 'bottomLeft' });
    $('.toolTips-Bottom a.fancyTooltip[title]').createTooltips({ position: 'bottomMiddle' });
    $('.toolTips-BottomRight a.fancyTooltip[title]').createTooltips({ position: 'bottomRight', tip: 'topLeft' });

})            