(
function ()
	{
	function addEvent(objTgt, strEvt, objFun)
		{
		if(objTgt.addEventListener)
			objTgt.addEventListener(strEvt, objFun, false);
		else if(objTgt.attachEvent)
			objTgt.attachEvent("on" + strEvt, objFun);
		}

	addEvent(window, "load", startPage);
	
	function startPage()
		{
		createLogin();
		if(document.location.search.indexOf("ergerrno=1") > -1)
			{
			alert("Utente o password errati.");
			document.getElementById("txtUser").focus();
			}
		}
	
	function createLogin()
		{
		var objPar = document.getElementById("erglogin");
		var objFm;
		var objEl;
		
		// form
		
		objFm = document.createElement("form");
		objFm.id = "frmLogin";
		objFm.className = "erginput";
		objFm.method = "post";
		objFm.action = "ordini/chklgn.asp";
		objPar.appendChild(objFm);
		
		objEl = document.createElement("input");
		objEl.type = "text";
		objEl.className = "erginput";
		objEl.style.top = "30px";
		objEl.name = "txtUser";
		objEl.id = "txtUser";
		objEl.maxLength = 15;
		objFm.appendChild(objEl);
		
		objEl = document.createElement("input");
		objEl.type = "password";
		objEl.className = "erginput";
		objEl.style.top = "56px";
		objEl.name = "txtPass";
		objEl.id = "txtPass";
		objEl.maxLength = 15;
		objFm.appendChild(objEl);
		
		objEl = document.createElement("a");
		objEl.href = "javascript:void(0)";
		objEl.className = "ergbutton";
		addEvent(objEl, "click", doLogin);
		
		objFm.appendChild(objEl);
		}

	function doLogin()
		{
		var objFm = document.getElementById("frmLogin");
		
		if(objFm.txtUser.value == "")
			{
			alert("Inserire il nome di login.");
			objFm.txtUser.focus();
			return;
			}
		
		if(objFm.txtPass.value == "")
			{
			alert("Inserire la password.");
			objFm.txtPass.focus();
			return;
			}
		
		objFm.submit();
		}
	}
)();

