<!--

/********************************/
function validateLogin()
{
	var li_login_return_code;
	var ls_userid = userid.value;
	var ls_password = password.value;
	var ls_cookies_enabled = "N";
	var li_MSAK_flag = -1;
	var ls_MSAK_cookie = "";
	var lobj_wfx_dom = new wfxDom();
	
	if (ls_userid == null || ls_userid == "")
	{
		alert("Please enter a valid user-id to log into the application.");
		setFocus(userid);
		return;
	}
	
	if (ls_password == null || ls_password == "")
	{
		alert("Please specify a password to login into the application.") ;
		setFocus(password);
		return;
	}
	// create window name for cache - the name is a GUID unique value	
	if (window.name == "")
	{
		window.name = createNodeGUID();
	}

	lobj_wfx_dom.addParam("Action", 8, "LOGIN");
	lobj_wfx_dom.addParam("userid", 8, ls_userid);
	lobj_wfx_dom.addParam("password", 8, ls_password);
	lobj_wfx_dom.addParam("cookies", 8, CookiesEnabled() ? "Y" : "N" );

	if ( lobj_wfx_dom.retrieveData("wfx_ret_login.asp", true) == null )
	{
		divMessage.innerHTML = "Exception was encountered. Unable to log in.";
		return;
	}

	
	if (lobj_wfx_dom.getErrorCount() > 0)
	{
		lobj_error_handler = new wfxErrorHandler();
		lobj_error_handler.checkErrors(lobj_wfx_dom.domObj);
		return;
	}
	
	li_login_return_code = lobj_wfx_dom.getValue("login_return_code");
	
	if (li_login_return_code <= 0)
	{
		ls_set_focus = lobj_wfx_dom.getValue("login_set_focus");
		ls_additional_message = lobj_wfx_dom.getValue("login_additional_message");
		setFocus(eval(ls_set_focus));
		divMessage.innerHTML = ls_additional_message;
	}
	else
	{
		divMessage.innerHTML = "";
				
		li_MSAK_flag = lobj_wfx_dom.getValue( "MSAK_flag" );
		
		if ( li_MSAK_flag > 0 )
		{
			ls_MSAK_cookie = lobj_wfx_dom.getValue( "MSAK_cookie" );
			SetCookieDirect( ls_MSAK_cookie );
			lobj_wfx_dom.deleteValue( "MSAK_cookie" );
		}
	
		successfulLogin(li_login_return_code, lobj_wfx_dom);
	}
	
	lobj_wfx_dom = null;
	
}
/********************************/
function setFocus(el)
{
	el.focus();
}
/********************************/
function successfulLogin(ai_login_return_code, aobj_wfx_dom)
{
	var lobj_wfx_dom;
	
	if (window.opener == "" || window.opener == null)
	{
		IncomingPageXML.loadXML( aobj_wfx_dom.getXML() );
		// create the window name which will be used by the caching mechanism, the name has
		// to be unique and will be GUID
		ls_window_name = createNodeGUID();
		if(ai_login_return_code == 1)
		{
			//window.open("startpage.htm", ls_window_name, "Top=0, Left=0, Height=600, Width=800, location=no, menubar=no, toolbar=no, status=yes");
			window.open("startpage.htm", ls_window_name, "Top=0, Left=0, Height=692, Width=1014, location=no, menubar=no, toolbar=no, status=yes");
		}	
		else
		{
			//window.open("tsi_uie_license_agreement.htm", ls_window_name, "Top=0, Left=0, Height=600, Width=800, location=no, menubar=no, toolbar=no, status=yes");
			window.open("tsi_uie_license_agreement.htm", ls_window_name, "Top=0, Left=0, Height=692, Width=1014, location=no, menubar=no, toolbar=no, status=yes");
		} 
	}  		
	else
	{
		var ls_page_name;
		
		if( ai_login_return_code == 1 )
		{
			ls_page_name = "startpage.asp";
		}
		else
		{
			ls_page_name = "tsi_uie_license_agreement.asp";
		}	
		
		aobj_wfx_dom.sendDataForm("POST", ls_page_name);	
	}
}
/********************************/
function resetPage()
{
	userid.value = "";
	password.value = "";
	divMessage.innerHTML= "";
	IncomingPageXML.loadXML("");
	setFocus(userid);
}
/********************************/
function keyPress()
{
	if ( document.activeElement.id == "butSubmit" )
	{
		return;
	}
	
	if ( window.event.keyCode == 13 )
	{
		validateLogin() ;
	}	
}
/********************************/

//-->
