//-------------------------------
// Class
//-------------------------------

function FeaturedContentApp() {

	
	var _self = this;

	//-------------------------------
	// Constants
	//-------------------------------
	
	//var XML_PATHS = [{"type" : "tabs", "url" : "xml/featuredtabs.xml"}, {"type" : "content", "url" : "xml/featuredcontent.xml"}];
	var XML_PATHS = [{"type" : "tabs", "url" : "http://www.nba.com/blazers/1tabs_grid/rss.xml"}, {"type" : "content", "url" : "http://www.nba.com/blazers/1feature_grid/rss.xml"}];
	
	//-------------------------------
	// Properties
	//-------------------------------
	
	var _featuredContentDataModel;
	var _featuredContentController;
	var _featuredTabsView;
	
	var _counter = 0;
	
	//-------------------------------
	// Constructor
	//-------------------------------
	
	$j(function() {
		_featuredContentController = new FeaturedContentController();
		_featuredContentDataModel = new FeaturedContentDataModel();
		_featuredTabsView = new FeaturedTabsView();
		
		$j(_featuredContentDataModel).bind(_featuredContentDataModel.DATA_COMPLETE, onContentDataComplete);
		
		init();
	});
	
	//-------------------------------
	// Public Methods
	//-------------------------------
	
	//-------------------------------
	// Private Methods
	//-------------------------------
	
	function init() {
		loadData();
	}
	
	function loadData() {
		_featuredContentDataModel.loadJSON(XML_PATHS[_counter]);
	}
	
	//-------------------------------
	// Listeners
	//-------------------------------
	
	function onContentDataComplete(event, data, path) {
		
		switch(path.type) {
			case "tabs" :
				_featuredTabsView.deploy(data);
				break;
			case "content" :
				var d = new Object();
				d.content = data;
				d.type = path.type;
				
				_featuredContentController.deploy(d);
				break;
		}
		
		if(_counter < XML_PATHS.length - 1)	_counter++;
		else return false;
		
		loadData();
	}
}
