	
	var login = {
		errorMsg: "",
		duplicateMsg: "",
		start: function()
		{
			if(window.XMLHttpRequest)
				xmlhttp = new XMLHttpRequest();
			else if(window.ActiveXObject)
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			else
				return false;
			
			linklm = document.getElementById("loginLink")
			statlm = document.getElementById("statusLine")
			with(linklm.style){
				visibility = "hidden"
				position = "absolute"
			}
			with(statlm.style){
				position = "static"
				visibility = "visible"
			}
			
			xmlhttp.open("GET", document.location.pathname + "?ajaxWEBsysLogin=getHash", true);
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState == 4)
					if (xmlhttp.readyState)
						login.logging(xmlhttp.responseText);
			}
			xmlhttp.send(null);
		},
		logging: function(hash)
		{
			if(window.XMLHttpRequest)
				xmlhttp = new XMLHttpRequest();
			else if(window.ActiveXObject)
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			else
				return false;
			xmlhttp.open("POST", document.location.pathname + "?ajaxWEBsysLogin=auth", true);
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState == 4)
					if (xmlhttp.readyState)
					{
						if (xmlhttp.responseText)
						{
							if (xmlhttp.responseText == 'failed')
							{
								login.doOverlay(login.errorMsg);
							}
							else if (xmlhttp.responseText == 'duplicated')
							{
								login.doOverlay(login.duplicateMsg);
							}
						}
						else
						{
							location.reload();
						}
					}
			}
			xmlhttp.send(hex_md5(hash + hex_md5(document.getElementById('wsPassword').value))+document.getElementById('wsUserName').value);
		},
		reload: function()
		{
			if(window.XMLHttpRequest)
				xmlhttp = new XMLHttpRequest();
			else if(window.ActiveXObject)
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			else
				return false;
			xmlhttp.open("GET", document.location.pathname + "?ajaxWEBsysLogin=reload", true);
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState == 4)
					if (xmlhttp.readyState)
						login.reloadFinish();
			}
			xmlhttp.send(null);
		},
		reloadFinish: function()
		{
			document.getElementsByTagName("body").item(0).removeChild(document.getElementById("overlay"));
			document.getElementsByTagName("body").item(0).removeChild(document.getElementById("overlayBox"));
		},
		logout: function()
		{
			location.href = document.location.pathname + "?logout=1";
		},
		doOverlay: function (str)
		{
			with(document.getElementById("statusLine")){
				style.visibility = "hidden";
				style.position = "absolute";
			}
			with(document.getElementById("logIn")){
				style.visibility = "hidden";
				style.position = "absolute";
			}
			with(document.getElementById("loginError")){
				style.visibility = "visible";
				style.position = "static";
				innerHTML = str;
			}
			
			button = document.getElementById("confirmButton");
			if(button) button.focus();

			/*
			var objBody = document.getElementsByTagName("body").item(0);
			var objOverlay = document.createElement("div");
			objOverlay.setAttribute('id','overlay');
			objBody.appendChild(objOverlay);
			
			var objOverlayBox = document.createElement("div");
			objOverlayBox.setAttribute('id','overlayBox');
			var objBox = document.createElement("div");
			objBox.innerHTML = str;
			objOverlayBox.appendChild(objBox);
			objBody.appendChild(objOverlayBox);
			
			//patch, hogy menjen az oldal tetejére
			document.location.href = '#';
		 	*/
		}
	}
	