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

//	Writing Class

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

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

// Create the Application Class
YAHOO.cb.Writing = function(inOverlayManager) {
	this.content_simpledialog = null;
	this.overlayManager = inOverlayManager;
	this.init();
};

YAHOO.cb.Writing.prototype.content_simpledialog = null;


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

//	Init

//*********************************************************************
YAHOO.cb.Writing.prototype.init = function() { 
	if ( this.content_simpledialog == null ) {
		
		this.content_simpledialog = new YAHOO.widget.SimpleDialog(
	        "content_simpledialog",
	        { 
	            constraintoviewport: true,
	            fixedcenter:false,
	            width:"270px",
	            x:10,
	            y:50,
				effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.25},
				modal:false,
				visible:false
	        }
	    );

		this.content_simpledialog.setHeader("");
		this.content_simpledialog.setBody("");
		this.content_simpledialog.setFooter("");
		this.content_simpledialog.render(document.body);
		
		if ( this.overlayManager != null ) {
			this.overlayManager.register([this.content_simpledialog]); 
		}
	}
	
}

YAHOO.cb.Writing.prototype.loadContent = function(inURL){ 
	// ::TODO:: if its already up don't reload!
	this.content_simpledialog.setHeader("Loading ....");
	this.content_simpledialog.setBody("");
	this.content_simpledialog.show();

	// Load Content
	// var sUrl = "content/IsItYou.html";
	var transaction = YAHOO.util.Connect.asyncRequest('GET', inURL, this, null);

	// var anim = new YAHOO.util.Motion('content_simpledialog', { points: { to: [300,300] } });
	// anim.animate();
}

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

/*
var contentHandler =  {
  success: contentHandleSuccess,
  failure: contentHandleFailure,
  argument: { foo:"foo", bar:"bar" },
  timeout: 10000
};
function contentHandleSuccess(obj){
	alert('success');
	alert(obj);
}
function contentHandleFailure() {
	alert('failure');
	contentPanel.setHeader("Failure");
	contentPanel.setBody( "Unable to Load Content");
	contentPanel.render(document.body);
}
*/

