var minScreenSize = { width: 950, height: 640 };
var layoutMode = "box";

var zmax = 0;

function centerBoxes() {
    $("#boxes").verticalCenter({
        minH: 500,
        maxH: 500,
        offsetTop: 40,
        offsetBot:0     
    });  
}

//Array of objects which contain start and end points
/* studio, commerce,  media, software,  agency*/
var boxGrid = [
    {
        start:{x:214,y:-987},
        end:{x:214,y:13}
    },
    {   
        start:{x:-993,y:154},
        end:{x:7,y:154}
    },
    {
        start:{x:1551,y:123},
        end:{x:551,y:123}
    },
    {
        start:{x:618,y:1253},
        end:{x:618,y:253}
    },
    {   
        start:{x:133,y:1284},
        end:{x:133,y:284}
    }
];

// wait for background image to load
$(document).bind('backgroundLoaded', function(){
    
    // initialize the page
    $('div.landing-container').fadeIn(500);
    $('div.loading-container').fadeOut(500);

    // setup the dynamic arrange on the boxes, init the slide show at the end of each element's animation
    $('#boxes').dynamicArrange(boxGrid,'box-','div.movebox-content *',null,'');
  
    centerBoxes();
});

$(window).resize(centerBoxes);

$(document).ready(function(){
    
    
    $('div.movebox').draggable({
        stack: { group: '.movebox', min: 1003 },
        handle: '.movebox-title'
    });
    
    $('div.movebox').mousedown(function() {
        $(this).siblings('div.movebox').each(function() {
            zmax = Math.max(zmax, $(this).css('zIndex'));
        });
        $(this).css('zIndex', zmax+1);
    });
    
    
});