$(document).ready(function() {
	var menu_a=$(".menu_a");
	var title=$(".settitle").attr("title");
	
	if(title=="null"||title==null){
			title=$("title").html();
		}
		else{
		//$("title").html($("title").html()+"-"+title);
		var tmp=$("title").html()+"-"+title;
		$(document).attr("title",tmp);
		}
	var sub_menu=$(".sub_menu");
	var mouse_move=$(".mouse_move");
	var head_menu=$(".head_menu");
	var tmp_index=0;
	var stra="m_up_";
	var strb="m_down_";
	//alert(title);
	if(title==null){
				title="";
			}
   /*sub_menu.mouseout(function(){
		sub_menu.each(function(){
				$(this)	.hide();
			})
		sub_menu.eq(tmpindex).show();
   })*/
 	$(".mouse_move").hover(function(){
		mousemoves();
	})
	function mousemoves(){
			sub_menu.each(function(){
				$(this)	.hide();
			})
		var str=menu_a.eq(tmpindex).children().attr("src");
		menu_a.each(function(){
			var str=$(this).children().attr("src");
			var index=menu_a.index($(this));
			menu_a.eq(index).children().attr("src",str.replace(stra,strb))
		});
		menu_a.eq(tmpindex).children().attr("src",str.replace(strb,stra));
		sub_menu.eq(tmpindex).show();
		}
	var tmpindex=0;
	var flag=true;
	menu_a.each(function(){
		if(title.search($(this).attr("title"))>=0){
				var str=$(this).children().attr("src");
				//alert(menu_a.index($(this)));
				var index=menu_a.index($(this));
				menu_a.eq(index).children().attr("src",str.replace(strb,stra))
				flag=false;
				sub_menu.eq(index).show();
				tmpindex=index;
				
			}
		else{
				//alert(title.search($(this).attr("title")));
				var str=$(this).children().attr("src");
				$(this).children().attr("src",str.replace(stra,strb));
			}
	});
	if(flag){
			var str=menu_a.eq(0).children().attr("src");
			menu_a.eq(0).children().attr("src",str.replace(strb,stra));
			sub_menu.eq(0).show();
		}
	menu_a.hover(function(){
		var index=menu_a.index($(this));
		tmp_index=index;
		//alert(menu_a.index($(this)));
		//alert(tmp_index);
		menu_a.each(function(){
			if(menu_a.index($(this))!=index){
					var str=$(this).children().attr("src");
					$(this).children().attr("src",str.replace(stra,strb));
				}
		})
		var str=$(this).children().attr("src");
		if(str.search("((?!"+strb+").)*$")>0){
			$(this).children().attr("src",str.replace(strb,stra));
			sub_menu.each(function(){
				$(this)	.hide();
			})
			var index=menu_a.index($(this));
			sub_menu.eq(index).show();
		}
	})
	
});
