﻿window.onload = function () {

    // fix the background image
    var number_of_images = 4;
    var pick_random_image = (Math.floor(Math.random(0) * number_of_images));
    $('div#background_image').css('background-image', 'url(App_Themes/Woberator/bg_woberator_' + pick_random_image + '.jpg)');

    // scroll to the correct step
    var step = $.query.get('step');

    if (step == '' || step == true || isNaN(step) || step < 1 || step > 10) {
        // querstring 'step' is not defined, too big, too small, or not a number: jump to step 1
        $('div#keyhole').scrollTo($("#step01"), 0);
        $('#stepbar a.stepbar01').addClass('selected');
    }
    else {
        // jump to correct step
        var stepstring = String(step);
        if (stepstring.length < 2) stepstring = '0' + stepstring;
        $('div#keyhole').scrollTo($("#step" + stepstring), 0);
        $('#stepbar a.stepbar' + stepstring).addClass('selected');
    }

    EmbedVideos(videos);

};

function EmbedVideo(_clip_id) {

    swfobject.embedSWF(
                "http://vimeo.com/moogaloop.swf?clip_id=" + _clip_id + "&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1",
                "AlternativeContent" + _clip_id,
                "250",
                "141",
                "9.0.0",
                false,
                { 'js_api': 1 }, /* flashvars */
                {'allowfullscreen': true, 'allowscriptaccess': 'always' }, /* params */
                {'id': 'VimeoObject' + _clip_id} /* attributes */
            );

}

function EmbedVideos() {
    for (var t = 0; t < videos.length; t++) {
        EmbedVideo(videos[t]);
    }
}

function PauseVideo(_clip_id) {
    var vimeoAPI = document.getElementById('VimeoObject' + _clip_id);
    vimeoAPI.api_pause();
}

function PauseVideos() {
    for (var t = 0; t < videos.length; t++) {
        PauseVideo(videos[t]);
    }
}


