function startRwiz(str, opt) {
  actionBox('registration-wizard/'+str, opt);
  return false;
}

/* entrance functions - functions that will begin the registration wizard process */
function rwizAppSelect() {
  startRwiz('app-select', {});
}

function similar_click_check(popup, args, object_id, hash) {
  var content_id = 'extra_'+object_id+'_'+hash;
  var is_checked = true;
  if($(content_id).innerHTML == '') {
    actionElement(popup, args, content_id);
    is_checked = true; 
  } else {
    $(content_id).innerHTML = '';
    is_checked = false;
  }
  $('check_'+hash).checked = (!is_checked ? 'checked' : '');
}

/*************/
/* Directors */
/*************/

function regwiz_director( page_id, content_div )
{
  return {
    onConfirm : function( form )
    {  
        addMembership( $(form).serialize(true), function(){ startRwiz('similar', serialize({item_id:page_id, item_type:'Page'})); } );
        $(content_div).innerHTML = "<div style=\"text-align:center;padding:20px;background:#f8f8f8;font-size:1.6em;color:#359;\">Adding Page...<br /><img src='img/indicator.gif' /></div>";
        //new Effect.Highlight(content_div, { duration:3.0 });
    },
    onCancel : function(){ 
        if($(content_div)) {
          $(content_div).innerHTML = '';
        }
      }
  }
}

function similar_director( page_id, content_div )
{
  return {
    
    onConfirm : function( form )
    {  
        addMembership( $(form).serialize(true), function(){} );
        $(content_div).innerHTML = "<strong>Page Added</strong>";
        new Effect.Highlight(content_div);
    },
    onCancel : function(){ 
        if($(content_div)) {
          $(content_div).innerHTML = '';
        }
      }
  }
}

/*****************
 other 
 ****************/

function callback_to_app_select(src) {
  return function() {
    actionBox('registration-wizard/app-select', src);
  }
}

function from_view_people(bucket_id) {
  return function() {
    var args = serialize({item_type:'Bucket', item_id:bucket_id});
    actionBox('registration-wizard/similar', args);
  }
}

function callback_to_similar() {
  actionBox('registration-wizard/similar', '');
}

