var randoms = new Array(5,10,1,20,17,13,7,3,4,19);
$(function(){
    $('#main').find('div.box').each(boxy);
});

function boxy(i,el) {
    var e= $(el).children('div.image');
    if(!e.hasClass('static')) make_animate(e,i);
    if(parseInt($('img.logo_z',el).css('bottom'))>0)$('img.logo_z',el).css('bottom',($('span.title',el).height()+7)+'px');
}

function make_animate(el,i) {
    setTimeout(function(){make_cycle(el);},randoms[i]*275);
    var parent = el.parent();
    var ratio = parent.width()/parent.height();
    var w = 20*ratio;
    var h = 20;
    el.parent().hover(function(){
        el.stop().animate({'width':parent.width()+w,'height':parent.height()+h,'left':-w/2,'top':-h/2},1000,"easeOutCirc");
    },function(){
        el.stop().animate({'width':parent.width(),'height':parent.height(),'left':0,'top':0},1000);
    });
}

function make_cycle(el) {
        el.cycle({
            fx:'fade'
        });
}

function startVideo (url) {
    $(function(){
        var params = { allowScriptAccess: "always" };
        var atts = { id: "myytplayer" };
        swfobject.embedSWF(url+"?autoplay=1&amp;enablejsapi=1&amp;playerapiid=ytplayer", 
                           "ytapiplayer", "100%", "100%", "8", null, null, params, atts);
    });
}

function onYouTubePlayerReady(playerId) {
    ytplayer = document.getElementById("myytplayer");
    ytplayer.mute();
}
