//
// Streamstudio Javascript library
// (c) 2006, World Television
// 

function _isStStFrame(name) {
    return name == "robotframe";
}

function StstResize(targetWidth, targetHeight) {
		resizeAllowed = true;
		try 
		{
			top.window.resizeTo(targetWidth,targetHeight);
		}
		catch(xyz)
		{
			resizeAllowed = false;
		}
		if (resizeAllowed) 
		{
	    try 
	    {
	        if (top.window.innerHeight) 
	        {
	            top.window.innerHeight = targetHeight;
	            top.window.innerWidth = targetWidth;
	            if (top.window.outerHeight == targetHeight) 
	            {
	                    if (top.window.document.body.clientWidth) 
	                    {
	                        top.window.document.body.style.margin = "0px 0px";
	                        top.window.resizeTo(targetWidth+(targetWidth-top.window.document.body.clientWidth),targetHeight+(targetHeight-top.window.document.body.clientHeight));
	                    }
	                    else 
	                    {
	                        top.window.resizeTo(targetWidth+10,targetHeight+60);
	                    }
	            }
	        }
	        else if (top.window.document.body.clientWidth) 
	        {
	                top.window.document.body.style.margin = "0px 0px";
	                top.window.resizeTo(targetWidth+(targetWidth-top.window.document.body.clientWidth),targetHeight+(targetHeight-top.window.document.body.clientHeight));
	        }
	        else 
	        {
	            top.window.resizeTo(targetWidth+10,targetHeight+60);
	        }
	    }
	    catch(xyz)
	    {
	        top.window.resizeTo(targetWidth+10,targetHeight+60);
	    }
  	}
}


function getFrame(framename)
{
    var current = window; 
    while (current != current.parent)
    {
        if (framename == null)
            return current.parent; 
        else
            return current.parent.frames[framename];
        
        current = current.parent; 
    }
    
    return null; 
}

function getMediaPlayerFrame() {
    ststMediaFrame = getFrame("streamPage");
    if (ststMediaFrame != null)
        return ststMediaFrame;
    else
        return null;
}

function output(str)
{ document.write(str); }

var _FLplayerState = { time: 0, totalTime: 0 };
var FLplayer = null;

function playerReady(thePlayer) { FLplayer = window.document[thePlayer.id]; FLplayer.addModelListener("TIME", "mediaPlayerInternal_timeListener"); }

function mediaPlayerInternal_timeListener(event) {
    _FLplayerState['time'] = Math.round(event.position);
    _FLplayerState['totalTime'] = Math.round(event.duration);
}
