﻿window.onload = function() {

    // Get selector
    var selector = document.getElementById("selector");
    if (selector != null) {

        // Get panes
        var home = document.getElementById("home");
        var accommodation = document.getElementById("accommodation");
        var business = document.getElementById("business-breaks");
        var party = document.getElementById("party-breaks");

        // Reset function
        var reset = function() {

            home.className = "panel";

            this.className = "panel hide";

            for (i = 0; i < selector.childNodes.length; i++) {
                if (selector.childNodes[i].nodeName == "LI") {
                    selector.childNodes[i].className = selector.childNodes[i].className.replace(" hit", "");
                }
            }

        }

        // Wire selector events
        for (i = 0; i < selector.childNodes.length; i++) {

            if (selector.childNodes[i].nodeName == "LI") {

                selector.childNodes[i].onmouseover = function() {

                    var element = document.getElementById(this.className)

                    if (element != null) {

                        if (document.getElementById(this.className).className != "panel") {
                            document.getElementById(this.className).className = "panel";
                        }

                        if (this.className != "home") { home.className = "panel hide" };
                        if (this.className != "accommodation") { accommodation.className = "panel hide" };
                        if (this.className != "business-breaks") { business.className = "panel hide" };
                        if (this.className != "party-breaks") { party.className = "panel hide" };

                        this.className += " hit";

                        for (j = 0; j < this.parentNode.childNodes.length; j++) {
                            if (this.parentNode.childNodes[j].nodeName == "LI" && this.parentNode.childNodes[j].className != this.className) {
                                this.parentNode.childNodes[j].className = this.parentNode.childNodes[j].className.replace(" hit", "");
                            }
                        }
                    }

                }

            }

        }

    }

}