window.addEvent('domready', function() {                
    checkError();
} );

// ---------------------------------------
//  Funzione per il recupero dell'host
// ---------------------------------------
function getHost(referer, ht, ctxPath) {
//	 var indice = referer.indexOf(":");
//     var protocollo = referer.substring(0,indice);
//     var host = referer.substring(0,indice)+ "://"+ht+ctxPath+"/JSON-RPC";
//     var host = referer + "//"+ht+ctxPath+"/JSON-RPC";

     return host;
}
// ---------------------------------------
//  Fine funzione 
// ---------------------------------------



// Funzione comune a tutta l'applicazione 
// Al domready vengono presi tutti gli elementi input contenuti nel container '.field_content_radio'
// e vengono nascosti
window.addEvent('domready', function() {
	var allRadioContainer = $$('.field_content_radio');

	allRadioContainer.each(function(e){
		e.getElements('input').each( function(el){
			if (navigator.userAgent.match('MSIE')) {
				el.style.visibility = 'visible';
			} else {
				el.style.visibility = 'hidden';
			}
			el.style.width = 0;
			el.style.height = 0;
			el.style.marginRight = 0;
			el.style.marginTop = 0;
		});
	});
});


function checkError(){

	var basePath = '..';
	if ($defined(document.getElementById('magnoliaContextPathID'))) {
		basePath = document.getElementById('magnoliaContextPathID').value;
	}
	
	//if(!isNull(document.getElementById('checkError'))){
	if ($defined(document.getElementById('checkError'))) {
		if(document.getElementById('checkError').value == 'warning'){
			if(document.getElementById('errorPageId').value != "")
			{
				MOOdalBox.open(basePath + "/error/"+document.getElementById('errorPageId').value+".jsp?"+"START_PAGE="+window.location.pathname, "", "594 306");
			}else
				MOOdalBox.open(basePath + "/error/warning.jsp?"+"START_PAGE="+window.location.pathname+"&twoWay=false&twoButton=true", "", "594 306");
		}
		if(document.getElementById('checkError').value == 'error'){
			MOOdalBox.open(basePath + "/error/error.jsp?"+"START_PAGE="+window.location.pathname, "", "594 306");
		}
	}
}


function setSelectedNavigationBarButton(buttonId){
	if (document.getElementById(buttonId)) {
	document.getElementById(buttonId).className = 'selected';
	}
	
	var standardConvImg = $('standardConvImg');
	var activeConvImg = $('activeConvImg');
	
	if (buttonId=='secondLevelNavigationBar4'){
		if ( standardConvImg != null ){
			standardConvImg.style.visibility = 'hidden';
			activeConvImg.style.visibility = 'visible';
		}
	}
	else{		
		if ( standardConvImg != null ){
			standardConvImg.style.visibility = 'visible';
			activeConvImg.style.visibility = 'hidden';
		}
	}
}
