function logado(){
	return (readCookie("pst_login")=="S" && readCookie("usuario")!="" && readCookie("usuario")+""!="null");
} 

/**
 * Funcao que exibe a frase carregando enquanto o iframe eh carregado
 * @iframeId Id do Iframe
 */
function showIFrameModule( iframeId ) {
    if ( document.getElementById( iframeId ) ) {
        document.getElementById( "load" + iframeId ).style.display = "none";
        document.getElementById( iframeId ).style.display = "block";
    }
}

function personalizacaoNaoLogado(){
	if(logado()){
		document.getElementById("modulosConteiner").innerHTML = "";		
		//loadJavaScript("/script/personalizacao/personalizacao-all.js");
		init();
	} else {
		/*
		jQuery('#availableModules').html('<p>Para controle dos m&oacute;dulos &eacute; necess&aacute;rio entrar com o usu&aacute;rio e senha.</p>');
		jQuery('#availableModules').show();
		*/
		var obj = document.getElementById("personalizacaoNaoLogado");
		obj.style.display = "block";
		
		// Carrega a lista de modulos possiveis do servidor e guarda em cache
		PersonalizacaoController.getAvailableModules( function( modules ) {
			PersonalizacaoUtil.modules = modules;

			if ( PersonalizacaoUtil.config.loadAvailableModulesCallback ) {
				PersonalizacaoUtil.config.loadAvailableModulesCallback( modules );
			}
		});
		// Carrega o estado do servidor
		PersonalizacaoUtil.loadState();
		// Carrega menu de personalizacao
		PersonalizacaoUtil.loadMenu();
	}
}


/**
 * Simple way to add events to trigger after the page has loaded. 
 * This of course attaches all your events to the onload event handler 
 * which some still see as necessary, 
 * nevertheless it does exactly what it?s supposed to, and does it well.
 */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


function loadJavaScript(file,name){

	var head = document.getElementsByTagName("head");
	
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.id = name;
	var d = new Date();
	//script.src = file + "?" + d;	
	script.src = file;
	head[0].appendChild(script);
	
}

/**
 *Esconde a ajuda do modulo
 *@param id Id do modulo
 **/
function exameHideHelp( id ) {
    document.getElementById("ajuda" + id).style.display="none";
    var obj = document.getElementById("contents" + id);
    if(obj){
    	obj.className = document.getElementById("contents" + id).className.replace(/showhelp/,"");
    }    
}

/**
 *Exibe a ajuda do modulo
 *@param id Id do modulo
 **/
function exameShowHelp( id ) {
    document.getElementById("ajuda" + id).style.display="inline";
    var obj = document.getElementById("contents" + id);
    if(obj){
    	obj.className += " showhelp";
    }
}


