
RISE.McPagePreview = SZN.ClassMaker.makeClass({
	NAME: "Tabs",
	VERSION: "1.0",
	CLASS: "class"
});
RISE.McPagePreview.prototype.$constructor = function(id) {
	this.previewTabs = false;
	this.tabTimer = false;
	
	
	this.eventsCache = [];
	this.eventsCache.push(SZN.Events.addListener(window,"unload",this,"$destructor",false,true));
	
}
RISE.McPagePreview.prototype.$destructor = function() {
	for (var i=0;i<this.eventsCache.length;i++) {
		SZN.Events.removeListener(this.eventsCache[i]);
	}
	for (var p in this) { this[p] = null; }
}

RISE.Slide = SZN.ClassMaker.makeClass({
	NAME: "Slide",
	VERSION: "1.0",
	CLASS: "class"
});
RISE.Slide.prototype.$constructor = function(idTab) {
	this.imageTimer = false;
	this.elements = [];
	this.timeout = 3000;
	this.fadeTime = 600;
	this.timer = false;
	this.active = false;
	
	this.eventsCache = [];
	this.eventsCache.push(SZN.Events.addListener(window,"unload",this,"$destructor",false,true));
	/*
	var legends = $('#mcPagePreviewTabs .legend').get();
	for(l=0;l<legends.length;l++){
		this.eventsCache.push(SZN.Events.addListener(legends[l],"click",this,"stop",false,true));
	}
	this.eventsCache.push(SZN.Events.addListener(SZN.gEl(idTab),"click",this,"start",false,true));
	*/
	//this.start();
}
RISE.Slide.prototype.$destructor = function() {
	for (var i=0;i<this.eventsCache.length;i++) {
		SZN.Events.removeListener(this.eventsCache[i]);
	}
	for (var p in this) { this[p] = null; }
}
RISE.Slide.prototype.add = function(id) {
	this.elements.push(SZN.gEl(id));
	if(this.elements.length>1) $(SZN.gEl(id)).hide();
	else{
		this.active = 0;
	}
	if(this.timer) this.start();
	this.eventsCache.push(SZN.Events.addListener(SZN.gEl(id),"click",this,"next",false,true));
}
RISE.Slide.prototype.start = function() {
	this.stop();
	var mThis = this;
	this.timer = setInterval(function(){ mThis.next(); },this.timeout);
}
RISE.Slide.prototype.stop = function() {
	clearInterval(this.timer);
}
RISE.Slide.prototype.next = function() {
	
	if(this.elements.length<2) return false;

	$(this.elements[this.active]).fadeOut(this.fadeTime);
	this.active++;
	if(this.active>=this.elements.length) this.active=0;

	$(this.elements[this.active]).fadeIn(this.fadeTime);
}
