function Document()
{
}

Document.prototype.initialize = function()
{
    this.printYear();
    this.setBackground();
}

Document.prototype.printYear = function()
{
    var text = document.createTextNode(new Date().getFullYear());
    document.getElementById('year').appendChild(text);
}

Document.prototype.setBackground = function()
{
    var image = null;
    
    if (screen.width <= 800)
    {
        image = this.getPath() + 'pics/background_800_600.jpg';
    }
    else if (screen.width <= 1024)
    {
        image = this.getPath() + 'pics/background_1024_768.jpg';
    }
    else if (screen.width <= 1152)
    {
        if (screen.height <= 768)
        {
            image = this.getPath() + 'pics/background_1152_768.jpg';
        }
        else
        {
            image = this.getPath() + 'pics/background_1152_864.jpg';
        }
    }
    else if (screen.width <= 1280)
    {
        if (screen.height <= 720)
        {
            image = this.getPath() + 'pics/background_1280_720.jpg';
        }
        else if (screen.height <= 800)
        {
            image = this.getPath() + 'pics/background_1280_800.jpg';
        }
        else
        {
            image = this.getPath() + 'pics/background_1280_960.jpg';
        }
    }
    else if (screen.width <= 1366)
    {
        image = this.getPath() + 'pics/background_1366_768.jpg';
    }
    else if (screen.width <= 1440)
    {
        if (screen.height <= 960)
        {
            image = this.getPath() + 'pics/background_1440_960.jpg';
        }
        else
        {
            image = this.getPath() + 'pics/background_1440_1080.jpg';
        }
    }
    else if (screen.width <= 1600)
    {
        if (screen.height <= 900)
        {
            image = this.getPath() + 'pics/background_1600_900.jpg';
        }
        else
        {
            image = this.getPath() + 'pics/background_1600_1200.jpg';
        }
    }
    else if (screen.width <= 1920)
    {
        if (screen.height <= 1080)
        {
            image = this.getPath() + 'pics/background_1920_1080.jpg';
        }
        else
        {
            image = this.getPath() + 'pics/background_1920_1440.jpg';
        }
    }
    else if (screen.width <= 2048)
    {
        if (screen.height <= 1152)
        {
            image = this.getPath() + 'pics/background_2048_1152.jpg';
        }
        else
        {
            image = this.getPath() + 'pics/background_2048_1536.jpg';
        }
    }
    else if (screen.width <= 2560)
    {
        if (screen.height <= 1440)
        {
            image = this.getPath() + 'pics/background_2560_1440.jpg';
        }
        else if (screen.height <= 1600)
        {
            image = this.getPath() + 'pics/background_2560_1600.jpg';
        }
        else if (screen.height <= 1920)
        {
            image = this.getPath() + 'pics/background_2560_1920.jpg';
        }
        else
        {
            image = this.getPath() + 'pics/background_2560_2048.jpg';
        }
    }
    else if (screen.width <= 2800)
    {
        image = this.getPath() + 'pics/background_2800_2100.jpg';
    }
    else if (screen.width <= 3200)
    {
        image = this.getPath() + 'pics/background_3200_2400.jpg';
    }
    
    if (image != null)
    {
        document.getElementsByTagName('body')[0].setAttribute('style', 'background-image:url("' + image + '")');
    }
}

Document.prototype.getPath = function()
{
    return document.getElementById('path').content;
}

Document.prototype.loadXMLDocument = function(filename)
{
    var xhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
    xhttp.open('GET', this.getPath() + 'xml/' + filename, false);
    xhttp.send('');
    return xhttp.responseXML;
}