/* ------------------------------------------------------------ */
/*                                                              */
/*                         global param                         */
/*                                                              */
/* ------------------------------------------------------------ */

var _loc      = location.pathname;
var _pathName = _loc.substring(0,_loc.lastIndexOf('/')+1);
var _fileName = _loc.substring(_loc.lastIndexOf('/')+1);
var _path    = _loc.substring(0,_loc.lastIndexOf('/')+1);
var _lv1path = _path.split('/')[1];
var _lv2path = _path.split('/')[2];
var _lv3path = _path.split('/')[3];

var _swfAry   = new Array();

function _(p,q) {q=new Image;q.src=p;p=q.src;q.src='#';return p}
// var _absPath  = (_(document.getElementsByTagName('script')[0].src.split('_global')[0]));
var _absPath  = '/';





/* ------------------------------------------------------------ */
/*                                                              */
/*                       import libraries                       */
/*                                                              */
/* ------------------------------------------------------------ */
document.write('<script type="text/javascript" src="http://ad.president.co.jp/www/delivery/spcjs.php?id=1"></script>');
document.write('<script type="text/javascript" src="/_global/js/core/swfobject.js"></script>');
document.write('<script type="text/javascript" src="/_global/js/lib/jquery.innerfade2.js"></script>');
document.write('<script type="text/javascript" src="/_global/js/lib/jquery.imghover.js"></script>');
document.write('<script type="text/javascript" src="/_global/js/lib/iepngfix/iepngfix_tilebg.js"></script>');
document.write('<script type="text/javascript" src="/_global/js/lib/jquery.scrollTo.js"></script>');
document.write('<script type="text/javascript" src="/_global/js/lib/jcarousellite/jcarousellite.js"></script>');
document.write('<script type="text/javascript" src="/_global/js/lib/thickbox/thickbox.js"></script>');
document.write('<link rel="stylesheet" type="text/css" href="/_global/js/lib/thickbox/thickbox.css" media="screen" />');

var $j = jQuery.noConflict();





/* ------------------------------------------------------------ */
/*                                                              */
/*         legacy functions for backward compatibility          */
/*                                                              */
/* ------------------------------------------------------------ */

function popImage(image,features) {
  newWin = window.open("","popup","scrollbars=yes,resizable=yes,"+features);
  newWin.document.open();
  newWin.document.write("<html><head><title>Image</title></head><body><div align=center><a href='javascript:window.close();'><img src="+image+" border=0><br /><small>[閉じる]</small></a></div></body></html>\n");
  newWin.document.close();
}
function openImage(image,size) {
  iWin = window.open('','imageWin','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,width=770,height=550');
  iWin.document.open();
  iWin.document.write('<html><head><title>拡大画面</title></head><body style="margin:0 0 1em;padding:0px;" onload="focus();"><img src='+image+'><div style="text-align:center;font-size:smaller;">[ <a href="javascript:window.close();">このウインドウを閉じる</a> ]</div></body></html>\n');
  iWin.document.close();
}
function openWin(url) {
  var nWin;
  nWin=window.open(url);
  nWin.window.focus();
}
function openImageVL(image,pid) {
  iWin = window.open('','imageWin','toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,width=770,height=550');
  iWin.document.open();
  iWin.document.write('<html><head><title>拡大画面</title></head><body style="margin:0 0 1em;padding:0px;" onload="focus();"><img src='+image+'><div style="text-align:center;font-size:smaller;">[ <a href="javascript:window.close();">このウインドウを閉じる</a> ]</div><script type="text/javascript" src="https://www06.tracer.jp/VL/Trace?c=ch2101&p='+pid+'&tp=1"></script></body></html>\n');
  iWin.document.close();
}






/* ------------------------------------------------------------ */
/*                                                              */
/*                           IEPNGFix                           */
/*                                                              */
/* ------------------------------------------------------------ */

document.write('<style type="text/css">.transparent, #header_bar,#header ul.nav_category li a { behavior:url(/_global/js/lib/iepngfix/iepngfix.htc) }</style>');





/* ------------------------------------------------------------ */
/*                                                              */
/*                          initialize                          */
/*                                                              */
/* ------------------------------------------------------------ */

$j(function($){


  // tabs --------------------------------------------------------
  if($('#tabs').size()) $.fn.tabs('#tabs');

  // button : image -------------------------------------------
  $('div.button').addClass('centered');
  $('a.button').prepend('<span>&nbsp;</span>').wrap('<div class="button centered"></div>');
  $('a.button_s').prepend('<span>&nbsp;</span>').wrap('<div class="button_s centered"></div>');

  // shadow : image -------------------------------------------
  $('.jcarousel-skin li dt img').removeClass('shadow').addClass('border');
  $('.shadow').parent('a').wrap('<div class="shadowWrap"></div>').each(function(){
    $(this).parent('.shadowWrap').width($(this).width());
  });
  
  // anchor ------------------------------------------------------------
  $('a.more').append('<img src="/_global/css/img/arrow/arrow.png" width="12" height="12" alt="" />');

  // list -------------------------------------------
  $('.list li:last-child, dl.inline dt:first-child, dl.inline dd:first-child').addClass('last');
  $('#feature .list li').removeClass('last');
  $('.stripe li:even, table.stripe tr:even').addClass('even');
  $('.stripe li:odd, table.stripe tr:odd').addClass('odd');

  $('ol.list').each(function(){
    $(this).children('li').each(function(j){
      $(this).prepend('<span class="num">'+(j+1)+'</span>');
    });
  });
  $('ol.list li:even, ol.recommend li:even').addClass('even');
  $('ol.list li:odd, ol.recommend li:odd').addClass('odd');

  //  $('.module_body ul:last-child, .module_body ol:last-child, .module_body dl:last-child, .module_body li dl').css({'padding-bottom':'0px'});
  $('li.hasChild + li.hasChild').css({'margin-top':'-6px'});

  $('.article dl.left,.article dl.right').each(function(){
    $(this).width($(this).children('dt').children('img').width());
  });
  $('img[align="left"]').addClass('left');
  $('img[align="right"]').addClass('right');

  // _blank window -----------------------------------------------------
  $('a.blank, area.blank').click(function(){ window.open(this.href, '_blank'); return false; });
  $('a.blank').append('&nbsp;<img src="/_global/css/img/arrow/blank.png" width="12" height="12" alt="" />');

  // img hover -------------------------------------------
  $('.imghover').imghover();

  // map hilight -------------------------------------------
//  $('.map').maphilight();

  // slider ------------------------------------------------------------
  $('body#home #feature .style_list .module_body .pad ul.bannerlist').fadeIn('slow').doShuffle().doSlide().doSlide();

  // mod_synergy : jCarouselLite ------------------------------------------------------------
  // jCarouselLite:CSS setting -->> module.css 
  $('.carousel').parent().parent().parent().prev('.module_head').children('.pad_module').append('<div class="btn_next"></div><div class="btn_prev"></div>').find('h2').css({'text-align':'center'});

  $('#feature .style_list2').jCarouselLite({
    auto: 1000,
    speed: 1000,
    visible: 30
  });

  $('#feature .mod_itemlist .carousel').jCarouselLite({
    btnNext: '#feature .mod_itemlist .btn_next',
    btnPrev: '#feature .mod_itemlist .btn_prev',
    visible: 5
  });
  $('#feature .mod_carousel .carousel').jCarouselLite({
    btnNext: '#feature .mod_carousel .btn_next',
    btnPrev: '#feature .mod_carousel .btn_prev',
    auto: 5000,
    speed: 1000,
    visible: 4,
    start: Math.floor(Math.random()*$('#feature .mod_carousel .carousel ul li').size())
  });
  $('#feature .style_list .carousel').jCarouselLite({
    btnNext: '',
    btnPrev: '',
    auto: 3000,
    speed: 1000,
    visible: 5,
    start: Math.floor(Math.random()*$('#feature .style_list .carousel ul li').size())
  });
  $('.m2 #main .mod_itemlist .carousel').jCarouselLite({
    btnNext: '#main .mod_itemlist .btn_next',
    btnPrev: '#main .mod_itemlist .btn_prev',
    auto: 8000,
    speed: 1000,
    visible: 5,
    start: Math.floor(Math.random()*$('#main .mod_itemlist .carousel ul li').size())
  });
  $('.e-m-s #main .mod_itemlist .carousel').jCarouselLite({
    btnNext: '#main .mod_itemlist .btn_next',
    btnPrev: '#main .mod_itemlist .btn_prev',
    auto: 8000,
    speed: 1000,
    visible: 2
  });
  $('body#alba #main .mod_itemlist .carousel').jCarouselLite({
    btnNext: '#main .mod_itemlist .btn_next',
    btnPrev: '#main .mod_itemlist .btn_prev',
    auto: 8000,
    speed: 1000,
    visible: 3
  });
  $('#main .mod_carousel .carousel').jCarouselLite({
    btnNext: '#main .mod_carousel .btn_next',
    btnPrev: '#main .mod_carousel .btn_prev',
    auto: 5000,
    speed: 1000,
    visible: 2
  });
  $('#sub .carousel').jCarouselLite({
    vertical: true,
    btnNext: '#sub .mod_carousel .btn_next',
    btnPrev: '#sub .mod_carousel .btn_prev',
    auto: 5000,
    speed: 1000,
    visible: 2,
    start: Math.floor(Math.random()*$('#sub .carousel ul li').size())
  });

  // Search Text Label -------------------------------------------
  swapValues = [];
  $('.swap_value').each(function(i){
    swapValues[i] = $(this).val();
    $(this).focus(function(){
      if ($(this).val() == swapValues[i]) $(this).val("");
    }).blur(function(){
      if ($.trim($(this).val()) == "") $(this).val(swapValues[i]);
    });
  });
  /*
  */

  // png fix -----------------------------------------------------
  /*
  $.ifixpng('/_global/img/blank.gif'); 
  $('img[src$=.png]').ifixpng();
  */

  // current menu -------------------------------------------
  //  $('ul.nav_category li.' + _pathName.split('/')[1]+' a').addClass('current');

  // centered ------------------------------------------------------------
  $('.centered').each(function(j){
    var marginL = ($(this).parent().width() - $(this).width())/2;
    $(this).css({'margin-left':marginL+'px'});
  });

  // dl-column ------------------------------------------------------------
  $('dl.dt-left,dl.dt-right').each(function(j) {
    $(this).each(function() {
      var maxW = 0;
      $('dt',this).each(function(i) {
        maxW = ($(this).width() > maxW) ? $(this).width() : maxW;
      });
      maxW+=5;
      if($(this).attr('class').indexOf('dt-left')>-1) $('dd',this).css({'margin-left':maxW+'px'});
      if($(this).attr('class').indexOf('dt-right')>-1) $('dd',this).css({'margin-right':maxW+'px'});
    });
  });

  // news ticker ------------------------------------------------------------
  $('#headbar ol.ticker').innerfade({
    timeout: 5000
  }).children('li').each(function(j){
    $(this).prepend('[ '+(j+1)+ '/' +$('#headbar ol.ticker li').size()+ ' ] ');
  });
  $('#main .ticker').innerfade({
    timeout: 7000,
    type: 'random'
  }).children('li').css({'text-align':'center'});

  // append -------------------------------------------
  $('.active').next('.active').addClass('append');

  // multi-column -------------------------------------------
  $.fn.setColumn();

  // sidebar expand ------------------------------------------------------------
  /*
  $j('#headbar').toggle(
    function(){
      $j('#extra').hide('500',function(){
        $j('#container').addClass('m-s');
      });
    },
    function(){
      $j('#extra').show('500');
      $j('#container').removeClass('m-s');
    }
  );
  */

  // footer banner -------------------------------------------
  $('#feature .csc-textpic-imagewrap a[href="pre/information/bcp/"]').attr('target', '_blank');
  $('#footer .csc-textpic-imagewrap a[href="pre/information/bcp/"]').attr('target', '_blank');

});





/* ------------------------------------------------------------ */
/*                                                              */
/*                           tabs                               */
/*                                                              */
/* ------------------------------------------------------------ */
document.write('<style type="text/css">div.tabbodys { display:none; overflow:hidden; }</style>');
(function($){
  $.fn.extend({
    tabs: function(containerId) {
      var start = (location.search) ? parseInt(location.search.split('?')[1]) : 1;
      var ON_CLASS = 'on';
      var id = containerId;
      var i = (isNaN(start)) ? 0 : (start - 1);
      $(id + ' div.tabbody').css({'display':'none'});
      $(id + ' div.tabbody:eq(' + i + ')').css({'display':'block'});
      $(id + ' div.tabbodys').css({'display':'block'});
      var tabWidth = Math.floor($(id + '>ol.tabsnav').width() / $(id + '>ol.tabsnav>li').size());
      $(id + '>ol.tabsnav>li').each(function(){
        $(this).css({'width':tabWidth+'px','margin-left':'0px'});
      });
      var tabHeight = $(id + '>ol.tabsnav').height();
      $(id + '>ol.tabsnav>li').each(function(){
        $(this).height(tabHeight);
      });
      $(id + '>ol>li:nth-child(' + (i+1) + ')>a').addClass(ON_CLASS).children('img').each(function(){
        $(this).attr('src',$(this).attr('src').replace(/^(.+)(\.[a-z]+)$/,'$1_on$2'));
      });
      $(id + '>ol>li a').click(function() {
        if (!$(this).is('.' + ON_CLASS)) {
          var re = /([_\-\w]+$)/i;
          var target = $('#' + re.exec(this.href)[1]);
          if (target.size() > 0) {
            $(id + ' div.tabbody:visible').css({'display':'none'});
            target.css({'display':'block'});
            $(id + '>ol>li>a').removeClass(ON_CLASS).children('img').each(function(){
              $(this).attr('src',$(this).attr('src').replace(/^(.+)_on(\.[a-z]+)$/,'$1$2'));
            });
            $(this).addClass(ON_CLASS).children('img').each(function(){
              $(this).attr('src',$(this).attr('src').replace(/^(.+)(\.[a-z]+)$/,'$1_on$2'));
            });
          }
        }
        return false;
      });
    }
  });
})(jQuery);





/* ------------------------------------------------------------ */
/*                                                              */
/*                        multi column                          */
/*                                                              */
/* ------------------------------------------------------------ */
(function($){
  $.fn.extend({
    setColumn: function() {
      $.each(['col2','col3','col4','col5','col6','col7','col8'], function(i, targ) {
        var targ  = '.' + targ;
        var N     = i+2;
        if ($(targ).size()) {
          $(targ).each(function(){
            var targW = $(this).width();
            $(this).children('li').width(Math.floor(targW/N));
            $(this).children('li:last').width(targW - (Math.floor(targW/N)*(N-1)));
            $(this).children('li.double').width(Math.floor(targW/N)*2);
          });
        }
      });
    }
  });
})(jQuery);





/* ------------------------------------------------------------ */
/*                                                              */
/*                            Animate                           */
/*                                                              */
/* ------------------------------------------------------------ */
(function($){
  $.fn.extend({
    doShuffle: function() {
      var shuffled = this.find('li').get().sort(function(){
        return Math.round(Math.random())-0.5; //just a random number between -0.5 and 0.5
      });
      $(shuffled).appendTo(this);
      return this;
    },
    delay: function(time, callback){
      // Empty function:
      jQuery.fx.step.delay = function(){};
      // Return meaningless animation, (will be added to queue)
      return this.animate({delay:1}, time, callback);
    },
    doSlide: function() {
      return this.delay(3000)
      .animate({left: -1*(this.width() - 1270)+'px'}, 3000, 'linear')
      .delay(1000)
      .animate({left: 0}, 4000);
    }
  });
})(jQuery);





/* ------------------------------------------------------------ */
/*                                                              */
/*                      Google Mini Search                      */
/*                                                              */
/* ------------------------------------------------------------ */
function doSearch(q) {
  location.href = 'http://search.president.co.jp/search?proxystylesheet=default_frontend&site=default_collection&output=xml_no_dtd&client=default_frontend&numgm=5&q=' + encodeURIComponent(q);
}
function doSearchNanaoh(q) {
  location.href = 'http://search.president.co.jp/search?proxystylesheet=nanaoh&site=nanaoh&output=xml_no_dtd&client=nanaoh&numgm=5&q=' + encodeURIComponent(q);
}





/* ------------------------------------------------------------ */
/*                                                              */
/*                      Flash  -  SWFObject                     */
/*                                                              */
/* ------------------------------------------------------------ */
// <div id="swfPFHolder"></div>
// <script type="text/javascript">_swf({type:'pageflip',rootPath:'/fileadmin/family/pageflip/',xml:'20080530.xml'});</script>

function _swf(obj) {
  if (typeof obj == 'undefined') return null;
  if (_swfAry.toString().indexOf(obj.type)>-1) return null;

  switch (obj.type) {
    case 'pageflip':
      prm = {w:260,h:195,id:'swfPF',wmode:'transparent',swf:'/_global/swf/pageflip.swf',param:'_rootPath='+obj.rootPath+'&_xml='+obj.xml}; _swfAry.push(obj.type); break;
    case 'pageflip2':
      prm = {w:360,h:250,id:'swfPF',wmode:'transparent',swf:'/_global/swf/pageflip2.swf',param:'_rootPath='+obj.rootPath+'&_xml='+obj.xml}; _swfAry.push(obj.type); break;
  }

  /* --- case of undefined --- */
  if (!prm.v)      prm.v      = 8;
  if (!prm.bg)     prm.bg     = '#ffffff';
  if (!prm.scale)  prm.scale  = 'noscale';
  if (!prm.salign) prm.salign = 'TL';

  var so = new SWFObject(prm.swf, prm.id, prm.w, prm.h, prm.v, prm.bg);

  /* --- add param --- */
  so.addParam('scale',  prm.scale);
  so.addParam('salign', prm.salign);
  if (prm.wmode == 'transparent') {
    so.addParam('wmode', prm.wmode);  // Japanese IME & Scroll Wheel issue
  }

  /* --- add variable --- */
  if (prm.param) { var pAry=prm.param.split('&'); for (var i=0;i<pAry.length;i++) {var a=pAry[i].split('='); so.addVariable(a[0],a[1]);} };
  if (location.search) { var sAry=location.search.substr(1).split('&'); for (var i=0;i<sAry.length;i++) {var a=sAry[i].split('='); so.addVariable(a[0],a[1]);} };
  so.addVariable('_pathName', _pathName);

  /* --- marginFix & write --- */
  so.setAttribute('style', ';');
  so.write(prm.id+'Holder');
}

