/*
*******************************************************************
 * 
 * Copyright (c) 2009 MMC Planning Co. Ltd.
 *
*******************************************************************
*/


/*
*******************************************************************
 * 
 * 製品情報ナビゲーション
 * 
*******************************************************************
*/

$(function(){
	$("ul#gloval li").hover(function(){
		$(this).find("ul").slideDown("fast");
	},
	function(){
		$(this).find("ul").hide("fast");
	});
});



/*
*******************************************************************
 * 
 * スムーズスクロール
 * 
*******************************************************************
*/
$(document).ready(function() {
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
			&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			
			if ($target.length) {
			var targetOffset = $target.offset().top;
			$('html,body').animate({scrollTop: targetOffset}, 400);
			return false;
			}
		}
	});
});



/*
*******************************************************************
 * 
 * ロールオーバー
 *
*******************************************************************
*/
$(document).ready( function()
{
   PEPS.rollover.init();
});

PEPS = {};

PEPS.rollover =
{
   init: function()
   {
      this.preload();
     
      $(".imgover").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); },
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.imgover').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   {
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0];
   },

   oldimage: function( src )
   {
      return src.replace(/_o\./, '.');
   }
};
