/*
======== Script Properties ==================================

交通アクセス｜大阪商業大学

大阪商業大学までの交通アクセス
(ルート確認したい駅名をクリックしてください。)

Neccesary:
- jquery-1.2.6.min.js

============================================================
*/


/*----------------------------------------------------------
Ready
----------------------------------------------------------*/

var r_map;

$( function()
{
	var map_id = 'r_map';
	var index_id = 'r_index';
	var route_id = [
		'r_tennouji',
		'r_nishikujou',
		'r_sannomiya',
		'r_kyoubashi',
		'r_amagasaki',
		'r_oosaka',
		'r_nanba',
		'r_kyouto',
		'r_ouji',
		'r_yamatoyagi'
	];
	
	r_map = new route_map( map_id, index_id, route_id );
});


/*----------------------------------------------------------
Route Map Class
----------------------------------------------------------*/

// constructor
// --
function route_map( my_map_id, my_index_id, my_route_id )
{
	this.$map = $( '#' + my_map_id );
	this._index_id = my_index_id;
	this._route_id = my_route_id;
	
	this.init();
};

// prototype
// --
route_map.prototype =
{
	$map: {},
	_index_id: '',
	_route_id: [],
	
	init: function()
	{
		this.$map.find( 'p' ).not( '#' + this._index_id ).hide();
		this.attach_event();
	},
	
	attach_event: function()
	{
		var owner = this;
		
		this.$map.find( 'map area' ).click( function()
		{
			var href = $(this).attr( 'href' ).split( '#' );
			var click_id = ( href.length > 1 ) ? href[ 1 ] : '';
			
			return owner.click_area( click_id );
		});
	},
	
	click_area: function( my_click_id )
	{
		this.$map.find( 'p' ).fadeOut( 'normal' );
		this.$map.find( 'p#' + my_click_id ).fadeIn( 'normal' );
		
		return false;
	}
};
