var activeIndexPanelNews = 1;
var activeIndexPanelMaxNews = 18;
var panelNewsTimerId = 0;

$(document).ready(function(){
 	startPanelNewsButtonSlide();
 	for (i=0;i<activeIndexPanelMaxNews;i++) {
		$("#n"+(i+1)).click(function(){ var sid = this.id; howmany = ((parseInt(sid.substr(1))-1)*(-472)); $("#hp-panel-news-module-slider").animate({left: howmany}, 600); activeIndexPanelNews=(parseInt(sid.substr(1))); switchOnPanelNewsButton(this.id); return false; });	
	}
});

function switchOnPanelNewsButton(id) {
 	clearTimeout(panelNewsTimerId); 
 	for (i=0;i<activeIndexPanelMaxNews;i++) { document.getElementById("n"+(i+1)).className="hp-panel-news-module-selecta-btn"; }
 	for (i=0;i<activeIndexPanelMaxNews;i++) { if (id==("n"+(i+1))) document.getElementById("n"+(i+1)).className="hp-panel-news-module-selecta-btn-act"; }	
	panelNewsTimerId = setTimeout ( "slidePanelNewsButton()", 5000 );
}

function startPanelNewsButtonSlide() {
	panelNewsTimerId = setTimeout ( "slidePanelNewsButton()", 5000 );
}

function slidePanelNewsButton() {
 	lastId = "n"+activeIndexPanelNews;
 	document.getElementById(lastId).className="hp-panel-news-module-selecta-btn"; 
 	activeIndexPanelNews += 1;
 	if (activeIndexPanelNews>activeIndexPanelMaxNews) activeIndexPanelNews = 1;
	id = "n"+activeIndexPanelNews;
	document.getElementById(id).className="hp-panel-news-module-selecta-btn-act"; 
	if (activeIndexPanelNews == 1) {$("#hp-panel-news-module-slider").animate({left: "0"}, 600);} else {$("#hp-panel-news-module-slider").animate({left: "-=472"}, 600);}
	panelNewsTimerId = setTimeout ( "slidePanelNewsButton()", 5000 );
}


