function initFieldVals()
{
for (i=1;i<6;i++)
	{
	eval("document.f" + i + ".el" + i + ".value=getCookie('goo_el" + i + "');")
	}
for (i=7;i<37;i++)
	{
	eval("document.f" + i + ".el" + i + ".value=getCookie('goo_el" + i + "');")
	}
document.fo6.elo6.value=getCookie('goo_elo6');
}

function setUpOnSubmits()
{
	if (document.getElementsByTagName)
	{
	//loop through all form elements
	var formEl = document.getElementsByTagName("form");
	for (i=0;i<formEl.length;i++)
		{
		//if the form is named, grab the name attribute - we'll use that in a mo 
		if(formEl[i].name.length>0)
			{
			var thisFormId = formEl[i].name.split("f");
			thisFormId = thisFormId[1];
			eval("formEl[i].onsubmit = function() { setCookie('goo_el" + thisFormId + "', document.f" + thisFormId + ".q.value);return true;}")
			}
		}
	}
}

function checkWindow()
{
if (window.parent!=window)
	location.href = 'http://en.wikipedia.org/wiki/Google';
}

//load the form updates on page load, unobtrusively
addEvent(window, 'load', initFieldVals, false);

//attach the onsubmit behaviors, unobtrusively
addEvent(window, 'load', setUpOnSubmits, false);

//make sure we're in the right window
addEvent(window, 'load', checkWindow, false);
