/*
* Landing_Home
*/

var minScreenSize = { width: 950, height: 650 };
var layoutMode = "box";

var totalLength = $('ul.copy-collection li').length;

var zmax = 0;

function showNextCopy(index){    

    if(index >= totalLength) {
        index = 0;
    }
    
    var current = $('ul.copy-collection li')[index];
    
    $(current).css("display","block");    
    $(current).siblings().css("display","none");  
}

function centerBoxes() {
    $("#boxes").verticalCenter({
        minH: 400,
        maxH: 400,
        offsetTop:70,
        offsetBot:0
    });
}

//Array of objects which contain start and end points
// software, our work,
var boxGrid = [
    {
        start: { x: 1614, y: 222 },
        end: { x: 614, y: 202 }
    },
    {
        start: { x: -1011, y: 132 },
        end: { x: 400, y: 50 }
    },
    {
        start: { x: 524, y: 1077 },
        end: { x: 524, y: -77 }
    },
    {
        start: { x: 575, y: -933 },
        end: { x: 550, y: -55 }
    },
    {
        start: { x: 575, y: -933 },
        end: { x: 11, y: 50 }
    }
];

//Executed after the box arrangement is complete
function postArrangement() {
    // initialize large flash
    var flashvars_large = {
        mediapath: videoPath,
        launchSiteURL: url
    };
    var params_large = {
        wmode: 'transparent',   // so draggable windows can appear on top of flash
        allowFullScreen: 'true',
        bgcolor: "#000000"
    }; 
    var attributes_large = {};
    if(swfPath == '')
    { 
        if(location.pathname == '/en/')
            swfPath = '/swf/video_FS_483x298.swf'; 
        else
            swfPath = '/swf/video_483x298.swf'; 
    }            
    swfobject.embedSWF(swfPath, 'large-media', '483', '298', '8.0.0', '/swf/expressInstall.swf', flashvars_large, params_large, attributes_large);
    
    //Start slideshow
    $('ul.image-collection-slideshow').cycle({
	    fx: 'fade', 
        speed: 1500 
	});
    
}


// wait for background image to load
$(document).bind('backgroundLoaded', function(){
    
    $('div.loading-container').fadeOut(500);
    $('div.landing-container').show();
    
    // 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,null);

    centerBoxes();  //must be post-background load!
    postArrangement();
});                

$(window).resize(centerBoxes);

$(document).ready(function() {



    $('ul.copy-collection li').css("display", "none");

    if (!($.browser.msie)) {
        $('select.sr').replaceSelect();

    }

    $(".move-shadow-03").bgiframe();
    $(".movebox-shadow-container-01").bgiframe();

    $('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);
    });
});




