//$(function(){
//    var image = new Image()
//    image.onload = function() {
//        var FullscreenrOptions = {
//            width: 1220,
//            height: 700,
//            bgID: '#backgroundImage',
//            callbackFunc: function(left, top, width, height){
//                moveObjects(left, top, width, height);
//            }
//        };
//        $.fn.fullscreenr(FullscreenrOptions);
//    }
//    image.src = $('#backgroundImage').attr('src');
//});

$(function(){
    $('#backgroundImage').width(1220);
    $('#backgroundImage').height(700);
    $(window).resize(function(){
        adjustImage();
    });
    $(window).resize();
});

function adjustImage() {
    $('#backgroundImage').height($(window).height());
    $('#backgroundImage').width(
        1220 * parseInt($('#backgroundImage').height()) / 700
        );
            
    $('#backgroundImage').css('margin-left', ($(window).width() - $('#backgroundImage').width()) / 2);
    moveObjects(parseInt($('#backgroundImage').css('margin-left')), 0, $('#backgroundImage').width(), $('#backgroundImage').height());
}

var defaultPositions = [[280,136],[522,136],[760,136],[390,475],[660,475]];

function moveObjects(left, top, width, height) {
    var ratio = height / 700;

    $('.linkObject').each(function(index){
        $(this).width(200 * ratio);
        $(this).height(200 * ratio);
        $(this).css('left', (defaultPositions[index][0] * ratio  + parseInt(left)) + 'px');
        $(this).css('top',  (defaultPositions[index][1] * ratio + parseInt(top)) + 'px');
    });
}
