/*
	Tyco Login JAVASCRIPT settings and functions
	Author: Eytan Chen
	Published: January 2008
	all rights reserved to Tyco Interactive ltd.
	http://www.tyco.co.il
*/

function checkLogin(cForm)
{
	if (cForm.userNamelog.value == username_t || cForm.passwordlogin.value == "")
	{
		alert(_login_userandpass);
		if(cForm.userNamelog.value == username_t)
			cForm.userNamelog.focus();
		else if(cForm.passwordlogin.value == "")
			cForm.passwordtxt.focus();
	}
	else
	{
		// ajax check login
		var url = "tyco_login.ajax.php?logMember=true&userName="+cForm.userNamelog.value+"&password="+cForm.passwordlogin.value+"&cstType="+cForm.cstType.value;
		var xml = LoadXML(url);
		if(xml != null)
		{
			if (xml.getElementsByTagName('login')[0].firstChild.data == "logged"){
				location.reload();
			}
			else
			{
				var message = xml.getElementsByTagName('rsp')[0].firstChild.data;
				alert (message);
				cForm.userNamelog.focus();
			}
		}
	}
	return false;
}

function getHTTPObject()
{
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	try { return new XMLHttpRequest(); } catch(e) {}
	alert("XMLHttpRequest not supported");
	return null;
 }

function LoadXML(url)
{
	var xmlHttp = getHTTPObject();
	xmlHttp.open("GET",url, false);
	xmlHttp.onreadystatechange = function()
	{
		   if (xmlHttp.readyState != 4)  { return; }
		   var serverResponse = xmlHttp.responseText;
	};
	xmlHttp.send(null);
	return xmlHttp.responseXML.documentElement;
}