﻿$(document).ready(function(){
    //$('.lv2').css('display','none');
    //$('.lv3').css('display','none');
    initMenu();
    
    
});

function initMenu()
{
    var aTags = $('#slidedown_menu A');
    var brATags = $('.breadcrumb A');
    var sLoop=1;
    for(var iLoop=0; iLoop<aTags.length; iLoop++)
    {

        if(location.href.indexOf(aTags[iLoop].href)>=0)
        {         
            $(aTags[iLoop].parentNode).children().eq(0).attr('className','subTitle');
            //aTags[iLoop].parentNode.children[0].className='subTitle';
            //if(aTags[iLoop].parentNode.children.length>1){
            if($(aTags[iLoop].parentNode).children().length>1){
                $(aTags[iLoop].parentNode).children().eq(1).addClass(' openMenu');
                $(aTags[iLoop].parentNode).children().eq(1).css('display','');
                //aTags[iLoop].parentNode.children[1].className+=' openMenu';
                //aTags[iLoop].parentNode.children[1].style.display='';
                
            }
            
        }else
        {
            for(var jLoop=sLoop; jLoop<brATags.length; jLoop++)
            {
                if(brATags[jLoop].href.indexOf(aTags[iLoop].href)>=0)
                {         
                   if(sLoop>1) $(aTags[iLoop].parentNode).children().eq(0).attr('className','subTitleParent');
                    //if(sLoop>1) aTags[iLoop].parentNode.children[0].className='subTitleParent';
                    if($(aTags[iLoop].parentNode).children().length>1){
                        $(aTags[iLoop].parentNode).children().eq(1).addClass(' openMenu');
                        $(aTags[iLoop].parentNode).children().eq(1).css('display','');
//                        aTags[iLoop].parentNode.children[1].className+=' openMenu';
//                        aTags[iLoop].parentNode.children[1].style.display='';
                    }
                    
                    
                    sLoop++;
                    break;

                }
            }
        }
    }
    
}



//현재 사용할 필요 없음
function getSelMenuByCookies()
{
    var selMenuList=getCookie('selMenu').split("|");
    alert(getCookie('selMenu'));
    for(var iLoop=0;iLoop<selMenuList.length;iLoop++)
    {
        
        $('#' + selMenuList[iLoop]).css('display','');
    }
}

function setCookieOfDivID(divID)
{
    var getCookieMenu=getCookie('selMenu');
    if(getCookieMenu.length==0)
    {
        setCookie('selMenu',divID);
    }else
    {
        if(getCookieMenu.indexOf(divID)<0){
            setCookie('selMenu',getCookieMenu + "|" + divID);
        }
    }
}
function setCookie(name, value)
{
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + 1 );
    document.cookie = name + '=' + escape( value ) + '; path=/; expires=' + todayDate.toGMTString() + ';'

}

function getCookie( 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 "";
}


