var menu = {};

menu.init = function(){
    var test = location.href;
    var homeRegex = /\/help\/|\/info2\/|\/policies\//;
    var supportRegex = /\/support\//;
    var helpRegex = /\/wizard\//;
    var serviceRegex = /supportpages.html\?a=2&/;
    var statsRegex = /supportpages.html\?a=212/;
    var enquiriesRegex = /my.html\?action=contact_sales/;
    var codeRegex = /\/support\/service\/code_of_practice.shtml/;
    if (test.match(codeRegex)) {
            menu.highlight('codePracticeMenu');
        }
    else if (test.match(supportRegex)) {
            menu.highlight('supportPagesMenu');
        }
    else if (test.match(homeRegex)) {
        menu.highlight('helpAndSupportHomeMenu');
    }
    else if (test.match(helpRegex)) {
            menu.highlight('helpAndQuestionsMenu');
        }
    else if (test.match(serviceRegex)) {
            menu.highlight('serviceStatusMenu');
        }
    else if (test.match(statsRegex)) {
            menu.highlight('customerSupportStatsMenu');
        }
    else if (test.match(enquiriesRegex)) {
            menu.highlight('salesEnquiriesMenu');
        }
}

menu.highlight = function(theItem){
    $('.item').removeClass('selected');
    $('.item.' + theItem).addClass('selected');
}

$(document).ready(function() {
    if ($('#side_navigation').length > 0 ) {
        menu.init();   
    }
});

