document.observe('dom:loaded',function() {
    $$('.memberY').each(
      function (obj) {
       obj.observe( 'click', memberYN );
       });

    $$('.memberN').each(
      function (obj) {
       obj.observe( 'click', memberYN );
       });
});

function redirect (url, secs) {
  // go to an URL after a delay
  var msecs = secs * 1000;
  setTimeout( "document.location = '"+ url +"'", msecs );
}

function memberYN(e) {

  try {
    var radio = Event.findElement(e, 'input');
    var matches = radio.id.match(/_(\d+)$/);
    if ( matches ) {
      id = matches[1];
    } else {
      id = '';
    }
    
    $('loginText_' +id).hide();
  
    var memberY = $('memberY_' + id);
    var memberN = $('memberN_' + id);
  
    if ( memberY.checked ) {
      if ( $('subscription_id_' + id) ) {
        subscription_id = $('subscription_id_' + id).value
      }
  
      $('loginMember_' + id).show();
      $('loginEmail_' + id).hide();
      $('loginEmailLabel_' + id).hide();
      //GB_showCenter_ex(LOGIN_CAP, LOGIN_URL, parseInt(LOGIN_H),parseInt(LOGIN_W));
      Coop_Login('/wsp/coop61/frontend.cgi?func=publish.view_secure&func_id=1139&table=PUBLISH&template=abonnemnet&help_id=0&open=1139');
      $('loginMember_' + id).hide();
      //redirect('/wsp/coop61/frontend.cgi?func=publish.view_secure&template=din_side&next_template=abonnemnet&next_func_id=1121&subscription_id='+ subscription_id, 3);    
      // Hardcoded publish_id 1121
    } else {
      $('loginMember_' + id).hide();
      $('loginEmail_' + id).show();
      $('loginEmailLabel_' + id).show();
    }
  } catch (err) {
    var msg = err.description ? err.description : err;
    alert( msg );
  }
}
