
$j(function(){
  var bodyCl = $j('body').attr('class');
  var bodyID = $j('body').attr('id');
  var isMSIE = /*@cc_on!@*/false;

 /*--------------------------------
  header navi active
 -------------------------------*/
  if($j('body').is(':has("ul#h-nav")')){
    $j('ul#h-nav li.hnav').each(function(){
      var activeNv = $j(this).attr('id').split('-')[1];
      if(bodyID == activeNv){
        $j(this).find('a').css('background','url("/images/common/hnav_bgr.jpg") top right no-repeat');
        if(bodyID == 'genre'){
          $j(this).find('ul').find('li').find('a').css('background','#ff6b00');
          $j(this).find('ul').find('li').find('a').hover(
            function(){
              $j(this).css('background','url("/images/common/hnav_sicon.gif") center right no-repeat #ffdc72');
            },
            function(){
              $j(this).css('background','#ff6b00');
            }
          );
          $j(this).find('ul').find('li').find('ul').find('li').find('a').css('background','#ffdc72');
          $j(this).find('ul').find('li').find('ul').find('li').find('a').hover(
            function(){
              $j(this).css('background','#ffdc72');
            },
            function(){
              $j(this).css('background','#ffdc72');
            }
          );
        }
      }
    });
  }

/*--------------------------------
  header navigation pulldown
 -------------------------------*/

  $j('div#header ul li#hnav-genre').hover(
    function(){
      $j('li#hnav-genre ul').show();
      $j('li#hnav-genre ul ul').hide();
    },function(){
      $j('li#hnav-genre ul').hide();
    }
  );
  
  $j('div#header ul li#hnav-genre ul li').hover(
    function(){
      if(isMSIE){
        $j(this).find('ul').css('margin-top','-' + $j(this).attr('offsetHeight') + 'px');
      }else{
        $j(this).find('ul').css('margin-top','-' + $j(this).css('height'));
      }
      $j(this).find('ul').show();

    },function(){
      $j(this).find('ul').hide();
    }
  );

/*--------------------------------
  hover bg color
 -------------------------------*/
  $j('ul.colorBg li').hover(
    function(){
      var clName = $j(this).attr('class');
      if(clName == 'return'){
        $j(this).css('background','#f7e4de');
      }else if(clName == 'cond_return'){
        $j(this).css('background','#ffcccc');
      }else if(clName == 'info'){
        $j(this).css('background','#e1ecfe');
      }else if(clName == 'cond_info'){
        $j(this).css('background','#add8e6');
      }else if(clName == 'check'){
        $j(this).css('background','#ffffc7');
      }else if(clName == 'cond_check'){
        $j(this).css('background','#ffff99');
      }else if(clName == 'apology'){
        $j(this).css('background','#CCFF99');
      }else if(clName == 'cond_apology'){
        $j(this).css('background','#ccff66');
      }else if(clName == 'overseas'){
        $j(this).css('background','#fff8dc');
      }else if(clName == 'cond_overseas'){
        $j(this).css('background','#deb887');
      }else{
        $j(this).css('background','#ededed');
      }
    },
    function(){
      var clName = $j(this).attr('class');
      if(clName == 'return'){
        $j(this).css('background','#ffffff');
      }else if(clName == 'cond_return'){
        $j(this).css('background','#f7e4de');
      }else if(clName == 'info'){
        $j(this).css('background','#ffffff');
      }else if(clName == 'cond_info'){
        $j(this).css('background','#e1ecfe');
      }else if(clName == 'check'){
        $j(this).css('background','#ffffff');
      }else if(clName == 'cond_check'){
        $j(this).css('background','#ffffc7');
      }else if(clName == 'apology'){
        $j(this).css('background','#ffffff');
      }else if(clName == 'cond_apology'){
        $j(this).css('background','#CCFF99');
      }else if(clName == 'overseas'){
        $j(this).css('background','#ffffff');
      }else if(clName == 'cond_overseas'){
        $j(this).css('background','#fff8dc');
      }else{
        $j(this).css('background','');
      }
    }
  );

  $j('table.colorBg tr').hover(
    function(){
      var clName = $j(this).attr('class');
      if(clName == 'return'){
        $j(this).css('background','#f7e4de');
      }else if(clName == 'info'){
        $j(this).css('background','#e1ecfe');
      }else if(clName == 'check'){
        $j(this).css('background','#ffffc7');
      }else if(clName == 'apology'){
        $j(this).css('background','#CCFF99');
      }else if(clName == 'overseas'){
        $j(this).css('background','#fff8dc');
      }else{
        $j(this).css('background','#ededed');
      }
    },
    function(){
      $j(this).css('background','#fff');
    }
  );
  
/*------------------------
  topic path
------------------------*/
  if($j('ul#topic-path')){
    $j('ul#topic-path li a').after('<span>&nbsp;&gt;&nbsp;</span>');
  }
  
/*------------------------
  swapImg
------------------------*/
  swapImgs = $j('.swapImg');
  swapObj = new Image();
  swapImgs.each(function(){
    
    //ImgPreLoad
    preLoad = $j(this).attr('src').replace(/_n/i,'_r');
    imgNm = $j(this).attr('name',preLoad);
    
    //MouseOver
    $j(this).hover(
      function(){
        $j(this).attr('lowsrc',$j(this).attr('src'));
        $j(this).attr('src',$j(this).attr('name'));
      },
      function(){
        $j(this).attr('src',$j(this).attr('lowsrc'));
      }
    );
  });

});

/*------------------------
  target="_blank"
------------------------*/
jQuery.fn.extend({
  tBlank:  $j(document).ready(function(){
    return $j('a._blank').click(function(){
      this.target = '_blank';
    });
  })
});

 $j(document).ready(
    function(){
      $j('#headPR').innerfade({
        animationtype: 'fade',
        speed: 800,
        timeout: 4000,
        type: 'random',
        containerheight: '1em'
      });
  });

