﻿function menu() {
    var thisMenu = this;
    var idlePath = "./images/menu/idle/";
    var hoverPath = "./images/menu/hover/";
    var timer = 0;

    this.home = document.getElementById('menuHome');
    this.features = document.getElementById('menuFeatures');
    this.tour = document.getElementById('menuTour');
    this.faq = document.getElementById('menuFAQ');
    this.freeTrial = document.getElementById('menuFreeTrial');
    this.purchase = document.getElementById('menuPurchase');
    this.support = document.getElementById('menuSupport');
    this.integration = document.getElementById('menuIntegration');
    this.tablet = document.getElementById('menuTablet');
    this.contact = document.getElementById('menuContact');
    this.troubleshooting = document.getElementById('troubleshooting');
    this.bulklicencing = document.getElementById('bulklicencing');

    this.home.onmouseover = function() { thisMenu.clear(); this.className = "menuitemtophot"; };
    this.home.onmouseout = function() { this.className = "menuitemtop"; thisMenu.highlightCurrent(); };

    this.features.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.features.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); };

    this.tour.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.tour.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); };

    this.faq.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.faq.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); };

    this.freeTrial.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.freeTrial.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); };

    this.purchase.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.purchase.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); };

    this.support.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.support.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); };

    this.integration.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.integration.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); };

    this.tablet.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.tablet.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); };

    this.contact.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.contact.onmouseout = function() { this.className = "menuitembottom"; thisMenu.highlightCurrent(); }

    this.troubleshooting.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.troubleshooting.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); }

    this.bulklicencing.onmouseover = function() { thisMenu.clear(); this.className = "menuitemhot"; };
    this.bulklicencing.onmouseout = function() { this.className = "menuitemmid"; thisMenu.highlightCurrent(); }

    var aspx = window.location.toString().toLowerCase().lastIndexOf("aspx") - 1;
    if (aspx == -1) {
        aspx = window.location.toString().length;
    }
    this.location = window.location.toString().toLowerCase().substring(window.location.toString().toLowerCase().lastIndexOf("/") + 1, aspx).toLowerCase();

    this.highlightCurrent = function() {
        function go() {
            if (timer != 0) {
                switch (thisMenu.location.toLowerCase()) {
                    case "default":
                        thisMenu.home.className = "menuitemtophot";
                        break;
                    case "features":
                        thisMenu.features.className = "menuitemhot";
                        break;
                    case "screenshots":
                        thisMenu.tour.className = "menuitemhot";
                        break;
                    case "faq":
                        thisMenu.faq.className = "menuitemhot";
                        break;
                    case "download":
                        thisMenu.freeTrial.className = "menuitemhot";
                        break;
                    case "purchase":
                        thisMenu.purchase.className = "menuitemhot";
                        break;
                    case "support":
                        thisMenu.support.className = "menuitemhot";
                        break;
                    case "integration":
                        thisMenu.integration.className = "menuitemhot";
                        break;
                    case "tablet":
                        thisMenu.tablet.className = "menuitemhot";
                        break;
                    case "contact":
                        thisMenu.contact.className = "menuitemhot";
                        break;
                    case "troubleshooting":
                        thisMenu.troubleshooting.className = "menuitemhot";
                        break;
                    case "bulklicnesing":
                        thisMenu.troubleshooting.className = "menuitemhot";
                        break;
                    default:
                        thisMenu.home.className = "menuitemtophot";
                        break;
                }
            }
        }
        timer = setTimeout(go, 75);
    };

    this.clear = function() {
        clearTimeout(timer);
        timer = 0;
        this.home.className = "menuitemtop";
        this.features.className = "menuitemmid";
        this.tour.className = "menuitemmid";
        this.faq.className = "menuitemmid";
        this.freeTrial.className = "menuitemmid";
        this.purchase.className = "menuitemmid";
        this.support.className = "menuitemmid";
        this.integration.className = "menuitemmid";
        this.tablet.className = "menuitemmid";
        this.contact.className = "menuitembottom";
        this.troubleshooting.className = "menuitemmid";
        this.bulklicencing.className = "menuitemmid";

    };

    this.highlightCurrent();
}
