/**
 * AbstractNetcastContentHandler
 *
 */

var AbstractNetcastContentHandler = Class.create(AbstractContentHandler,  {
	show: function(data){
		this.data = data;
		netcastTemplateEngine.process(this.tpl, data, this.target, this.finished.bind(this));
	}
});

/**
 * NetcastSimpleRequestHandler
 *
 */

var NetcastSimpleRequestHandler  = Class.create(AbstractNetcastContentHandler, {
	initialize: function(favo){
		this.favo = favo;
		this.provider = new SimpleRequestProvider();
	},
	
	load: function(url, parms){
		this.provider.simpleResultQuery(
				url,
				parms,
				this.simpleResultCallback.bind(this)
			);
	},
	
	showSimpleResult: function(result){
		res = result.getStateText();
		if (result.getState())
			core.notify(res);
		else
			core.notify(res, false);
		if (this.favo)
			netcastcore.loadFavo();
	}
});

/**
 * NetcastMenuHandler
 *
 */

var NetcastSettingsHandler  = Class.create(AbstractNetcastContentHandler, {
	initialize: function($super, target){
		$super('tplSettings', target);
		this.provider = new NetcastSettingsProvider(this.show.bind(this));
		this.ajaxload = true;
	},

	show : function(data){
		setContentHd(netcastMenu.setup);
		netcastcore.currentNetcastList = netcastcore.NONE;
		this.data = data;
		this.onFinished = [function(){ setSelected(data.bitrate);} ];
		netcastTemplateEngine.process(this.tpl, data, this.target, this.finished.bind(this));
	}
	
});

/**
 * NavNetcastHandler
 *
 */

var NavNetcastHandler  = Class.create(AbstractNetcastContentHandler, {
	initialize: function($super, target, onFinished){
		$super('tplNav', target, onFinished);
		this.provider = new NavNetcastProvider(this.show.bind(this));
		this.ajaxload = true;
	},

	show : function(data){
		this.data = data;
		netcastTemplateEngine.process(this.tpl, data, this.target, this.finished.bind(this));
	}
});

/**
 * CurrentNetcastHandler
 *
 */

var CurrentNetcastHandler  = Class.create(AbstractNetcastContentHandler, {
	initialize: function($super, curTarget, volTarget){
		$super('tplCurrent', curTarget);
		this.provider = new CurrentNetcastProvider(this.show.bind(this));
		this.volTpl = 'tplVolume';
		this.volTarget = volTarget;
	},

	show : function(data){
		this.data = data;
		netcastTemplateEngine.process(this.volTpl, data, this.volTarget);
		netcastTemplateEngine.process(this.tpl, data, this.target, this.finished.bind(this));
	}
});

/**
 * NetcastListHandler
 *
 */

var NetcastListHandler  = Class.create(AbstractNetcastContentHandler, {
	initialize: function($super, target){
		$super('tplList', target);
		this.provider = new NetcastListProvider(this.show.bind(this));
		this.ajaxload = true;
	},
	
	sort: function(by){
		this.provider.sort(by)
	}
});

/**
 * NetcastPluginsHandler
 *
 */

var NetcastPluginsHandler = Class.create(AbstractNetcastContentHandler, {
	initialize: function($super, target){
		$super('tplNavExternals', target);
		this.provider = new NavNetcastPluginsProvider(this.show.bind(this));
		this.ajaxload = false;
	}
});

