﻿
$(document).ready( function(){
    // PNG fixer (too heavy)
//    $('.pngfix').supersleight({ shim: '/Resources/images/blank.gif', apply_positioning: true });
    var regex = new RegExp('^/[0-9]+');
    var loc = location.pathname.toLowerCase(); // current location
    var host = location.host.toLowerCase(); // current host
    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")
            });
        }
        // search the links for a match with the current pathname
        $("a[href*=" + loc + "]").each(function() {

            $(this).addClass("current")

        });

    };

    if (host.match(".prefinio.com")) {
        // $("body").addClass("Prefinio");
        // TODO: remove from jQuery and place into a Page.Load event
        $(".darkRedBox").addClass("darkGrayBox").removeClass("darkRedBox");
        $(".redLinks").addClass("grayLinks").removeClass("redLinks");
    }        

    if (loc.match("/mymorrisby/")) {
        // $("body").addClass("MyMorrisby");
        // TODO: remove from jQuery and place into a Page.Load event
        $("#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");
    }

    //$('#banner-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: 'topRight' });
//    $('#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' });

})            