


function CheckOS()
{
/* document.write("OS: " + navigator.platform + "<BR>");*/

os = navigator.platform.substr(0,3);

if (os != "Win" && os != "Mac") 
		{
		alert ("Our Eastman website works best with a Windows Operating System or a Macintosh System.")
		}
else
	     {
		    browsername = navigator.appName.substr(0,5);

		    if (browsername != "Micro") 
			  {
			   alert("Our Eastman website works best with Microsoft  Internet Explorer  version 5.0 or higher. Using any other browser may give unexpected results.")
			  } 
		}
}


function updateParent(newURL){

 opener.location.href = newURL

 }

/*******************************************************************************
' Function Name		FormValidation 
'
' Description		This function handles the validation of the form controls
'			and submits the user credentials .				
'
' Modification Log
'
'       Date                Author                           Modification 
'    04-Apr-2005   Jacob Eapen,Infosys Tech Ltd.             Initial Version
'*******************************************************************************/

function FormValidation (obj,cookieDomain,CustomerCenterURL)

{

	var browserName = navigator.appName

	//-- cookieEnabled only works in MSIE.

	if (browserName=="Microsoft Internet Explorer")

	{

		if (navigator.cookieEnabled==false)

		{

			alert("Your web browser must have cookies enabled to login to the Customer Center.");

			document.getElementById(obj+"txtUserName").value = "";

			document.getElementById(obj+"txtPassword").value = "";

			document.getElementById(obj+"txtUserName").focus();

			return false;

		}

	}  



	if (fnTrimString(document.getElementById(obj+"txtUserName").value) == "")

	{

		alert ("Please enter your UserID.");

		document.getElementById(obj+"txtUserName").focus ();

		return false;

	}



	if (fnTrimString(document.getElementById(obj+"txtPassword").value) == "")

	{

		alert ("Please enter your Password.");

		document.getElementById(obj+"txtPassword").focus ();

		return false;

	}



	if (document.getElementById(obj+"txtUserName").value.length > 20)

	{

		document.getElementById(obj+"txtUserName").value = "";

		document.getElementById(obj+"txtPassword").value = "";

		document.getElementById(obj+"txtUserName").focus();

		return false;

	}



	fnSetCookie(obj,cookieDomain);
	document.frmHomePage.USER.value = document.getElementById(obj+"txtUserName").value;
	document.frmHomePage.PASSWORD.value = document.getElementById(obj+"txtPassword").value;
	document.frmHomePage.CustURL.value = CustomerCenterURL;
	
	var CCWindow = window.open('OpenCustCenter.asp');
	if (!CCWindow)
		alert('Please disable the popup blocker to open up the Customer Center');
	else
		setTimeout('refresh()',3000);
	return false;
}

function fnLogout (sCustomerCenterURL, sLogoutURL)
{
	var logoutWindow = window.open(sCustomerCenterURL + sLogoutURL);
	if (!logoutWindow)
		alert('Please disable the popup blocker temporarily');
	setTimeout('refresh()',3000);
	//logoutWindow.close();
}

function refresh()
{
	window.location.href = window.location.href;
}

function encrypt(text) {

	return rsaEncode([17],[148299941,57683965,5687041],text)

}

function GetCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
		return unescape(aCrumb[1]);
	}

	// a cookie with the requested name does not exist
	return null;
}


function fnSetCookie(obj,cookieDomain){

	var intCtrValue

	strDomain = cookieDomain;


	intCtrValue = GetCookie("LoginCount");
	if (intCtrValue == null)
		{intCtrValue = 0}
	intCtrValue = parseInt(intCtrValue)
	intCtrValue = intCtrValue + 1

	strNameValue = document.getElementById(obj+"txtUserName").value;

	strPasswordValue = document.getElementById(obj+"txtPassword").value;

	//strPasswordValue = rc4encrypt("eastman",strPasswordValue);



	strText = strNameValue + ";" + strPasswordValue;

	strEnc = encrypt(strText);

	document.cookie = "Creds="+ escape(strEnc) + "; " +
	"; path=" +
	"; domain=" + strDomain + "; " + "secure";



	document.cookie = "USERID="+ escape(strNameValue) + "; " +
	"; path=" +
	"; domain=" + strDomain + "; "+"secure";


	document.cookie = "LoginCount="+ escape(intCtrValue) + "; " +
	"; path=" +
	"; domain=" + strDomain + "; "+"secure";

	document.cookie = "BLCOUNTER=" + escape(1) +
	"; path=" +
       "; domain=" + strDomain + "; "+"secure";



	return false;

}




/*******************************************************************************
' Function Name		fnSetCtrlEnterClick
'
' Description		This function handles the enter key press. If enter key is 
'					pressed, it calls the formvalidation function
'
' Modification Log
'
'       Date                Author                           Modification 
'    04-Apr-2006   Jacob Eapen,Infosys Tech Ltd.             Initial Version
'    13-oct-2006   Jacob Eapen,Infosys Tech Ltd.	     modified to work with non-IE browsers
'*******************************************************************************/

function fnSetCtrlEnterClick(obj,cookieDomain,CustomerCenterURL)
{
	
	  if (document.getElementById(obj+"txtUserName").value != "" || document.getElementById(obj+"txtPassword").value !="")
	{
	//call the formvalidation function	
	FormValidation(obj,cookieDomain,CustomerCenterURL);
	}

}

function fnTrimString(str)
	 {
		var x;
		var TrimmedString = new String("");
		x=0;
		while(str.charAt(x) == ' ') x++;
		for(;x<str.length;x++) {
			TrimmedString = TrimmedString + str.charAt(x);
		}
		str = TrimmedString;
		TrimmedString = "";
		x=str.length-1;
		while(str.charAt(x) == ' ') x--;
		for(var y=0;y<=x;y++) {
			TrimmedString = TrimmedString + str.charAt(y);
		}
		return TrimmedString;
	}