
function getXMLHTTP()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				return null;
			}
		}
	}
	
	return xmlHttp;
}

function tellAFriend()
{ 
	xmlhttp = getXMLHTTP();
	if(xmlhttp != null)
	{

		xmlhttp.onreadystatechange = function()
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == '200')
			{
				sendEmail(xmlhttp.responseText);
			}
		}
		
		var params = "name=" + $('name').value + "&friend=" + $('friendName').value;
		
		xmlhttp.open("POST", "/osauk/tellafriendemailcontent.html", true);
		
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		
		xmlhttp.send(params);
	}
}


function sendEmail(emailcontent)
{
	
	
	var mailtoURL = "mailto:" + $('toemailaddress').getProperty('value') + "?subject=" + $('emailSubject').getProperty('value') + "&body=" + emailcontent;
	
	var win = window.open( mailtoURL );
	
	win.close();
	
	return false;
}

