//*********************************************************************

//	YouTubeManager Class

//*********************************************************************

// Set up the Namespace for the Application
YAHOO.namespace("cb");

// Create the Application Class
YAHOO.cb.YouTubeManager = function(inOverlayManager) {
	this.youTubePlayers = new Array();
	this.overlayManager = inOverlayManager;
};
YAHOO.cb.YouTubeManager.prototype.youTubePlayers;
YAHOO.cb.YouTubeManager.prototype.overlayManager;
YAHOO.cb.YouTubeManager.prototype.loadPlayer = function( inURL ) { 
	//::TODO:: This manager is way lame needs to clean up on close
	this.youTubePlayers.push( new YAHOO.cb.YouTubePlayer(this.overlayManager) );
	this.youTubePlayers[this.youTubePlayers.length-1].init(inURL);
}



//*********************************************************************

//	YouTubePlayer Class

//*********************************************************************

// Create the Application Class
YAHOO.cb.YouTubePlayer = function(inOverlayManager) {
	this.overlayManager = inOverlayManager;
};
YAHOO.cb.YouTubePlayer.prototype.overlayManager;


//*********************************************************************

//	Init

//*********************************************************************
YAHOO.cb.YouTubePlayer.prototype.init = function( inURL ) { 
	this.inURL = inURL;
	this.idName = "div" + this.rnd( 9999999 );

	// Set Up Logon Panel
	this.simpledialog = new YAHOO.widget.SimpleDialog(
        this.idName,
        { 
            constraintoviewport: true,
            fixedcenter:false,
            width:"440px",
            height:"380px",
			// effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.25},
			modal:false
        }
    );
	this.simpledialog.setHeader("YouTube");
	this.simpledialog.render(document.body);

	this.simpledialog.setBody('<object width="425" height="350"><param name="movie" value="' + inURL + '"></param><param name="wmode" value="transparent"></param><embed src="' + inURL + '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>');
	this.simpledialog.show();
	
	if ( this.overlayManager != null ) {
		this.overlayManager.register([this.simpledialog]); 
	}

	this.simpledialog.beforeHideEvent.subscribe(this.closeDialog, this, true);

}


YAHOO.cb.YouTubePlayer.prototype.closeDialog = function() { 
	this.simpledialog.setBody('');
}

YAHOO.cb.YouTubePlayer.prototype.rnd = function( max ) { 
  var rndnum = max * Math.random()
  rndnum = Math.ceil (rndnum)
  return rndnum
}






	