function getLinkToUsURI(title)
{
	var ourURI = window.location.href;
	var addTextBox = document.getElementById('linkToUs');

	var linkBox = "<a href=\"" + ourURI + "\">" + title + "</a>";
	var textBox = "<textarea rows=\"4\" cols=\"64\" style=\"padding: 3px 3px 3px 3px; overflow: auto; width: 409px; height: 78px; border: 1px solid #A7ABAE; font-family: Verdana; font-size: 11px; color: #464646\">" + linkBox + "</textarea>";

	addTextBox.innerHTML = textBox;
}

function drawLink(title)
{
	var ourURI = window.location.href;
	var addLink = document.getElementById('drawLink');

	var linkBox = "<a class=\"textLink\" href=\"" + ourURI + "\">" + title + "</a>";
	addLink.innerHTML = linkBox;
}

function ajaxInit(url, post)
{
	try
	{
		var requester = null;										// Reset the requester

		if (window.XMLHttpRequest)
		{								// Standard XML Http Request
			requester = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{						// Microsoft ActiveX
			requester = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{													// No browser Support
			alert("Your browser is not supported");
		}

		if (requester)
		{
			requester.onreadystatechange = function()
			{				// When the request comes through
				try
				{
					if (requester.readyState == 4 && requester.status == 200)
					{
						var response = requester.responseXML;
						if (response)
						{
							try
							{
								var blockObject = document.getElementById("blockAll");
								var emailObject = document.getElementById("emailFriendLayer") ;
								blockObject.style.display = 'none';
								emailObject.style.display = 'none';
								alert("Your email has been sent, thank you");
							}
							catch ( closeException )
							{
								alert("There was a problem sending your email.");
							}
						}
					}
				}
				catch (exception)
				{
					alert("There was a problem sending your email.");
				}
			}

			//
			// This is an addition to support POST requests.  This enabled us to send long data strings etc.
			//

			if ( post != '' && post !=null && post != "undefined" )
			{
				requester.open("POST", url, true);
				requester.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				requester.setRequestHeader("Content-length", post.length);
				requester.setRequestHeader("Connection", "close");
				requester.send(post);
			}
			else
			{
				requester.open("GET", url, true);
				requester.send(null);
			}
		}
	}
	catch (outerAjaxException)
	{
		alert("Exception Request False: in Ajax: " + outerAjaxException.message);
	}
}

function processEmailSend(url)
{
	var yourName 		= document.getElementById("yourName").value;
	var articleType 	= document.getElementById("articleType").value;
	var friendEmail 	= document.getElementById("friendEmail").value;
	var yourMessage 	= document.getElementById("yourMessage").value;

	if (typeof url == "undefined")
	{
    	url = "/London/EmailAFriend";
	}

	if (yourName && articleType && friendEmail )
	{
		ajaxInit(url, "directory=no&yourName="+yourName+"&articleType="+articleType+"&friendEmail="+friendEmail+"&yourMessage="+yourMessage+"" );
	}
	else
	{
		var errors = "";
		if (!yourName) errors += "Please enter your name\n" ;
		if (!friendEmail) errors += "Please enter your friends email address\n";
		if (!articleType) errors += "Please choose the article you want to send\n";
		alert("There was a problem sending your email..\n\n" + errors) ;
	}
}

function killEmailAFriend()
{
	try
	{
		var __o = document.getElementById("ShortCuts");
		__o.style.display = '';
	}
	catch (__ex) {}

	var blockObject = document.getElementById("blockAll");
	var emailObject = document.getElementById("emailFriendLayer") ;
	blockObject.style.display = 'none';
	emailObject.style.display = 'none';
}

function emailToFriend(event)
{
	var _event = event || window.event;

	var screenWidth = screen.availWidth;
	var screenHeight = screen.availHeight + document.body.scrollTop;

	if ((navigator.userAgent.toLowerCase()).match("msie"))
	{
		screenWidth = document.body.clientWidth;
	}

	try
	{
		var width = 300 ;
		var height = 300 ;

		try
		{
			var __o = document.getElementById("ShortCuts");
				__o.style.display = 'none';
		}
		catch (__ex) {}

		var blockObject = document.getElementById("blockAll");
		blockObject.style.width = screenWidth;
		blockObject.style.height = screenHeight;
		blockObject.style.display = '';

		var emailObject = document.getElementById("emailFriendLayer") ;

		var resultLocationX = (document.all ? _event.clientX : _event.pageX);
		var resultLocationY = (document.all ? _event.clientY : _event.pageY);

		emailObject.style.display = '';
		emailObject.style.position = 'absolute';
		emailObject.style.top = resultLocationY - 200;
		emailObject.style.left = resultLocationX;
	}
	catch (emailToFriendException)
	{
		alert("Exception: EmailToFriend: " + emailToFriendException.message);
	}
}