/* $Id: Login.js,v 1.42 2009/09/25 11:06:31 gayathri Exp $ */

function showDialog()
{
    document.getElementById('showDomainDetails').style.visibility='visible';// No I18N
}

function closeDialog()
{
    document.getElementById('showDomainDetails').style.visibility='hidden';// No I18N
}

function encryptPassword(textPassword)
{
	var num_out = "";
	var str_in = escape(textPassword);
	for(i = 0; i < str_in.length; i++)
	{
		num_out += str_in.charCodeAt(i) - 23;
	}
	return num_out;
}

function decryptPassword(encPassword)
{
	var str_out = "";
	var num_out = encPassword;
	for(i = 0; i < num_out.length; i += 2)
	{
		num_in = parseInt(num_out.substr(i,[2])) + 23;
		num_in = unescape('%' + num_in.toString(16));// No I18N
		str_out += num_in;
	}
	var textPassword = unescape(str_out);
	return textPassword ;
}
// SD-11880 to list domain name(s) for local authentication, When user login as Local Authentication.
function checkLocalAuth(domainname)
{
	// SD-11880 checking to list domain name(s) for the user login as local authentication
	if(document.login.domain.value=="Local Authentication")
    	{	
       		 loadLocalAuthDomainNameList();
    	}
}
// SD-11880 Only for Local Authentication. Its listing domain name(s) from aaalogin table for the user to login as local authentication.
function loadLocalAuthDomainNameList()
{
	var reqName = document.login.j_username.value;
	if ((reqName!=null))
	{
        var dte = Date();
        url = "/domainServlet/AJaxDomainServlet?action=searchLocalAuthDomain&timestamp="+dte+"&search="+reqName;
        if (window.XMLHttpRequest)
        {
            req = new XMLHttpRequest();
            if(req)
            {
                try
                {
                    // sd-11880 waiting process state to list domain name(s) for AD User to login as Local Authentication.
                    req.onreadystatechange = processStateForLocalAuthDomain;
                    req.open("GET", url, true);//NO I18N
                } catch (e)
                {
                    alert(e);
                }
                req.send(null);
            }
        }
        else if (window.ActiveXObject)
        {
            try
            {
                req = new ActiveXObject("Msxml2.XMLHTTP");//NO I18N
            }catch(e)
            {
                //alert("ee "+e);
                req = new ActiveXObject("Microsoft.XMLHTTP");//NO I18N
            }

            if (req)
            {
                // sd-11880 waiting process state to list domain name(s) for AD User to login as Local Authentication.
                req.onreadystatechange = processStateForLocalAuthDomain;
                try
                {
                    req.open("GET", url, true);//NO I18N
                }catch(e)
                {
                    alert(e);
                }
                req.send(null);
            }
        }
	}
}
// sd-11880 To list domain name(s) for local authentication.listing domain name(s) from aaalogin table based on login name. Only for local authentication.Following user can login with this 1. Not in Domain for manually added user. 2. AD imported user can login as local Authentication. 3. User can login as local authentication when user imported using Ad and domain name(s) is deleted in domaininfo.
function processStateForLocalAuthDomain()
{
	if (req.readyState == 4) // if value is 4, then it is Ready State.
	{
		if (req.status == 200) // if 200 - success , returned with a object.
		{
			var value = req.responseText;
			if ((value!='null') && (value!="Not in Domain"))//sd-11880 don't show for domain name(s) list when no domain for the user.
			{
				var domainList=value;
				var mytool_array=domainList.split("|");//NO I18N
                                //sd-11880 domain list does not show if only one domain for the user.
				if(mytool_array.length==1)
				{
					domainLabel=document.getElementById("LocalAuthLabel");

					domainLabel.innerHTML="<input type='hidden' name='dlabel' readonly='true' value='"+mytool_array[0]+"'>";
					var doname=document.getElementById("LocalAuthdomainname");
					doname.innerHTML="<input type='hidden' name='dname' readonly='true' value='"+mytool_array[0]+"'>";
					document.forms['login'].DomainCount.value=1;
				}
				else // sd-11880 listing domain when more than a domain for the user.
				{
                    domainLabel=document.getElementById("LocalAuthLabel"); //NO I18N
                    //sd-11880 label to identify the local authentication.
                    domainLabel.innerHTML="<label><b><nobr>"+document.login.fordomain.value+"</nobr></b></label>";
                    var doname=document.getElementById("LocalAuthdomainname");
                    var innerHTMLContent="<select class='formStyle' style='width:180px;' name='dname'>";
                    for (var pos=0;pos<mytool_array.length;pos++)
                    {

                        innerHTMLContent=innerHTMLContent+"<option value="+pos+">"+mytool_array[pos]+"</option>";
                        document.forms['login'].DomainCount.value=pos+1;//NO I18N
                    }
                    doname.innerHTML=innerHTMLContent+"</select>&nbsp;<a href='javascript:void(0);' onClick='showDialog();'><img src='images/spacer.gif' align='absmiddle' class='helptool-icon-thumb' border='0' /></a>";//NO I18N
				}
			}
			else //sd-11880 to avoid For Domain list for local authentication when no domain for the user
			{
                document.forms['login'].DomainCount.value=0;
			}
		}
		else
		{
                    alert(getMessageForKey("sdp.login.domain.search")+" " + req.statusText);//No I18n
		}
	}
}

function loadDomainListForADLogin(username)
{
	// sd-11880 Only login for AD Authentication. Here checking AD enable is true And dynamic user addition is false. Listing domain name(s) based on aaalogin,sduser,domaininfo and the domain should be public.
	var reqName = username.value;
	if ((reqName!=null) && (document.login.AdEnable.value=='true') && (document.login.dynamicUserAddition_status.value=='false'))
	{
        var dte = Date();
        url = "/domainServlet/AJaxDomainServlet?action=searchDomain&timestamp="+dte+"&search="+reqName;//NO I18N
        if (window.XMLHttpRequest)
        {
            req = new XMLHttpRequest();
            if(req)
            {
                try
                {
                    // sd-11880 waiting process state to list domain name(s) for AD User to login as AD authentication.
                    req.onreadystatechange = processStateADDomain;
                    req.open("GET", url, true);//NO I18N
                } catch (e)
                {
                    alert(e);
                }
                req.send(null);
            }
        }
        else if (window.ActiveXObject)
        {
            try
            {
                req = new ActiveXObject("Msxml2.XMLHTTP");//NO I18N
            }catch(e)
            {
                //alert("ee "+e);
                req = new ActiveXObject("Microsoft.XMLHTTP");//NO I18N
            }

            if (req)
            {
                // sd-11880 waiting process state to list domain name(s) for AD User to login as AD authentication
                req.onreadystatechange = processStateADDomain;
                try
                {
                    req.open("GET", url, true);//NO I18N
                }catch(e)
                {
                    alert(e);
                }
                req.send(null);
            }
        }
	}
	else
	{
        if ((document.login.AdEnable.value=='false') && (document.login.LDAPEnable.value=='false'))
        {
            // sd-11880 listing domain name(s) when AD enbable is false. to list domain name from aaalogin.
            loadLocalAuthDomainNameList()
        }
	}

}
//sd-11880 listing domain name(s) for AD Imported User login as AD Authentication.
//20776,20795
function processStateADDomain()
{
	if (req.readyState == 4)
	{
		if (req.status == 200)
		{
			var value = req.responseText;
			if ((value=='null'))
			{
				if (document.login.localAuthEnable.value=='true') // sd-11880 The user is not in AD. local authentication will be added to domain list to user to select Local Authentication.
				{
					document.forms['login'].domain.options.length = 0;
					document.forms['login'].domain.options[0] = new Option(document.getElementById("LocalAuthentication").innerHTML,"Local Authentication");//NO I18N
					loadLocalAuthDomainNameList()
				}
				else
				{
					// sd-11880 -Domain not Found- when the user is not imported By AD and The local authentication is false.
					document.forms['login'].domain.options.length = 0;//NO I18N
					document.forms['login'].domain.options[0] = new Option(getMessageForKey("sdp.login.domain.not.found"),0);//No I18n
				}

			}
			else
			{
                // sd-11880 listing domain name(s) for AD authentication.
                var domainList=value;
                var mytool_array=domainList.split("|");//NO I18N
                document.forms['login'].domain.options.length = 0;
                document.forms['login'].domain.options[0] = new Option(document.login.choosedomain.value,0);//NO I18N

                var bolNotInDomain=false;
                for (var pos=0;pos<mytool_array.length;pos++)
			    {
					if (mytool_array.length==1) //sd-11880 the choose domain will be overwritten by the domain name when only one domain for the user.
					{
						document.forms['login'].domain.options[pos] = new Option(mytool_array[pos],pos);//NO I18N
					}
					else
					{
						document.forms['login'].domain.options[pos+1] = new Option(mytool_array[pos],pos+1);//NO I18N
					}
					document.forms['login'].DomainCount.value=pos+1;//NO I18N
                }
                if(document.login.localAuthEnable.value=='true') //sd-11880 Local Authentication won't show when Local authentication is false.
                {
                    if (mytool_array.length==1)//sd-11880 the choose domain will be overwritten by the domain name when only one domain for the user.
                    {
                        document.forms['login'].domain.options[pos] = new Option(document.getElementById("LocalAuthentication").innerHTML,"Local Authentication");//NO I18N
                    }
                    else
                    {
                        document.forms['login'].domain.options[pos+1] = new Option(document.getElementById("LocalAuthentication").innerHTML,"Local Authentication");//NO I18N
                    }
                }
			}


		}
		else
		{
                    alert(getMessageForKey("sdp.login.domain.search")+" " + req.statusText);//No I18n
		}
	}
}


function checkForNullInLogin(form)
{
	if(document.login.j_username.value == "" || document.login.j_password.value == "")
	{
		alert(document.getElementById("jserror").innerHTML);
		if(document.login.j_username.value=="")
		{
			document.login.j_username.focus();
		}
		else
		{
			document.login.j_password.focus();
		}
		return false;
	}
	var expDate = new Date();
	var thisCookie;
	if(document.login.checkbox.checked)
	{
		expDate.setTime(expDate.getTime()+(24*60*60*1000*365));
		document.cookie="username= "+document.login.j_username.value+";expires= "+((expDate).toGMTString());//NO I18N
		var textPassword = document.login.j_password.value ;
		var encPassword = encryptPassword(textPassword);
		document.cookie="password= "+ encPassword +";expires= "+((expDate).toGMTString());//NO I18N
        var sso = "true";//NO I18N
        document.cookie="singlesignon= "+ sso +";expires= "+((expDate).toGMTString());//NO I18N
	}
	else
	{
		expDate.setTime(expDate.getTime());
		document.cookie="username= "+document.login.j_username.value+";expires= "+((expDate).toGMTString());//NO I18N
		document.cookie="password= "+document.login.j_password.value+";expires= "+((expDate).toGMTString());//NO I18N
        document.cookie="singlesignon= 'false';expires= "+((expDate).toGMTString());//NO I18N
	}

	/*
	* Opertions to be performed for Domain List
	*/
	if (document.login.AdEnable.value=='true')
	{
		var domainList="";
		if (document.login.domain.value=="Local Authentication" || document.login.domain.value== "-- Choose --") //No internationalization
		{
			domainList =document.login.domain.value ;
		}
		else
		{
			domainList = document.login.domain.options[document.login.domain.value].text;
		}
		if((domainList!=""))
		{

			if((domainList == "") || (domainList==document.getElementById('choosedomain').value) || (domainList=="-- Choose --") || (domainList=="-Domain not Found-"))
			{
				alert(document.getElementById('choosedomain').value);
				document.login.domain.focus();
				return false;
			}
			if(document.login.checkbox.checked)
			{
				expDate.setTime(expDate.getTime()+(24*60*60*1000*365));
			}
			else
			{
				expDate.setTime(expDate.getTime());
			}
				var count=document.forms['login'].DomainCount.value;//NO I18N
		
			if (domainList=="Local Authentication")	
			{
			var varLocalAuthwithDomain;
			  if (count!=0)			
			    {
			  	if(count==1)
				{
			    		varLocalAuthWithDomain=document.login.dname.value;
				}
				else
				{
					varLocalAuthWithDomain=document.login.dname.options[document.login.dname.value].text;
				}
			     }
			  else
			     {
				   varLocalAuthWithDomain="Not in Domain";//NO I18N
			     }
			document.cookie="localAuthWithDomain= "+varLocalAuthWithDomain+";expires= "+((expDate).toGMTString());//NO I18N
			}
			document.cookie="domainname= "+domainList+";expires= "+((expDate).toGMTString());//NO I18N
		}
    // sd-11880 To login AD user. Domain_name is created when the user choose domain name. not in domain for login as local authentication.
		var domainvalue="";
		if (document.login.domain.value=="Local Authentication")
		{
			domainvalue =document.login.domain.value ;
		}
		else
		{
			domainvalue = document.login.domain.options[document.login.domain.value].text;
		}
		document.login.logonDomainName.value=domainvalue;
        //sd-11880 The domain list will be overwritten when dynamic user addition is false.
		if (document.login.dynamicUserAddition_status.value=='false')
		{
			if ((domainvalue!="Local Authentication")) //sd-11880 The user can login as AD authentication.
			{
				createDomain_NameForLogin(domainvalue);
				document.forms['login'].LocalAuthWithDomain.value=domainvalue;//NO I18N
			  	document.forms['login'].LocalAuth.value="No";//NO I18N
			}
			else
			{
				// sd-11880 The user can login as local authentication.
				var count=document.forms['login'].DomainCount.value;//NO I18N
				document.forms['login'].LocalAuth.value="yes";//NO I18N
				if(count==1)
				{
                    domainvalue=document.login.dname.value;

				}
				else
				{
					domainvalue=document.login.dname.options[document.login.dname.value].text;

				}

				//if (domainvalue!="Not in Domain")//sd-11880 No need to create domain_name for manually added user. if Not in domain shows in domain list, it means the user is added by manually.
				//{
					createDomain_NameForLogin(domainvalue);
					document.forms['login'].LocalAuthWithDomain.value=domainvalue;//NO I18N
				//}

			}
		}
		else
		{

			//sd-11880 Here domain name(s) added in domain list when Login.jsp is created. The user can login with AD authentication as well as local authenticaion.
			if(domainvalue!='Local Authentication') // sd-11880 When user login with AD Authentication.
		   	{
                createDomain_NameForLogin(domainvalue);
                document.forms['login'].LocalAuthWithDomain.value=domainvalue;//NO I18N
                document.forms['login'].LocalAuth.value='No';//NO I18N
		   	}
			else //sd-11880 When user login as local authentication.
			{

                var count=document.forms['login'].DomainCount.value;//NO I18N

                if (count!=0)
			    {
                    if(count==1)
                    {
			    		domainvalue=document.login.dname.value;
                    }
                    else
                    {
                        domainvalue=document.login.dname.options[document.login.dname.value].text;
                    }

                    //if (domainvalue!="Not in Domain") // sd-11880 domain_name will be created for local authentication with domain support.
                    //{
                        createDomain_NameForLogin(domainvalue);
                        document.forms['login'].LocalAuthWithDomain.value=domainvalue;//NO I18N
                        document.forms['login'].LocalAuth.value='No';//NO I18N
                    /*}
                    else
                    { // sd-11880 the user is added by manually.
                        document.forms['login'].LocalAuthWithDomain.value='No';//NO I18N
                        document.forms['login'].LocalAuth.value='yes';//NO I18N
                    }*/
			    }
			}
		}
	}
	//20405 unable to login via local authentication, if LDAP is enabled and also AD is imported.
	else if(document.login.LDAPEnable.value == 'true') 
	{
		if(document.login.checkbox.checked)
		{  
			expDate.setTime(expDate.getTime()+(24*60*60*1000*365));
   		  }
		else
		{   
			expDate.setTime(expDate.getTime());
		}

	        var count=document.forms['login'].DomainCount.value;//NO I18N
        	if (count!=0)
	        {
		  if(count==1)
            	  {
                     domainvalue=document.login.dname.value;
                  }
                  else
                  {
                      domainvalue=document.login.dname.options[document.login.dname.value].text;
                  }
                  //if (domainvalue!="Not in Domain") //sd-11880 the user is added using AD for login as local authentication with domain based.
                  //{
                     createDomain_NameForLogin(domainvalue);
                     document.forms['login'].LocalAuthWithDomain.value=domainvalue;//NO I18N
                     document.forms['login'].LocalAuth.value='No';//NO I18N
		     document.cookie="localAuthWithDomain= "+domainvalue+";expires= "+((expDate).toGMTString());//NO I18N
		     document.cookie="domainname=Local Authentication;expires= "+((expDate).toGMTString());//NO I18N
                  /*}
                  else //sd-11880 the user is added by manually for login as local authentication.
                 {
		     document.cookie="localAuthWithDomain=Not in Domain;expires= "+((expDate).toGMTString());//NO I18N
		     document.cookie="domainname=Local Authentication;expires= "+((expDate).toGMTString());//NO I18N
                     document.forms['login'].LocalAuthWithDomain.value='No';//NO I18N
                     document.forms['login'].LocalAuth.value='yes';//NO I18N
                 }*/
            }
	}
	else//sd-11880 only for local authentication.
	{
			if(document.login.checkbox.checked)
			  {  
				expDate.setTime(expDate.getTime()+(24*60*60*1000*365));
			  }
			  else
		   	  {   
				expDate.setTime(expDate.getTime());
			  }

        var count=document.forms['login'].DomainCount.value;//NO I18N
        if (count!=0)
        {

            if(count==1)
            {
                domainvalue=document.login.dname.value;
            }
            else
            {
                domainvalue=document.login.dname.options[document.login.dname.value].text;
            }
            //if (domainvalue!="Not in Domain") //sd-11880 the user is added using AD for login as local authentication with domain based.
            //{
                createDomain_NameForLogin(domainvalue);
                document.forms['login'].LocalAuthWithDomain.value=domainvalue;//NO I18N
                document.forms['login'].LocalAuth.value='No';//NO I18N
		document.cookie="localAuthWithDomain= "+domainvalue+";expires= "+((expDate).toGMTString());//NO I18N
		document.cookie="domainname=Local Authentication;expires= "+((expDate).toGMTString());//NO I18N
            /*}
            else //sd-11880 the user is added by manually for login as local authentication.
            {
		document.cookie="localAuthWithDomain=Not in Domain;expires= "+((expDate).toGMTString());//NO I18N
		document.cookie="domainname=Local Authentication;expires= "+((expDate).toGMTString());//NO I18N
                document.forms['login'].LocalAuthWithDomain.value='No';//NO I18N
                document.forms['login'].LocalAuth.value='yes';//NO I18N
            }*/
        }
	}


	/* ## To convert username to lowercase ## */
	document.login.username.value=document.login.username.value.toLowerCase();

	return true;
}

function setFocus(name)
{
    name.focus();
}

function getSSOCookie()
 {  
    document.login.j_username.value="";
    init = (document.cookie).indexOf("username");        
    if(init != -1 )
    {
        userlen = "username".length;//NO I18N
        beginIndex = ((document.cookie).indexOf("username")+userlen);        
        endIndex = (document.cookie).indexOf(";",beginIndex);
		if(endIndex == -1)
		{
			endIndex = (document.cookie).length;
		}
        username=(document.cookie).substring(beginIndex+1,endIndex);
        
        startIndex = ((document.cookie).indexOf("password")+"password".length);//NO I18N
        endInd = (document.cookie).indexOf(";",startIndex); 
        var encPassword=(document.cookie).substring(startIndex+1,endInd);
		password = decryptPassword(encPassword);
        
        var ssoStart = ((document.cookie).indexOf("singlesignon")+"singlesignon".length);//NO I18N
        var ssoEnd = (document.cookie).indexOf(";",ssoStart);
        if(ssoEnd == -1)
        {
            ssoEnd=(document.cookie).length;
        }
        var singlesignon = (document.cookie).substring(ssoStart+1,ssoEnd);
        
        document.login.j_username.value=username;
        document.login.j_password.value=password;
        document.login.checkbox.checked=false;
	
		/**********
		*  If domainList is available, cookie will be set 
		************/
		domainList = document.login.domain;
		if(domainList!=null)
		{
			domainStartIndex = ((document.cookie).indexOf("domainname")+"domainname".length);//NO I18N
			domainEndIndex = (document.cookie).indexOf(";",domainStartIndex);
			
			if(domainEndIndex == -1)
			{
				domainEndIndex=(document.cookie).length;
			}
			domain=(document.cookie).substring(domainStartIndex+1,domainEndIndex);
			if (domain=="Local Authentication")
			{	
				localDomainStartIndex = ((document.cookie).indexOf("localAuthWithDomain")+"localAuthWithDomain".length);//NO I18N
				localDomainEndIndex = (document.cookie).indexOf(";",localDomainStartIndex); //NO I18N
				
				if(localDomainEndIndex == -1)
				{
					localDomainEndIndex=(document.cookie).length;
				}	
				localAuthDomain=(document.cookie).substring(localDomainStartIndex+1,localDomainEndIndex);
				if (localAuthDomain=="Not in Domain")
				{
				document.forms['login'].LocalAuthWithDomain.value="No";//NO I18N
				document.forms['login'].LocalAuth.value='Yes';//NO I18N
				}
				else
				{
				document.forms['login'].LocalAuthWithDomain.value=localAuthDomain;//NO I18N
				createDomain_NameForLogin(localAuthDomain);
			        document.forms['login'].LocalAuth.value='Yes';//NO I18N
				}
				
			}
			var domainCount = domainList.length;
			for(i=0; i<domainCount; i++)
			{
				var data="";
				if (document.login.domain.options[i].value=="Local Authentication")
					{
						data="Local Authentication";//NO I18N
					}
			        else
				{	
					data = document.login.domain.options[i].text;	
				}
				if(data == domain)
				{
				   
				   if (data!="Local Authentication")	
			           {
				   createDomain_NameForLogin(domain);
				   }   
				   document.login.logonDomainName.value=data;	
				   document.login.domain.options[i].selected = true;
				   break
				}
			}
		}
		else
		{
				localDomainStartIndex = ((document.cookie).indexOf("localAuthWithDomain")+"localAuthWithDomain".length);//NO I18N
				localDomainEndIndex = (document.cookie).indexOf(";",localDomainStartIndex); 
				
				if(localDomainEndIndex == -1)
				{
					localDomainEndIndex=(document.cookie).length;
				}	
				
				localAuthDomain=(document.cookie).substring(localDomainStartIndex+1,localDomainEndIndex);
				//SD-13897 Checking for manually added user. After clear the cookies localauthwithDomain is cleard.
				if ((localAuthDomain=="Not in Domain") || ((document.cookie).indexOf("localAuthWithDomain")==-1))
				{
				document.forms['login'].LocalAuthWithDomain.value="No";//NO I18N
				document.forms['login'].LocalAuth.value='Yes';//NO I18N
				}
				else
				{
				document.forms['login'].LocalAuthWithDomain.value=localAuthDomain;//NO I18N
				createDomain_NameForLogin(localAuthDomain);
			        document.forms['login'].LocalAuth.value='Yes';//NO I18N
				}
		}
		//************ End of DomainList Operation
        if(singlesignon=="true" && username!="" && password!="")
        {
            document.login.checkbox.checked=true;
            document.login.submit();
		
        }
    }
    else
    {
       //document.login.j_username.focus();
    }
}
// sd-11880 DOMAIN_NAME will be created for AD authentication and local authentication with domain based. No need to create the domain_name object for user added by manually.
function createDomain_NameForLogin(domainvalue)
{
    if(domainvalue != null && domainvalue == 'Not in Domain')//NO I18N
    {
	    domainvalue = "-";//NO I18N
    }
    var doname=document.getElementById("domainname");
    var DOMAINNAME=document.createElement("input");
    DOMAINNAME.setAttribute("name","DOMAIN_NAME");//NO I18N
    DOMAINNAME.setAttribute("type","hidden");//NO I18N
    DOMAINNAME.setAttribute("value",domainvalue);//NO I18N
    doname.appendChild(DOMAINNAME);
}
function getCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while(i < clen) {
		var j = i + alen;
		if(document.cookie.substring(i, j) == arg){
			return getCookieValue(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0) {
            break;
		}
	}
	return null;
}

getCookieValue = function (name) {
	var len = name.length;        
	var index = (document.cookie).indexOf(name);
	if (index == -1) {
		return null;
	}
	var beginIndex = index+len;
	var endIndex = (document.cookie).indexOf(";",beginIndex);         
	return (document.cookie).substring(beginIndex+1,endIndex);
}

function deleteCookie(name){
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = getCookie(name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();//NO I18N
}

function hideLoginInfo() {
	window.open("sd/HideLogin.sd", "LoginInfo");//NO I18N
	document.getElementById("loginInfo").style.display = 'none';//NO I18N
}

function loadLogin(isSSOEnabled) {
	if(!isSSOEnabled) {
		getSSOCookie();
		domainList = document.login.domain;
		if(domainList!=null) {
			var domainCount = domainList.length;
			if(domainCount==3) {
				domainList[1].selected = true;
				hideDomainList();
			}
			else {
				var cookieDomain = document.login.domain.selectedIndex;
				if(cookieDomain != 0 && loginError != "true"){
					hideDomainList();
				}
			}
		}
	}
	else {
		if( logged_user != null && logged_domain != null ) {
			logged_user = logged_user.toLowerCase();
			document.login.j_username.value = logged_user;
			document.login.j_password.value = '********' ;
			document.login.logonDomainName.value = logged_domain;
			createDomain_NameForLogin(logged_domain);
			//Method changed to get since sso was not working in IE
			document.login.method = "get";//NO I18N
			document.login.submit();
		}
	}
}

function hideShowDomainList() {
	if(document.getElementById("domainListSelect").style.display=="block") {
		hideDomainList();
	}
	else {
		showDomainList();
	}
}

function hideDomainList() {
	var selectedDomain = document.login.domain.selectedIndex;
	document.getElementById("domainListText").style.display="none";//NO I18N
	document.getElementById("domainListBlankText").style.display="block";//NO I18N

	document.getElementById("domainListSelect").style.display="none";//NO I18N
	document.getElementById("domainListBlankSelect").style.display="block";//NO I18N

	var optionMsg = document.getElementById("moreOptionsMsg").innerHTML + " &gt;";//NO I18N
	document.getElementById("optionMsg").innerHTML = optionMsg;//NO I18N
}

function showDomainList() {
	document.getElementById("domainListText").style.display="block";//NO I18N
	document.getElementById("domainListBlankText").style.display="none";//NO I18N

	document.getElementById("domainListSelect").style.display="block";//NO I18N
	document.getElementById("domainListBlankSelect").style.display="none";//NO I18N

	var optionMsg ="&lt; " +  document.getElementById("moreOptionsMsg").innerHTML;//NO I18N
	document.getElementById("optionMsg").innerHTML = optionMsg;
}

function ShowHide(divId) {
	var id = document.getElementById(divId);
	if (id.style.display == "none") {
		id.style.display = 'block';//NO I18N
	}
	else {
		id.style.display = 'none';//NO I18N
	}
}
