var diamantConf = {
    initialized: false,
    duration:    2500,  // [msec]
    pause:       3000,  // [msec]  pauze tussen einde van de vorige en begin van de volgende
    //duration:    600,   // [msec]
    //pause:       200,   // [msec]  pauze tussen einde van de vorige en begin van de volgende
    randomLeft:  -1,    // [px]    marge links (-1 = automatisch, linkerkant van wrapper)
    randomTop:   75,    // [px]    marge boven
    randomWidth: 950    // [px]    hoe breed is het vlak waarbinnen de diamant moet verschijnen?
};

function docLoaded(startMovie, startDiamant) {
    if (startMovie) {
        var ufoOptions = {
            movie: "/flash/diamanten.swf",
            allowfullscreen: "true",
            width: 620, //950,
            height: 620,
            wmode: 'transparent',
            majorversion: "7",
            build: "0"
        }
        UFO.create(ufoOptions, 'movie');
        window.setTimeout("var el = document.getElementById('movie'); if (el) el.style.display='none';", 8300);
    }
    if (startDiamant) {
        window.setTimeout("startDiamant()", 8300);
    }
}

function startDiamant() {
    if (!diamantConf.initialized) {
        var ufoOptions = {
            movie: "/flash/diamant.swf",
            allowfullscreen: "true",
            width: 15,
            height: 20,
            wmode: 'transparent',
            majorversion: "7",
            build: "0"
        }
        UFO.create(ufoOptions, 'diamant');
        diamantConf.initialized = true;
    }
    var el = document.getElementById('diamant'); 
    if (!el) {
        return false;
    }
    
    // randomize positie
    var scrollY = 0;
    if (window.pageYOffset) {
        scrollY = window.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        scrollY = document.documentElement.scrollTop;
    } else if (document.body) {
        scrollY = document.body.scrollTop;
    }

    var bodyWidth, bodyHeight;
    if (self.innerHeight) {
        // all except Explorer
        bodyWidth = self.innerWidth;
        bodyHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        // Explorer 6 Strict Mode
        bodyWidth  = document.documentElement.clientWidth;
        bodyHeight = document.documentElement.clientHeight;
    } else if (document.body) {
        // other Explorers
        bodyWidth = document.body.clientWidth;
        bodyHeight = document.body.clientHeight;
    } else {
        bodyWidth = 1000;
        bodyHeight = 500;
    }

    diamantConf.randomLeft = (bodyWidth / 2) - (950 / 2);

    var x = Math.floor(diamantConf.randomLeft + Math.random() * diamantConf.randomWidth - 20);
    var y = Math.floor(diamantConf.randomTop + scrollY + Math.random() * (bodyHeight - diamantConf.randomTop) - 25);

    el.style.left    = x + 'px';
    el.style.top     = y + 'px';
    el.style.display = '';

    window.setTimeout("var el = document.getElementById('diamant'); if (el) el.style.display='none';", diamantConf.duration);
    window.setTimeout("startDiamant();", diamantConf.duration + diamantConf.pause);
}
