Javascript cookies problem

I am having problems retrieving cookie value. I’ve never used javascript cookies and found this script and thought I wanted to see how it works on my simple page. Here’s the script

//capture user name
function getUser(){
    
    var value = null;
    
    while(value==null || value==''){
        value = prompt('Please enter your name','');
    }
    
    if(value !=null || value !=''){
        createCookie(cook,value,0);
    }
}

function createCookie(cook,value,days) {
    
    if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/wizzy/";
}

//read cookie
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;
}

//disposing of cookie.
function cookie_destroy(){
    createCookie(cook,"",-1);
}

And I wanted to capture and display the cookie value here:

<!-- page header --->
        <div id="header">
            <img src="buzz.jpg" alt="Images" align="left"width="97" height="97 /><h1 class="center"></h1>
            <span class="style3">&nbsp;
		<script type="text/javascript">
		    document.write(date+' '+month+', '+year+' '+hours+':'+minutes+':'+seconds+'<br/>');
		    window.onload = getUser();
		    
		    getCook();
		    
		    var user = readCookie(name);
			       
		    if(user){	    
			document.write('&nbsp; Welcome, '+user+'<br/>');		
		    }    
		</script>
            
            </span>
            <h3>Buzz TechNews Online</h3>


      </div><!-- end header --->

Thanks

window.onload = getUser();

Change to

window.onload = getUser;

then it actually gets called on load not immediately.

Followed by:

 getCook();

 var user = readCookie( "userName" );

 if( user )
 {	    
   document.write('&nbsp; Welcome, '+user+'<br/>');		
 }    



function getUser(){
    
    var value = null;
    
    while(value==null || value=='') /* These tests need work */
    {
        value = prompt('Please enter your name','');
    }
    
    if(value !=null || value !=''){
        createCookie( [B]"userName"[/B] ,value,0);
    }
}