$(document).ready(function() {
	//Header 메뉴 슬라이드
	$("#Header ul.headerMenu").bind("mouseenter focusin", function(){
		$("#Header ul.headerMenu li ul").slideDown(180);
		$("#Header").animate({ height:"194px" }, 180);
		//$("#Container").animate({	marginTop:"-194px" }, 300 );
	});
	$("#Header ul.headerMenu").bind("mouseleave focusout", function(){
		$("#Header ul.headerMenu li ul").slideUp(100);
		$("#Header").animate({ height:"54px" }, 100);
		//$("#Container").animate({	marginTop:"-54px" }, 300 );
	});
	$("#Header ul.headerMenu li ul li a").bind("mouseenter focusin", function(){
		$(this).children().css("display","none");
		var bodyId = $("body").attr("id");
		//if (!$(this).parent().is("."+bodyId))	{
		//	$(this).fadeOut(50).fadeIn(200);
		//}
	});
});

var select = {
	action : function(el,state){
		// state = 0 or 1
		var SelectElement = document.getElementById(el.id);
		var ListElement = SelectElement.getElementsByTagName("span")[0];
		var ActionElement = ListElement.getElementsByTagName("a");
		if(ListElement.style.display == "block"){
			select.close(ListElement);
			return false;
		} else {
			ListElement.style.display = "block";
		}

		var strSelected = SelectElement.getElementsByTagName("a")[0];
		strSelected.focus();
		for(var i=0; i<ActionElement.length; i++){
			if(strSelected.firstChild.nodeValue == ActionElement[i].firstChild.nodeValue){
				select.elementClass = ActionElement[i];
				select.elementClass.className = "selected";
				ActionElement[i].onclick = function(){
					return false;
				}
			} else {
				ActionElement[i].onclick = function(){
					if(this.href.indexOf("javascript")>-1){
						eval(this.href);
					} else if(this.href == "" || this.href.indexOf("#")>-1){
					} else if(this.target == "_blank"){
						window.open(this.href);
					} else {
						location.href(this.href);
					}
					if(state==1){
						strSelected.firstChild.nodeValue = this.firstChild.nodeValue;
					}
					return false;
				}
			}
			ActionElement[i].onmouseover = function(){
				//select.elementClass.className = "";
				//this.className = "selected";
				select.elementClass = this;
			}
		}

		SelectElement.onmouseover = function(){ strSelected.onblur = function(){}}
		SelectElement.onmouseout = function(){ strSelected.onblur = function(){ select.close(ListElement); }}

	},
	close : function(el){
		select.elementClass.className = "";
		el.style.display = "none";
		return false;
	}
}

	//-----------------------------------------
	//쿠키값 가져오기 
	//-----------------------------------------
	function getCookie( name ){
			var nameOfCookie = name + "=";
			var x = 0;
			while ( document.cookie.length )
			{
					var y = (x+nameOfCookie.length);
					if ( document.cookie.substring( x, y ) == nameOfCookie ) {
							if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
									endOfCookie = document.cookie.length;
							return unescape( document.cookie.substring( y, endOfCookie ) );
					}
					x = document.cookie.indexOf( " ", x ) + 1;
					if ( x == 0 )
							break;
			}
			return "";
	}

	//-------------------------------------------
	//팝업창 오늘 열지 말기 
	//2012-02-06 이보화
	//--------------------------------------------
	function bannerTodayClose(bannerName) {

			setCookie_Time(bannerName , 'Y', 24, 'dalkomm.com');
			$("#"+bannerName).hide();
	}



	//-------------------------------------------
	//쿠키 시간 설정  
	//2012-02-06 이보화
	//--------------------------------------------
	function setCookie_Time(name, value, expireTimes, domain) {
		var todayDate = new Date();
		
		if (expireTimes) {
			todayDate.setTime(todayDate.getTime() + (1000 * 60 * 60 * expireTimes));
		}
			
		document.cookie = name + "=" + escape(value) + "; path=/;" +
		((expireTimes != null) ? " expires=" + todayDate.toGMTString() + ";" : "") +
		((domain != null) ? " domain=" + domain + ";" : "");
	}
	
