$(document).ready(
	function() {
	}
);

function subscribe_loginform_magsearch(magid) {
	subscribe_loginform(magid, true);
}
function subscribe_loginform(magid, registerable) {
var html = " \
<form action='https://mypage.mag2.com/subscribe/SubscribeMagazineLoginDispatcher.do' method='post'> \
  <input class='hidden' name='reg' value='search' type='hidden'> \
  <input class='hidden' name='magazineId' value='/@@magid/' type='hidden'> \
  <ul class='clearfix'> \
";
if (registerable) {
  html += " \
    <li>このメルマガは無料です。1クリックで登録完了します。</li> \
    <li><input name='registBtn' value='登録' class='submit' type='submit'></li> \
  ";
}
html += " \
    <li><input name='cancellationBtn' value='解除' class='submit' type='submit'></li> \
  </ul> \
</form> \
<div class='box-foot-l'></div><div class='box-foot-r'></div> \
";

$('#rm-subscribe-form-'+magid).html(html.replace("/@@magid/", magid));
}

function subscribe_loginform_archive1(magid, registerable) {
  var id = "rm-subscribe-unlogin-form1";
  subscribe_loginform_archive(id, magid, registerable);
}
function subscribe_loginform_archive2(magid, registerable) {
  var id = "rm-subscribe-unlogin-form2";
  subscribe_loginform_archive(id, magid, registerable);
}
function subscribe_loginform_archive(id, magid, registerable) {
var html = " \
<form action='https://mypage.mag2.com/subscribe/SubscribeMagazineLoginDispatcher.do' method='post'> \
  <input class='hidden' name='reg' value='bnform' type='hidden'> \
  <input class='hidden' name='magazineId' value='/@@magid/' type='hidden'> \
  <input class='hidden' name='op' type='hidden'> \
";
if (registerable) {
  html += " \
  <a href='#' class='reg'><img src='http://img.mag2.com/archive/regist_btn.gif' width='59' height='28' alt='登録' title='登録' /></a> \
  ";
}
html += " \
  <a href='#' class='unreg'><img src='http://img.mag2.com/archive/cancel_btn.gif' width='59' height='28' alt='解除' title='解除' /></a> \
</form> \
";
if (registerable) {
  html += " \
  <span>登録した方には、まぐまぐの公式メルマガ（無料）をお届けします。</span> \
  ";
}

$('#'+id).html(html.replace("/@@magid/", magid));
}

function subscribe_loginform_init() {
	$( 'a.reg' ).click( function() {
		var regform = $( this ).parent().get(0);
		regform.target = '_blank';
		regform.op.name = 'registBtn';
		regform.submit();
		return false;
	});
	$( 'a.unreg' ).click( function() {
		var regform = $( this ).parent().get(0);
		regform.target = '_blank';
		regform.op.name = 'cancellationBtn';
		regform.submit();
		return false;
	});
} 