
function checkPosition(){
    var containerHeight;
    var containerWidth;
    var windowHeight;
    var windowWidth;
    var check;
    var marginAdd;
    var new_margin;

    containerHeight = $('container').getStyle('height').replace('px', '');
    windowHeight    = screen.availHeight;
    check           = windowHeight - containerHeight;
    marginAdd       = 0;
    check = Math.round(check / 2);
    if (check < 0) {
        if ((windowHeight / 2) != Math.round(windowHeight / 2)){
            marginAdd = 1;
        }
        new_margin = - (Math.round(windowHeight / 2) - marginAdd);
    }else{
        new_margin = - Math.round(containerHeight / 2);
    }
    $('container').setStyle('margin-top', new_margin + 'px');

    containerWidth = $('container').getStyle('width').replace('px', '');
    windowWidth    = screen.availWidth;
    check           = windowWidth - containerWidth;
    marginAdd       = 0;
    check = Math.round(check / 2);
    if (check < 0) {
        if ((windowWidth / 2) != Math.round(windowWidth / 2)){
            marginAdd = 1;
        }
        new_margin = - (Math.round(windowWidth / 2) - marginAdd);
    }else{
        new_margin = - Math.round(containerWidth / 2);
    }
    $('container').setStyle('margin-left', new_margin + 'px');
}



window.addEvent('domready', checkPosition);
window.addEvent('resize', checkPosition);

