$( function()
{
	/**
	 * setActive
	 */
	var path = document.URL;
	var path_arr = path.split( '/' );
	path_arr.shift();
	path_arr.shift();
	path_arr.shift();
	var root_path = '/' + path_arr.join( '/' );
	
	$( '#mainNavi ul a' ).each( function()
	{
		var target_href = $( this ).attr( 'href' );
		target_href = target_href.replace( /\./g, '' );
		var re = new RegExp( '^' + target_href );
		var target_img = $( this ).find( 'img' );
		
		if( target_href == '/' )
		{
			if( root_path == '/' )
			{
				target_img.attr( 'src', target_img.attr( 'src' ).replace( /^(.+)(_out)(\.[a-z]+)$/, '$1_active$3' ) );
			}
		}
		else
		{
			if( root_path.match( re ) )
			{
				target_img.attr( 'src', target_img.attr( 'src' ).replace( /^(.+)(_out)(\.[a-z]+)$/, '$1_active$3' ) );
			}
		}
	})
	
	$( '#subColumn ul a' ).each( function()
	{
		var target_href = $( this ).attr( 'href' );
		target_href = target_href.replace( /\.\.\//g, '' );
		target_href = target_href.replace( /\.\//g, '' );
		var re = new RegExp( target_href );
		
		if( root_path.match( re ) )
		{
			$( this ).addClass( 'active' );
		}
	})
	
	
	
	/**
	 * ストライプ
	 */
	$( '#subColumn ul' ).each( function()
	{
		$( 'li', $(this) ).each( function(i)
		{
			if( i % 2 )
			{
				$( $(this) ).css( 'background-color', '#FFFFFF' );
			}
		})
	})
	
	$( 'ul.relatedPost li' ).each( function(i)
	{
		if( i % 2 )
		{
			$( $(this) ).css( 'background-color', '#FFFFFF' );
		}
	})
	
	$( 'ul.st-related-posts li' ).each( function(i)
	{
		if( i % 2 )
		{
			$( $(this) ).css( 'background-color', '#FFFFFF' );
		}
	})
	
	$( 'ul.listArea li' ).each( function(i)
	{
		if( i % 2 )
		{
			$( $(this) ).css( 'background-color', '#FFFFFF' );
		}
	})
	
	$( 'table.stripe tr' ).each( function(i)
	{
		if( i % 2 )
		{
			$( $(this) ).addClass( 'stripe' );
		}
	})
	
	
	
	/**
	 * スワップ
	 */
	$( '.swap' ).mouseover( function()
	{
		$(this).attr( 'src', $(this).attr( 'src' ).replace( /^(.+)(_out)(\.[a-z]+)$/, '$1_over$3' ) );
	})
	.mouseout( function()
	{
		$(this).attr( 'src', $(this).attr( 'src' ).replace( /^(.+)(_over)(\.[a-z]+)$/, '$1_out$3' ) );
	})
	
	
	
	/**
	 * スムーススクロール
	 */
	$.fn.extend(
	{
		scrollTo : function(speed, easing)
		{
			if(!$(this)[0].hash || $(this)[0].hash == "#")
			{
				return false;
			}
			return this.each(function()
			{
				var targetOffset = $($(this)[0].hash).offset().top;
				$('html,body').animate({scrollTop: targetOffset}, speed, easing);
			})
		}
	})
	
	$(function()
	{
		$('a.smoothScroll[href*=#]').click(function()
		{
			$(this).scrollTo(1000);
			return false;
		})
	})
})

