var winCol = 0;
function runMovie(src, id, w, h) {
    
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + w +'" height="' + h +'" id="' + id + '" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + src + '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="' + src + '" quality="high" wmode="transparent" width="' + w + '" height="' + h +'" name="' + id + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function wshow(url, width, height) {

    if (!width) width = 640;
    if (!height) height = 480;
    window.open(url, (winCol++), 
                'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' 
                + width + 
                ',height=' + height + 
                ',left=' + ((screen.width - width) / 2) + 
                ',top=' + ((screen.height - height) / 2));
    return false;
}

function trim(str) {

    beg = 0;
    while (str.charAt(beg) == " ") { beg++; }
    end = str.length - 1;
    while (str.charAt(end) == " ") { end--; }

    if (beg <= end) { return str.substring(beg, end + 1); }
    else            { return ""; }
}

// TODO: remove in production
function trace(obj) {

    var s = '';
    for (var a in obj) {

        s += a + ': ' + obj[a] + '\n<br>';
    }    
    var width = 800;
    var height = 600;
    var w = window.open('', 'debug', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
    w.document.write(s);
}
