//////////////////////////
// New Management       //
//////////////////////////

var news = {};

// current image index
news.currentNewsId = null;

news.initialize = function(newCount){
	
	news.currentNewsId = "article-1";
	
	for (i = 2; i <=  newCount; i++){
		new Fx.Slide("article-" + i + "-long").hide();		
	}

	$(news.currentNewsId).morph("div.article-short-selected");
		
	ReMooz.assign('a.article-img-a', {
		'origin': 'img',
		'shadow': 'onOpenEnd', // fx is faster because shadow appears after resize animation
		'resizeFactor': 0.8, // resize to maximum 80% of screen size
		'cutOut': false, // don't hide the original
		'opacityResize': 0.4, // opaque resize
		'dragging': false, // disable dragging
		'centered': true // resize to center of the screen, not relative to the source element
	});
}

news.swapNews = function (elem) {

	// close the current element
	if ($(news.currentNewsId) != null) {
		new Fx.Slide(news.currentNewsId + "-long").slideOut().chain(
			function(){
    			news.openNews(elem);
			}
		);
		$(news.currentNewsId).morph("div.article-short");
	}	
	else {
		news.openNews(elem);
	}
	
}
news.openNews = function(elem){
	// open the new element
	if ( news.currentNewsId != elem.id) {
		news.currentNewsId = elem.id;
		
		new Fx.Slide(news.currentNewsId + "-long").slideIn();
		$(news.currentNewsId).morph("div.article-short-selected");

	// reset currentNewsId if is the same of new element
	} else {
		news.currentNewsId = null;
	}
}

news.onClickImage = function(obj){
}
