function placeFocus() 
{
	if (document.forms.length > 0) 
	{
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) 
		{
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea")) 
			{
				document.forms[0].elements[i].focus();
				break;
			}
		}
	}
	getRelatedArticles();
}

function quickEnter(keypressed)
{
	var key;
	if (document.all)
	{ 
		key=window.event.keyCode;
		//alert (key);
	}
	else
	{ 
		key=keypressed.which;
};

	if (key==13)
	{ 
		//If I use this I add an extra cycle through the Page_Init and Load event handlers:
		//document.getElementById("_ctl0:ibtnGo").click();  
		document.Form1.submit();
	}
}

function getRelatedArticles() {
    var kw = document.getElementById("metaKeywords").content;
    var oXmlHttp = zXmlHttp.createRequest();

    if(kw != "") {
		oXmlHttp.open("get", "/relatedarticlesresults.aspx?kw=" + kw + "&ref=" + document.location.href, true);
		oXmlHttp.onreadystatechange = function () {
			if (oXmlHttp.readyState == 4) {
				if (oXmlHttp.status == 200) {
					displayresults(oXmlHttp.responseText.match('<div id=\"googleresults\">([^`]*?)<\/div>')[0]);
				} else {
					displayresults("An error occurred: " + oXmlHttp.statusResults); //statusResults is not always accurate
				}
			}            
		}
		oXmlHttp.send(null);
	}	
	else {
		displayresults("<p>No keywords are set for this article.</p>");
	};	
}

function displayresults(sResults) {
    var divResults = document.getElementById("googleresults");
    if(divResults) {
		divResults.innerHTML = sResults;
	}
}