﻿$(document).ready(function() {

    $("#nav a").each(function() {

        var hreflink = $(this).attr("href").toLowerCase();
        hreflink = hreflink.split("/");

        var loc = location.href.toLowerCase();

        if (loc.indexOf("contact.aspx") != -1) { //an index page - make the main nav active
            if (loc.indexOf(hreflink[0]) != -1)
                $(this).addClass("active");
        }
        else if (loc.indexOf("resources.aspx") != -1) { //an index page - make the main nav active
            if (loc.indexOf(hreflink[0]) != -1)
                $(this).addClass("active");
        }
        else if (loc.indexOf("newsroom.aspx") != -1) { //an index page - make the main nav active
            if (loc.indexOf(hreflink[0]) != -1)
                $(this).addClass("active");
        }
        else if (loc.indexOf("about.aspx") != -1) { //an index page - make the main nav active
            if (loc.indexOf(hreflink[0]) != -1)
                $(this).addClass("active");
        }
        else if (loc.indexOf("industries.aspx") != -1) { //an index page - make the main nav active
            if (loc.indexOf(hreflink[0]) != -1)
                $(this).addClass("active");
        }
        else if (loc.indexOf("services.aspx") != -1) { //an index page - make the main nav active
            if (loc.indexOf(hreflink[0]) != -1)
                $(this).addClass("active");
        }
    });

    $(".buttons a").each(function() {

        var hreflink2 = $(this).attr("href").toLowerCase();
        hreflink2 = hreflink2.split("/");

        var loc2 = location.href.toLowerCase();
        //alert(loc2.indexOf("locations.aspx"));
        if (loc2.indexOf("locations.aspx") != -1 || loc2.indexOf("location.aspx") != -1) { //an index page - make the main nav active            
            if (hreflink2 == "locations.aspx") {
                $(this).addClass("active");
            }
        }
        
        else if (loc2.indexOf("partners.aspx") != -1 || loc2.indexOf("viewpartner.aspx") != -1) { //an index page - make the main nav active        
            if (hreflink2 == "partners.aspx") {
                $(this).addClass("active");
            }
        }

        else if (loc2.indexOf("events.aspx") != -1) { //an index page - make the main nav active
            if (hreflink2 == "events.aspx") {
                $(this).addClass("active");
            }
        }

        else if (loc2.indexOf("careers.aspx") != -1) { //an index page - make the main nav active
            if (hreflink2 == "careers.aspx") {
                $(this).addClass("active");
            }
        }

        else if (loc2.indexOf("articles.aspx") != -1) { //an index page - make the main nav active
            if (hreflink2 == "articles.aspx") {
                $(this).addClass("active");
            }
        }
    });
});