﻿$(document).ready(function() {
    var path = window.location.pathname;
    // Grab just the current page name, discarding all other path info
    var fileName = path.substring(path.lastIndexOf('/') + 1).toLowerCase();
    
    // Look for each secondary nav link 
    $("a.button-style").each(function() {
        // Get the href value of the current link
        var linkHref = $(this).attr("href").substring($(this).attr("href").lastIndexOf('/') + 1).toLowerCase();
        var linkOrigHref = $(this).attr("href").substring($(this).attr("href").lastIndexOf('/') + 1, $(this).attr("href").indexOf('?')).toLowerCase();
        var OrigHrefContains = (linkOrigHref == linkHref.replace(".aspx", ""));
        
        var parentSection = path.substring(1, path.lastIndexOf('/'));
        // bool value which is true if the path contains the current link's href attribute
        var pathContains = (parentSection == linkHref.replace(".aspx", ""));
        
        // If the path is equal to or contains the href value, set the current class
        if (linkHref == fileName || pathContains) { $(this).addClass("current"); }
        
    
        // Assign title tags to all elements with alt tags
        $("img:not([title])[alt!='']").each(function(){$(this).attr("title", $(this).attr("alt"))});

    });
});

function googleSubmit()
{
    document.getElementById('q').value = document.getElementById('google_form_q').value;
    document.getElementById('sitesearch').checked = document.getElementById('google_form_sitesearch').checked;
    document.getElementById('google_form').submit();
}