		var loginId = readCookie('loginId');
		var handle = readCookie('handle');
		var nydnssocookie = readCookie('NYDNSsoCookie');

		//login cookie is present
		if(loginId && handle){
			writeUserDetails(true);
		//check to see if user is logged on - pull the values from the NYDNSsoCookie
	    }else{
			if(nydnssocookie){
				readNYDNSsoCookie(decode64(nydnssocookie));
				writeUserDetails(true);
			}else{
				writeUserDetails(false);
			}
		}

		function writeUserDetails(loggedIn){
			document.write('<ul id="profile">');
			if(loggedIn){
			  document.write('<li><a href="/nydn/logout.do" rel="nofollow">Log-Out</a></li>');
  			  document.write('<li><a href="/nydn/content/protected/userAccount.jsp" rel="nofollow">Your Profile</a></li>');
			  document.write('<li class="nydn-last">Welcome, '+handle+'</li>');
			}else{
			  document.write('<li><a href="/nydn/form/login.jsp" rel="nofollow">Login</a></li>');
			  document.write('<li class="nydn-last"><a href="/nydn/form/register.jsp" rel="nofollow">Register</a></li>');
			}
			document.write('</ul>');
		}

		function readNYDNSsoCookie(cookie){
			var ca = cookie.split(';');
			loginId = ca[0].substring('loginId='.length,ca[0].length);
			handle = ca[5].substring('handle='.length,ca[5].length);
		}

		function decode64(input) {
		   var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
		   var output = "";
		   var chr1, chr2, chr3;
		   var enc1, enc2, enc3, enc4;
		   var i = 0;

		   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
		   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		   do {
			  enc1 = keyStr.indexOf(input.charAt(i++));
			  enc2 = keyStr.indexOf(input.charAt(i++));
			  enc3 = keyStr.indexOf(input.charAt(i++));
			  enc4 = keyStr.indexOf(input.charAt(i++));

			  chr1 = (enc1 << 2) | (enc2 >> 4);
			  chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			  chr3 = ((enc3 & 3) << 6) | enc4;

			  output = output + String.fromCharCode(chr1);

			  if (enc3 != 64) {
				 output = output + String.fromCharCode(chr2);
			  }
			  if (enc4 != 64) {
				 output = output + String.fromCharCode(chr3);
			  }
		   } while (i < input.length);

		   return output;
		}

