/* Dialog invite 2 view */


var handleSuccesspostI2V = function(o){
  obj=eval('('+o.responseText+')');
  if(obj.stat == 'fail'){
    $('i2v_error').innerHTML='<b>'+obj.result.error_text+'</b>';
    return;
  }
  $('dlgPostI2V').hide();
};


function postI2V(){
   
  var params={
    method:'zack.util.invite2View',
    appKey:ZACK.appKey,
    mKey:ZACK.mKey,
    i2v_from:$('i2v_from')?$F('i2v_from'):null,
    i2v_to:$('i2v_to')?$F('i2v_to'):null,
    i2v_name:$('i2v_name')?$F('i2v_name'):null,
    i2v_text:$('i2v_text')?$F('i2v_text'):null,
    groupID: ZACK.groupID,
    itemID: ZACK.ID,
    ID: ZACK.ID,
    rspm: 'json'
  }
  var elem=$('l_i2v_from');
  if(!emailCheck(params.i2v_from)){
    elem.style.color='red';
    return false;
  }
  elem.style.color='#999';
  
  var elem=$('l_i2v_name');
  if(!params.i2v_name){
    elem.style.color='red';
    return false;
  }
  elem.style.color='#999';
  
  var elem=$('l_i2v_to');
  if(!emailCheck(params.i2v_to)){
    elem.style.color='red';
    return false;
  }
  elem.style.color='#999';

  new Ajax.Request(ZACK.RESTURL,   {
    method:'post',
    parameters: params,
    onSuccess: handleSuccesspostI2V,
    onFailure: function(o){
       alert('error: ');}
  });
  return true;
}
