/**
  * ACCSports Javascript Toolkit
  * A collection of methods and materials for providing dynamic functionality in
  * the ACC Sports Journal website.
  * @author	Thomas Ingham
  * @created	8/28/08 1:26 PM
 */
 
/**
  * accsports::emailLink
  * Sends a link via ajax.
  * @return	[bool] Always false.
  * @author	Thomas Ingham
  * @created	8/28/08 3:26 PM
 */
function emailLink(form)
{
	var yourname,youremail,theirname,theiremail,title,destination;
	yourname = form.yourname.value;
	youremail = form.youremail.value;
	theirname = form.theirname.value;
	theiremail = form.theiremail.value;
	title = form.title.value;
	destination = document.location.href;
	destination = destination.split("?");
	destination = destination[0];
	
	if( yourname == "" || youremail == "" || theirname == "" || theiremail == "" || youremail.indexOf("@") < 1 || theiremail.indexOf("@").indexOf < 1)
	{
		window.alert("Please ensure that all the fields in the \"Send This Post\" form are filled out before attempting to send.");
		return false;
	}
	
	var url = "/xml/ajax.php?func=Distro.sendEmailLink&yourname="+yourname+"&youremail="+youremail+"&theirname="+theirname+"&theiremail="+theiremail+"&destination="+destination+"&title="+title;
	var ajax = new Ajax.Request(url, {method:'get', onFailure:null, asynchronous:false} );
	var strAjaxResult =     ajax.transport.responseText;
	
	//window.prompt(url,strAjaxResult);
	
	//hide the drawer	
	if( global_cmDrawerController )
	{
		global_cmDrawerController.closeDrawer("drawerFor_activatorEmailLink",false);
	}
	return false;
}