/*[ Copyright 2006 Sean Colombo and Motive Force LLC.]*/
////
// Author: Sean Colombo
// Date: 20060326
//
// Allows a small form to send an invite asynchronously.
////


////
// Sends an invite and changes the div to reflect the change.
// The conventions required for using this function are that the subject,message, and to-address
// are in invite_subj, invite_msg, and invite_to respectively.
//
// Note: a full form was decided against in favor of just a bar for addresses. Lower barriers == higher usage.
////
function sendInvite(projId){
	// Send out the data from the form but don't wait for a response.
	
	var subj = '';var msg = '';
	//var subj = el('invite_subj').value;
	//var msg = el('invite_msg').value;
	var to = el('invite_to').value;
	if(to==''){alert('Please enter at least one email address.');return;}
	//if(msg != ""){msg = '&invite_message=' + encodeURI(msg);}
	//if(subj != ''){subj = '&invite_subject=' + encodeURI(subj);}
	var data = 'project='+projId+'&invite_to='+encodeURI(to)+subj+msg;
	data += '&formName=doInvite&squelch=true'; // squelches the HTML output (it isn't needed, so save some bandwidth)
	http.open('post', 'invite.php', true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.send(data);

	
	alert("Invitation sent.");
	
	//el('invite_subj').value = '';
	//el('invite_msg').value = '';
	el('invite_to').value = '';
} // end sendInvite(...)

