﻿startList = function() {
    if (document.all && document.getElementById) {
        navRoot = document.getElementById("main_nav");
        if (!navRoot) {
            return false
        }
        for (i = 0; i < navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName == "DD") {
                node.onmouseover = function() {
                    this.className += " over";
                }
                node.onmouseout = function() {
                    this.className = this.className.replace(" over", "");
                }
            }
        }
    }
}


var cch = (function() {
    var Event = Aris.Event;
    var DOM = Aris.DOM;

  
    Event.onDOMLoaded.add(function() {
        aFontSizer = new FontSizer('main', 'fsUp', 'fsDown', 'fsNormal');
    });
})();


var Cookies = {
    add: function(name, value, days) {
        var expires = '';
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            expires = '; expires=' + date.toGMTString(); ;
        }
        document.cookie = name + "=" + escape(value) + expires + "; path=/";
    },
    remove: function(name) {
        this.add(name, '', -1);
    },
    get: function(name) {
        var results = document.cookie.match(name + '=([^;]*?)(;|$)');
        if (results)
            return (unescape(results[1]));
        else
            return null;
    }
};

var FontSizer = Function.extend({
    constructor: function(type, upid, downid, resetid) {
        this.type = type;
        this.baseSize = 14;
        this.minSize = 9;
        this.maxSize = 20;
        this.stepSize = 2;
        this.cookieName = type + 'FontSize';
        var x = Cookies.get(this.cookieName);
        this.currentSize = x ? parseInt(x) : this.baseSize;

        if (this.currentSize != this.baseSize)
            this.update();

        Aris.Event.add(upid, 'click', this.increase, this);
        Aris.Event.add(downid, 'click', this.decrease, this);
        Aris.Event.add(resetid, 'click', this.reset, this);
        FontSizer[type] = this;
        return this;

    },
    reset: function(e) {
        Cookies.remove(this.cookieName);
        this.currentSize = this.baseSize;
        this.update();
        Aris.Event.stopEvent(e);
    },
    update: function() {
        Cookies.add(this.cookieName, this.currentSize, 7);
        var cont = document.getElementById(this.type);
        Aris.DOM.setStyle(cont, 'fontSize', (this.currentSize / this.baseSize) + 'em');

    },
    increase: function(e) {
        this.currentSize = Math.min(this.currentSize + this.stepSize, this.maxSize);
        this.update();
        Aris.Event.stopEvent(e);
    },
    decrease: function(e) {
        this.currentSize = Math.max(this.currentSize - this.stepSize, this.minSize);
        this.update();
        Aris.Event.stopEvent(e);
    }
});

aFontSizer = new FontSizer('main', 'fsUp', 'fsDown', 'fsNormal');

window.onload = startList;
