var ids=new Array('submenu_1','submenu_2','submenu_3','submenu_4', 'submenu_5');

function switchid(vObj, id, img, active, path){	
	hideallids();
	showdiv(id);
	var margin_x = document.getElementById('submenu').offsetLeft;
	var container_x = document.getElementById('submenu').offsetWidth;
	var media_x = document.getElementById(id).offsetWidth;
	if (vObj) {
		var x = ( vObj.offsetLeft - margin_x);
		x = (x - (media_x / 2));
		x = (x + (vObj.offsetWidth / 2));
		if ((x - 30) < margin_x) x = 30;
		if (((x + media_x) + 30) > container_x) x = ((container_x - media_x) - 30);
		document.getElementById(id).style.left = x + 'px';
	}
	for (var i = 0; i <= 6; i++) {
		if (i != img) eval('document.menu_0'+i+'.src=\''+path+'/image/menu/menu_0'+i+'.jpg\'');
	}
	eval('document.menu_0'+img+'.src=\''+path+'/image/menu/menuhover_0'+img+'.jpg\'');
	eval('document.menu_0'+active+'.src=\''+path+'/image/menu/menuhover_0'+active+'.jpg\'');
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}