﻿
jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	
	return this;
};


//sleep함수
function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

//_jaso
function _jaso()
{		
	document.getElementById("hdJaso").value = hangulToJaso(document.getElementById("txtKeyword").value).join("");
	return false;
}


var tabInterval = 250;

//토목뉴스(이미지형)
var objTimer;

//토목행사
var objEventTimer;


$(document).ready(function() {
    

    $('#btnSearch').click(function() {     
        /*  
        if (!$(this).val()) {
            alert('검색어를 입력하십시오.');
            $('#txtKeyword').focus();
            return (false);
        }
        */

        $('#hdJaso').val(hangulToJaso($('#txtKeyword').val()).join(""));

    });


    //인기검색어 뒷쪽 | 빼기
    $("#ingi dd:last").addClass('b_x');
    
    //시방서 및 설계기준
    var slideTime = 250;

    $('#s_stand').click(function() {
        
        if($('#div_kict1').is(':hidden'))
            $('#div_kict1').slideDown(slideTime);
        else
            $('#div_kict1').hide();
    });

    $('#s_prof').click(function() {
        
        if($('#div_kict2').is(':hidden'))
            $('#div_kict2').slideDown(slideTime);
        else
            $('#div_kict2').hide();
    });

    $('#s_design').click(function() {
        
        if($('#div_kict3').is(':hidden'))
            $('#div_kict3').slideDown(slideTime);
        else
            $('#div_kict3').hide();
    });


    var closingKictInfomation = function(item){        
        if(item == null)
        {
             if(!$('#div_kict1').is(':hidden'))
                $('#div_kict1').hide();

            if(!$('#div_kict2').is(':hidden'))
                $('#div_kict2').hide();

            if(!$('#div_kict3').is(':hidden'))
                $('#div_kict3').hide();
        }
    };


    //바로바로 클릭
    $('#s_barobaro').click(function() {
        if($('#div_baro1').is(':hidden'))
        {
            $('#s_baro1').attr("src", "images/main_barobaro1_on.gif");
            $('#s_baro2').attr("src", "images/main_barobaro2.gif");
            $('#s_baro3').attr("src", "images/main_barobaro3.gif");
            $('#s_baro4').attr("src", "images/main_barobaro4.gif");

            $('#div_baro1').show();
            $('#div_baro_site1').show();                       
        }
        else
        {
            $('#div_baro1').hide();     
        }    
    });

    $('#content').mouseover(function() {
        if(!$('#div_baro1').is(':hidden'))
        {
            $('#s_baro1').attr("src", "images/main_barobaro1.gif");
            $('#s_baro2').attr("src", "images/main_barobaro2.gif");
            $('#s_baro3').attr("src", "images/main_barobaro3.gif");
            $('#s_baro4').attr("src", "images/main_barobaro4.gif");

            $('#div_baro1').hide();                  
            $('#div_baro_site1').hide();
            $('#div_baro_site2').hide();
            $('#div_baro_site3').hide();
            $('#div_baro_site4').hide();
        }
    });


    $('#s_baro1').mouseover(function() {

        $('#s_baro1').attr("src", "images/main_barobaro1_on.gif");
        $('#s_baro2').attr("src", "images/main_barobaro2.gif");
        $('#s_baro3').attr("src", "images/main_barobaro3.gif");
        $('#s_baro4').attr("src", "images/main_barobaro4.gif");

        $('#div_baro_site1').show();
        $('#div_baro_site2').hide();        
        $('#div_baro_site3').hide();        
        $('#div_baro_site4').hide();        
    }); 

    $('#s_baro2').mouseover(function() {

        $('#s_baro1').attr("src", "images/main_barobaro1.gif");
        $('#s_baro2').attr("src", "images/main_barobaro2_on.gif");
        $('#s_baro3').attr("src", "images/main_barobaro3.gif");
        $('#s_baro4').attr("src", "images/main_barobaro4.gif");

        $('#div_baro_site2').show();  
        $('#div_baro_site1').hide();      
        $('#div_baro_site3').hide();        
        $('#div_baro_site4').hide();          
    }); 

    $('#s_baro3').mouseover(function() {

        $('#s_baro1').attr("src", "images/main_barobaro1.gif");
        $('#s_baro2').attr("src", "images/main_barobaro2.gif");
        $('#s_baro3').attr("src", "images/main_barobaro3_on.gif");
        $('#s_baro4').attr("src", "images/main_barobaro4.gif");

        $('#div_baro_site3').show(); 
        $('#div_baro_site1').hide();
        $('#div_baro_site2').hide();               
        $('#div_baro_site4').hide();          
    }); 

    $('#s_baro4').mouseover(function() {

        $('#s_baro1').attr("src", "images/main_barobaro1.gif");
        $('#s_baro2').attr("src", "images/main_barobaro2.gif");
        $('#s_baro3').attr("src", "images/main_barobaro3.gif");
        $('#s_baro4').attr("src", "images/main_barobaro4_on.gif");

        $('#div_baro_site4').show();    
        $('#div_baro_site1').hide();
        $('#div_baro_site2').hide();        
        $('#div_baro_site3').hide();               
    }); 



    //VOD navi 초기값 설정
    var vod_nav_init = location.hash;
    if (vod_nav_init == "" || vod_nav_init == "#") {
        $('#imgSeminarIndi1').attr("src", "images/main_vod_on.gif");
    }
    else {
        vod_nav_init = String(vod_nav_init);
        vod_nav_init = parseInt(vod_nav_init.substring(vod_nav_init.length, vod_nav_init.length - 1));

        VodImgSet(vod_nav_init);    
    }

    //VOD nav 위로 클릭
    $('#vod_nav_up').click(function() {

        var str = $('#vod_nav_up').attr('href');
        str = String(str);
        str = parseInt(str.substring(str.length, str.length - 1));

        str--;

        if (str < 1)
            str = 1;

        $('#vod_nav_up').attr('href', '#vod_section' + str);
        $('#vod_nav_down').attr('href', '#vod_section' + str);

        VodImgSet(str);

    });


    //VOD nav 아래로 클릭
    $('#vod_nav_down').click(function() {

        var str = $('#vod_nav_down').attr('href');
        str = String(str);
        str = parseInt(str.substring(str.length, str.length - 1));

        str++;

        if (str > 3)
            str = 3;

        $('#vod_nav_down').attr('href', '#vod_section' + str);
        $('#vod_nav_up').attr('href', '#vod_section' + str);

        VodImgSet(str);

    });

    //온라인 VOD 직접클릭1
    $('#vod_navi_section1').click(function() {

        $('#vod_navi_section1').attr('href', '#vod_section1');
        $('#vod_navi_section2').attr('href', '#vod_section2');
        $('#vod_navi_section3').attr('href', '#vod_section3');

        $('#vod_nav_down').attr('href', '#vod_section1');
        $('#vod_nav_up').attr('href', '#vod_section1');


        VodImgSet(1);
    });

    //온라인 VOD 직접클릭2
    $('#vod_navi_section2').click(function() {

        $('#vod_navi_section1').attr('href', '#vod_section1');
        $('#vod_navi_section2').attr('href', '#vod_section2');
        $('#vod_navi_section3').attr('href', '#vod_section3');

        $('#vod_nav_down').attr('href', '#vod_section2');
        $('#vod_nav_up').attr('href', '#vod_section2');

        VodImgSet(2);
    });

    //온라인 VOD 직접클릭3
    $('#vod_navi_section3').click(function() {

        $('#vod_navi_section1').attr('href', '#vod_section1');
        $('#vod_navi_section2').attr('href', '#vod_section2');
        $('#vod_navi_section3').attr('href', '#vod_section3');

        $('#vod_nav_down').attr('href', '#vod_section3');
        $('#vod_nav_up').attr('href', '#vod_section3');

        VodImgSet(3);
    });



    function VodImgSet(numb)
    {
        switch(numb)
        {
            case 1 :
                $('#imgSeminarIndi1').attr("src", "images/main_vod_on.gif");
                $('#imgSeminarIndi2').attr("src", "images/main_vod_off.gif");
                $('#imgSeminarIndi3').attr("src", "images/main_vod_off.gif");
                break;
            case 2 : 
                $('#imgSeminarIndi1').attr("src", "images/main_vod_off.gif");
                $('#imgSeminarIndi2').attr("src", "images/main_vod_on.gif");
                $('#imgSeminarIndi3').attr("src", "images/main_vod_off.gif");
                break;
            case 3 :
                $('#imgSeminarIndi1').attr("src", "images/main_vod_off.gif");
                $('#imgSeminarIndi2').attr("src", "images/main_vod_off.gif");
                $('#imgSeminarIndi3').attr("src", "images/main_vod_on.gif");
                break;
            default : break;       
        } 
    }


    //즐겨찾기 추가
    $('#addBookMark').click(function() {

        var url = "http://www.ceric.net";
        var title = "[CERIC]토목연구정보센터에 오신것을 환영합니다";
        window.external.AddFavorite(url, title);

    });

    //아이디, 패스워드 초기화
    if (!$('#txtMemID').val())
        $('#txtMemID').addClass('id_load_loginbox');

    $('#txtPasswd').addClass('pw_load_loginbox');


    //아이디, 패스워드 백그라운드 이미지 클리어
    $('.loginbox').click(function() {
        $('#txtMemID').addClass('clear_loginbox');
        $('#txtPasswd').addClass('clear_loginbox');
    });



    //포토뉴스 초기화
    objTimer = setTimeout('photo_news_rotation("1", true);', 100);

    $('#left_photonews1').mouseover(function() {
        clearTimeout(objTimer);
        return;
    });

    $('#left_photonews1').mouseout(function() {
        objTimer = setTimeout("photo_news_rotation(parseInt($('#spn_indicator').html()), true);", 100);
    });


    //토목행사 초기화
    objEventTimer = setTimeout("slideSwitch('next', 'auto');", 5100);





    //오픈갤러리 이미지 넘버링 초기화 
    $('#imgOpnNum1').attr('src', 'images/main_gallery_num1_on.gif');


    //헤드라인 뉴스
    var rowIndex = 0;
    $('#ul_news li').each(function(index) {
        if (rowIndex == 0) {
            $(this).addClass('headline');
        }
        rowIndex++;
    });

    var NewsTabTimeId;

    //뉴스탭1
    $('#news_tab1').mouseover(function() {

        NewsTabTimeId = setTimeout('f_news1()', tabInterval);

    });

    $('#news_tab1').mouseout(function() {

        if (NewsTabTimeId) {
            clearTimeout(NewsTabTimeId);
        }
    });


    //뉴스탭2
    $('#news_tab2').mouseover(function() {

        NewsTabTimeId = setTimeout('f_news2()', tabInterval);

    });

    $('#news_tab2').mouseout(function() {

        if (NewsTabTimeId) {
            clearTimeout(NewsTabTimeId);
        }
    });


    var KinTabTimeId;

    //지식인 전체
    $('#kin_all').mouseover(function() {
        KinTabTimeId = setTimeout('f_kinall()', tabInterval);
    });

    $('#kin_all').mouseout(function() {
        if (KinTabTimeId) {
            clearTimeout(KinTabTimeId);
        }
    });

    //지식인 질문
    $('#kin_question').mouseover(function() {
        KinTabTimeId = setTimeout('f_kinquestion()', tabInterval);
    });

    $('#kin_question').mouseout(function() {
        if (KinTabTimeId) {
            clearTimeout(KinTabTimeId);
        }
    });

    //지식인 답변
    $('#kin_answer').mouseover(function() {
        KinTabTimeId = setTimeout('f_kinanswer()', tabInterval);
    });

    $('#kin_answer').mouseout(function() {
        if (KinTabTimeId) {
            clearTimeout(KinTabTimeId);
        }
    });


    var ReTabTimeId;

    //연구자모집정보
    $('#imgResearcher').mouseover(function() {
        ReTabTimeId = setTimeout('f_researcher()', tabInterval);
    });

    $('#imgResearcher').mouseout(function() {
        if (ReTabTimeId) {
            clearTimeout(ReTabTimeId);
        }
    });


    //연구지원정보
    $('#imgResearchSupport').mouseover(function() {
        ReTabTimeId = setTimeout('f_resupport()', tabInterval);
    });

    $('#imgResearchSupport').mouseout(function() {
        if (ReTabTimeId) {
            clearTimeout(ReTabTimeId);
        }
    });

    //세릭 인사이드 탭1 클릭
    $('#imgCericInsideTab1').click(function() {
        $('#left_inside_content').load('../contents_update/InsCericInsideTab1.html', function() {
            $('#imgCericInsideTab1').attr("src", "images/left_cericinside_tab_01_on.gif");
            $('#imgCericInsideTab2').attr("src", "images/left_cericinside_tab_02.gif");
        });

    });

    //세릭 인사이드 탭2 클릭
    $('#imgCericInsideTab2').click(function() {
        $('#left_inside_content').load('../contents_update/InsCericInsideTab2.html', function() {
            $('#imgCericInsideTab1').attr("src", "images/left_cericinside_tab_01.gif");
            $('#imgCericInsideTab2').attr("src", "images/left_cericinside_tab_02_on.gif");
        });
    });


    $('#prev_inside_tab, #next_inside_tab').click(function() {
        //현재 인사이드 탭이 tab1이면..
        if($('#imgCericInsideTab1').attr("src") == "images/left_cericinside_tab_01_on.gif")
        {
            $('#left_inside_content').load('../contents_update/InsCericInsideTab2.html', function() {
                $('#imgCericInsideTab1').attr("src", "images/left_cericinside_tab_01.gif");
                $('#imgCericInsideTab2').attr("src", "images/left_cericinside_tab_02_on.gif");
            });            
        }
        else
        {
            $('#left_inside_content').load('../contents_update/InsCericInsideTab1.html', function() {
                $('#imgCericInsideTab1').attr("src", "images/left_cericinside_tab_01_on.gif");
                $('#imgCericInsideTab2').attr("src", "images/left_cericinside_tab_02.gif");
            });
        }
    });



    /* 자동완성기능 */

    var selectedItem = null;

    var setSelectedItem = function(item) {

        selectedItem = item;
        if (selectedItem == null) {
            $autocomplete.hide();
            return;
        }

        if (selectedItem < 0) {
            selectedItem = 0;
        }

        if (selectedItem >= $autocomplete.find('li').length) {
            selectedItem = $autocomplete.find('li').length - 1;
        }

        $autocomplete.find('li').removeClass('ac_selected').eq(selectedItem).addClass('ac_selected');
        $autocomplete.show();

    };

    //autocomplete initialize   
    var $autocomplete = $('<ul class="ac_box"></ul>').hide().insertAfter('#txtKeyword');

    //현재 자동완성기능을 사용하고 있으면, down 이미지를 보여준다.
    if ($.cookie('suggest') != 'Off') {
        $('#img_suggest').attr("src", "images/header_btn_search_exa.gif");
    }
    else {
        $('#img_suggest').attr("src", "images/header_btn_search_exa_up.gif");
    }




    //txtKeyword keyup
    $('#txtKeyword').attr('autocomplete', 'off').keyup(function(event) {


        //기능이 켜있으면 자동완성기능을 사용한다.
        if ($.cookie('suggest') != 'Off') {

            //40이하는 특수키 (엔터, 방향키, ESC등)
            //8은 백스페이스키
            //16은 시프트키
            //32는 스페이스
            if (event.keyCode > 40 || event.keyCode == 8 || event.keyCode == 16 || event.keyCode == 32) {

                //txtKeyword에 값이 있으면..
                if ($('#txtKeyword').val()) {
                    autocomplete_callback();
                }
                else {
                    setSelectedItem(null);
                }
            }
            else if ((event.keyCode == 38 || event.keyCode == 33) && selectedItem != null) {
                //위쪽 방향키 또는 페이지업키를 눌렀을때..
                setSelectedItem(selectedItem - 1);
                $('#txtKeyword').val($autocomplete.find('li').eq(selectedItem).text());

            }
            else if (event.keyCode == 40 || event.keyCode == 34) {

                //아랫쪽 방향키 또는 페이지다운키를 눌렀을때..  
                if (selectedItem != null) {
                    setSelectedItem(selectedItem + 1);
                    $('#txtKeyword').val($autocomplete.find('li').eq(selectedItem).text());
                    $('#hdJaso').val(hangulToJaso($autocomplete.find('li').eq(selectedItem).text()).join(""));
                }
                else {
                    if ($('#txtKeyword').val() != "") {
                        setSelectedItem(0);
                        $('#txtKeyword').val($autocomplete.find('li').eq(selectedItem).text());
                        $('#hdJaso').val(hangulToJaso($autocomplete.find('li').eq(selectedItem).text()).join(""));
                    }
                }
            }
            else if (event.keyCode == 27) {
                // ESC를 눌렀을때..
                $('#txtKeyword').val('');
                setSelectedItem(null);
            }
            else if (event.keyCode == 18 || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39) {
                //ALT 또는 TAB키 <-  -> 키를 눌렀을때.. 그대로 유지한다.
            }
            else // 그외..
            {
                setSelectedItem(null);
            }

        } //Cookies

     
        //keyup    

    }).click(function() {

        //기능이 켜있으면 자동완성기능을 사용한다.
        if ($.cookie('suggest') != 'Off') {
            //#txtKeyword를 클릭했을때... 공백이 아니면..
            if ($('#txtKeyword').val() != '') {
                if ($autocomplete.is(":hidden")) {
                    autocomplete_callback();
                }
                else {
                    setSelectedItem(null);
                }
            }
        }

    }); //click



    function autocomplete_callback() {

        var txtJaso = hangulToJaso($('#txtKeyword').val()).join("");
        $('#hdJaso').val(txtJaso);

        $.ajax({
            url: '/ajax_autocomplete.aspx',
            data: { 'txtKeyword': $('#txtKeyword').val(), 'txtJaso': txtJaso },
            dataType: 'text',
            type: 'POST',
            success: function(data) {

                $autocomplete.empty();

                //검색된 데이터가 있으면...
                if (data.length > 2) {
                    data = eval("(" + data + ")");

                    $.each(data, function(index, term) {

                        var o_term = term;
                        term = term.replace($('#txtKeyword').val(), "<font color=#FF6600><strong>" + $('#txtKeyword').val() + "</strong></font>");

                        $('<li></li>').html(term).appendTo($autocomplete).mouseover(function() {
                            setSelectedItem(index);

                        }).click(function() {

                            //li 클릭시 txtKeyword, hdJaso에 값을 넣고 창을 닫는다.
                            $('#txtKeyword').val(o_term);
                            $('#hdJaso').val(hangulToJaso(o_term).join(""));
                            setSelectedItem(null);

                        });

                    }); //$.each


                    //기능끄기
                    var $setSuggestOff = $('<a>[기능끄기]</a>').click(function() {

                        setSelectedItem(null);
                        $('#img_suggest').attr("src", "images/header_btn_search_exa_up.gif");
                        $.cookie('suggest', 'Off');

                    });

                    //footer 달기
                    $('<div class="ac_footer"></div>').append($setSuggestOff).appendTo($autocomplete);


                    //검색이 되면.. index값을 null로 초기화한다.
                    setSelectedItem(null);

                    $autocomplete.show();

                }
                else {
                    //검색된 데이터가 없으면.. 
                    setSelectedItem(null);
                }
            }

        }); //.ajax    


    } //autocomplete_callback()


    /*
    //txtKeyword에 포커싱을 잃으면 창을 숨긴다.
    $('#txtKeyword').blur(function(event){
    setTimeout(function(){
    setSelectedItem(null);
    }, 250);  
    });
    */

    $('body').click(function() {
        setSelectedItem(null);   
        closingKictInfomation(null);        
    });


    //자동완성기능 켜기/끄기
    $('#img_suggest').click(function() {

        if ($(this).attr("src") == "images/header_btn_search_exa_up.gif") {
            $(this).attr("src", "images/header_btn_search_exa.gif");

            //#txtKeyword를 클릭했을때... 공백이 아니면..
            if ($('#txtKeyword').val() != '') {
                setSelectedItem(null);
                autocomplete_callback();
            }

            $.cookie('suggest', 'On');

        }
        else {
            setSelectedItem(null);
            $('#img_suggest').attr("src", "images/header_btn_search_exa_up.gif");
            $.cookie('suggest', 'Off');

        }

    });



});              
//document ready ~~



//js 버젼 한글을 자소로 분리하는 함수.. 
//복모음과 복자음도 분리가 가능하도록 개선 2009/08 (ikchoi@ceric.net)
var hangulToJaso = function (text)
{

    //초성(19자) ㄱ ㄲ ㄴ ㄷ ㄸ ㄹ ㅁ ㅂ ㅃ ㅅ ㅆ ㅇ ㅈ ㅉ ㅊ ㅋ ㅌ ㅍ ㅎ
    var ChoSeong = new Array (	0x3131, 0x3132, 0x3134, 0x3137, 0x3138,
														    0x3139, 0x3141, 0x3142, 0x3143, 0x3145, 0x3146, 0x3147, 0x3148,
														    0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e );

    //중성(21자) ㅏ ㅐ ㅑ ㅒ ㅓ ㅔ ㅕ ㅖ ㅗ ㅘ(9) ㅙ(10) ㅚ(11) ㅛ ㅜ ㅝ(14) ㅞ(15) ㅟ(16) ㅠ ㅡ ㅢ(19) ㅣ
    var JungSeong = new Array (	0x314f, 0x3150, 0x3151, 0x3152, 0x3153,
														    0x3154, 0x3155, 0x3156, 0x3157, 0x3158, 0x3159, 0x315a, 0x315b,
														    0x315c, 0x315d, 0x315e, 0x315f, 0x3160, 0x3161, 0x3162, 0x3163 );

    //종성(28자) <없음> ㄱ ㄲ ㄳ(3) ㄴ ㄵ(5) ㄶ(6) ㄷ ㄹ ㄺ(9) ㄻ(10) ㄼ(11) ㄽ(12) ㄾ(13) ㄿ(14) ㅀ(15) ㅁ ㅂ ㅄ(18) ㅅ ㅆ ㅇ ㅈ ㅊ ㅋ ㅌ ㅍ ㅎ
    var JongSeong = new Array (	0x0000, 0x3131, 0x3132, 0x3133, 0x3134,
														    0x3135, 0x3136, 0x3137, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d,
														    0x313e, 0x313f, 0x3140, 0x3141, 0x3142, 0x3144, 0x3145, 0x3146,
														    0x3147, 0x3148, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e );
    var chars = new Array()
    var v = new Array();
    for (var i = 0; i < text.length; i++) 
    {
	    chars[i] = text.charCodeAt(i);
	    //// "AC00:가" ~ "D7A3:힣" 에 속한 글자면 분해		
	    if (chars[i] >= 0xAC00 && chars[i] <= 0xD7A3) 
	    {
		    var i1, i2, i3;
			
		    i3 = chars[i] - 0xAC00;
		    i1 = i3 / (21 * 28);			
		    i3 = i3 % (21 * 28);		
			
		    i2 = i3 / 28;
		    i3 = i3 % 28;			
			
		    v.push(String.fromCharCode(ChoSeong[parseInt(i1)]));

	        //복모음 분리
	        switch(parseInt(i2))
	        {
	            case 9 : v.push('ㅗㅏ'); break;
		        case 10 : v.push('ㅗㅐ'); break; 
	            case 11 : v.push('ㅗㅣ'); break;
	            case 14 : v.push('ㅜㅓ'); break;
	            case 15 : v.push('ㅜㅔ'); break;
	            case 16 : v.push('ㅜㅣ'); break;
	            case 19 : v.push('ㅡㅣ'); break;		       
		        
	            default : v.push(String.fromCharCode(JungSeong[parseInt(i2)]));
	        }			
		    //v.push(String.fromCharCode(JungSeong[parseInt(i2)]));
			
			
			
		    if (i3 != 0x0000) // c가 0이 아니면, 즉 받침이 있으면
		    {						
		        //복자음 분리
		        switch(parseInt(i3))
		        {
		            case 3 : v.push('ㄱㅅ'); break;
			        case 5 : v.push('ㄴㅈ'); break; 
		            case 6 : v.push('ㄴㅎ'); break;
		            case 9 : v.push('ㄹㄱ'); break;
		            case 10 : v.push('ㄹㅁ'); break;
		            case 11 : v.push('ㄹㅂ'); break;
		            case 12 : v.push('ㄹㅅ'); break;
		            case 13 : v.push('ㄹㅌ'); break;
		            case 14 : v.push('ㄹㅍ'); break;
		            case 15 : v.push('ㄹㅎ'); break;
		            case 18 : v.push('ㅂㅅ'); break;
			        
		            default : v.push(String.fromCharCode(JongSeong[parseInt(i3)])); 
		        }
		    }
			
	    }
	    else {
		    v.push(String.fromCharCode(chars[i] ));
	    }
    }
	
    return v;
}


//포토뉴스 썸네일 마우스오버시..
function photo_thumb_over(indicator)
{
    switch(indicator)
    {
        case 1 :     
            $('#li_photo_thumb1 a').removeClass('roll').addClass('roll'); 
            $('#li_photo_thumb2 a').removeClass('roll');
            $('#li_photo_thumb3 a').removeClass('roll');     
            
            //$('#imgPhotoLarge').src = ImageArr1[0];
            document.getElementById('div_photo_large').innerHTML = ImageArr1[0];
            document.getElementById('div_photo_txt').innerHTML = ImageArr2[0];
            $('#spn_indicator').html("1");
                        
                   
            break;
            
        case 2 :
            $('#li_photo_thumb1 a').removeClass('roll');            
            $('#li_photo_thumb2 a').removeClass('roll').addClass('roll');
            $('#li_photo_thumb3 a').removeClass('roll');
            
            //$('#imgPhotoLarge').src = ImageArr1[1];
            document.getElementById('div_photo_large').innerHTML = ImageArr1[1];
            document.getElementById('div_photo_txt').innerHTML = ImageArr2[1];
            $('#spn_indicator').html("2");
            
            break;
            
        case 3 :
            $('#li_photo_thumb1 a').removeClass('roll');        
            $('#li_photo_thumb2 a').removeClass('roll');        
            $('#li_photo_thumb3 a').removeClass('roll').addClass('roll');
            
            //$('#imgPhotoLarge').src = ImageArr1[2];
            document.getElementById('div_photo_large').innerHTML = ImageArr1[2];
            document.getElementById('div_photo_txt').innerHTML = ImageArr2[2];
            $('#spn_indicator').html("3");                                    
            
            break;
        
        default : break;
        
    }      
        
}


//포토뉴스 썸네일 마우스아웃시..
function photo_thumb_out(indicator)
{
        
}

//포토뉴스 로테이션
function photo_news_rotation(indicator, playOption)
{           
    clearTimeout(objTimer);    
    
    //실행
    photo_thumb_over(indicator);

    indicator = parseInt($('#spn_indicator').html());
    
    indicator ++;
    
    if (indicator > 3)
        indicator = 1;    
    
    //재귀호출
    if(playOption == true)
    {         
        objTimer = setTimeout('photo_news_rotation(' + indicator + ', true);', 5000);    
    }
    
}

//갤러리 1,2,3 클릭
function opengallery_view(seq, num)
{
    $('#div_opengallery').load('InsOpengallery.aspx?seq=' + seq, function() { 
    });
    
    for(var i=1; i <= 3; i++)
    {
        if(i == num)
            $('#imgOpnNum' + i).attr('src', 'images/main_gallery_num' + i + '_on.gif');
        else
            $('#imgOpnNum' + i).attr('src', 'images/main_gallery_num' + i + '.gif');
    }
}



//토목행사 이미지 슬라이드쇼
function slideSwitch(opt, evt) {
    
    var $active = $('#left_event .imglst a.active');
    if ( $active.length == 0 ) $active = $('#left_event .imglst a:last');    
        
    var $next;
        
    if(opt == "next")
    {
        $next =  $active.next().length ? $active.next() : $('#left_event .imglst a:first');        
    }
    else
    {
        $next =  $active.prev().length ? $active.prev() : $('#left_event .imglst a:last');    
    }
    

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 80, function() {
            $active.removeClass('active last-active');
        });

    if(evt == "auto")
    {    
        objEventTimer = setTimeout("slideSwitch('next','auto');", 5000);
    }

}


function f_news1()
{
    $('#ul_news').load('InsCivilNews.aspx?nType=synthetic', function() {        

        //헤드라인 뉴스
        var rowIndex = 0;
        $('#ul_news li').each(function(index){
            if(rowIndex == 0)
            {
                $(this).addClass('headline');            
            }
            rowIndex++;
        });      


        //document.getElementById('news_tab2').src = "images/main_news_tab_2.gif";
        document.getElementById('news_tab1').src = "images/main_news_tab_1_on.gif";        
          
    });

}

function f_news2()
{
    $('#ul_news').load('InsCivilNews.aspx?nType=ranking', function() {
        document.getElementById('news_tab1').src = "images/main_news_tab_1.gif";
        document.getElementById('news_tab2').src = "images/main_news_tab_2_on.gif";    
    });                	
}


function f_kinall()
{
    $('#kin_content').load('InsKin.aspx?nType=all', function() {
        $('#kin_all').attr("src", "images/main_kin_tab_01_on.gif");
        $('#kin_question').attr("src", "images/main_kin_tab_02.gif");
        $('#kin_answer').attr("src", "images/main_kin_tab_03.gif");
     
    });                 
}

function f_kinquestion()
{
    $('#kin_content').load('InsKin.aspx?nType=question', function() {
        $('#kin_all').attr("src", "images/main_kin_tab_01.gif");
        $('#kin_question').attr("src", "images/main_kin_tab_02_on.gif");
        $('#kin_answer').attr("src", "images/main_kin_tab_03.gif");
    });          	 
}

function f_kinanswer()
{
    $('#kin_content').load('InsKin.aspx?nType=answer', function() {
        $('#kin_all').attr("src", "images/main_kin_tab_01.gif");
        $('#kin_question').attr("src", "images/main_kin_tab_02.gif");
        $('#kin_answer').attr("src", "images/main_kin_tab_03_on.gif");    
    });                	   
}

//연구자 모집정보
function f_researcher()
{
    $('#research_content').load('InsResearch.aspx?nType=researcher', function() {
        $('#imgResearcher').attr("src", "images/main_research_tab01_on.gif");
        $('#imgResearchSupport').attr("src", "images/main_research_tab02.gif");      
    });         
}

//연구지원정보
function f_resupport()
{
    $('#research_content').load('InsResearch.aspx?nType=researchsupport', function() {
        $('#imgResearcher').attr("src", "images/main_research_tab01.gif");
        $('#imgResearchSupport').attr("src", "images/main_research_tab02_on.gif");       
    });     

}