function StartNews(){
	var ng = new newsgallery(3);

}

var newsgallery = new Class({
	initialize: function(divs){
		//alert("Intialized");
        this.maxDivs = divs;
		this.currentDiv = 1;
		
		this.topicFadeIn = new Fx.Morph('news_topic_1', {duration: 'long', transition: Fx.Transitions.Sine.easeOut});
		this.topicFadeIn.start(".selected_news_topic");
		
		var zdex = 1;
		for(n=1; n<= this.maxDivs; n++) {
			$('news_'+n).setStyle('opacity', 1);
			zdex = this.maxDivs - (n - 1);
			$('news_'+n).setStyle('zIndex', zdex);
		}
		/*
		$('news_2').setStyle('zIndex', 1);
		$('news_1').setStyle('zIndex', 2);
		*/
		this.timer = this.nextFrame.periodical(5000, this);
		
		//set up the links for the newstopics
		for(n=1; n <= this.maxDivs; n++) {
			$('news_topic_'+n).addEvent('click', this.clickTopic.bindWithEvent(this, n));
		}
    },
	nextFrame: function() {
		this.gotoFrame(this.currentDiv+1);	
	},
	gotoFrame: function(frame) {
		var fade = this.currentDiv;
		this.currentDiv = frame;
		if(this.currentDiv > this.maxDivs) {
			this.currentDiv = 1;	
		}
		//alert(fade+" "+this.currentDiv);
		/*
		$('news_'+fade).setStyle('zIndex', 2);
		$('news_'+this.currentDiv).setStyle('zIndex', 1);
		*/
		$('news_'+fade).setStyle('zIndex', this.maxDivs);
		$('news_'+this.currentDiv).setStyle('zIndex', this.maxDivs-1);
		$('news_'+fade).setStyle('opacity', 1);
		$('news_'+this.currentDiv).setStyle('opacity', 1);
		
		this.myEffect = new Fx.Morph('news_'+fade, {duration: 'long', transition: Fx.Transitions.Sine.easeOut});
		this.topicFadeIn = new Fx.Morph('news_topic_'+this.currentDiv, {duration: 'long', transition: Fx.Transitions.Sine.easeOut});
		
		
		this.myEffect.start({
			'opacity': [1, 0]
		});
		
		this.topicFadeIn.start(".selected_news_topic");
		//alert($('news_topic_'+fade).hasClass("selected_news_topic"));
/*		$('.selected_news_topic').setStyles({
			color: "#ff0000",
			'background-image': 'url(../../images/news-arrows.jpg)'
		});*/
		$('news_topic_'+fade).setStyles({
			width: 230
		});
		
		//alert(fade+" "+frame);
	},
	clickTopic: function(e, n) {
		$clear(this.timer);
		try{
			this.myEffect.cancel();
			this.topicFadeIn.cancel();
		} catch(err) {}
		if(this.currentDiv != n) 
			this.gotoFrame(n);
		this.timer = this.nextFrame.periodical(5000, this);
	}
});