//$.cookie('pdf_alert','1',{expires:7,domain:'hc.go.kr', path:'/', secure:0}); 생성
//$.cookie('pdf_alert',false); 삭제
(function($){
	$.cookie = function(key, value, options) {
		if(arguments.length > 1) {
			var o = $.extend({}, $.cookieOptions, options);
	        if (value === null || value === undefined) {
	            value = '';
	            o.expires = -1;
	        }
	        if (o.expires.constructor != Date) {
				var today = new Date();
				today.setDate(today.getDate() + o.expires);
				o.expires = today;
			}
			// Create the cookie string
			document.cookie = 
				key + '=' + value +
				'; expires=' + o.expires.toUTCString() +
				(o.path? '; path=' + (o.path) : '') +
				(o.domain? '; domain=' + (o.domain) : '') +
				(o.secure? '; secure' : '');
		} else {
			if(result = new RegExp(key+"=(.*?)(?:;|$)").exec(document.cookie))
				return decodeURIComponent(result[1]);
			return false;
		}
	};
	$.cookieOptions = {
		expires: 365,
		path: '/'
	}
})(jQuery);

function maintab(id){
	for(var i=1;i<7;i++){
		var cont = $('#div_maintab'+i);
		var img1 = $('#maintab_img'+i+'_1');
		var img2 = $('#maintab_img'+i+'_2');
		if(cont)cont.hide();
		if(img1)img1.show();
		if(img2)img2.hide();
	}
	$('#div_maintab'+id).show();
	$('#maintab_img'+id+'_1').hide();
	$('#maintab_img'+id+'_2').show();
}

function show_main_menu(){
	if($('#laymenu').css('display') == 'none'){
		$('#laymenu').show();
		$('#main_search_select').hide();
	}else{
		$('#laymenu').hide();
		$('#main_search_select').show();
	}
}

function show_hide_menu(id){
	if($('#'+id).css('display') == 'none'){
		$('#department').hide();
		$('#doanne').hide();
		$('#oivne').hide();
		$('#'+id).show();
	}else{
		$('#'+id).hide();
	}
}

function show_sub_menu(id){
	for(var i=1;i<7;i++){
		var cont = $('#main_submenu_'+i);
		var img1 = $('#main_top_'+i+'_1');
		var img2 = $('#main_top_'+i+'_2');
		if(cont)cont.hide();
		if(img1)img1.show();
		if(img2)img2.hide();
	}
	
	$('#main_submenu_'+id).show();
	$('#main_top_'+id+'_1').hide();
	$('#main_top_'+id+'_2').show();
}


function village_menu(id){	
	$('#village_menu_'+id).show();
}
function hide_village_menu(id){
	$('#village_menu_'+id).hide();
}

function show_town_menu(id){
	for(var i=1;i<=7;i++){
		var cont = $('#sub_menu_'+i);
		if(cont)cont.hide();
	}
	if($('#sub_menu_'+id).html()){
		$('#sub_menu_'+id).show();
	}
}

function hide_town_menu(id){
	$('#sub_menu_'+id).hide();
}

function all_hide_town_menu(){
	for(var i=1;i<=7;i++){
		$('#sub_menu_'+i).hide();
	}
}


	
function session_clear(){
	jConfirm('로그아웃하시겠습니까?', '확인창', function(r) {
		//jAlert('Confirmed: ' + r, 'Confirmation Results');
		if(r){
			//tb_show('', '/?c=utility&m=ajax_login&height=150&width=300&modal=true&act=/board_auth/board_delete_login/<?=$board_id?>/<?=$readno?>&dst='+url , '');
			tb_show('', '/?c=utility&m=session_clear&height=150&width=300&modal=true' , '');
		}
	});
}	

function admin_session_clear(){
	jConfirm('로그아웃하시겠습니까?', '확인창', function(r) {
		//jAlert('Confirmed: ' + r, 'Confirmation Results');
		if(r){
			tb_show('', '/?c=utility&m=admin_session_clear&height=150&width=300&modal=true' , '');
		}
	});
}


	function go_popup(url) {
		window.open(url,'popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=650,height=445 ,top=0, left=100');
	}

	function BodyPrint2() {
		new_window = open("","PrintWindow","width=700,height=600,left=10,top=10,resizable=yes,scrollbars=yes");
		new_window.document.open();
		// 아래 부분에 새창으로 나타날 내용을 html형식에 맞게 만든다.
		new_window.document.write("<html>");
		new_window.document.write("<link href='http://www.hc.go.kr/js_css/basic_styles.css' rel='stylesheet' type='text/css'>");
		new_window.document.write("<link href='http://www.hc.go.kr/kor/open_content/css/layout.css' rel='stylesheet' type='text/css'>");
		new_window.document.write("<link href='http://www.hc.go.kr/kor/open_content/css/content.css' rel='stylesheet' type='text/css'>");
		new_window.document.write("<link href='http://www.hc.go.kr/kor/open_content/css/template.css' rel='stylesheet' type='text/css'>");
		//new_window.document.write("<link href='/kor/open_content/css/base.css' rel='stylesheet' type='text/css'>");
		new_window.document.write("<link href='http://www.hc.go.kr/kor/open_content/css/default.css' rel='stylesheet' type='text/css'>");		
		new_window.document.write("<body leftmargin=15 topmargin=250 marginwidth=0 marginheight=0>");
		//new_window.document.write(document.all.titleprint.outerHTML);
	
		new_window.document.write(document.all.body2.outerHTML);
		new_window.document.write("<script>print()</script>");
		//new_window.document.write("<a href='#' onclick='print()' ><img src='http://new.hc.go.kr/kor/open_content/images/btn/5480000_btn_print.gif' border=0></a>");
		new_window.document.write("</body>");
		new_window.document.write("</html>");
		// 문서를 닫는다.
		new_window.document.close();
	}

	function login_confirm(url){
		jConfirm('권한이 없습니다.실명인증 하시겠습니까?', '확인창', function(r) {
			//jAlert('Confirmed: ' + r, 'Confirmation Results');
			if(r){
				//tb_show('', '/?c=utility&m=ajax_login&height=150&width=300&modal=true&dst='+url , '');
				tb_show('', 'http://hc.go.kr/?c=utility&m=name_check&height=150&width=300&modal=true&dst='+url+'&TB_iframe=true' , '');
			}
		});
	}
	
	//메뉴이미지 마우스오버
	$('document').ready(function(){
		for(var i=1;i<7;i++){
			$('.n_menu'+i).hover(function(){
				top_menu_over($(this));
			},function(){
				top_menu_out($(this));
			});
		}
	});		
	
	function top_menu_sub_display(obj){
		var xy = obj.offset(); //해당메뉴 좌표값
		var menu_no = obj.attr('menu_no');
		var menu = $('#top_sub_menu'+menu_no).html();
		$('#top_sub_menu').html(menu);
		$('#top_sub_menu').css('position','absolute');
		$('#top_sub_menu').css('left',xy.left);
		$('#top_sub_menu').css('top',xy.top + 28);
		$('#top_sub_menu').css('display','block');
		$('#top_sub_menu').attr('menu_no',menu_no);
	}
	

	//영어사이트 아이콘 포커스시에 펼처진 메뉴사라지게 하기
	$('document').ready(function(){		
		$('#english').focus(function(){
			for(var i=1;i<7;i++){
				$('.n_menu'+i).removeClass('n_menu'+i+'_hover');
			}
			$('#top_sub_menu').css('display','none');
		});
	});

	//통합검색 라디오버튼 포커스시에 펼쳐진 메뉴사라지게 하기
	$('document').ready(function(){		
		$('#head_menu_searchm1').focus(function(){
			$('#top_link_menu').css('display','none');
		});
	});

	function top_menu_clear(){	
		for(var i=1;i<7;i++){
			$('.n_menu'+i).removeClass('n_menu'+i+'_hover');
		}
	}
	
	function top_menu_over(obj){
		top_menu_clear();
		var menu_no = obj.attr('menu_no');
		obj.addClass('n_menu'+menu_no+'_hover');
		top_menu_sub_display(obj);
	}
	
	function top_menu_out(obj){
		var menu_no = obj.attr('menu_no');
		obj.removeClass('n_menu'+menu_no+'_hover');
		$('#top_sub_menu').css('display','none');
	}
	
	//서브메뉴 마우스오버
	$('document').ready(function(){
		$('#top_sub_menu').hover(function(){
			var menu_no = $('#top_sub_menu').attr('menu_no',menu_no);
			var obj = $('.n_menu'+menu_no);
			top_menu_over(obj);
		},function(){
			var menu_no = $('#top_sub_menu').attr('menu_no',menu_no);
			var obj = $('.n_menu'+menu_no);
			top_menu_out(obj);
		});
	});
	
	//읍면팝업메뉴에 마우스오버
	$('document').ready(function(){
		$('#top_link_menu').hover(function(){
			$('#top_link_menu').css('display','block');
		},function(){
			$('#top_link_menu').css('display','none');
		});
	});		

	//실과/읍면 링크포커스
	var n_top_link_icon;
	$('document').ready(function(){
		$('.n_top_link_menu').focus(function(){
			var menu_no = $(this).attr('menu_no');
			var menu = $('#top_link_menu'+menu_no).html();
			$('#top_link_menu').html(menu);
			set_link_position($(this));
		},function(){
			$('#top_link_menu').css('display','none');
		});
	});

	//실과/읍면 링크오버
	$('document').ready(function(){
		$('.n_top_link_menu').hover(function(){
			var menu_no = $(this).attr('menu_no');
			var menu = $('#top_link_menu'+menu_no).html();
			$('#top_link_menu').html(menu);
			set_link_position($(this));
		},function(){
			$('#top_link_menu').css('display','none');
		});
	});

	
	//전체메뉴보기 클릭
	var n_top_link_icon;
	/*$('document').ready(function(){
		$('.n_top_all_menuicon').bind('click',function(){
			var xy = $(this).offset(); //해당메뉴 좌표값
			$('#top_all_menu').css('position','absolute');
			$('#top_all_menu').css('left',xy.left - 745);
			$('#top_all_menu').css('top',90);
			if($('#top_all_menu').css('display') == 'block'){
				$('#top_all_menu').hide();
			}else{
				$('#top_all_menu').show();
			}
		});
	});*/	

	$('document').ready(function(){
		$('.n_top_all_menuicon').hover(function(){
			var xy = $('.n_top_all_menuicon').offset(); //해당메뉴 좌표값
			$('#top_all_menu').css('position','absolute');
			$('#top_all_menu').css('left',xy.left - 745);
			$('#top_all_menu').css('top',90);
			$('#top_all_menu').show();
		},function(){
			
		});
	});

	function hide_menu(){
		$('#top_all_menu').hide();	
	}
	function show_menu(){
		var xy = $('.n_top_all_menuicon').offset(); //해당메뉴 좌표값
		$('#top_all_menu').css('position','absolute');
		$('#top_all_menu').css('left',xy.left - 745);
		$('#top_all_menu').css('top',90);
		$('#top_all_menu').show();
	}

	//상단 한글뷰어링크 포커스시에 펼쳐진 메뉴사라지게 하기
	$('document').ready(function(){		
		$('#hangul').focus(function(){
			$('#top_all_menu').hide();
		});
	});
	
	
	//실과읍면링크위치세팅
	function set_link_position(obj){
		var xy = obj.offset(); //해당메뉴 이미지의 좌표값
		var imgheight = obj.attr("height"); //해당메뉴 이미지의 세로크기
		//서브메뉴의 div 위치지정
		$('#top_link_menu').css('position','absolute');
		$('#top_link_menu').css('left',xy.left);
		$('#top_link_menu').css('top',xy.top + imgheight);
		$('#top_link_menu').css('display','block');
	}
	
	//통합검색_click
	function main_menu_search(){
		var ck_obj = $('[name=head_menu_searchm]');
		var txt_obj = $('#head_menu_searchm_text');
		if(txt_obj.val()){
			if(ck_obj[0].checked){
				//window.location='/search/board/searchm/'+txt_obj.val();
				$.blockUI({ message: $('#searchm_message') }); 
				setTimeout(function() { window.location.replace('/search/board/searchm/'+txt_obj.val()); }, 1000);
			}else if(ck_obj[1].checked){
				//window.location='/search/employee/searchm/'+txt_obj.val();
				$.blockUI({ message: $('#searchm_message') }); 
				setTimeout(function() { window.location.replace('/search/employee/searchm/'+txt_obj.val()); }, 1000);
			}else{
				var arg = '경남 합천군 ' + txt_obj.val();
				arg = encodeURI(arg);
				window.open("http://www.lets114.co.kr/Web/GlobalSearch/Search.aspx?q="+arg);

			}
		}else{
			jAlert('검색어를 입력하세요');
		}
	}

	//통합검색_keypress
	$('document').ready(function(){
		$('#head_menu_searchm_text').bind('keypress',function(e){
			if(e.which == 13){
				var ck_obj = $('[name=head_menu_searchm]');
				var txt_obj = $('#head_menu_searchm_text');
				if(txt_obj.val()){
					if(ck_obj[0].checked){
						//window.location='/search/board/searchm/'+txt_obj.val();
						$.blockUI({ message: $('#searchm_message') }); 
						setTimeout(function() { window.location.replace('/search/board/searchm/'+txt_obj.val()); }, 1000);
					}else if(ck_obj[1].checked){
						//window.location='/search/employee/searchm/'+txt_obj.val();
						$.blockUI({ message: $('#searchm_message') }); 
						setTimeout(function() { window.location.replace('/search/employee/searchm/'+txt_obj.val()); }, 1000);
					}else{
						var arg = '경남 합천군 ' + txt_obj.val();
						arg = encodeURI(arg);
						window.open("http://www.lets114.co.kr/Web/GlobalSearch/Search.aspx?q="+arg);
		
					}
				}else{
					jAlert('검색어를 입력하세요');
				}
			}
		});
	});
	
	
	//실과통합검색
	$('document').ready(function(){
		$('#dp_search').bind('click',function(){			
			var txt_obj = $('#dp_searchm_text');			
			if(txt_obj.val()){				
				//window.location='/search/board/searchm/'+txt_obj.val();
				$.blockUI({ message: $('#searchm_message') }); 
				setTimeout(function() { window.location.replace('/search/dp_board/searchm/'+txt_obj.val()); }, 1000);								
			}else{
				jAlert('검색어를 입력하세요');
			}
		});
	});

	//읍면통합검색
	$('document').ready(function(){
		$('#town_search').bind('click',function(){			
			var txt_obj = $('#town_searchm_text');
			var htxt_obj = $('#town_uri_text');
			if(txt_obj.val()){				
				//window.location='/search/board/searchm/'+txt_obj.val();
				$.blockUI({ message: $('#searchm_message') }); 
				setTimeout(function() { window.location.replace('/search/town_board/searchm/'+txt_obj.val()); }, 1000);								
			}else{
				jAlert('검색어를 입력하세요');
			}
		});
	});
	
	//프린트
	$('document').ready(function(){
		$('#btn_body_print').bind('click',function(){
			var obj = $('#n_contents_print');
			if($('#n_contents_print2').length)obj = $('#n_contents_print2');
			pagePrint(obj);
		});
	});
	
	function pagePrint(Obj) { 
		var W = Obj.offsetWidth;        //screen.availWidth; 
		var H = Obj.offsetHeight;        //screen.availHeight; 
		var features = "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,width=" + W + ",height=" + H + ",left=0,top=0"; 
		var PrintPage = window.open("about:blank",Obj.id,features); 
		PrintPage.document.open(); 
		PrintPage.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n<html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><title></title><link  href='http://kr.hc.go.kr/css/n_base.css' rel='stylesheet' type='text/css' />\n</head>\n<body>" + Obj.html() + "\n</body></html>"); 
		PrintPage.document.close(); 
		PrintPage.document.title = document.domain; 
		PrintPage.print(PrintPage.location.reload()); 
	}
	
	//줌인줌아웃
	$('document').ready(function(){
		$('#n_top_icon_zoomIn').bind('click',function(){
			zoomIn();
		});
		$('#n_top_icon_zoomOut').bind('click',function(){
			zoomOut();
		});
		$('#n_top_icon_default').bind('click',function(){
			zoomDefault();
		});
	});
	
	var nowZoom = 100; // 현재비율 
	var maxZoom = 200; // 최대비율(500으로하면 5배 커진다) 
	var minZoom = 80; // 최소비율 
	
	//화면 키운다. 
	function zoomIn() 
	{ 
		if (nowZoom < maxZoom) 
		{ 
			nowZoom += 10; //25%씩 커진다. 
		} 
		else 
		{ 
			return; 
		} 
		document.body.style.zoom = nowZoom + "%"; 
	} 
	
	
	//화면 줄인다. 
	function zoomOut() 
	{ 
		if (nowZoom > minZoom) 
		{ 
			nowZoom -= 10; //25%씩 작아진다. 
		} 
		else 
		{ 
			return; 
		} 
		document.body.style.zoom = nowZoom + "%"; 
	} 
	
	//화면 원래대로 
	function zoomDefault() 
	{ 
		nowZoom = 100; 
		document.body.style.zoom = nowZoom + "%"; 
	}
	
	//파일다운
	function go_file_down(filename){
		location.href = "/?c=utility&m=filedown&file_name="+filename;
	}

	//문화관광 팝업
	function MM_openBrWindow(theURL,winName,features) { //v2.0
		window.open(theURL,winName,features);
	}
	
	function go_main_jump_menu(url){
		//alert(url);
		window.open(url,'');
	}

	function banner_pop(){
		javascript:window.open('/?c=utility&m=pop_banner_list','','width=675,height=600,scrollbars=yes');
	}