/** ページ内スクロール **/
$(function() {
  $('a[href*=#]').each(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname
        && this.hash.replace(/#/,'') ) {
          var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
          var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
      if ($target) {
        var targetOffset = $target.offset().top;
        $(this).click(function() {
          $($.browser.opera ? document.compatMode == 'BackCompat' ? 'body' : 'html' :'html,body').animate({scrollTop: targetOffset}, 400);
          return false;
        });
      }
    }
  });
});

/** ロールオーバー**/
$(function(){
  var postfix = '_on';
  $('.rollover').not('[src*="' + postfix + '."]').each(function(){
    var img = $(this);
    var src = img.attr('src');
    var src_on = src.substr(0, src.lastIndexOf('.')) + postfix + src.substring(src.lastIndexOf('.'));
    $('<img>').attr('src', src_on);
    img.hover(
        function(){
          img.attr('src', src_on);
        },
        function(){
          img.attr('src', src);
        }
    );
  });
});

/** ウォーターマーク */
$(function(){
  $('form input.watermark, form textarea.watermark').formtips({
    tippedClass: 'tipped'
  });
});
