var popUpWin=0;

function initAccountNav()
{
	setAccountNav();
}

function popUpWindow(URLStr, left, top, width, height)
{	
	if(popUpWin){
		if(!popUpWin.closed) popUpWin.close();
	}
 	
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

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 popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  }
  
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function setAccountNav()
{
	if (!document.getElementById('sb_account_nav'))
		return false;

	var username = readCookie('thespringbox_username');
	
	if(username){
		if (readCookie('thespringbox_admin')=='true')
			username = '<span style="color: cyan;">' + username.replace(/\+/, ' ') + '</span>';
		document.getElementById('sb_account_nav').innerHTML = '<span style="font-size:11px;">'+username+'</span> - <a href="/users/profile/">Profile</a> | ';
		document.getElementById('sb_account_nav').innerHTML+= '<a href="/users/logout/"><span>Logout</a>';
	}else{
		document.getElementById('sb_account_nav').innerHTML = '<a href="/users/register/">Register</a> | ';
		document.getElementById('sb_account_nav').innerHTML+= "<a href=\"/users/login/true\" onclick=\"return GB_showCenter('Please Login', this.href, 270, 500, setAccountNav)\"><span>Login</a>";
	}
}