$(document).ready(function(){
	
/* クッキーの有効期間 */
//var cookie_expires = 365;

/* replace img */
var authyes = $('#auth-yes');
var authno = $('#auth-no');
authyes.mouseover(function(){
	$(this).attr('src',$(this).attr('src').replace('_off.','_on.'));
})
authyes.mouseout(function(){
	$(this).attr('src',$(this).attr('src').replace('_on.','_off.'));
})
authno.mouseover(function(){
	$(this).attr('src',$(this).attr('src').replace('_off.','_on.'));
})
authno.mouseout(function(){
	$(this).attr('src',$(this).attr('src').replace('_on.','_off.'));
})

/* go inside */
var authsrc;
var cookie = $.cookie('alert');
var noalert = $('#noalert');
/*var authstr = '<div id="wrap-auth"></div>	<div id="auth"><div id="auth-head"></div><div id="auth-middle">'
	+ '<h4><img src="<$mt:StaticWebPath$>themes/dmrg-default/img/auth_title.gif" width="451" height="58" alt="糖尿病リソースガイド　第1部　医薬品・医療機器・検査機器・試薬" /></h4>'
	+ '<p>第1部は、糖尿病に関連した薬剤や医療機器の情報を、<br />'
	+ '医療関係者の方に提供することを目的に作成されています。<br />'
	+ '一般の方への情報提供を目的としたサイトではありませんので、ご了承ください。<br />'
	+ '薬の処方や治療法において疑問や不都合などがある場合には、<br />'
	+ '必ず主治医に相談してください。</p>'
	+ '<p>医療関係者の方は、「はい」をクリックして中へお進みください。<br />'
	+ '「いいえ」をクリックすると、トップページへ戻ります。</p>'
	+ '<p><strong>あなたは医療関係者ですか?</strong><br />'
	+ '<a href="1/"><img src="<$mt:StaticWebPath$>themes/dmrg-default/img/auth_yes_off.gif" width="154" height="54" alt="はい" id="auth-yes" /></a>'
	+ '<img src="<$mt:StaticWebPath$>themes/dmrg-default/img/auth_no_off.gif" width="154" height="54" alt="いいえ" id="auth-no" /><br />'
	+ '<input type="checkbox" id="noalert" /> 次回から表示しない</p>'
	+ '</div><div id="auth-foot"></div></div>'*/
	
if (cookie == true){
	noalert.attr('checked','checked');
} else {
	noalert.attr('checked', '');
}

$('.auth-lnk, #sec1').click(function(){
	authsrc = $(this).attr('class').replace('auth-lnk ','');
	if (cookie == 'true'){
		location.href = authsrc;
	} else {
		$('#wrap-auth').slideDown('slow');
		$('#auth').fadeIn('slow');
		location.href = '#container';
		return false;
	}
})

$('#wrap-auth').click(function(){
	$('#auth').fadeOut('slow');
	$('#wrap-auth').slideUp('slow');
})

$('#auth-yes').click(function(){
	location.href = authsrc;
	return false;
})

$('#auth-no').click(function(){
	$.cookie('alert', null);
	$('#auth').fadeOut('slow');
	$('#wrap-auth').slideUp('slow');
})

/* save cookie */
$('#noalert').click(function(){
	var chk_value = $(this).attr('checked');
	if (chk_value == true){
		//$.cookie('alert', 'true', {expires:cookie_expires});
		$.cookie('alert', 'true');
	} else {
		$.cookie('alert', null)
	}
})

});

