/*
	File: first_equity.js
	Description:  This file houses all of the custom client-side javascript functions needed for the First Equity Card Online mall.
	Author: Ping Lay
	Date: 1/5/2007
*/


function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++){
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function getFirstName() {
    var cookieString = readCookie("mn");
    var cookieArray;
    
    if (cookieString)
    	cookieArray = cookieString.split('%7C');
	else
		return(null);
		
    if (cookieArray)
    	return outword(cookieArray[1]);
	else
		return (null);
}

function writeWelcome() {
	
    var firstName = getFirstName();
	//var firstName = "First Equity Member";
	
    if ((firstName != null))
    {
        if (document.getElementById)
        {
            x = document.getElementById('welcomeBar');
            if (x != null)
            	x.innerHTML = "Welcome, " + firstName + ". <br/> If you're not " + firstName + ", <a href=\""+logout+"\">click here.</a>";
        }
        else if (document.all)
        {
            x = document.all[id];
            if (x != null)
            	x.innerHTML = "Welcome, " + firstName + ". <br/> If you're not " + firstName + ", <a href=\""+logout+"\">click here.</a>";
        }
    }
    
}

function outword(word) {
  if (word != null && word != '')
  {
	  lower = word.toLowerCase();
	  upper = word.toUpperCase();
	  normal = upper.substring(0,1) + lower.substring(1,lower.length);
	  return normal;
  }
  else
  	return null;
} 
