/**
 * Simple tabs
 * 
 * Copyright (c) 2009 Kyosuke Nakamura (kyosuke.jp)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 */

$(function(){
	$('.tabNav').each(function(){
		var tabs = $(this).find('a[href^=#]');
		var contents;
		tabs.each(function(){
			var selecter = $(this).attr('href');
			if (contents) {
				contents = contents.add(selecter);
			} else {
				contents = $(selecter);
			}
			$(this).click(function(){
				tabs.removeClass('active');
				$(this).addClass('active');
				contents.hide();
				$(selecter).show();
				return false;
			});
		});
        var n = 0;  //タブ番号
        var s = location.href;
        for (var i = 0; i < tabs.length; i++) {
          if (tabs[i] == s) { //location.hrefと一致
            n = i;
            break;
          }
        }
                tabs.eq(n).trigger('click');   //n番のタブclick
	});
location.hash ? $('a[href="' + location.hash.replace(/\"/, '\\"') + '"]').trigger('focus') : tabs.eq(0).trigger('focus');});


