$(function() {
	$('.on_login').show().css({ 'visibility': 'hidden' });
	var p = 'mc';
	$.ajax({
		url: 'https://h-sodan.com/'+p+'/info',
		dataType: 'jsonp',
		success: function(r) {
			if(r.status == 'logout') {
				$('.on_login').hide();
				$('.on_logout').show();
			} else {
				$('.on_login').css({ 'visibility': 'visible' }).show();
				var mmsg = {
//					2: '現在代理店との面談日時の調整中ですので、お待ちくださいませ。',
//					3: '現在代理店との面談日時の調整中ですので、お待ちくださいませ。',
					7: '面談日時が決定し、メールを送らせて頂きました。<br />ご確認ください。'
				};
				var cmsg = {
					3: 'ファイナンシャルプランナーからの回答をお待ちください。<br />詳しくは<a href="https://h-sodan.com/mc/info">マイページ</a>をご確認ください。',
					4: 'ファイナンシャルプランナーからの回答が届きました。<br />詳しくは<a href="https://h-sodan.com/mc/info">マイページ</a>をご確認ください。',
					5: 'ファイナンシャルプランナーからの回答が届きました。<br />詳しくは<a href="https://h-sodan.com/mc/info">マイページ</a>をご確認ください。',
					6: 'ファイナンシャルプランナーからの回答が届きました。<br />詳しくは<a href="https://h-sodan.com/mc/info">マイページ</a>をご確認ください。'
				};
				$('#loginMessage').html(mmsg[r.meeting] || cmsg[r.consult] || '現在お知らせはございません。');

				$('.login_text .status_'+r.status).show();
			}
		}
	})
});
$(function() {
	var found;
	var nearly;
	$('#contents_link, #footerNest').find('A').each(function() {
		var href = $(this).attr('href');
		if(location.pathname == href) {
			found = this;
		} else if(location.pathname.indexOf(href) == 0) {
			if(!nearly || nearly[1] < href.length) {
				nearly = [ this, href.length ];
			}
		}
	});
	if(found) {
		$(found).addClass('select');
	} else if(nearly) {
		$(nearly[0]).addClass('select');
	}
});
$(function() {
	$('a').each(function() {
		var href = this.getAttribute('href');
		if(!href) {
			return;
		}
		if(href.indexOf("/mc/") == 0) {
			;
		} else if(href.indexOf("/") == 0) {
			this.href = "http://www.hokenqing.com" + href;
		}
	});
});
$(function() {
	var c = $('#login_chk').get(0);
	if(!c) {
		return;
	}
	var v = $.cookie("QINGLOGIN");
	if(v) {
		var up = v.split(" ");
		$('#ClientUid').val(up[0]);
		$('#ClientPwd').val(up[1]);
		c.checked = true;
	}
	$(c.form).submit(function() {
		if(c.checked) {
			var v = $('#ClientUid').val()+" "+$('#ClientPwd').val();
			$.cookie("QINGLOGIN", v, { expires: 14, secure: true });
		} else {
			$.cookie("QINGLOGIN", null);
		}
	});
});
$(function() {
	var h = $('#header').height();
	
	if(typeof document.documentElement.style.maxHeight != "undefined") {
		// IE 7.0 and modern browsers
		$('#pageTop').css({ 'padding-top': h+'px' });
		$('#header').before('<div id="headerBackground">&nbsp;</div>');
		$('#header').css({ 'position': 'fixed', 'top': '0px',
			'z-index': 2, 'overflow': 'visible' });
		
		$('#headerBackground').css({
			'position': 'fixed', 'top': '0px', 'left': '0px',
			'float': 'left',
			'z-index': 1, 'width': '100%', 'height': h+'px' });
	} else {
		// IE6
	}
});
