﻿var Index =
{
    init: function (record_hit_count) 
    {
        var reSize = function () 
        {
            $('#contentDiv').css({ height: ($('#mainView').height() - ($("#copyrightDiv").height() + $("#mainMenu").height())) + "px" });
        }

        var unLoad = function () 
        {
            $.ajax({
                url: 'servlets/sign-out.asp',
                type: 'POST',
                dataType: 'xml'
            });
        }

        var thisYear = function () 
        {
            $.ajax({
                url: 'servlets/copyright.asp',
                type: 'POST',
                dataType: 'xml',
                timeout: 7000,
                error: function (xml) { alert(xml.responseText); },
                success: function (xml) 
                {
                    var copyright;
                    $('element', xml).each(function (i) {
                        copyright = $(this).find('copyright').text();
                    });
                    $('#copyright').text(copyright);
                }
            });
        }

        reSize();
        thisYear();

        if (record_hit_count) 
        {
            $.ajax({
                url: 'servlets/hitcount.asp',
                type: 'POST',
                dataType: 'xml'
            });
        }

        $(window).bind('resize', reSize);
        $(window).bind('unload', unLoad);
        $(document).bind('contextmenu', function () { return false; });
    },

    menulink: function (object, destination) {
        var ext = destination.substring(destination.lastIndexOf('.'));

        if (ext != '.html') {
            var uid = 'uid=' + (new Date()).getTime();
            if (destination.indexOf('?') == -1) {
                destination += '?';
            }
            else {
                destination += '&';
            }
            destination += uid;
        }
        object.location = destination;
    }
}
