document.onready = [];

(function() {
     try {
         var d = document.createElement('DIV');
         d.style.display = 'none';
         document.body.appendChild(d);
         d.parentNode.removeChild(d);
     } catch(e) {
         window.setTimeout(arguments.callee, 10);
         return;
     }

     for (var i = 0; i < document.onready.length; i++)
         document.onready[i]();
})();

fixLayout = function() {
    var m = document.getElementById('main'),
        g = document.getElementById('gallery-photos'),
        w = m.clientWidth;

    if (window.lteIE6)
        m.style.width = (w > 1800) ? '1700px' : 'auto';

    g.style.width = 'auto';
    var n = Math.floor(document.getElementById('gallery').clientWidth / 236);
    g.style.width = n * 240 + 'px';

    /*if (w < 1100) {
        g.style.width = '708px';
        //g.style.marginLeft = '-354px';
    } else {
        g.style.width = '944px';
        //g.style.marginLeft = '-472px';
    } */
}

document.onready.push(function() {
    fixLayout();

    document.body.onresize = fixLayout;
    window.onresize = fixLayout;
});

moveRight = function() {
    var g = document.getElementById('gallery-photos'),
        p = g.getElementsByTagName('A');
    g.appendChild(g.removeChild(p[0]));
}

moveLeft = function() {
    var g = document.getElementById('gallery-photos'),
        p = g.getElementsByTagName('A');
    g.insertBefore(g.removeChild(p[p.length - 1]), p[0]);
}