$(document).ready(function() {
	var menuIndent = 5;
	var speed =0;
	
	//for IE6
	var ieVer = "ok";
	if ($.browser.msie && $.browser.version < 7){
		ieVer = "fuk";
	}
	
	//---------------------------------------------------------------
	//allErs
	function allErs(){
		for (var i = 1; i < 6; i++){
		   $('#gn-0'+i+'-dm').hide();
		   $('#gn-0'+i+'-dm div').hide();
		   $('#gn-0'+i).removeClass('hovering');
		}
	}
	
	//hoverErs
	function hoveringErsId(id){
			$(id).removeClass('hovering');
	}
	
	//---------------------------------------------------------------
	//for "gn-05(because this == right of win)"
	var gn05width = $("#gn-05-03 div").width();
	gn05width = gn05width - menuIndent;
	
	//---------------------------------------------------------------
	//onload(reset?)
	for (var i = 1; i < 6; i++){
	   $('#gn-0'+i+'-dm').hide();
	   $('#gn-0'+i+'-dm div').hide();
	}
	
	$('#headerRim').css("overflow","visible");
	
	//----------------------------------------------------------------------------------------------------------
	//userAct
	$('#gNavi ul > li').mouseover(function() {
		var menuId = ($(this).attr("id"));
		
		for (var i = 1; i < 6; i++){
		   if(menuId != 'gn-0'+i){
		   	$('#gn-0'+i+'-dm').hide(speed);
		  	 hoveringErsId('#gn-0'+i);
		   }
		}
		$(this).addClass('hovering');
		
		$('#'+menuId+'-dm').show(speed);
		
		//dm2 Position
		var dmPosi;
		dmPosi = $('#'+menuId+'-dm > ul > li').width();
		dmPosi = dmPosi - menuIndent;
		
		//for "gn-05"
		if(menuId == "gn-05"){
			$('#'+menuId+'-dm  div').css('left',-gn05width);
			if(ieVer == "fuk"){//for IE6
				$('#'+menuId+'-dm  div').css('left',-gn05width-4);
				$('#'+menuId+'-dm  div').css('width',gn05width+4);
			}
		}else{
			$('#'+menuId+'-dm  div').css('left',dmPosi);
			if(ieVer == "fuk"){//for IE6
				$('#'+menuId+'-dm  div').css('left',dmPosi+5);
			}
		}
		
	});
	
	//***dm2/Show & Hide
	$('#gNavi ul ul > li').mouseover(function() {
		$('#gNavi ul ul li div').hide(speed);
		$(this).children().show(speed);
	});
	
	//----------------------------------------------------------------------------------------------------------
	//ErsArea
	$('#topInfo').mouseover(function() {
		allErs();
	});
	$('#siteName').mouseover(function() {
		allErs();
	});
	$('#contents').mouseover(function() {
		allErs();
	});
});