/**
 * Streaming Culture Global Scripts
 *
 * @version $Id: global.js,v 1.13 2004/04/18 22:34:54 david Exp $
 * @author <a href="http://www.pudg.org">Public Digital</a>
 */

/* Constants */
var LAUNCH_URL      = "http://www.streamingculture.org:80"
  + "/directory/launch/preferences?mediaid=";
var LAUNCH_WIDTH    = 325;
var LAUNCH_HEIGHT   = 390;
var LAUNCH_FEATURES = "left=10,top=10,screenx=10,screeny=10,scrollbars=no,resizeable=yes,status=yes";

/* This popup window */
var sclaunch = null;
var launchURL = null;



/**
 * Creates a window for choosing speed and format
 * preferences for a piece of media.
 *
 * Parameter id: the media's id number, as is catalogued
 * in the content management system
 */
function launch(id) {
    var myIDStr = new Number(id).toString();
    var myLaunchFeatures = LAUNCH_FEATURES + ",width=" + LAUNCH_WIDTH 

        + ",height=" + LAUNCH_HEIGHT;

    launchURL = LAUNCH_URL + myIDStr;
    sclaunch = window.open (launchURL, "StreamingCulture", myLaunchFeatures);
    setTimeout("checkLaunch()", 500);
}




/**

 * Create a window for choosing spped and format

 * preferences with space for a credit line at the bottom

 */

function cobrandLaunch(id) { 

    LAUNCH_HEIGHT = 405;

    launch(id);

    LAUNCH_HEIGHT = 390;

}




/**
 * Test that the 'sclaunch' popup was successfully created.
 * If not, send the main browser window to the media launch page.
 */
function checkLaunch() {
    if((typeof(sclaunch) != "object") || (sclaunch == null)) {
        // Oops, popup not created--popup blocker?
        if (launchURL != null) {
            window.location.href=launchURL;
        }
    } else {
        // Window created--bring to fore
        if (! sclaunch.closed) { 
            sclaunch.focus();
        }
    }
}
