﻿
var isAboutSection = (location.pathname.indexOf('/about/') !== -1);
var isSolutionsSection = (location.pathname.indexOf('/solutions/') !== -1);
var isServicesSection = (location.pathname.indexOf('/services/') !== -1);
var isCustomersSection = (location.pathname.indexOf('/customers/') !== -1);
var isMediaCenterSection = (location.pathname.indexOf('/mediacenter/') !== -1);
var isContactsSection = (location.pathname.indexOf('/contacts/') !== -1);

(function($)
{

    $.fn.TopNav = function()
    {

        $(".hoverswap").hover(
		    function()
		    {
		        $(this).attr("src", $(this).attr("src").replace('-off.png', '-on.png'));
		        $(this).TurnOnSection();
		    },
		    function()
		    {
		        $(this).attr("src", $(this).attr("src").replace('-on.png', '-off.png'));
		        $(this).TurnOnSection();
		    }
	    );

	    $(this).TurnOnSection();
    }

    $.fn.TurnOnSection = function()
    {
        switch (true)
        {
            case isAboutSection:
                $("#hrefAbout :first-child").attr("src", $("#hrefAbout :first-child").attr("src").replace('-off.png', '-on-page.png'));
                break;

            case isSolutionsSection:
                $("#hrefSolutions :first-child").attr("src", $("#hrefSolutions :first-child").attr("src").replace('-off.png', '-on-page.png'));
                break;

            case isServicesSection:
                $("#hrefServices :first-child").attr("src", $("#hrefServices :first-child").attr("src").replace('-off.png', '-on-page.png'));
                break;
            case isCustomersSection:
                $("#hrefCustomers :first-child").attr("src", $("#hrefCustomers :first-child").attr("src").replace('-off.png', '-on-page.png'));
                break;
            case isMediaCenterSection:
                $("#hrefEvents :first-child").attr("src", $("#hrefEvents :first-child").attr("src").replace('-off.png', '-on-page.png'));
                break;
            case isContactsSection:
                $("#hrefContacts :first-child").attr("src", $("#hrefContacts :first-child").attr("src").replace('-off.png', '-on-page.png'));
                break;
        }
    }

})(jQuery);


