/*
	File: amg.js
	Description:  This file houses all of the custom client-side javascript functions needed for AMG Online malls.
	Author: Ping Lay
	Date: 1/12/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 writeWelcome() {
	
    var firstName = readCookie("fname");
    var uid = readCookie("uid");
	
    if ((firstName != null) && (uid != null))
    {
        if (document.getElementById)
        {
            x = document.getElementById('welcomeBar');
            if (x != null)
            	x.innerHTML = "Hi, " + 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 = "Hi, " + firstName + ".  If you're not " + firstName + ", <a href=\""+logout+"\">click here.</a>";
        }
    }
    else
    {
		if (document.getElementById)
		{
			// this is the way the standards work
			var wbar = document.getElementById('welcomeBar');
           	if (wbar != null) {
				var style2 = wbar.style;
	            if (style2 != null)
	    			style2.display = "none";
           }
		}
		else if (document.all)
		{
			// this is the way old msie versions work
			var wbar = document.all['welcomeBar'];
          	if (wbar != null) {
	 			var style2 = wbar.style;
	            if (style2 != null)	
	    			style2.display = "none";         	
          	}
		}
		else if (document.layers)
		{
			// this is the way nn4 works
			var wbar = document.layers['welcomeBar'];
          	if (wbar != null) {
				var style2 = wbar.style;
	            if (style2 != null)
	            	style2.display = "none";
          	}
		}		
    }
    
}

