/*
Last UpDate 2010-01-06
*/

$(function(){
  //現在居るファイル名
  var currentFile = location.href.split('/').pop();

  //ua取得
  var ua = navigator.userAgent;

  //classが、'nav'で終わるulの、最後のliに、'last'クラスを付ける
  $('ul[class$="nav"]').each(function(){
    $('li:last',this).addClass('last');
  });

  $('#fnav ul').each(function(){
    $('li:last',this).addClass('last');
  });
  $('#flow ol').each(function(){
    $('li:last',this).addClass('last');
  });

  //classが、'list'で終わるulの、偶数の要素に、'even'クラスを付ける
  $('ul[class$="list"] li:nth-child(even)').addClass('even');

  //classが、'table'で終わるテーブルの、偶数trに、'even'クラスを付ける
  $('table[class$="table"] tr:nth-child(even)').addClass('even');

  //rollover
  $('a img').each(function(){
    var imgSrc = $(this).attr('src');
    //smartRollover
    if(imgSrc.match(/(.*)_off(\..*)/)){
      var repSrc = RegExp.$1+'_on'+RegExp.$2;
      $('<img />').attr('src',repSrc);
      $(this).hover(function(){
        $(this).attr('src',repSrc);
        $(this).css({opacity:'1',filter:'alpha(opacity=100)'});
      },function(){
        $(this).attr('src',imgSrc);
      });
      //ウィンク効果
    }else if(!$(this).hasClass('not')){
      $(this).hover(function(){
        $(this).css({opacity:'0.7', filter:'alpha(opacity=70)'});
      },function(){
        $(this).css({opacity:'1', filter:'alpha(opacity=100)' });
      });
    }
  });



  //submit押した感 & ウィンクorsmartrollover
  $('form p.submit input').mousedown(function(){
    $(this).css({position:'relative',top:'1px',left:'1px'});
  }).mouseup(function(){
    $(this).css({position:'static'});
  }).mouseout(function(){
    $(this).css({position:'static'});
  })
  /* ウィンク版 */
    /*
    .hover(function(){
    $(this).css({opacity:0.2});
    $(this).fadeTo('slow',1.0);
    */
    /* smartrollover版　*/
    .hover(function(){
    $(this).attr('src',$(this).attr('src').replace(/^(.*)_off.(.*)$/,'$1_on.$2'));
    },function(){
    $(this).attr('src',$(this).attr('src').replace(/^(.*)_on.(.*)$/,'$1_off.$2'));
  });

  //lightBox
  /*
  try{
  $('.lb a[href$=".jpg"],.lb a[href$=".png"],.lb a[href$=".gif"],.lb a[href$=".JPG"],.lb a[href$=".PNG"],.lb a[href$=".GIF"]').lightBox({
  overlayBgColor: '#000',
  overlayOpacity: 0.8,
  imageLoading:   'js/images/lightbox-ico-loading.gif',
  imageBtnPrev:   'js/images/lightbox-btn-prev.gif',
  imageBtnNext:   'js/images/lightbox-btn-next.gif',
  imageBtnClose:  'js/images/lightbox-btn-close.gif',
  imageBlank:     'js/images/lightbox-blank.gif'
  });
  }catch(error){
  }
  */


  // jQuery SmoothScroll | Version 10-04-30
  // http://blog.medianotions.de/en/articles/2009/smoothscroll-for-jquery
  $('a[href*=#]').click(function(){
    // duration in ms
    var duration=300;
    // easing values: swing | linear
    var easing='swing';
    // get / set parameters
    var newHash=this.hash;
    var target=$(this.hash).offset().top;
    var oldLocation=window.location.href.replace(window.location.hash, '');
    var newLocation=this;
    // make sure it's the same location
    if(oldLocation+newHash==newLocation)
      {
        // animate to target and set the hash to the window.location after the animation
        $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {
          // add new hash to the browser location
          window.location.href=newLocation;
        });
        // cancel default click action
        return false;
      }
  });


  //colorbox
  //http://colorpowered.com/colorbox/
  /*
  $(".gallery a[rel='cb']").colorbox({
    transition:"none",
    speed:"300",
    opacity:"0.5"
  });
  */








// end parent function
});



