// Hide And Show Toggle
var cc=0
function hideShow(id) {
    if (cc==0) {
        cc=1
        document.getElementById(id).style.display="none";
    } else {
        cc=0
        document.getElementById(id).style.display="block";
    }
}

// Show And Hide Toggle
var cc=0
function showHide(id) {
    if (cc==0) {
        cc=1
        document.getElementById(id).style.display="block";
    } else {
        cc=0
        document.getElementById(id).style.display="none";
    }
}

// Local Navigation Toggle
function lnbToggle(id) {
	for(num=1; num<=3; num++) document.getElementById('D3MG'+num).style.display='none'; //D4MG1~D4MG3 까지 숨긴 다음
	document.getElementById(id).style.display='block'; //해당 ID만 보임
}

// IS
function chkIsKind(key, value) {
    showHide('selectOrder');
    xGetElementById('search_target'+key).checked = true;
    xInnerHtml('search_target_label', value);
}



function web_translate()
{
if(document.getElementById("web_url").value=='' || document.getElementById("web_url").value=='http://')
{
alert('웹주소를 입력해주세요');
document.getElementById("web_url").focus();
return;
}
window.open('http://translate.google.com/translate_c?u='+document.getElementById("web_url").value+'&sl='+document.getElementById("sl").value+'&tl='+document.getElementById("tl").value+'&hl=ko&ie=UTF-8','','')
}


// family site
function startFamilySiteScroll() {
	setTimeout("slideFamilySite()", 10);
}
function slideFamilySite() {
	el = document.getElementById("site_list");

	if (el.heightPos == null || (el.isDone && el.isOn == false)) {
		el.isDone = false;
		el.heightPos = 0;
		el.heightTo = 80;
	} else if (el.isDone && el.isOn){
		el.isDone = false;
		el.heightTo = 0;
	}
	if (Math.abs(el.heightTo - el.heightPos) > 1) {
		el.heightPos += (el.heightTo - el.heightPos) / 10;
		el.style.height = el.heightPos + "px";
		startFamilySiteScroll();
	} else {
		if (el.heightTo == 80) {
			el.isOn = true;
		} else {
			el.isOn = false;
		}
		el.heightPos = el.heightTo;
		el.style.height = el.heightPos + "px";
		el.isDone = true;
	}
}

// Roll_over Menu 1
// Brower
var browserType=''; 
if(navigator.userAgent.indexOf("MSIE") >-1) {
   browserType = 'IE'; 
} else if(navigator.userAgent.indexOf("Firefox") >-1) {
   browserType = 'FF'; 
} else {
   browserType = 'OTHER'; 
}

function gnbinToggle(id, gnbblock) {
 if(browserType == 'FF') {
    gnbinToggleFF(id, gnbblock);
 } else if (browserType == 'OTHER' ) {
    gnbinToggleFF(id, gnbblock);
 } else {
    gnbinToggleIE(id, gnbblock);
 }
}

// Local Navigation Toggle IE
function gnbinToggleIE(id, gnbblock) {
 for(num=0; num<gnb_count; num++) {
  document.getElementById('gnb'+num).style.display='none';              // 2nd Menu
  document.getElementById('gnbli'+num).setAttribute('className', 'off');  // 1st Menu
 }
 var sub_1 = document.getElementById('gnbli'+id);     // 1st Menu 
 var sub_2 = document.getElementById('gnb'+id);     // 2nd Menu
  document.getElementById('gnb'+id).style.display = 'block';
  gnbblock.className = "on";
     
}

// Local Navigation Toggle FF
function gnbinToggleFF(id, gnbblock) {
 for(var num=0; num<gnb_count; num++) {
  document.getElementById('gnb'+num).style.display='none'; // 2nd Menu
  document.getElementById('gnbli'+num).className = null;  // 1st Menu
 }
 var sub_1 = document.getElementById('gnbli'+id);     // 1st Menu 
 var sub_2 = document.getElementById('gnb'+id);     // 2nd Menu
  document.getElementById('gnb'+id).style.display = '';
  gnbblock.className = "on";
}

function reset_menu()
{
  var sub_1 = document.getElementById('gnbli'+gnb_count_now);     // 1st Menu 
  var sub_2 = document.getElementById('gnb'+gnb_count_now);     // 2nd Menu
}

// Roll_over Menu 2
// Brower
var browserType=''; 
if(navigator.userAgent.indexOf("MSIE") >-1) {
   browserType = 'IE'; 
} else if(navigator.userAgent.indexOf("Firefox") >-1) {
   browserType = 'FF'; 
} else {
   browserType = 'OTHER'; 
}

function gnbinToggle2(id, gnbblock) {
 if(browserType == 'FF') {
    gnbinToggle2FF(id, gnbblock);
 } else if (browserType == 'OTHER' ) {
    gnbinToggle2FF(id, gnbblock);
 } else {
    gnbinToggle2IE(id, gnbblock);
 }
}

// Local Navigation Toggle IE
function gnbinToggle2IE(id, gnbblock) {
 for(num=0; num<gnb_count; num++) {
  document.getElementById('gnb'+num).style.display='none';              // 2nd Menu
  document.getElementById('gnbli'+num).setAttribute('className', 'off');  // 1st Menu
 }
 var sub_1 = document.getElementById('gnbli'+id);     // 1st Menu 
 var sub_2 = document.getElementById('gnb'+id);     // 2nd Menu
 var bodyWrap = document.getElementById('bodyWrap');  // Contents Width
  document.getElementById('gnb'+id).style.display = 'block';
  gnbblock.className = "on";

 var sub_2_left =sub_1.offsetLeft - sub_2.offsetWidth /4 ;

 // 2차메뉴 크기에 따른 위치 조절
 if (sub_2_left < 0)
	 sub_2_left = 0;
 else if( (sub_2_left + sub_2.offsetWidth) > 840 )
	 sub_2_left=(840 - sub_2.offsetWidth);
	 sub_2.style.marginLeft = sub_2_left + 'px';
}

// Local Navigation Toggle FF
function gnbinToggle2FF(id, gnbblock) {
 for(var num=0; num<gnb_count; num++) {
  document.getElementById('gnb'+num).style.display='none'; // 2nd Menu
  document.getElementById('gnbli'+num).className = null;  // 1st Menu
 }
 var sub_1 = document.getElementById('gnbli'+id);     // 1st Menu 
 var sub_2 = document.getElementById('gnb'+id);     // 2nd Menu
 var bodyWrap = document.getElementById('bodyWrap');  // Contents Width
  document.getElementById('gnb'+id).style.display = '';
  gnbblock.className = "on";

 var sub_2_left =sub_1.offsetLeft - sub_2.offsetWidth /4 ;

 // 2차메뉴 크기에 따른 위치 조절
 if (sub_2_left < 0)
	 sub_2_left = 0;
 else if( (sub_2_left + sub_2.offsetWidth) > 840 )
	 sub_2_left=(840 - sub_2.offsetWidth);
	 sub_2.style.marginLeft = sub_2_left + 'px';
}

function reset_menu2()
{
  var sub_1 = document.getElementById('gnbli'+gnb_count_now);     // 1st Menu 
  var sub_2 = document.getElementById('gnb'+gnb_count_now);     // 2nd Menu
  var bodyWrap = document.getElementById('bodyWrap');  // Contents Width

  var sub_2_left =sub_1.offsetLeft - sub_2.offsetWidth /4 ;

  // 넓이가 0미만일경우 0
  if (sub_2_left < 0)
 	  sub_2_left = 0;
  else if( (sub_2_left + sub_2.offsetWidth) > 840 )
	  sub_2_left=(840 - sub_2.offsetWidth);
	  sub_2.style.marginLeft = sub_2_left + 'px';
}

// Roll_over Menu 3
// Brower
var browserType=''; 
if(navigator.userAgent.indexOf("MSIE") >-1) {
   browserType = 'IE'; 
} else if(navigator.userAgent.indexOf("Firefox") >-1) {
   browserType = 'FF'; 
} else {
   browserType = 'OTHER'; 
}

function gnbinToggle3(id, gnbblock) {
 if(browserType == 'FF') {
    gnbinToggle3FF(id, gnbblock);
 } else if (browserType == 'OTHER' ) {
    gnbinToggle3FF(id, gnbblock);
 } else {
    gnbinToggle3IE(id, gnbblock);
 }
}

// Local Navigation Toggle IE
function gnbinToggle3IE(id, gnbblock) {
 for(num=0; num<gnb_count; num++) {
  document.getElementById('gnb'+num).style.display='none';              // 2nd Menu
  document.getElementById('gnbli'+num).setAttribute('className', 'off');  // 1st Menu
 }
 var sub_1 = document.getElementById('gnbli'+id);     // 1st Menu 
 var sub_2 = document.getElementById('gnb'+id);     // 2nd Menu
 var bodyWrap = document.getElementById('bodyWrap');  // Contents Width
  document.getElementById('gnb'+id).style.display = 'block';
  gnbblock.className = "on";

 var sub_2_left =sub_1.offsetLeft - sub_2.offsetWidth /4 ;

 // 2차메뉴 크기에 따른 위치 조절
 if (sub_2_left < 0)
	 sub_2_left = 0;
 else if( (sub_2_left + sub_2.offsetWidth) > 950 )
	 sub_2_left=(950 - sub_2.offsetWidth);
	 sub_2.style.marginLeft = sub_2_left + 'px';
}

// Local Navigation Toggle FF
function gnbinToggle3FF(id, gnbblock) {
 for(var num=0; num<gnb_count; num++) {
  document.getElementById('gnb'+num).style.display='none'; // 2nd Menu
  document.getElementById('gnbli'+num).className = null;  // 1st Menu
 }
 var sub_1 = document.getElementById('gnbli'+id);     // 1st Menu 
 var sub_2 = document.getElementById('gnb'+id);     // 2nd Menu
 var bodyWrap = document.getElementById('bodyWrap');  // Contents Width
  document.getElementById('gnb'+id).style.display = '';
  gnbblock.className = "on";

 var sub_2_left =sub_1.offsetLeft - sub_2.offsetWidth /4 ;

 // 2차메뉴 크기에 따른 위치 조절
 if (sub_2_left < 0)
	 sub_2_left = 0;
 else if( (sub_2_left + sub_2.offsetWidth) > 950 )
	 sub_2_left=(950 - sub_2.offsetWidth);
	 sub_2.style.marginLeft = sub_2_left + 'px';
}

function reset_menu3()
{
  var sub_1 = document.getElementById('gnbli'+gnb_count_now);     // 1st Menu 
  var sub_2 = document.getElementById('gnb'+gnb_count_now);     // 2nd Menu
  var bodyWrap = document.getElementById('bodyWrap');  // Contents Width

  var sub_2_left =sub_1.offsetLeft - sub_2.offsetWidth /4 ;

  // 넓이가 0미만일경우 0
  if (sub_2_left < 0)
 	  sub_2_left = 0;
  else if( (sub_2_left + sub_2.offsetWidth) > 950 )
	  sub_2_left=(950 - sub_2.offsetWidth);
	  sub_2.style.marginLeft = sub_2_left + 'px';
}

jQuery(document).ready(function () {

	/**
	* 플로팅 메뉴, 페이지의 최상단과 최하단 이동을 편리하게 한다.
	* by Jowrney
	*/
	var currentPosition = parseInt(jQuery(".slideMenu").css("top")); 
	jQuery(window).scroll(function() {

	var position = jQuery(window).scrollTop(); // 현재 스크롤바의 위치값을 반환합니다.
	var sum = position + currentPosition+"px";
	jQuery(".slideMenu").stop().animate({top:sum},500);
	});

	/* Select Language */
	jQuery('.select_language_button button').click(function () {
			jQuery(this).css({'border-bottom':'1px'});
			jQuery('.language_line ul').slideToggle('fast');
	});

});

