var index = 0;

var div_num = 3;
var getTime = 5000;

function DisplayMenu(idx) { 
	index = idx;
	for (z=1; z<=div_num; z++){ 
		var show_tab  = document.getElementById("show_tab" + z);
		var show_menu = document.getElementById("show_menu" + z);
		if(index == z){
		show_tab.style.display = "";
		show_menu.style.display = "";
		}else{
		show_tab.style.display = "none";
		show_menu.style.display = "none";
		}
	}
}

var timer = null;
function setTimer(){
	var argLength = arguments[0].length;
	timer = setInterval( function(){
	DisplayMenu(index=index<argLength? ++index:1);
	},getTime);
}

function setOnMouse(){
	arg = arguments[0];
	for (var k=0; k<arg.length; k++){
		arg[k].onmouseover = function(){
		if(timer) clearInterval(timer);
		}
		arg[k].onmouseout = function(){ 
		setTimer(arg);
		}
	}
}
 window.onload = function(){
	var obj = [];
		obj.push( document.getElementById('show_menu1') );
		obj.push( document.getElementById('show_menu2') );
		obj.push( document.getElementById('show_menu3') );
		setTimer(obj); 
		setOnMouse(obj);
}
