
//
//	functions.js
//
//	$Id: functions.js,v 1.3 2008/03/17 00:51:30 simon Exp $
//

function findFormField(form, name)
{
    var elements = form.elements;
    for (var i=0; i<elements.length; i++)
    {
	if (elements[i].name == name)
	{
	    return elements[i];
	}
    }
    return null;
}

function getElement(doc, name)
{
    if (doc.getElementById)
    {
	return doc.getElementById(name);
    }
    if (doc.all)
    {
	return doc.all[name];
    }
    if (doc.layers)
    {
	return doc[name];
    }
    return null;
}

function openExampleClover(type)
{
    window.open("exampleClover.php?example=" + type, "image",
              "toolbar=no,resizable=yes,scrollbars=yes,width=400,height=500");
}

function focusNextError(field)
{
    field.focus();
}

function gotoNextError(fieldName)
{
    var field = findFormField(document.myForm, fieldName);
    location = "#hash_" + fieldName;
    focusNextError(field);
}

function openGoodPasswordWindow()
{
    window.open("/goodPassword.php", "goodPassword",
	    "height=400,width=500," +
	    "menubar=no,scrollbars=yes,toolbar=no,status=no,resizable=yes");
    return false;
}

