// Changes input field background color in IE
hiLite = function()
{	
	// Parent element ID
	formRoot = document.getElementById ("lukko_form");
	for (i = 0; i < formRoot.childNodes.length; i++)
	{
		node = formRoot.childNodes[i];	
		// Child elements to modify
		if (node.nodeName == "INPUT" || node.nodeName == "TEXTAREA" || node.nodeName == "SELECT")
		{
			// Focus
			node.onfocus = function()
			{
				// Style declarations here
				this.style.backgroundColor = "#f5f6be";
			}
			// Blur
			node.onblur = function()
			{
				// Style declarations here
				this.style.backgroundColor = "#ebeaea";
			}
		}
	}
}

// Shows/hides dropdown submenus in IE
startList = function()
{
	// Parent element ID
	navRoot = document.getElementById ("navi");
	for (i  =0; i < navRoot.childNodes.length; i++)
	{
		node = navRoot.childNodes[i];	
		// Child element to modify
		if (node.nodeName=="LI")
		{
			// MouseOver
			node.onmouseover = function()
			{
				// Style class name declaration
				this.className += " over";
			}
			// MouseOut
			node.onmouseout = function()
			{
				// Style class name declaration
				this.className = this.className.replace (" over", "");
			}
		}
	}
}

// Required functions on window load
initFunctions = function()
{
	if (document.all&&document.getElementById)
	{
		startList();
		hiLite();
	}
}

//window.onload = initFunctions;

window.onload = function ()
{
	setTimeout("initFunctions()", 250);
}

function checkFormFields(formID)
{
  var f = document.forms[formID];
  if ( ! f ) return;
  var required_fields = new Array(
    "etunimi",
    "sukunimi",
    "puhelin",
    "yritys",
    "katuosoite",
    "postinumero",
    "postiosoite",
    "tyokatuosoite",
    "tyopostinumero",
    "tyopostiosoite",
    "tyokuvaus"
  );
  for (i = 0; i < required_fields.length; i++)
  {
    if (f.elements[required_fields[ i ]].value == "")
    {
      alert('Täytä kaikki vaaditut kentät');
      return false;
    }
  }
  return true;
}
