/*==================================================================
//
//  Page Scroll
//
==================================================================*/
jQuery.extend( jQuery.easing,
{
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	}
});


function initPageScroll()
{
	//
	// <a href="#***">の場合、スクロール処理を追加
	//
	jQuery( 'a[href*=#]' ).click( function()
	{
		if ( location.pathname.replace( /^\//, '' ) == this.pathname.replace( /^\//, '' ) && location.hostname == this.hostname )
		{
			var $target = jQuery( this.hash );
			$target = $target.length && $target || jQuery( '[name=' + this.hash.slice(1) + ']' );
			if ( $target.length )
			{
				var targetOffset = $target.offset().top;
				jQuery( 'html, body' ).animate( {
					scrollTop: targetOffset
				}, 1200, 'easeOutExpo' );
				return false;
			}
		}
	});
};
//
jQuery(document).ready( initPageScroll );

/*==================================================================
//
//  RollOver
//
==================================================================*/
function initRollOver()
{
	// image rollover
	var _obj = jQuery( ".rollOverSwitch a img, img.rollOverSwitch" );
	jQuery.each( _obj, function()
	{
		changeBtImage( jQuery( this ), jQuery( this ) );
	} );
	//------------------------------
	jQuery( ".rollOverFade a img" ).hover (
		function()
		{
			jQuery( this ).fadeTo( 100, 0.6 );
		},
		function()
		{
			jQuery( this ).fadeTo( 100, 1 );
		}
	);
	//------------------------------
	function changeBtImage( target, clickableArea )
	{
		var _imageCashe = new Object();
		//
		target.not( "[src*='_on.']" ).each( function( i )
		{
			var _this = this; 
			var _imgsrc = _this.src;
			var _dot = _this.src.lastIndexOf( '.' );
			var _imgsrc_on = _this.src.substr( 0, _dot ) + '_on' + _this.src.substr( _dot, 4 );
			_imageCashe[ _this.src ] = new Image();
			_imageCashe[ _this.src ].src = _imgsrc_on;
			//------------------------------
			clickableArea.hover(
				function() { _this.src = _imgsrc_on; },
				function() { _this.src = _imgsrc; }
			);
		});
	};
};
//
jQuery( document ).ready( initRollOver );
