//#####################################
//##
//## ÄíÅ° ÁöÁ¤ÇÔ¼ö
//##
//#####################################
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1) endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {	//while open
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
   }	//while close
   return null;
}

function SetCookie (name, value) {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
      ((expires == null) ? "" : 
         ("; expires=" + expires.toGMTString())) +
      ((path == null) ? "" : ("; path=" + path)) +
      ((domain == null) ? "" : ("; domain=" + domain)) +
      ((secure == true) ? "; secure" : "");
} 

function setIdAutoInput( id_value )
{
   var expires = new Date(); 
   expires.setDate( expires.getDate() + 999 );

   SetCookie( "foreston_id_auto_input", id_value, expires, "/", "gv.goanygate.com" );
}

function getIdAutoInput()
{
   return GetCookie( "foreston_id_auto_input" );
}

//#####################################
//##
//## ÀÚ¿¬ÈÞ¾ç¸² ¿¹¾à½Ã½ºÅÛ °ü·Ã ÇÔ¼ö
//##
//#####################################
// ÈÞ¾ç¸² URL
var restUrl = "http://www.huyang.go.kr";
//var restUrl = "http://new.huyang.go.kr:8080";

function makeRestUrlForAutoLink( actionUrl )
{
	var resultUrl = restUrl;
	resultUrl = resultUrl + "/user/member/loginLink.action?encString=" + document.hiddenForm.loginLink.value;
	resultUrl = resultUrl + "&redirectUrl=" + encoding( actionUrl );
	return resultUrl;
}

// ±¹¸³ÀÚ¿¬ÈÞ¾ç¸² ¿¹¾àÇÏ±â
function openReservation( param )
{
	// param ¿¹: rcode=35&mcode=55&hcode=0101
	var actionUrl = "/user/forest/User_contentIntro.action";
	window.open( makeRestUrlForAutoLink( actionUrl + "?" + param ), "huyang" );
}


// ¿¹¾à³»¿ª - iframe
function openMemberReservationInfo()
{
	var actionUrl = "/user/mypage/User_reserveListForest.action";
	$( "infoFrame" ).src = makeRestUrlForAutoLink( actionUrl );
	// document.write( makeRestUrlForAutoLink( actionUrl ) );
}

// È¸¿ø°¡ÀÔÆäÀÌÁö
/*
function openJoin()
{
	var actionUrl = "/user/member/User_memberAgreement.action";
	window.open( restUrl + actionUrl, "huyang" );
}
*/

//ID, ºñ¹øÃ£±â
/*
function openFindId()
{
	var actionUrl = "/user/member/User_memberFind.action";
	window.open( restUrl + actionUrl, "huyang" );
}
*/

// È¸¿øÁ¤º¸º¯°æ - ·Î±×ÀÎ ÇÊ¿ä
function openMemberInfoModify()
{
	var actionUrl = "/user/mypage/User_memberRead.action";
	window.open( makeRestUrlForAutoLink( actionUrl ), "huyang" );
}

// È¸¿øÅ»Åð - ·Î±×ÀÎ ÇÊ¿ä
function openMemberRetired()
{
	var actionUrl = "/user/mypage/User_memberOut.action";
	window.open( makeRestUrlForAutoLink( actionUrl ), "huyang" );
}

function encoding( text )
{
	var encodedInputString = escape( text );
	encodedInputString = encodedInputString.replace( /\+/g, "%2B" );
	encodedInputString = encodedInputString.replace( /\//g, "%2F" ); 
	return encodedInputString;
}

//#####################################
//##
//## ½£¿¡¿Â ±âÅ¸ ÇÔ¼ö
//##
//#####################################

// Âò
function zzim( scoIdx )
{
	document.hiddenProcessFrame.location.href="/mypage/saveContents.action?si=" + scoIdx;
}

/* 20090917 ÃÖÀº¼±
function zzim_out()
{
	alert("·Î±×ÀÎÀ» ÇØÁÖ¼¼¿ä!");
	//mainlogin();
}
*/

/* 20091007 ÃÖÀº¼±
// ÄÁÅÙÃ÷ Ã£±â
function searchOptionCode( code )
{
	var fileName = "/contents/listPopup.action?bs=" + code;
	window.open(fileName, "code", "width=600, height=480, top=0,left=0,scrollbars=yes,resizable=0,toolbar=0,menubar=0,location=0,directories=0,status=0");
	return false;
}
*/

// Ã¹¹øÂ° Ç×¸ñÀº È­¸é¿¡ Ãâ·ÂÇÏ°í ³ª¸ÓÁö´Â ¼û±è
// visibility
function showOnlyOne()
{
	if( arguments.length == 3 )
	{
		for( var i = 1; i <= arguments[2]; i++ )
		{
			if( i != arguments[1] )
			{
				$( arguments[0] + i ).setStyle( { visibility: 'hidden' } );
			}
		}
		$( arguments[0] + arguments[1] ).setStyle( { visibility: 'visible' } );
	}
}

// display
function displayOnlyOne() {
	if( arguments.length == 3 )	{
		for( var i = 1; i <= arguments[2]; i++ ) {
			if( i != arguments[1] )	$( arguments[0] + i ).setStyle( { display: 'none' } );
		}
		$( arguments[0] + arguments[1] ).setStyle( { display: 'block' } );
	}
}

function layerDisplay( objId, img1, img2 )
{
	var dis = document.getElementById( objId );
	if( dis.style.display != 'inline' )
	{
		if( img1 > '' && img2 > '' )
		{
			swapImage( img1, img2 );
		}
		dis.style.display = 'inline';
	}
	else
	{
		dis.style.display = 'none';
	}
}

//ÇÁ¸°Æ®ÇÏ±â
function printBody( css )
{
	// ºó ÇÁ·¹ÀÓ¿¡ Ãâ·Â ·¹ÀÌ¾Æ¿ô ¼³Á¤
	hiddenProcessFrame.location.href = "/contents/print.action?css=" + css;
	// window.open( "/contents/print.action?css=" + css );
}

function printPageInner()
{
	// $( "realContents" ).innerHTML = opener.document.getElementById( "realContents" ).innerHTML;
	// È­¸é ·Îµå°¡ ³¡³ª¸é ÇÁ¸°Æ® ½ÇÇà. Æ÷Ä¿½º & ÇÁ¸°Æ®
	$( "realContents" ).innerHTML = parent.document.getElementById( "realContents" ).innerHTML;
	parent.hiddenProcessFrame.focus();
	window.print();
}


//ÀÌ¿ëÆòÁ¡ÁÖ±â
function submitPoint( theForm )
{
	if( theForm.spoComment.value.length < 2 )
	{
		alert( '20ÀÚÆòÀ» ÀÛ¼ºÇØÁÖ¼¼¿ä.' );
		return false;
	}
	else if( theForm.spoComment.value == '20ÀÚÆò¾²±â' )
	{
		alert( '20ÀÚÆòÀ» ÀÛ¼ºÇØÁÖ¼¼¿ä.' );
		return false;
	}
	else
	{
		return true;
	}
}

// ÀÌ¿ëÆòÁ¡»èÁ¦
function deletePoint( theForm, si, sp )
{
	theForm.si.value = si;
	theForm.sp.value = sp;
	theForm.submit();
}

// ¿øÇÏ´Â ÀÌ¹ÌÁö¸¦ Æ¯Á¤ ÀÌ¹ÌÁö id¿¡ º¸ÀÌ°Ô Ãâ·ÂÇÔ.
function swapImage( imgOrig, imgTarget )
{
	$( imgOrig ).src = $( imgTarget ).src;
	$( imgOrig ).alt = $( imgTarget ).alt;
}

function changeText( id, text )
{
	$( id ).innerHTML = text;
}

function changeImage( id, imageSrc, imageAlt )
{
	$( id ).src = imageSrc;
	$( id ).alt = imageAlt;
}

function swapImageAndTitle( id, image, title )
{
	$( id ).src = $( image ).src;
	$( id ).alt = $( image ).alt;

	changeText( title, $( image ).alt );
}

// ÆË¾÷
function popupRescFacility( url )
{
	popupRescPath( url );
}

//³ªÀÇÅÂ±×º¸±â
function viewMyTag()
{
	if( $( 'my_taglist' ).style.display == 'block' )
	{
		$( 'my_taglist' ).style.display = 'none';
	}
	else
	{
		$( 'my_taglist' ).style.display = 'block';
	}
}

//³ªÀÇ ÅÂ±× ÀÚµ¿ ÀÔ·Â
function inputTag( val )
{
	if( $( 'writeProc_tagString' ).value == "" )
	{	
		coma = "";
	}
	else
	{
		coma = ",";
	}
	$( 'writeProc_tagString' ).value += coma + val;
}

//ÅÂ±×°Ë»ö ÆäÀÌÁö·Î ÀÌµ¿
/* 20090917 ÃÖÀº¼±
function searchTag(tagId, tagName) {
	
	document.location.href = "/tag/result.action?mi=10025&st=name&ti=" + tagId;
}
*/

function popupPvr()
{
	window.open( "/data/pvr/01.html", "popupPvr", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=519, width=800" );
}

/* 20091012 ÃÖÀº¼±
function popupChild()
{
	window.open( "/child/index.action", "childOn", "menubar=no, resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=no, height=676, width=816" );
}
*/
/* 20090917 ÃÖÀº¼±
function popupRescPath( url )
{
	window.open( "/jsp/_common/popupImage.jsp?img=/data/cms/contents/image/" + url, "popupImage", "menubar=no, resizable=yes, scrollbars=no, status=yes, titlebar=yes, toolbar=no, height=100, width=100" );
}

function popupPhotoGallery( idx, bs )
{
	window.open( "/contents/photoGallery.action?si=" + idx + "&bs=" + bs, "photoGallery", "menubar=no, resizable=no, scrollbars=no, status=yes, titlebar=yes, toolbar=no, height=730, width=610" );
}

function popupCfMovie( idx )
{
	window.open( "/recreation/movie.action?si=" + idx, "moviePlayer", "menubar=no, resizable=no, scrollbars=no, status=yes, titlebar=yes, toolbar=no, height=100, width=100" );
}
*/
// ÀÓ½Ã - 100´ë¸í»ê µ¿¿µ»ó
function popupMovie( idx )
{
	window.open( "/contents/popupMovie.action?idx=" + idx, "moviePlayer", "menubar=no, resizable=no, scrollbars=no, status=yes, titlebar=yes, toolbar=no, height=100, width=100" );
}

//µî»ê·ÎÁöµµ : UBI
function popupMountainMap( courseId )
{
	document.hiddenForm.hiddenVal.value = courseId;
	window.open( "/data/mountain_map/ForestOn.html", "mountainMap", "menubar=no, resizable=no, scrollbars=no, status=yes, titlebar=yes, toolbar=no, height=720, width=1000" );
}
/* 20090929 ÃÖÀº¼±
function popupContest( url )
{
	window.open( url, "photoGallery", "menubar=no, resizable=no, scrollbars=no, status=yes, titlebar=yes, toolbar=no, height=830, width=618" );
}
*/
// ÀÓ½Ã - ½£ÇØ¼³
function linkForest()
{
	window.open( "http://www.foreston.go.kr/shsdsa/programCreList.do?method=list&paging=1&prm_reqkind=1&prm_division=FO" );
}

/* 20090922 ÃÖÀº¼±
// ÀÓ½Ã - µî»ê¾È³»ÀÎ
function linkMount()
{
	window.open( "http://www.foreston.go.kr/shsdsa/programCreList.do?method=list&paging=1&prm_reqkind=1&prm_division=MO" );
}
*/

// µðÀÚÀÎ ÂÊ¿¡¼­ ÀÛ¼ºÇÑ ÇÔ¼ö
var backdu_old='';
function backdu_menu( name )
{
	submenu=eval("submenu_"+name+".style");
	if(backdu_old!=submenu)
	{
		if(backdu_old!='')
		{
			backdu_old.display='none';
		}
		submenu.display='block';
		backdu_old=submenu;
	}
	else
	{
		submenu.display='none';
		backdu_old='';
	}
}
/* 20090922 ÃÖÀº¼±
// popuup
function Winpop( sURL,sName,swidth,sheight,scrollbars,left,top)
{
	var winpop;
	winpop = window.open(sURL, sName, "status=no,toolbar=no,resizable=no,scrollbars="+scrollbars+",menubar=no, width="+swidth+", height="+sheight+", left="+left+", top="+top);
}
*/

//Element ID ºÒ·¯¾²±â
function dEI(elementID){
	return document.getElementById(elementID);
}


// Tab Content
function tabCheck(dotabid , tnum){
	var inum=parseInt(tnum)-1;
	var linkTab=dEI(dotabid).getElementsByTagName("a");
	for (i=0;i<linkTab.length;i++) {
		var tabimg = linkTab.item(i).getElementsByTagName("img").item(0);
		var tabContents= dEI(dotabid+(1+i));
		if (i==inum) {
			if(tabContents.style.display!="block"){
			tabimg.src=tabimg.src.replace(".jpg", "_1.jpg");
			tabContents.style.display="block";
			}
		}else{
		tabimg.src=tabimg.src.replace("_1.jpg", ".jpg");
		tabContents.style.display="none";
		}
	}
}

//100´ë¸í»ê
function selAreaMountain(num) {
	for( var i = 1 ; i <= 9 ; i++ ) {
		var mt = document.getElementById("mountain100_0" + i);
		if( i == num ) mt.style.display = "";
		else mt.style.display = "none";
	}
}

function initMountainPosition() {
	for( var i = 1 ; i <= 9 ; i++ ) {
		var mt = document.getElementById("mountain100_0" + i);
		mt.className = "district_map";
	}
}

//Áö¿ªº°Ã£±â
function selAreaCity(num) {
	for( var i = 1 ; i <= 9 ; i++ ) {
		var mt = document.getElementById("city_map0" + i);
		var img = document.getElementById("cimg" + i);
		if( i == num ) {
			mt.style.display = "";	
			if( img.src.indexOf("_on.gif") < 0 ) img.src = img.src.replace(".gif", "_on.gif");
		} else {
			mt.style.display = "none";
			if( img.src.indexOf("_on.gif") > 0 ) img.src = img.src.replace("_on.gif", ".gif");
		}
	}
}

function initCityPosition() {
	for( var i = 1 ; i <= 9 ; i++ ) {
		var mt = document.getElementById("city_map0" + i);
		mt.className = "city_district_map";
		mt.style.display = "none";
	}
}

//Áö¿ªº° »êÃÌ»ýÅÂ¸¶À»
function selAreaVillage(num) {
	for( var i = 1 ; i <= 8 ; i++ ) {
		var mt = document.getElementById("village0" + i);
		if( i == num ) mt.style.display = "";
		else mt.style.display = "none";
	}
}

function initVillagePosition() {
	for( var i = 1 ; i <= 8 ; i++ ) {
		var mt = document.getElementById("village0" + i);
		mt.className = "district_map";
	}
}

// ¼ö¸ñÀå¸² ½Ã¼³¾È³»
/*
function popupburial01()
{
	window.open( "/data/burials/photo01.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial02()
{
	window.open( "/data/burials/photo02.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial03()
{
	window.open( "/data/burials/photo03.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial04()
{
	window.open( "/data/burials/photo04.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial05()
{
	window.open( "/data/burials/photo05.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial06()
{
	window.open( "/data/burials/photo06.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial07()
{
	window.open( "/data/burials/photo07.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial08()
{
	window.open( "/data/burials/photo08.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial09()
{
	window.open( "/data/burials/photo09.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial10()
{
	window.open( "/data/burials/photo10.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial11()
{
	window.open( "/data/burials/photo11.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
function popupburial12()
{
	window.open( "/data/burials/photo12.html", "popupburials", "menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, toolbar=no, height=705, width=600" );
}
*/

/* ÀÚ¿¬ÈÞ¾ç¸² Áö¿ªº° Ã£±â */
 function selectArea(num) {
	if( num == 0 ) {
		for( var i = 1 ; i <= 9 ; i++ ) {
			var ida = document.getElementById("rest" + i);
			if( ida ) {
				if( i == 1 ) ida.style.display = "";
				else ida.style.display = "none";
				ida.style.top = "250px";
				ida.style.left = "539px";
				ida.style.position = "absolute";
			}
		}
	} else {
		for( var i = 1 ; i <= 9 ; i++ ) {
			var ida = document.getElementById("rest" + i);
			if( ida ) {
				if( i == num ) ida.style.display = "";
				else ida.style.display = "none";
			}
		}
	}
	
} 