/*----------------------------------------
	Tab Interface with History
----------------------------------------*/
(function($){
var _panels,_tabs;

function pageload(_hash) {
	// alert("pageload: " + hash);
	// hash doesn't contain the first # character.
	var _panel = _panels.eq(0).attr('id');
	var _tab = _panel.replace(/^area/, '');
	if(_hash) {
		_panel = _hash.replace(/^/, 'info');
		_tab = _hash;
	}
	activatePanel(_panel);
	activateTab(_tab);
}
function activatePanel(_panel){
	_panels.hide();
	_panels.filter('#' + _panel).show();
}
function activateTab(_tab){
	_tabs.removeClass('stay');
	_tabs.each(function(){
		var _this = $(this);
		if(_this.find('a').attr('href') == '#' + _tab){
			_this.addClass('stay');
		}
	});
}


$(function(){
	_panels = $('div.infoPanel');
	_tabs = $("#infoTab li");

	$.historyInit(pageload);
	// set onlick event for buttons
	var _anchors = $("#infoTab a").click(function(e){
		this.blur();
		var _hash = this.href;
		_hash = _hash.replace(/^.*#/, '');
		$.historyLoad(_hash);
		e.preventDefault();
	});
	if(location.hash == '') {
		_anchors.eq(0).click();
	}
});


/*
 Check Mobile Mail
*/
$(function(){
	$mobileAccount = $('#mobileAccount');
	$mobileDomain = $('#mobileDomain');
	
	$("a.submit", document.mobileform).click(function(e){
		if($mobileAccount.val() == "" || $mobileDomain.val() == ""){
			e.preventDefault();
			alert("メールアドレスを正しく入力してください");
		}
	});

});
})(jQuery);
