var recent_url = context+'/themes/recent/recentList.jsp?';
var issue_url = context+'/themes/themes_04List.jsp?';
var nation_url = context+'/abroad/abroad_04List.jsp?';
var theme_url = context+'/abroad/abroad_01List.jsp?';
var office_url = context+'/abroad/abroad_02List.jsp?';
var title_url = context+'/abroad/abroad_03List.jsp?';
var chosun_url = context+'/feature/feature_03List.jsp?';
var hankuk_url = context+'/feature/feature_07List.jsp?';
var daesang_url = context+'/themes/themes_03List.jsp?';
var generator_url = context+"/start.jsp?";	//운영 
//var generator_url = context+"/install_miplatform.jsp?";	//운영 
var ups_url = context+'/ups/ups_01List01.jsp?';
var ups_sub_url = context+'/ups/ups_01List.jsp?';
var day_url = context+'/themes/themes_05List.jsp?';
var local_url = context + '/abroad/office/localStatInfo.jsp?';	
	  
	  
	
	/*	LeftTab 상태 기억
		0 -> 모두 닫힌 경우
		1 -> 주제별 Tab
		2 -> 기관별 Tab
		3 -> 명칭별 Tab
		4 -> 이용방법 Tab
		5 -> 통계사이트 Tab
	*/
	function leftTab_memory(){
	
		var chk = Get_Cookie('left_memory');
		
		if(chk==0){
			closeTabInfo();
		}else{
			closeTabInfo(); openTabInfo(chk);
		}
	}

	function Get_Cookie(name) { 
			var nameOfCookie = name + "="; 
			var x = 0; 
			while ( x <= 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 ""; 
	} 
	function Set_Cookie(name,value,expires,path,domain,secure) { 
		expires = expires * 60*60*24*1000;
		var today = new Date();
		var expires_date = new Date( today.getTime() + (expires) );
	    var cookieString = name + "=" +escape(value) + 
	       ( (expires) ? ";expires=" + expires_date.toGMTString() : "") + 
	       ( ";path=" + "/kosis"); 
       document.cookie="";
	    document.cookie = cookieString; 
	} 
		
	//경기순환시계 링크
	function popupBcc(){
		//우선 Popup으로 구현 
		var bcc_url = "http://kosis.kr/bcc/main.html";
		//var bcc_url = "http://10.134.2.236:8190/kosis/bcc/Bcc.do";
		window.open (bcc_url, "bcc","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1020, height=820");
	}
	
	//G20 링크 2010-08-31
	function popupG20(){
		//var G20_url = context + "/bulletin/html/NsoBoard.html";
		//window.open (G20_url, "g20", "");
		//window.open (G20_url, "g20","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1020, height=820");
	
		var G20_url = context + "/bulletin/html/NsoBoard.html";
		var userwidth = (screen.width - 10);
		var userheight = (screen.height - 35);
		window.open(G20_url, 'g20', 'scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes,resizable=yes,width='+userwidth+',height='+userheight+',left=0,top=0');
	}
	
	//한국의 주요지표  링크
	function jipyo_link(){
		//우선 Popup으로 구현 
		if(context=="/nsp"){
			var jipyo_url = "http://www.kosis.kr/html/autoJipyo/jipyo_h_view.jsp";	
		} else {
			var jipyo_url = context+"/feature/feature_0102List.jsp?menuId=all&mode=listAll";	
		}		 
		window.open (jipyo_url, "spwin", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1000, height=696");
	}
	
	
	//디지털 간행물 링크 
	function ups_link(rootId,pubcode,type){
		if(pubcode==null){
			window.location.href = ups_sub_url+"grp_no="+rootId;
		}else{
			window.location.href = ups_url+"grp_no="+rootId+"&pubcode="+pubcode+"&type="+type;
		}
	}
	
	//최신통계 링크 
	function recent_link(q_listId){
		window.location.href = recent_url+"q_listId="+q_listId;
	}
	
	//공감통계 (이슈별통계)
	function issue_link(parentId,listnm){
		window.location.href = issue_url+"parentId="+parentId+"&listnm="+encodeURIComponent(listnm);
	}
	
	//국제통계 
	function nation_link(parentId){
		window.location.href = nation_url+"parentId="+parentId;
	}
	
	//주제별 통계
	function theme_link(parentId){
		window.location.href = theme_url+"parentId="+parentId;
	}
	
	//기관별 통계
	function office_link(parentId, parentId1){
		window.location.href = office_url+"parentId="+parentId;
	}
	
	//명칭별 통계
	function title_link(parentId){
		window.location.href = title_url+"parentId="+parentId;
	}
	
	function title_link1(titleId){
		window.location.href = title_url+"titleId="+titleId;
	}
	
	//Generator 화면 (통계DB검색)
	function generator_link(orgid, tblid, itm_id, path, vw_cd, list_id, scr_id, tblnm) {
		if (vw_cd == null || vw_cd == 'undefined')  vw_cd = '';
		if (list_id == null || list_id == 'undefined')  list_id = '';
		var empId = '';

		try {
		    if (g_empId != null && g_empId != 'undefined')  { empId = g_empId; }
		} catch (exception) { }			
			
		if(orgid=="null" || orgid==null || orgid == 'undefined'){
			orgid = "";
		}
		if(tblid=="null" || tblid==null || tblid == 'undefined'){
			tblid = "";
		}
		if(itm_id=="null" || itm_id==null || itm_id == 'undefined'){
			itm_id = "";
		}
		if(path=="null" || path==null || path == 'undefined'){
			path = "";
		}
		if(vw_cd=="null" || vw_cd==null || vw_cd == 'undefined'){
			vw_cd = "";
		}
		if(list_id=="null" || list_id==null || list_id == 'undefined'){
			list_id = "";
		}
		if(scr_id=="null" || scr_id==null || scr_id == 'undefined'){
			scr_id = "";
		}
		if(tblnm=="null" || tblnm==null || tblnm == 'undefined'){
			tblnm = "";
		}
		
		var conn_path=vw_cd;
		var path_name=document.location.pathname;
		if(path_name.indexOf("feature")>=0) {
			conn_path="B1";
		} else if(path_name.indexOf("ups")>=0) {
			conn_path="B4";
		} else if(path_name.indexOf("recentList")>=0) {
			conn_path="C1";
		} else if(path_name.indexOf("themes_02List")>=0) {
			conn_path="C2";
		} else if(path_name.indexOf("mymap_List")>=0) {
			conn_path="I1";
		} else if(path_name.indexOf("totalSearch")>=0) {
			conn_path="E1";
		} else if(path_name.indexOf("qsearch")>=0) {
			conn_path="E2";
		} else if(path_name.indexOf("/nsportal/")>=0 || path_name.indexOf("/nsportal/index/index.jsp")>=0) {
			vw_cd="";
		}

		//민지은 주무관님 요청으로 파라메터 추가 (05-17)
		var lurl = location.href;
		if(lurl.indexOf("kostat_onedepth")>=0){
			conn_path = "K1";
		}else if(lurl.indexOf("meta_onedepth")>=0){
			conn_path = "K2";
		}		
		
		if(context=="/nsp"){
			window.open(generator_url+"org_id="+orgid+"&tbl_id="+tblid+"&stts_nm="+encodeURIComponent(tblnm)+"&vwcd="+vw_cd+"&listid="+list_id+"&olapAt=Y&item="+itm_id+"&lanType=KOR", "install_miplatform", "width=1010, height=710");
		}else{
			if(itm_id==""){
				
			    var url = generator_url+"orgId="+orgid+"&tblId="+tblid+"&vw_cd="+vw_cd+"&list_id="+list_id+"&scrId="+scr_id+"&seqNo=&lang_mode=ko&obj_var_id=&itm_id=&conn_path="+conn_path+"&path="+escape(encodeURIComponent(path));
				window.open (url, "install_miplatform","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=1012, height=696");
			}else {
			    //var url = generator_url+"orgId="+orgid+"&tblId="+tblid+"&vw_cd="+vw_cd+"&list_id="+list_id+"&empId="+ empId  +"&scrId="+scr_id+"&seqNo=&dbkind=ETLDB&lang_mode=ko&dsu=nsi&path="+encodeURIComponent(path);
				var url = context+"/common/region_generator.jsp?orgId="+orgid+"&tblId="+tblid+"&vw_cd="+vw_cd+"&list_id="+list_id+"&itm_id="+itm_id+"&conn_path="+conn_path+"&path="+escape(encodeURIComponent(path));
				window.open (url, "install_miplatform","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=1012, height=696");
			}
		}
		//alert(url);
	}
	
    // 지방의 통계표보기 연결  
	function localInfo_link(orgid, tblid, localCode, path, vw_cd, list_id){
		var empId = '';
		if (g_empId != null && g_empId != 'undefined')  { empId = g_empId; }
			
	    var url = local_url + "orgId=" + orgid + "&tblId=" + tblid + "&vw_cd=" + vw_cd + "&list_id=" +list_id + "&empId=" + empId + "&localCode=" + localCode + "&path=" + encodeURIComponent(path);
	
	    select_tblinfo.location.href =url;
	}	
	
	//광복이전 통계
	function chosun_link(parentId){
		//alert(parentId);
		window.location.href = chosun_url+"parentId="+parentId;
	}
	
	//한국통계연감 통계
	function hankuk_link(parentId){
		//alert(parentId);
		window.location.href = hankuk_url+"parentId="+parentId;
	}
	
	//대상별 통계 
	function daesang_link(parentId, listnm){
		window.location.href = daesang_url+"parentId="+parentId+"&listnm="+encodeURIComponent(listnm);
	}
	
	//기념일별 통계 
	function day_link(parentId, parentNm){
		window.location.href = day_url+"parentId="+parentId+"&parentNm="+encodeURIComponent(parentNm);
	}
	
	
	/*	index,서브메인에서 클릭해서 들어왔을 경우	*/
	function sub_page(link_id){
		//parentId는 link_id.레벨
		//ul.id는 tree_ul_??
		var sub_link_id = "";
		var in_lev = 2;
		if(vwcd=="MT_OTITLE"){
			if(link_id.split(",").length==2){
				sub_link_id = link_id.substring(link_id.indexOf(",")+1, link_id.length);
				link_id = link_id.substring(0, link_id.indexOf(","));
			}else{
				in_lev = 3; 
			}
		}else if(vwcd=="MT_CTITLE"){
			sub_link_id = link_id.substring(link_id.indexOf(",")+1, link_id.length);
			link_id = link_id.substring(0, link_id.indexOf(","));
			in_lev = 3;
		}
	
		var in_id = link_id;
		var parentId = in_id+"."+(in_lev-1);
		
		//alert("sub_page :"+parentId);
		
		//ul은 link_id.2와 같은 parentId를 가지고 있음
		var ul_01 = document.getElementById('dhtmlgoodies_tree');
		var ul_02 = ul_01.getElementsByTagName('UL');
		var ulid = "";
		var isStop=false;
		for(var i=0; i<ul_01.children.length; i++){
			var li_02 = ul_02[i].getElementsByTagName('LI')[0].getAttribute("parentId");
			if(li_02!=null && li_02.substring(0, li_02.indexOf("."))==link_id){
				ulid = "tree_ul_"+i;
				i == ul_02.length;
			}
			if(vwcd=="MT_OTITLE" || vwcd=="MT_CTITLE"){
				var ul_03 = ul_02[i].getElementsByTagName('UL');
				for(var j=0; j<ul_03.length; j++){
					var li_03 = ul_03[j].getElementsByTagName('LI')[0].getAttribute("parentId");
					if(li_03.substring(0, li_03.indexOf("."))==link_id){
						var ulid_nm = ul_01.children.length+j;
						ulid = "tree_ul_"+ulid_nm;
						isStop=true; 
						break;
					}
				}
				if(isStop) {
					break;
				}
			}
		}
		
		ajaxObjectArray[ajaxObjectArray.length] = new sack();
		var ajaxIndex = ajaxObjectArray.length-1;
						
		// 기관별 목록일 경우에는 다른 페이지 (폴더인지 통계표인지 구별하는 법이 달라서 따로 페이지 만듬)
		if(vwcd=="MT_OTITLE"){
			var openYN = '';
			var openId = '';
			if (in_lev == '2') { openYN = 'Y';   openId = sub_link_id;    	    }		
			else if (in_lev == '3')  {
			    var btn_event = document.getElementById('all_close' + link_id);
			    if (btn_event != null) {
			         var parentLI = btn_event.parentNode.parentNode;
                     var img0 = parentLI.getElementsByTagName('IMG')[1];			         
                     var img1 = parentLI.getElementsByTagName('IMG')[2];
                     
                     img0.src = img0.src.replace(plusImage,minusImage);
                     img1.src = img1.src.replace(folderImage,folderOpenImage);                     
			    }
		    }
			
			ajaxObjectArray[ajaxIndex].requestFile = context+'/abroad/office/depthlist.jsp?' + 'parentId=' + in_id + '&listLev=' + in_lev + '&openYN=' + openYN + '&openId=' + openId + get_parameter();
		}else if(vwcd=="MT_TM1_TITLE" || vwcd=="MT_TM2_TITLE" || vwcd=="MT_TM3_TITLE"){
			ajaxObjectArray[ajaxIndex].requestFile = context+'/themes/treelist/depthlist.jsp?' + 'parentId=' + in_id + '&listLev=' + in_lev + get_parameter();	
		}else {
			ajaxObjectArray[ajaxIndex].requestFile = get_ajaxRequestFile() + 'parentId=' + in_id + '&listLev=' + in_lev + get_parameter();					
		}
		//alert(ajaxObjectArray[ajaxIndex].requestFile)
		var tempul = document.getElementById(ulid);
		tempul.style.display = "block";
		ajaxObjectArray[ajaxIndex].onCompletion = function() { getLinkData(ajaxIndex,ulid,parentId,sub_link_id); };	// Specify function that will be executed after file has been found					
		ajaxObjectArray[ajaxIndex].runAJAX();		// Execute AJAX function

		var allOpenCloseImg;	//전체 열기 닫기 버튼 
		allOpenCloseImg = document.getElementById(ulid).parentNode.getElementsByTagName('IMG');

		//전체 열기 
		if(allOpenCloseImg!=null && allOpenCloseImg.length>1){
			for(var oc=0; oc<allOpenCloseImg.length; oc++){
				if(allOpenCloseImg[oc].id.indexOf("all_close_top")>=0){
					allOpenCloseImg[oc].style.visibility="visible";
					break;
				}else if(allOpenCloseImg[oc].src.indexOf("allopen")>=0){
					var aTag_id = allOpenCloseImg[oc].parentNode;
					var imgId = "all_close"+aTag_id.id.split("atag_")[1];
					
					aTag_id.innerHTML = "<img src=\""+context+"/ext/image/comm/btn_allclose.gif\" alt=\"전체닫기\" id=\""+imgId+"\"/>";
					break;
				}
				
			}
			// 폴더 이미지 변경 ... 열림 이미지로 ...
             for(var oc=0; oc<allOpenCloseImg.length; oc++) {
                 if (allOpenCloseImg[oc].src.indexOf("sfolder.gif")>=0) {
                     allOpenCloseImg[oc].src = allOpenCloseImg[oc].src.replace(folderImage,folderOpenImage);
                     allOpenCloseImg[oc].width = "15";
                     allOpenCloseImg[oc].height= "14";
                     break;
                 }
             } 										
		}
	}

	function getLinkData(ajaxIndex,ulid, parentId,sub_link_id)
	{
		// 클릭한 트리에 데이터가 없으면 loadding 이라는 트리 요소 삭제
		//alert("getLinkData :innerHTML: "+document.getElementById(ulid).innerHTML);
		//alert("getLinkData :response: "+ajaxObjectArray[ajaxIndex].response);
		document.getElementById(ulid).innerHTML = ajaxObjectArray[ajaxIndex].response;
		ajaxObjectArray[ajaxIndex] = false;
		/*	명칭별 목록일 경우	*/
		if(vwcd=="MT_CTITLE"){
			//alert(ajaxIndex+","+ulid+","+parentId+","+sub_link_id);
			parseSubItems(ulid,parentId);

			var ulId = document.getElementById("ab_tl_027");
			var eventImg = ulId.getElementsByTagName("IMG");
			
			for(var i=0; i<eventImg.length; i++){
				var onOffImg = eventImg[i].src.split("_")[eventImg[i].src.split("_").length-1];
				var swapImg = eventImg[i].src.split(onOffImg);
				
				if(eventImg[i].id == sub_link_id){
					eventImg[i].src = swapImg[0]+"on.gif";
				}else {
					eventImg[i].src = swapImg[0]+"off.gif";
				}
			}
		}else{
			parseSubItems(ulid,parentId,sub_link_id);
		}
	}
	


/*그래프_상승국면*/
function openDiv_graph01()
{
	var graph02 = document.getElementById("graph02");
	graph02.style.visibility = "hidden";
	var graph03 = document.getElementById("graph03");
	graph03.style.visibility = "hidden";
	var graph04 = document.getElementById("graph04");
	graph04.style.visibility = "hidden";
	var view = document.getElementById("view");
	view.style.visibility = "hidden";
	var graph01 = document.getElementById("graph01");
	graph01.style.visibility = "visible";
}

/*그래프_회복국면*/
function openDiv_graph02()
{
	var graph01 = document.getElementById("graph01");
	graph01.style.visibility = "hidden";
	var graph03 = document.getElementById("graph03");
	graph03.style.visibility = "hidden";
	var graph04 = document.getElementById("graph04");
	graph04.style.visibility = "hidden";
	var view = document.getElementById("view");
	view.style.visibility = "hidden";
	var graph02 = document.getElementById("graph02");
	graph02.style.visibility = "visible";
}

function thisMovie(movieName) {
	 if (navigator.appName.indexOf("Microsoft") != -1) {
		 return window[movieName];
	 } else {
		 return document[movieName];
	 }
}

/*그래프_둔화국면*/
function openDiv_graph03()
{
	var graph01 = document.getElementById("graph01");
	graph01.style.visibility = "hidden";
	var graph02 = document.getElementById("graph02");
	graph02.style.visibility = "hidden";
	var graph04 = document.getElementById("graph04");
	graph04.style.visibility = "hidden";
	var view = document.getElementById("view");
	view.style.visibility = "hidden";
	var graph03 = document.getElementById("graph03");
	graph03.style.visibility = "visible";
}

/*그래프_하강국면*/
function openDiv_graph04()
{
	var graph01 = document.getElementById("graph01");
	graph01.style.visibility = "hidden";
	var graph02 = document.getElementById("graph02");
	graph02.style.visibility = "hidden";
	var graph03 = document.getElementById("graph03");
	graph03.style.visibility = "hidden";
	var view = document.getElementById("view");
	view.style.visibility = "hidden";
	var graph04 = document.getElementById("graph04");
	graph04.style.visibility = "visible";
}


/* 주요지표 & e지방지표 & 경기순환시계 화면전환*/
var count = 1;
function showDiv(){
	document.getElementById("content_00"+count).style.display = "none";
//	alert("전-"+document.getElementById("content_00"+count).style.display+"숫자"+count);
	count++;
	if(count == 4) count = 1;
	document.getElementById("content_00"+count).style.display = "block";
//	alert("후-"+document.getElementById("content_00"+count).style.display+"숫자"+count);
	
	var loop = setInterval(showDiv(), 3000);
}



/*	LeftTab 명칭별 리스트	*/
var ajaxObjectArray = new Array();
function changLeftTabTitle(rootId, e){
//	alert(rootId.substring(0,1));
	if(rootId!=null){
		//명칭별 Text에 Style주기
		leftTitle_setStyle(rootId.substring(0,1));

		var findId = rootId;
		var ajaxLeftTabFile = context+"/include/left_tab_title.jsp?rootId="+findId;
		
		ajaxObjectArray[ajaxObjectArray.length] = new sack();
		var ajaxIndex = ajaxObjectArray.length-1;

		ajaxObjectArray[ajaxIndex].requestFile = ajaxLeftTabFile;
		ajaxObjectArray[ajaxIndex].onCompletion = function() { getLeftTabPage(ajaxIndex); };	// Specify function that will be executed after file has been found					
		ajaxObjectArray[ajaxIndex].runAJAX();		// Execute AJAX function
	}
}

function getLeftTabPage(ajaxIndex){

	var idOfLeftTab = 'left_tab_title'; //list가 들어갈 Left Tab UL ID

	document.getElementById(idOfLeftTab).innerHTML = ajaxObjectArray[ajaxIndex].response;
	ajaxObjectArray[ajaxIndex] = false;
}

function leftTitle_setStyle(rootId){
	var l_title = (document.getElementById("sidetab_03_003")).getElementsByTagName("A");
	var l_title_cnt = l_title.length;
	var l_title_char = ["ㄱ", "ㄴ", "ㄷ", "ㄹ", "ㅁ", "ㅂ", "ㅅ", "ㅇ", "ㅈ", "ㅊ", "ㅌ", "ㅍ", "ㅎ", "기타"];
	
	//rootId = "A"면 "65" 
	rootId = rootId.charCodeAt(0);
	var l_title_inner;
	//alert(rootId);
	if(rootId>74){rootId = rootId-1;}
	
	for(var i=0; i<l_title_cnt; i++){ 
	
		if((rootId-65)==i){
			l_title_inner = "<font color=\"#261493\">"+l_title_char[i]+"</font>";
		}else{
			l_title_inner = "<font color=\"\">"+l_title_char[i]+"</font>"
		}
		
		l_title[i].innerHTML = l_title_inner;
	}
	
	
	
}

/*  팝업존 */
function stopPopupZone(){
	scroll_popup = window.clearInterval(scroll_popup);
}

function showPopupZone(cnt) {
	var tmpVal = 0;
	var popupZoneUL = document.getElementById("content_popupzone");
	var popupZoneCnt = popupZoneUL.getElementsByTagName("LI").length;
	popupZoneCnt = popupZoneCnt - 2;
	
	if(cnt==0){
		start_popup = 1;
		tmpVal = 1;
	}else if(cnt==99){
		start_popup = popupZoneCnt;
		tmpVal = popupZoneCnt;
	}else if((start_popup+cnt)>popupZoneCnt){
		start_popup = 1;
		tmpVal = 1;
	}else if((start_popup+cnt)<1){
		start_popup = popupZoneCnt;
		tmpVal = popupZoneCnt;
	}else{
		tmpVal = (start_popup+cnt);
		start_popup = (start_popup+cnt);
	}
	for(var i=1; i<=popupZoneCnt; i++){
		document.getElementById("lipopupzone_"+i).style.display = "none";
	}

	document.getElementById("lipopupzone_"+tmpVal).style.display = "block";

}

/*	공감/국제통계 이전,다음버튼	*/
function showSpecial01Dl(str, idx) {
	var statusUl = document.getElementById("content_special");
	var statusUl_child = statusUl.getElementsByTagName("UL");
	var statusUlCnt = 0;

	for(var i=0; i<statusUl_child.length; i++){
		var childId = statusUl_child[i].id;
		if(childId.indexOf(str)>=0){
			statusUlCnt = statusUlCnt+1;
		}
	}
	if(idx<0){
		idx = statusUlCnt-1;
	}else if(idx>(statusUlCnt-1)){
		idx = 0;
	}
	for(var i=0; i<statusUlCnt; i++){
		document.getElementById(str+i).style.display = "none";
	}
	document.getElementById(str+idx).style.display = "block";
}


/*	숫자로 보는 우리나라 index rolling	*/
var scroll_interval;
var startnum = 0;
function main_jipyo_prev_next(idx){
	if(idx=="prev"){
		startnum = startnum-5;
	}
	if(idx=="next"){
		startnum = startnum+5;	
	}

	var ul_node = document.getElementById("numkorea_list");
	var info_node;
	var value_node;
	var strtno = 0;
	var endno;
	
	if(startnum < 0 ){	startnum = 8-startnum;	}
	if(startnum > 8 ){	startnum = startnum-8;	}
	strtno = startnum;
	
	var no = strtno;
	for(var i=0; i<5; i++){
		info_node = ul_node.getElementsByTagName("dd")[i*2];
		value_node = ul_node.getElementsByTagName("dd")[(i*2)+1];

		if(strtno>6){
			no = strtno%7;
		}else{
			no = strtno;
		}

		info_node.innerHTML = "<a href=\"javascript:generator_link('"+arrNumStatList[no][5]+"','"+arrNumStatList[no][6]+"','','"+arrNumStatList[no][2].replace("'","`")+"','G2');\" title=\""+arrNumStatList[no][7]+"\"  class=\"numLink\">"+arrNumStatList[no][0]+"</a>";
		value_node.innerHTML = arrNumStatList[no][1];
		strtno++;
	}

	startnum = startnum+1;
}
function main_jipyo(idx){
	var ul_node = document.getElementById("numkorea_list");
	var info_node;
	var value_node;
	var strtno = 0;
	var endno;
	
	if(startnum < 0 ){	startnum = 6-startnum;	}
	if(startnum > 6 ){	startnum = startnum-6;	}
	strtno = startnum;
	
	var no = strtno;
	for(var i=0; i<5; i++){
		info_node = ul_node.getElementsByTagName("dd")[i*2];
		value_node = ul_node.getElementsByTagName("dd")[(i*2)+1];

		if(strtno>6){
			no = strtno%7;
		}else{
			no = strtno;
		}
		
		info_node.innerHTML = "<a href=\"javascript:generator_link('"+arrNumStatList[no][5]+"','"+arrNumStatList[no][6]+"','','"+arrNumStatList[no][2].replace("'","`") +"','G2');\" title=\""+arrNumStatList[no][7]+"\" class=\"numLink\">"+arrNumStatList[no][0]+"</a>";
		value_node.innerHTML = arrNumStatList[no][1];
		strtno++;
	}

	startnum = startnum+1;

	scroll_interval = setInterval("roll_jipyo()", 4000);
}

function roll_jipyo(idx){
	var ul_node = document.getElementById("numkorea_list");
	var info_node;
	var value_node;
	var strtno = 0;
	var endno;
	
	if(startnum>6){	startnum = 0;	}
	strtno = startnum;
	
	var no = strtno;
	for(var i=0; i<5; i++){
		info_node = ul_node.getElementsByTagName("dd")[i*2];
		value_node = ul_node.getElementsByTagName("dd")[(i*2)+1];

		if(strtno>6){
			no = strtno%7;
		}else{
			no = strtno;
		}
		info_node.innerHTML = "<a href=\"javascript:generator_link('"+arrNumStatList[no][5]+"','"+arrNumStatList[no][6]+"','','"+arrNumStatList[no][2].replace("'","`")+"','G2');\" title=\""+arrNumStatList[no][7]+"\" class=\"numLink\">"+arrNumStatList[no][0]+"</a>";
		value_node.innerHTML = arrNumStatList[no][1];
		strtno++;
	}

	startnum = startnum+1;
}

//한국의 주요지표 방향버튼
var jipyoNum = 1;
function showjipyoNumPrev() {
	document.getElementById("chartunit" + jipyoNum).style.display = "none";
	document.getElementById("chartDiv" + jipyoNum).style.display = "none";
	jipyoNum--;
	if (jipyoNum < 1) jipyoNum = 6;
	document.getElementById("chartunit" + jipyoNum).style.display = "block";
	document.getElementById("chartDiv" + jipyoNum).style.display = "block";
}
function showjipyoNumNext() {
	document.getElementById("chartunit" + jipyoNum).style.display = "none";
	document.getElementById("chartDiv" + jipyoNum).style.display = "none";
	jipyoNum++;
	if (jipyoNum > 6) jipyoNum = 1;
	
	document.getElementById("chartunit" + jipyoNum).style.display = "block";
	document.getElementById("chartDiv" + jipyoNum).style.display = "block";
}


//팝업존 Rolling
var scroll_popup;
var start_popup = 1;
function main_popupzone(){
	//Random으로 팝업존 보여주기 
	var popupZoneUL = document.getElementById("content_popupzone");
	var popupZoneCnt = popupZoneUL.getElementsByTagName("LI").length;
	popupZoneCnt = popupZoneCnt - 2;
	
	var popup_li;
	for(var i=1; i<=popupZoneCnt; i++){
		document.getElementById("lipopupzone_"+i).style.display = "none";
	}
	start_popup = Math.floor(Math.random() * popupZoneCnt) + 1;
	popup_li = document.getElementById("lipopupzone_"+start_popup);
	popup_li.style.display = "block";
	
	scroll_popup = setInterval("roll_popupZone()", 5000);
	
}
function roll_popupZone(){
	var popupZoneUL = document.getElementById("content_popupzone");
	var popupZoneCnt = popupZoneUL.getElementsByTagName("LI").length;
	popupZoneCnt = popupZoneCnt - 2;
	
	var popup_li;
	for(var i=1; i<=popupZoneCnt; i++){
		document.getElementById("lipopupzone_"+i).style.display = "none";
	}
	start_popup = start_popup+1;
	if(start_popup>popupZoneCnt){start_popup = 1;}
	popup_li = document.getElementById("lipopupzone_"+start_popup);
	popup_li.style.display = "block";

}

//주요지표, 경기순환시계, 이지방지표 Rolling
var scroll_center;
var start_center = 1;
function main_centerFlash(){
	//Random으로 팝업존 보여주기 
	start_center = Math.floor(Math.random() * 4) + 1;
	showContentDiv(start_center);
	scroll_center = setInterval("roll_centerFlash()", 5000);
	
}
function roll_centerFlash(){
	start_center = start_center+1;
	if(start_center>4){start_center = 1;}
	showContentDiv(start_center);
}

//주요지표 Rolling
var scroll_center;
function main_jipyoFlash(){
	hideContentDiv();
	document.getElementById("content_001").style.display = "block";
	document.getElementById("content_num1").src = context+"/ext/image/index/num_01_on.gif";
	
	showjipyoNumNext();
	scroll_center = setInterval("roll_jipyoFlash()", 5000);
	
}
function roll_jipyoFlash(){
	showjipyoNumNext();
}




/* 길이(num)이후 자르기 */
function limitLenCut(arg, num, tail)
{
    var len = arg.length ;
    var str1= "", str2= "" ;
    for( i = 0 ; i < len ; i ++ ){
        if (arg.charCodeAt(i) > 255){
            str1 += arg.charAt(i) + " " ;
        }
        else{
            str1 += arg.charAt(i) ;
        }
    }

    if(str1.charCodeAt(num-1) > 255){
        num = num-1 ;
    }

    for( i = 0 ; i < num ; i ++ ){
        if (str1.charAt(i) != " " ){
            str2 += str1.charAt(i) ;
        }
    }
	
	if(tail){
		if(arg.length!=str2.length)
			str2+=tail;
	}
	
    return str2 ;
}

/*	프린트	*/
function print_copy(){
	//print_popup_body
	var div_id = document.getElementById("print_popup_body");
	var copy_id;

	if(print_page.split("learning").length>2){
	//통계배우미
		copy_id = opener.document.getElementById("print_area");
	}else if(print_page.split("news_05").length>1 || print_page.split("news_06").length>1){
	//QNA, 홈페이지 개선의견 
		copy_id = opener.document.getElementById("print_area");
	}else {
		//통계알리미
		copy_id = opener.document.getElementById("content_area");
	}
	div_id.innerHTML = copy_id.innerHTML;
	window.print();
}


// 통계목록 엑셀로 받기 
function excelDownPopup() {
   	//팝업 생성 
	var tmp_vwcd = vwcd.split("MT_")[1];
   	//var url = context+"/ext/downXLS/"+tmp_vwcd+".xls";
   	var url = context+"/downXLS/"+tmp_vwcd+".zip";
    document.location.href=url;
}


//회원가입 - 약관다운로드
function agreementDownPopup() {
   	//팝업 생성 
   	var url = context+"/FileServlet?mode=downfile&path_type=srvc_list&file_name=agreement.hwp";
    document.location.href=url;
}


//Login 체크
function goClick(returnURL){
	if(confirm("로그인 후에 사용하실 수 있습니다.")){
		if(returnURL) {
			location.href = context+"/common/login/login.jsp?returnURL="+returnURL;
		}else {
			location.href = context+"/common/login/login.jsp";
		}
	}
}

function popupHelp_02(url) {
	var win = window.open(url,'helpWin','location=no,directories=no,resizable=no,status=no,toolbar=no,scrollbars=no,width=860,height=650');
	win.focus();
}

function opencredit(){
	var url = "http://www.mosf.go.kr/_lib/lib01/lib01a.jsp";
	var win = window.open(url,'credit','location=no,directories=no,resizable=yes,status=no,toolbar=no,scrollbars=yes,width=1024,height=650');
	win.focus();
}
function openstock(){
	var url = "http://www.krx.co.kr/hdm/lnk/jisu_4_both.jsp";
	var win = window.open(url,'stock','location=no,directories=no,resizable=no,status=no,toolbar=no,scrollbars=no,width=250,height=250');
	win.focus();
}
function openexchange(){
	var url = "http://www.keb.co.kr/exchange/fx1.htm";
	var win = window.open(url,'exchange','location=no,directories=no,resizable=no,status=no,toolbar=no,scrollbars=no,width=184,height=160');
	win.focus();
}

