function obj(sName) {
    if (document.all)
        return document.all[sName];
    else if (document.getElementById)
        return document.getElementById(sName);
    else
        return null;
}
var flashVideoPlayer;
var vidStarted = false;
var vidHitzone = obj('vidHitzone');
var isIE6 = false; // for initPlayer and toggleVideo

function initPlayer() {
    /* Check whether the browser is IE6. If so, flashVideoPlayer is
    window.videoPlayer. Otherwise, it's document.videoPlayer. The
    videoPlayer is the ID assigned to the <object> and <embed> tags. */
    isIE6 = (parseInt(navigator.appVersion.split('MSIE')[1]) == 6); // passed
    // this is for IE6
    //flashVideoPlayer = (isIE6) ? window['videoPlayer'] : document['videoPlayer'];
    flashVideoPlayer = document['videoPlayer'];
}

function toggleVideo(itemID, vid, targW, targH) {
    var vidObj = obj(itemID);
    var currentWidth = vidObj.style.width;
    var targetW = parseInt(targW);
    var targetH = parseInt(targH);
    if (!(targetW > 0)) { targetW = 320; }
    if (!(targetH > 0)) { targetH = 240; }


    // if toggleVideo() got called before initPlayer(), then flashVideoPlayer object is not set up yet...
    if (flashVideoPlayer == null || typeof flashVideoPlayer == "undefined") {
        initPlayer();
    }


    if (currentWidth == targetW + 'px') {
        flashVideoPlayer.width = 1;
        flashVideoPlayer.height = 1;
        vidObj.style.width = '1px';
        vidObj.style.height = '1px';
        vidObj.style.backgroundColor = '#fff';
    }
    else {
        flashVideoPlayer.width = targetW;
        flashVideoPlayer.height = targetH;
        vidObj.style.width = targetW + 'px';
        var adjHie6 = (isIE6) ? 10 : 0; // to fix height in IE6
        if (itemID != 'FlashAsset')
            var adjH = targetH + 20 + adjHie6; // to fix problem in IE7 with overflow;hidden
        else
            var adjH = targetH + adjHie6; // to fix problem in IE7 with overflow;hidden
        vidObj.style.height = adjH + 'px';
        vidObj.style.backgroundColor = '#3c3c3c';
    }

    if (vidStarted == false) {
        flashVideoPlayer.playVideo("rtmp://varolii.fcod.llnwd.net/a3774/o9/Public/Varolii.com/" + vid, "/shared/swf/video/ClearOverAll.swf");
        vidStarted = true;
    }
    else {
        flashVideoPlayer.pauseResume();
    }
}

function toggleInlineVideo(itemID, vid, targW, targH) {
    if (vidStarted == false) {
        obj('videoHotspot').style.display = 'none';
        obj('FlashAsset').style.right = '0';
        flashVideoPlayer.playVideo("rtmp://varolii.fcod.llnwd.net/a3774/o9/Public/Varolii.com/" + vid, "/shared/swf/video/ClearOverAll.swf");
        vidStarted = true;
    }
    else {
        flashVideoPlayer.pauseResume();
    }
}


