	//init required vars for encryption functions
	var now = new Date();
	var yName = now.getYear();
	var mName = now.getMonth();
	var dName = now.getDate();
	var todaysDate = mName+dName+yName;
	var varSeed = todaysDate % 10;
	
	function openSite(SiteType,UserID,Password,Account)
	{
		window.open ("http://"+SiteType+"?Option=2&username="+UserID+"&password="+encode(Password,varSeed)+"&account="+Account+"&datetime="+varSeed+"&URL=http://www.rrd.com/xsDemos/XSLogoff.asp");
	}
	
	function OpenWin(WinName,WinHeight,WinWidth) {
		Win = window.open(WinName, 'OpenWin', 'height=' + WinHeight + ',width=' + WinWidth + ',top=100,left=100,menubar=no,location=no,directories=no,fullscreen=no,resizable=yes,scrollbars=yes,status=no,toolbar=no')
		Win.focus();	
	}
	
	function encode (OrigString, CipherVal)
	{
        Ref="0123456789abcdefghijklmnopqrstuvwxyz._~ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        CipherVal = parseInt(CipherVal)
        var Temp=""
        for (Count=0; Count < OrigString.length; Count++) {
                var TempChar = OrigString.substring (Count, Count+1)
                var Conv = cton(TempChar)
                var Cipher=Conv^CipherVal
                Cipher=ntoc(Cipher)
                Temp += Cipher
        }
        return (Temp)
	}
	
	function cton (Char)
	{
        return (Ref.indexOf(Char));
	}

	function ntoc (Val)
	{
        return (Ref.substring(Val, Val+1))
	}
	
	function login2(sitetype,userid, password, account, seedin, optionalParms)
	{
	alert('hello')
	var epassword = MWJSCrypt(password, seedin);
	
	var requiredparm = "&account="+account;
	if (sitetype == "demo") {
		var urlRoot = "http://xsdemo.moorewallace.com/xs2/";
	}
	else {
		var urlRoot = "http://xs.moorewallace.com/xs2/";
	}
		var link = urlRoot+
	               "?Option=2&username="+userid+
	               "&password="+epassword+
	               requiredparm+
	               "&datetime="+seedin+
	               optionalParms;
	
	window.open (link);
	}
	
	
	function MWJSCrypt (OrigString, SeedIn) {

	// ----------- DO NOT EVER change the value of "Ref" ----------- //
    Ref="0123456789abcdefghijklmnopqrstuvwxyz._~ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 	// ----------- DO NOT EVER change the value of "Ref" ----------- //
  	
    var CipherVal = parseInt(SeedIn);// converts SeedIn to an integer value
    if ( isNaN(CipherVal)) 
    {    // error if SeedIn is not a number.
         document.writeln("<b>*** Error!! ***</b><br/>function MWJScrpyt parameter("+SeedIn+") is not a number.");
         throw new Error("function MWJScrpyt parameter("+SeedIn+") is not a number.");
         return("");
    } else { if ( (CipherVal < 1) || (CipherVal > 99999999)) 
    {
        // error if SeedIn is not a number.
         document.writeln("<b>*** Error!! ***</b><br/>function MWJScrpyt parameter("+SeedIn+") seed range error.");
         throw new Error("function MWJScrpyt parameter("+SeedIn+") seed range error.");
         return("");    }
		     else {
		         var Temp="";
		         for (Count=0; Count < OrigString.length; Count++) {
		                 // loops until end of password
		                 var TempChar = OrigString.substring (Count, Count+1); //get 1 char
		                 var Conv = Ref.indexOf(TempChar); // returns index of ref                 
		                 var Cipher=Conv^CipherVal; // logical 'or'
		                 var NewCipher = Cipher % Ref.length; // mod by length of Ref
		                 Cipher=Ref.substring(NewCipher, NewCipher+1) ;// call to function                 
		                 Temp += Cipher;// adds the new chars one by one
		         }
		         return (Temp);// returns the encrypted password
		     }
	}	     
 }
	
	//var dispform = strReplace(strReplace(form,'>','&gt;'),'<','&lt;');
	
	function strReplace(str1, str2, str3) { 
	  while(str1.indexOf(str2) != -1) {
	   str1 = str1.replace(str2, str3);
	 } 
	  return str1;     
	} 
	//-- end script -->