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

//	ImageViewerManager Class

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

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

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



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

//	YouTubePlayer Class

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

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


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

//	Init

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

	// Set Up Logon Panel
	this.simpledialog = new YAHOO.widget.SimpleDialog(
        this.idName,
        { 
            constraintoviewport: false,
            fixedcenter:false,
            width:"410px",
            height:"500px",
			effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.25},
			modal:false
        }
    );
	this.simpledialog.setHeader("Images");
	this.simpledialog.render(document.body);
	this.simpledialog.setBody("");
	this.simpledialog.show();
	
	if ( this.overlayManager != null ) {
		this.overlayManager.register([this.simpledialog]); 
	}

	this.simpledialog.beforeHideEvent.subscribe(this.closeDialog, this, true);
	
	// Load Content
	var sUrl = "content/images/index.html";
	var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, this, null);

}


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

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


// ::TODO:: Make this an Obj so I can have more asyncRequests 
YAHOO.cb.ImageViewer.prototype.success = function(obj){ 
	this.simpledialog.setBody( obj.responseText );
	this.simpledialog.show();
}
YAHOO.cb.ImageViewer.prototype.failure = function(obj){ 
	this.simpledialog.setHeader("Error");
	this.simpledialog.setBody( "" );
	this.simpledialog.setFooter( "" );
	this.simpledialog.show();
}



	