/**
 * @author Derek Carlin
 * Controls interactions with the side-menu service and handling user login status changes.
 */
function AdminMenuControl(loginControl) {
    this.loginControl = loginControl;
    loginControl.UserLoginEvent.subscribe(this.onLoginEvent, this);
}

AdminMenuControl.prototype.renderMenu = function(results){
	var div = document.getElementById('adminMenu');
	if (div) {
		div.innerHTML = results;
	}
	else 
		alert("not finding admin menu!");
}

AdminMenuControl.prototype.onLoginEvent = function(type, loginInfo, me){
	if (! loginInfo.loggedIn) {
		// user is not logged in, check if this is a resticted page, in which case we
		// need to leave/reload.
	//	window.location.reload();  // temp ... for now always reload?
	}

    AdminMenuService.renderMenu(function(results) {  me.renderMenu(results); });

}



var theAdminMenu = null;

YAHOO.util.Event.onDOMReady(function(){
    theAdminMenu = new AdminMenuControl(theLoginControl);
});


