// Random Image Loader Support Functions
function pickRandom(list) {
    return list[Math.round(Math.random() * (list.length - 1))];
}

function applyBgImg(imagePath, el) {
    if(document.getElementById) {
        var e = document.getElementById(el);
        if(e) {
            e.style.backgroundImage = 'url(' + imagePath + ')';
            return true;
        }
    }
    return false;
}

// Media Player Support Functions
function getMovie(swf) {
    if(navigator.appName.indexOf("Microsoft") != -1) return window[swf];
    else return document[swf];
}

function vidEvent(swf,typ,prm) { 
    getMovie(swf).sendEvent(typ,prm); 
}

function playVideo(vidId) {
    if(getMovie(vidId)) {
        vidEvent(vidId, 'playpause');
    } else {
        window.setTimeout(function(vidId) {
            playMovie(vidId);
        }, 1000);
    }
}

// Functions to open and close the video popup
function openPopup() {
    window.open(this.href, 'vid_window', 'location=no,menubar=no,resizable=no,status=no,toolbar=no,width=360,height=280');
    return false;
}

function closePopup() {
    if(getMovie('intro')) vidEvent('intro','stop');
    window.close();
    return false;
}