jQuery.noConflict();

function setCurrentMenu($){
	var path = getCurrentPath();
	//alert(path);
	for(var i=0; i < path.length; i++){
		if(Menu[path[i]] != undefined){
			var o = Menu[path[i]];
			var t = '#'+o.id;
			$(t).css(o.style);
			$(t).get(0).firstChild.removeAttribute('HREF', 0);
			$(t).get(0).firstChild.removeAttribute('ONMOUSEOVER', 0);
		}
	}
}

function getCurrentPath(){
	var arr = [];
	var path = location.pathname;
	if(path == "/"){
		arr.push("home");
		return arr;
	}else{
		var a = path.split('/');
		for(var i = 0; i < a.length;i++){
			if(a[i] != ""){
				var r = /\..*$/; // .htmlなどの拡張子を削除
				a[i] = a[i].replace(r, '');
				arr.push(a[i]);
				if(a.length == 3 && i == 1){
					arr.push(a[i]+'_top');
				}
			}
		}
		return arr;
	}
}

/*
--------------------------- set menu */
jQuery(function($){
	var r = /(\.jpg|\.gif|\.png)/;
	var r2 = /_ov/;
	if( $("#menu-global").html() ) {
		var path = getCurrentPath();
		if( $("#menu-global-"+path[1]).html() ) {
			$("#menu-global-"+path[1]).removeAttr('href');
			$("#menu-global-"+path[1]).removeAttr('onmouseover');
			$("#menu-global-"+path[1]).removeClass('btn');
			var ov_img = $("#menu-global-"+path[1]).find("img").attr("src").replace(r,"_ov$1");
			$("#menu-global-"+path[1]).find("img").attr("src",ov_img);
		}
		else if( $("#menu-global-"+path[0]).html() ) {
			$("#menu-global-"+path[0]).removeAttr('href');
			$("#menu-global-"+path[0]).removeAttr('onmouseover');
			$("#menu-global-"+path[0]).removeClass('btn');
			var ov_img = $("#menu-global-"+path[0]).find("img").attr("src").replace(r,"_ov$1");
			$("#menu-global-"+path[0]).find("img").attr("src",ov_img);
		}
	}
	$("a.btn").mouseover(function(e) {	
		e.target.src = e.target.src.replace(r,"_ov$1");
	});
	$("a.btn").mouseout(function(e) {
		e.target.src = e.target.src.replace(r2,"");
	});
});

