/* 
 * léápőúöüó
 * articles modul js fuggvenyei
 *
 */

/**
 * topstory lapváltó
 */
function articlesTopStoryChange(num) {
	articlesTopStory.set('actual',num);
	var h=$H($H(articlesTopStory).get('data')[num])

	$('articles_topstory_img_link').href=h.get('link');
	$('articles_topstory_img_src').src=h.get('img');
	//$('articles_topstory_img').update('<a href="#{link}"><img src="#{img}"></a>'.interpolate(h));
	$('articles_topstory_title').update('<a href="#{link}">#{title}</a>'.interpolate(h));
	$('articles_topstory_lead').update(h.get('lead')+'&nbsp;&nbsp;<a href="#{link}">Tovább &raquo;</a>'.interpolate(h));

	$$('.article_topstory .pages DIV').invoke('removeClassName','page_select');
	$('articles_topstory_page'+num).addClassName('page_select');
}

/**
 * topstory aktuális lap linkelése
 */
function articlesTopStoryLink() {
	var num=articlesTopStory.get('actual');
	location.href=$H($H(articlesTopStory).get('data')[num]).get('link');
}

/**
 * betolti elore a cikk kepeit
 */
function articlesTopStoryInit() {
	var h=articlesTopStory;

	h.get('data').each(function(item) {
		var hh=$H(item);
		var i=new Image();
		i.src=hh.get('img');
	});
}

/**
 * beállítja az automatikus léptetést
 */
function articlesTopStoryAutoNext(set) {
	articlesTopStoryAutoNextState=set;
}

/**
 * lépteti az ajánlót...
 */
function articlesTopStoryStep(id) {
	if(!articlesTopStoryAutoNextState) return false;
	if(articlesTopStoryAutoNextId!=id) return false;
	var actual=articlesTopStory.get('actual');
	articlesTopStoryChange((actual+1)%5);

	articlesTopStoryStep.delay(articlesTopStoryStepDelay,id);
}
