
$(function() {
	//팝업존 플러그인 컨트롤 부분
	$('#Pop_resume_bt').click(function() {
		$('#popzone').cycle('resume');
		return false;
	});

	$('#Pop_pause_bt').click(function() {
		$('#popzone').cycle('pause');
		return false;
	});

	$('#popzone > a > img').mouseover(function(){
		$('#popzone').cycle('pause');
		return false;
	}).mouseout(function(){
		$('#popzone').cycle('resume');
		return false;
	}).focus(function(){
		$(this).mouseover();
		return false;
	}).blur(function(){
		$(this).mouseout();
		return false;
	});

	//배너존 재생/정지 플러그인 컨트롤 부분
	$('#banner_play').click(function() {
		$('#canadaprovinces').cycle('resume');
		return false;
	});

	$('#banner_stop').click(function() {
		$('#canadaprovinces').cycle('pause');
		return false;
	});

	//배너존 재생/정지 플러그인 컨트롤 부분
	$('#stype_select').click(function() {
		$('#stype_list').show();
	});

	$('#stype_list > li > label').click(function() {
		var typeVal = $(this).text();
		$('#stype_title').text(typeVal);
		$('#stype_list').hide();
	});

	//탑메뉴 텝 전환 (마우스 오버시)
	$('#top_navi > ul > li > a').mouseover(function(){
		$('#top_navi > ul > li > ul').hide();
		$('#top_navi > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('ul').show();
	});

	$('#top_navi > ul > li > a').focus(function(){
		$('#top_navi > ul > li > ul').hide();
		$('#top_navi > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('ul').show();
	});

	//검색바하단주요타이틀매뉴 (마우스 오버시)
	/*$('#content_top_menu > ul > li > label').mouseover(function(){
		$('.content_top_menu_font').css({color : "#FFF"});
		$(this).css({color : "#FFE400"});
	});*/

	$('#content_top_menu > ul > li > label').click(function(){
		$('.content_top_menu_font').css({color : "#FFF"});
		$(this).css({color : "#FFE400"});
	}).keypress(function(){
		$(this).click();
	}).focus(function(){
		$('.content_top_menu_font').css("color", "#FFFFFF");
		$(".content_top_menu_font",this).css("color", "#FFE400");
	});



	//패밀리사이트 롤오버 (마우스 오버시)
	$('#family_list > ul > li > a').mouseover(function(){
		$('#family_list > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
	}).focus(function(){
		$(this).mouseover();
	});


	//hit주요매뉴 롤오버(마우스 오버시)
	$('#hit_menu > ul > li > a').click(function(){
		$('#hit_menu > ul > li > div').hide();
		$('#hit_menu > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('div').show("fast");
	});

	//hit주요매뉴 롤오버(텝 클릭시)
	$('#hit_menu > ul > li > a').keyup(function(){
		$('#hit_menu > ul > li > div').hide();
		$('#hit_menu > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('div').show("");
	});

	//hit주요매뉴 닫기
	$('.hit_close').click(function(){
		$(this).parent('div').hide("fast");
	});

	//hit주요매뉴1 닫기
	$('.hit_close_1').click(function(){
		$(this).parent('div').hide("fast");
	});

	//하위홈페이지 롤오버(마우스 오버시)
	$('#people > ul > li > a').mouseover(function(){
		$('#people > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
	});

	//하위홈페이지 롤오버(텝 클릭시)
	$('#people > ul > li > a').focus(function(){
		$('#people > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
	});

	//자주찾는정보서비스 (마우스 오버시)
	$('.first_service_list > li > a').mouseover(function(){
		$('.first_service_font').css("color", "#686868");
		$(".first_service_font",this).css("color", "#2167c7");
	});

	//자주찾는정보서비스 (텝 클릭시)
	$('.first_service_list > li > a').focus(function(){
		$('.first_service_font').css("color", "#686868");
		$(".first_service_font",this).css("color", "#2167c7");
	});

	//자주찾는민원서비스 (마우스 오버시)
	$('.people_service_list > li > a').mouseover(function(){
		$(".people_service_font").css("color", "#686868");
		$(".people_service_font",this).css("color", "#2167c7");
	});

	//자주찾는민원서비스 (텝 클릭시)
	$('.people_service_list > li > a').focus(function(){
		$(".people_service_font").css("color", "#686868");
		$(".people_service_font",this).css("color", "#2167c7");
	});

	//하단매뉴가이드 롤오버(마우스 오버시)
	$('#bottom_guide > ul > li > a').mouseover(function(){
		$('#bottom_guide > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
	});

	//하단매뉴가이드 롤오버(텝 클릭시)
	$('#bottom_guide > ul > li > a').focus(function(){
		$('#bottom_guide > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
	});

	//공지보드리스트 (마우스 오버시)
	$('#main_board > ul > li > a').mouseover(function(){
		$('#main_board > ul > li > div').hide();
		$('#main_board > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('.board_list').show();
	});

	//공지보드리스트 텝 전환 (텝 클릭시)
	$('#main_board > ul > li > a').focus(function(){
		$('#main_board > ul > li > div').hide();
		$('#main_board > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('.board_list').show();
	});

		//민원정보,생활정보,행정정보 (마우스 오버시)
	$('#main_board2 > ul > li > a').mouseover(function(){
		$('#main_board2 > ul > li > div').hide();
		$('#main_board2 > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('.board_list').show();
	});

	//민원정보,생활정보,행정정보 (텝 클릭시)
	$('#main_board2 > ul > li > a').focus(function(){
		$('#main_board2 > ul > li > div').hide();
		$('#main_board2 > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('.board_list').show();
	});

	//영상포토리스트 (마우스 오버시)
	$('#photoNews > ul > li > a').mouseover(function(){
		$('#photoNews > ul > li > div').hide();
		$('#photoNews > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('div').show();
	});

	//영상포토리스트 텝 전환 (텝 클릭시)
	$('#photoNews > ul > li > a').focus(function(){
		$('#photoNews > ul > li > div').hide();
		$('#photoNews > ul > li > a > img').each(function(index, value){
			$(this).attr('src',$(this).attr('src').replace('_on','_off'));
		});
		$('img:first',this).attr('src',$('img:first',this).attr('src').replace('_off','_on'));
		$(this).next('div').show();
	});

	//주요기관 롤오버(마우스 오버시)
	$('#justgo_list > ul > li > a').click(function(){
		$('#justgo_list > ul > li > div').hide();
		$(this).next('div').show("fast");
		return false;
	});

	//주요기관 롤오버(텝 클릭시)
	$('#justgo_list > ul > li > a').focus(function(){
		$('#justgo_list > ul > li > div').hide();
		$(this).next('div').show("fast");
	});

	//동매뉴 닫기
	$('.dong_close').click(function(){
		$('.dong_AllMenu').hide("fast");
	});

	//관내주요사이트 닫기
	$('.site_close').click(function(){
		$('.site_AllMenu').hide("fast");
	});

	//자치구홈페이지 닫기
	$('.homepage_close').click(function(){
		$('.homepage_AllMenu').hide("fast");
	});

	//자주찾는정보서비스 열기
	$('.first_service_show').click(function(){
		$('#Prm3').attr('value','transparent');
		$('.found_service_layer').hide();
		$('.first_service_layer').show("fast");
	});

	//자주찾는민원서비스 열기
	$('.found_service_show').click(function(){
		$('.first_service_layer').hide();
		$('.found_service_layer').show("fast");
	});

	//자주찾는민원서비스 닫기
	$('.found_close > img').click(function(){
		$('.found_service_layer').hide("fast");
	});

	//자주찾는민원서비스 닫기
	$('.first_close > img').click(function(){
		$('.first_service_layer').hide("fast");
	});

	//나의 메뉴 설정
	$('.first_MymenuCall').click(function () {
		j = 0;
		var dataVal = "";
		for(k = 0; k < document.MymenuFrm.MymenuChk_first.length; k++){
			if (document.MymenuFrm.MymenuChk_first[k].checked == true){
				j++;
				if(j < 11) {
					dataVal = dataVal+"|"+ document.MymenuFrm.MymenuChk_first[k].value;
				}
			}
		}
		
		if(j < 11){
			$.ajax({
				type: "POST",
				url: "/inc/s_myMenuAjax_first.php?mode=1",
				data: "qlinkc="+dataVal,
				success: function(msg){
					//alert(msg);
					$('.first_service_list').html(msg);
					$(".first_service_layer").hide();
				}
			});
		}else{
			alert("10개항목 이내로 선택해 주세요");
			return false;
		}
	});

	//나의 메뉴 설정
	$('.first_MymenuDefault').click(function () {
		j = 0;
		var dataVal = "";
		for(k = 0; k < document.MymenuFrm.MymenuChk_first.length; k++){
			switch (k){
				case	10	:
				case	11	:
				case	12	:
				case	13	:
				case	14	:
				case	15	:
				case	16	:
				case	17	:
				case	18	:
				case	19	:
					document.MymenuFrm.MymenuChk_first[k].checked = true;
					dataVal = dataVal+"|"+ document.MymenuFrm.MymenuChk_first[k].value;
				break;

				default :
					document.MymenuFrm.MymenuChk_first[k].checked = false;
				break;
			}
		}

		$.ajax({
			type: "POST",
			url: "/inc/s_myMenuAjax_first.php?mode=1",
			data: "qlinkc="+dataVal,
			success: function(msg){
				//alert(msg);
				$('.first_service_list').html(msg);
				$(".first_service_layer").hide();
			}
		});
	});

	//나의 메뉴 설정
	$('.found_MymenuCall').click(function () {
		j = 0;
		var dataVal = "";
		for(k = 0; k < document.MymenuFrm.MymenuChk_found.length; k++){
			if (document.MymenuFrm.MymenuChk_found[k].checked == true){
				j++;
				if(j < 11) {
					dataVal = dataVal+"|"+ document.MymenuFrm.MymenuChk_found[k].value;
				}
			}
		}
		
		if(j < 11){
			$.ajax({
				type: "POST",
				url: "/inc/s_myMenuAjax_found.php?mode=1",
				data: "qlinkc="+dataVal,
				success: function(msg){
					//alert(msg);
					$('.people_service_list').html(msg);
					$(".found_service_layer").hide();
				}
			});
		}else{
			alert("10개항목 이내로 선택해 주세요");
			return false;
		}
	});

	//나의 메뉴 설정
	$('.found_MymenuDefault').click(function () {
		j = 0;
		var dataVal = "";
		for(k = 0; k < document.MymenuFrm.MymenuChk_found.length; k++){
			switch (k){
				case	10	:
				case	11	:
				case	12	:
				case	13	:
				case	14	:
				case	15	:
				case	16	:
				case	17	:
				case	18	:
				case	19	:
					document.MymenuFrm.MymenuChk_found[k].checked = true;
					dataVal = dataVal+"|"+ document.MymenuFrm.MymenuChk_found[k].value;
				break;

				default :
					document.MymenuFrm.MymenuChk_found[k].checked = false;
				break;
			}
		}

		$.ajax({
			type: "POST",
			url: "/inc/s_myMenuAjax_found.php?mode=1",
			data: "qlinkc="+dataVal,
			success: function(msg){
				//alert(msg);
				$('.people_service_list').html(msg);
				$(".found_service_layer").hide();
			}
		});
	});

	$('.upbutton').click(function(){ //레이이 위치 변경

		var i = 0;
		var arr = [];
		var CookieArr = [];
		var Postion = null; //변수 초기화
		var offset = $(this).parent().parent().offset(); //클릭된 DIV 의 포지션 값을 구한다


		$('.moving').each(function(index, value){ //이동대상이 되는 DIV 전체를 배열 돌면서 각각의 포지션 값 및 Class명을 구한다
			var Toffset = $(this).offset();
			var ClassNm = $(this).attr("class").replace('moving ','');
			arr[i] = [Toffset.top, ClassNm];
			i++;
		});

		arr.sort(); //배열을 포지션 순으로 정렬 한다

		for (var i=0; i< arr.length ; i++){ //다시한번 순서대로 배열을 돌리면서 클릭된 DIV의 현제 위치를 정한다
			if (offset.top == arr[i][0]) Postion = i;
			//alert(arr[i][1]);
			switch (arr[i][1]){
				case "board" : CookieArr[i] = "s_MainBoard";		break;
				case "photo" : CookieArr[i] = "s_MainPhotoNews";	break;
				case "media" : CookieArr[i] = "s_MainOfficer";		break;
			}
		}

		switch(Postion){ //클릭된 DIV의 위치가 젤 윗쪽이면 작동안하고 2번째 3번째 일경우 서로 위치를 변경하도록 한다
			case 0 :
				Gap = arr[2][0] - arr[0][0];
				$("."+arr[0][1]).animate({"top": "+="+Gap+"px"}, "nomal");
				$("."+arr[2][1]).animate({"top": "-="+Gap+"px"}, "nomal");
			break;
			case 1 :
				Gap = arr[1][0] - arr[0][0];
				$("."+arr[0][1]).animate({"top": "+="+Gap+"px"}, "nomal");
				$("."+arr[1][1]).animate({"top": "-="+Gap+"px"}, "nomal");
			break;
			case 2 :
				Gap = arr[2][0] - arr[1][0];
				$("."+arr[1][1]).animate({"top": "+="+Gap+"px"}, "nomal");
				$("."+arr[2][1]).animate({"top": "-="+Gap+"px"}, "nomal");
			break;
		}
		setCookie("DivOrder",CookieArr,365);
	});

	//$('#BoardGosi').html('<iframe src="http://eminwon.suseong.kr/emwp/jsp/ofr/OfrNotAncmtLMiniSub.jsp?not_ancmt_se_code=01,04" frameborder="0" scrolling="no" title="고시공고" style="padding:0 0 0 14px; width:400px; height:120px;">').hide();

	//$('#BoardImp').html('<iframe src="http://eminwon.suseong.kr/emwp/jsp/ofr/OfrNotAncmtLMiniSub.jsp?not_ancmt_se_code=02" frameborder="0" scrolling="no" title="입찰정보" style="padding:0 0 0 14px; width:400px; height:120px;">').hide();

	//$('#BoardLaw').html('<iframe src="http://eminwon.suseong.kr/emwp/jsp/ofr/OfrNotAncmtLMiniSub.jsp?not_ancmt_se_code=03" frameborder="0" scrolling="no" title="입법예고" style="padding:0 0 0 14px; width:400px; height:120px;">').hide();
	/*$('#open_office_new2').click(function(){
		window.open('http://www.suseong.kr/test/director_index02.htm');
		return false;
	});*/
});

