/**
 * *********************** AUTHENTICATION TOOLBAR
 * JS*********************************
 */

function initProcess() {
	DWRCall();

}

function refreshBitSession() {
	DWRCall();
}

// Set Error Handler

DWREngine.setErrorHandler(eh);

function eh(msg) {

	window.status = msg;

}

// call to DWR
function DWRCall() {
	SsoUtility.getSsoUserDwr(showResult); //questa chiamata gi� rinnova il contesto su borsa
}


function showResult(data) {

	// TODO: riattivare per chiamata https 
	//document.getElementById('loginTopBar').action = data.actionUrl;

	if (data.username != null) {
		//document.getElementById('userInData').innerHTML = 'Welcome,&nbsp;' + data.username;
		setVisible('userlogoutBlock', true);
		setVisible('userloginBlock', false);
		
		//Only for portfolio
		setVisible('userlogoutBlock_navigatorP', true);
		setVisible('userloginBlock_navigatorP', false);
		setVisible('userlogoutBlock_pclassifiche', true);
		setVisible('userloginBlock_pclassifiche', false);
	} else {
		setVisible('userloginBlock', true);
		setVisible('userlogoutBlock', false);
		
		//Only for portfolio
		setVisible('userloginBlock_navigatorP', true);
        setVisible('userlogoutBlock_navigatorP', false);
		setVisible('userloginBlock_pclassifiche', true);
		setVisible('userlogoutBlock_pclassifiche', false);
	}
}



// Set display style for input element depending on boolean value
function setVisible(elementId, booleanValue) {
	var element = document.getElementById(elementId);
	if(element != undefined) {
		if (booleanValue) {
			element.style.display = 'inline';
		} else {
			element.style.display = 'none';
		}
	}
}



