function checkLogin(logout)
{
	var handler = getAjaxHandler();
	if (handler) {
		//document.body.style.cursor = 'wait';
		handler.onreadystatechange = function () {
			if (handler.readyState != 4)
				return;
			//document.body.style.cursor = 'default';
			loginResult(handler);
			};
		handler.open('GET', '/cgi-bin/jsid' +
				(logout ? '?logout=1' : ''));
		handler.setRequestHeader('Connection', 'close');
		handler.send();
	}
	return false;
}

function loginResult(handler)
{
	if (handler.status == 200) {
		var res = '' + handler.responseText;
		if (res == '')
			document.getElementById('password').value = '';
		else
			document.getElementById('id').innerHTML = res;
		document.getElementById('login').style.display =
			res == '' ? 'block' : 'none';
		document.getElementById('logout').style.display =
			res == '' ? 'none' : 'block';
	}
}

function getAjaxHandler()
{
	var handler = null;
	try {
		handler = new XMLHttpRequest();
	}
	catch (e) { }
	try {
		if (handler == null)
			handler = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e) {
		try { handler = new ActiveXObject("Microsoft.XMLHTTP"); }
		catch (e) { }
	}
	return handler;
}

