//-------------------------------
// Class
//-------------------------------

function SlideShowApp() {

	var _self = this;

	//-------------------------------
	// Constants
	//-------------------------------
	
	var XML_PATH = "http://www.nba.com/blazers/1thankyou/rss.xml";
	
	//-------------------------------
	// Properties
	//-------------------------------
	
	var _slideShowDataModel;
	var _slideShowView;

	var _length;
	
	//-------------------------------
	// Constructor
	//-------------------------------
	
	$j(function() {
		_slideShowDataModel = new SlideShowDataModel();
		_slideShowView = new SlideShowView();
		
		$j(_slideShowDataModel).bind(_slideShowDataModel.DATA_COMPLETE, onSlideShowData);
		$j(_slideShowView).bind(_slideShowView.CONTROLS_CLICK, onControlsClick);
		$j(window).resize(onWindowResize);
	});
	
	//-------------------------------
	// Public Methods
	//-------------------------------
	
	_self.deploy = function() {
		_slideShowDataModel.load(XML_PATH);
	}
		
	//-------------------------------
	// Private Methods
	//-------------------------------
	
	//-------------------------------
	// Listeners
	//-------------------------------
	
	function onWindowResize() {
		$j("#featuredTabContent #thankyou ul.mask li.right").width($j("body").width() - 975 + "px");
	}
	
	function onSlideShowData(event, data) {
		_slideShowView.deploy(data);
		_length = $j(data).find("item").length - 1;
	}
	
	function onControlsClick(event, target) {
		switch($j(target).attr("class")) {
			case "previous" :
				if(_slideShowView.current) _slideShowView.current--;
				break;
			case "next" :
				if(_slideShowView.current < _length) _slideShowView.current++;
				break;
		}
		
		_slideShowView.animate(_slideShowView.current);
		
	}
}
