var s_counter = 0;
var timerId = null;
var switchTime = 4; //Second
var work = 1;

function slideshow(){
	$("main_image").innerHTML = '<h2><img src="' + newsList[s_counter][0] + '" height="246" width="368" alt="' + newsList[s_counter][1] + '" /></h2>';
	$("news_text").innerHTML = newsList[s_counter][2];
	$("news_footer_link").innerHTML = '詳細は<a href="' + newsList[s_counter][3] + '">コチラ</a>';

	if(work == 1){
		s_counter = (s_counter + 1) % newsList.length;
		clearTimeout(timerId);
		timerId = setTimeout("slideshow()", switchTime * 1000);
	}
}

function stopSlide(event){
	clearTimeout(timerId);
	s_counter = Event.element(event).id.substring(10) - 1;
	work = 0;
	slideshow();
}

function startSlide(event){
	work = 1;
	slideshow();
}

Event.observe(window, "load", function(){
	for(var i=0; i<newsList.length; i++){
		var s_id = "news_image" + (i + 1);
		Event.observe($(s_id), "mouseover", stopSlide, false);
		Event.observe($(s_id), "mouseout", startSlide, false);
	}
	if(newsList.length != 0) slideshow();
}, false);
