﻿jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
    random: function (a, i, m, r) {
        return Math.round(Math.random() * r.length);
    }
});
function fIn() {
    var arr = jQuery.makeArray($("#splash div div:not(.open)"));
    $(arr[Math.floor(arr.length * Math.random())]).addClass("open").animate({ opacity: 1 }, 350, function () {
    });
    setTimeout("fIn()", Math.floor(Math.random() * 100) + 20);
}
$(document).ready(function () {
    var items = new Array();
    $(".splashitems").each(function () {
        items.push($(this))
        $(this).remove();
    });
    function makeBox1() {
        var o = items.pop()
        return "<div class=\"box1\">" + o.html().replace("/233/-1/", "/408/-1/") + "</div>"
    }
    function makeBox2() {
        var o = items.pop()
        return "<div class=\"box2\">" + o.html().replace("/233/-1/", "/198/-1/") + "</div>"
    }
    function makeBox3() {
        var o = items.pop()
        return "<div class=\"box3\">" + o.html().replace("/233/-1/", "/128/-1/") + "</div>"
    }
    function makeBox4() {
        var o = items.pop()
        return "<div class=\"box4\">" + o.html().replace("/233/-1/", "/93/-1/") + "</div>"
    }
    function gen4(last) {
        if (last)
            $("#splash").append("<div class=\"lastcol\">" + makeBox4() + makeBox4() + makeBox4() + makeBox4() + "</div>");
        else
            $("#splash").append("<div class=\"col\">" + makeBox4() + makeBox4() + makeBox4() + makeBox4() + "</div>");
    }
    function gen3(last) {
        if (last)
            $("#splash").append("<div class=\"lastcol\">" + makeBox3() + makeBox3() + makeBox3() + "</div>");
        else
            $("#splash").append("<div class=\"col\">" + makeBox3() + makeBox3() + makeBox3() + "</div>");
    }
    function gen2(last) {
        if (last)
            $("#splash").append("<div class=\"lastcol\">" + makeBox2() + makeBox2() + "</div>");
        else
            $("#splash").append("<div class=\"col\">" + makeBox2() + makeBox2() + "</div>");
    }
    function gen1(last) {
        if (last)
            $("#splash").append("<div class=\"lastcol\">" + makeBox1() + "</div>");
        else
            $("#splash").append("<div class=\"col\">" + makeBox1() + "</div>");
    }
    var r = Math.random() * 4
    if (r < 1) {
        gen3();
        gen2();
        gen1();
        gen2(true);
    } else if (r < 2) {
        gen1();
        gen3();
        gen1(true);
    } else if (r < 3) {
        gen2();
        gen4();
        gen2();
        gen3();
        gen2();
        gen4(true);
    } else {
        gen4()
        gen1()
        gen2()
        gen3()
        gen4(true)
    }
    $("#splash div div").each(function () {
        $(this).css({ opacity: 0, backgroundColor: "White" });

    });
    fIn();
});
