<!--

/*-------------------------
 タブ切り替え for JQuery
 TAKMAN
 ...use '#anchor_*' ID
--------------------------*/

function jqtab( object, target, element, default_show, flag ) {
	
	this.object = object;
	this.target = target;
	this.element = element;
	this.show = default_show;
	this.flag = flag;
	
	this.init =
	function() {
		var cl = this.show.substr( 1 );
		
		$( '#'+(this.target)+' ul' ).attr( 'class', cl );
		
		$( '.'+(this.element) ).hide();
		$( '#'+this.show.substr(8) ).show(); // delete '#anchor_'
		
		$( '#'+(this.target)+' ul li a' ).unbind( 'click' );
		$( '#'+(this.target)+' ul li a' ).bind( 'click',
		{
			'object': this.object,
			'target': this.target,
			'show': this.show
		},
		function ( e ) {
			var object = eval( e.data.object );
			var temp = this.getAttribute( 'href' ).split( '#' );
			var cl = temp[ temp.length - 1 ];
			var show = '#'+(cl);
			
			$( '#'+(e.data.target)+' ul' ).attr( 'class', cl );
			$( '#'+object.show.substr(8) ).hide(); // delete '#anchor_'
			object.show = show;
			$( '#'+show.substr(8) ).show(); // delete '#anchor_'
			
			// clear for IE
			document.body.style.fontSize = 'xx-large';
			document.body.style.fontSize = '';
			
			return false;
		});
		
		if ( this.flag ) {
			$( window ).scroll( function()
			{
				if( document.body.scrollTop ) {
					document.body.scrollTop = 0;
				}
				if ( document.documentElement.scrollTop ) {
					document.documentElement.scrollTop = 0;
				}
				$(window).unbind( 'scroll' );
			});
		}
	};
	
	return this;
}


// タブ切り替え開始
$(function () {
	var default_anchor = "anchor_general";
	var anchor = new String();
	var flag = false;
	
	if ( window.location.hash.length > 0 ) {
		anchor = window.location.hash.substr( 1 );
	}
	
	if ( anchor == 'anchor_general'
	  || anchor == 'anchor_audio'
	  || anchor == 'anchor_other' ) {
		default_anchor = anchor;
		flag = true;
	}
	
	tab = new jqtab( 'tab', 'tab_menu', 'contents_element', '#'+(default_anchor), flag );
	tab.init();
});

// -->