var $ = jQuery.noConflict();

function setPage()
{
    var hrefString = document.location.href ? document.location.href : document.location;
    
    if (document.getElementById("nav") != null) 
        setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
}

function setActiveMenu(arr, crtPage)
{
    for (var i = 0; i < arr.length; i++)
    {
        var array = crtPage.split('?');

        if (extractPageName(arr[i].href) == array[0])
        {
            var menuItem = document.getElementById(arr[i].id);
			
            if (array[0] == "print.php")
                menuItem.style.background = 'url(images/Print2.jpg) no-repeat';

            if (array[0] == "branding.php")
                menuItem.style.background = 'url(images/Branding2.jpg) no-repeat';

            if (array[0] == "advertising.php")
                menuItem.style.background = 'url(images/Advertising2.jpg) no-repeat';

            if (array[0] == "illustration.php")
                menuItem.style.background = 'url(images/Illustration2.jpg) no-repeat';
                
            if (array[0] == "art.php")
                menuItem.style.background = 'url(images/Art&Prints2.jpg) no-repeat';
                
            if (array[0] == "info.php")
                menuItem.style.background = 'url(images/Contact2.jpg) no-repeat';
        }
    }
}

function setMenu() {
    var hrefString = document.location.href ? document.location.href : document.location;
    
    if (document.getElementById("subnav") != null) 
        setActiveSubMenu(document.getElementById("subnav").getElementsByTagName("a"), extractPageName(hrefString));
}

function setActiveSubMenu(arr, crtPage)
{
    for (var i = 0; i < arr.length; i++)
    {
        if (extractPageName(arr[i].href) == crtPage)
        {
            var menuItem = document.getElementById(arr[i].id);

			menuItem.style.fontWeight = "bold";
			menuItem.style.color = "#000";
        }
    }
}

function extractPageName(hrefString)
{
    var arr = hrefString.split('/');

    return (arr.length < 2) ? hrefString : arr[arr.length - 1].toLowerCase();
}

function GetDescription(n)
{
	// Do not remove this function definition
}

$(document).ready(function () {
	setPage();

	setMenu();
});
