function confirmaLogout( caminho ) {
	if ( confirm("Voc\xEA tem certeza que deseja sair do Painel de Controle?") )
		window.location.replace( caminho );
}
function confirmaLogout_en( caminho ) {
	if ( confirm("Are you sure that you wish to leave the Control Panel?") )
		window.location.replace( caminho );
}
function confirmaLogout_pt( caminho ) {
	confirmaLogout( caminho );
}

function confirmaExclusao( msg, caminho ) {
	if ( confirm("Voc\xEA tem certeza que deseja excluir "+msg+"?") )
		window.location.replace( caminho );
}
function confirmaExclusao_en( msg, caminho ) {
	if ( confirm("Are you sure about the deletion of "+msg+"?") )
		window.location.replace( caminho );
}
function confirmaExclusao_pt( msg, caminho ) {
	confirmaExclusao( msg, caminho );
}
function confirmaExclusaoEmCascata( msg, msg2, caminho ) {
	if ( confirm("Voc\xEA tem certeza que deseja excluir "+msg+"?\n"+
				 "\n"+
				 msg2) )
		window.location.replace( caminho );
}
function confirmaExclusaoEmCascata_en( msg, msg2, caminho ) {
	if ( confirm("Are you sure about the deletion of "+msg+"?\n"+
				 "\n"+
				 msg2) )
		window.location.replace( caminho );
}
function confirmaExclusaoEmCascata_pt( msg, msg2, caminho ) {
	confirmaExclusaoEmCascata( msg, msg2, caminho );
}

function getById( elemento ) {
	return document.getElementById( elemento );
}
function elemento( elemento ) {
	return getById( elemento );
}

function isVisivel( elemento ) {
	return getById( elemento ).style.display == 'block';
}

function mostra( elemento ) {
	getById( elemento ).style.display = 'block';
}
function esconde( elemento ) {
	getById( elemento ).style.display = 'none';
}

function mostraEsconde( elemento ) {
	if ( isVisivel(elemento) )
		esconde( elemento );
	else
		mostra( elemento );
}

function escondeArray( elementos ) {
	for ( i=0 ; i < elementos.length ; i++ )
		esconde( elementos[i] );
}
function escondeArrayTry( elementos ) {
	for ( i=0 ; i < elementos.length ; i++ ) {
		try {
			esconde( elementos[i] );
		}
		catch( exc ) {
//			alert( i );
		}	
	}
}
function mostraArray( elementos ) {
	for ( i=0 ; i < elementos.length ; i++ )
		mostra( elementos[i] );
}


function mostraArrayAppear( elementos ) {
	for ( i=0 ; i < elementos.length ; i++ )
		new Effect.Appear( elementos[i], {duration: 1.5} );
}
function mostraAppear( elemento ) {
	new Effect.Appear( elemento, {duration: 1.5} );
}
function mostraArrayAppearTry( elementos ) {
	for ( i=0 ; i < elementos.length ; i++ ) {
		try {
			new Effect.Appear( elementos[i], {duration: 1.5} );
		}
		catch( exc ) {
//			alert( i );
		}
	}
}

function escondeObjeto( elemento ) {
	elemento.style.display = 'none';
}
function mostraObjeto( elemento ) {
	elemento.style.display = 'block';
}

function numeroAleatorio( limInf, limSup ) {
	return Math.floor( Math.random()*(1 + limSup - limInf) + limInf );
}

function getRequestAJAX() {
	if ( window.XMLHttpRequest )
		return new XMLHttpRequest();
	else if ( window.ActiveXObject )
		return new ActiveXObject( "Microsoft.XMLHTTP" );
	else {
		 alert( "Seu browser n\xE3o suporta AJAX!" );
		return null;
	}
}

/** Retorna o objeto flash.
 */
function getObjetoFlash( objetoFlash ) {
	if ( navigator.appName == "Netscape" )
		return document.embeds[0];
	else
		return window[ objetoFlash ];
}
function abreMenu( objetoFlash, quadro ) {
	// Vai para o quadro especificado pelo Numero
	//getObjetoFlash( objetoFlash ).GotoFrame( quadro );

	// Vai para o quadro especificado pelo Label
	getObjetoFlash( objetoFlash ).TGotoLabel( "_root", quadro );
	//getObjetoFlash( objetoFlash ).Play();
}

/** Elemento visivel. */
var elementoVisivel = null;
/** Esconde o elemento visivel atualmente, exibe outro elemento e atualiza a variavel 'elementoVisivel'.
 */
function escondeVisivelEMostra( elemento ) {
	if ( elementoVisivel != null )
		esconde( elementoVisivel );
	mostra( elemento );
	elementoVisivel = elemento;
}

function insereFlash( caminho, largura, altura, wmode, bgcolor, align ) {
	document.write(
		"<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\""+largura+"\" height=\""+altura+"\" id=\"topo\" align=\""+align+"\">"+
			"<param name=\"allowScriptAccess\" value=\"sameDomain\"/><param name=\"movie\" value=\""+caminho+"\"/><param name=\"quality\" value=\"high\"/><param name=\"scale\" value=\"noscale\"/><param name=\"wmode\" value=\""+wmode+"\"/><param name=\"bgcolor\" value=\""+bgcolor+"\"/>"+
			"<embed src=\""+caminho+"\" quality=\"high\" scale=\"noscale\" wmode=\""+wmode+"\" bgcolor=\""+bgcolor+"\" width=\""+largura+"\" height=\""+altura+"\" name=\"topo\" align=\""+align+"\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"/>"+
		"</object>"
	);
}

function algumMarcado( campo ) {
	if ( campo.length == undefined )
		return campo.checked;
	else
		for ( i=0 ; i < campo.length ; i++ )
			if ( campo[i].checked )
				return true;
	return false;
}

function menuMouseOver( elemento ) {
	elemento.parentNode.classNameAntigo = elemento.parentNode.className;
	elemento.parentNode.className = "TDMenuSelect";
	elemento.classNameAntigo = elemento.className;
	elemento.className = "NormalBranco";
}
function menuMouseOut( elemento ) {
	elemento.parentNode.className = elemento.parentNode.classNameAntigo;
	elemento.className = elemento.classNameAntigo;
	window.status = "Extranet Prumos Interativa.";
}

function mostraTagNome( t, nome ){
	var elementos = document.getElementsByTagName( t );
	for ( var i = 0; i < elementos.length; i++ ) {
		if ( elementos[i].id == nome ) {
			elementos[i].style.display = 'block';
		}
	}
}
function escondeTagNome( t, nome ){
	var elementos = document.getElementsByTagName( t );
	for ( var i = 0; i < elementos.length; i++ ) {
		if ( elementos[i].id == nome ) {
			elementos[i].style.display = 'none';
		}
	}
}
/*
 * Compara duas datas no formato dd/mm/aaaa. 
 * Retorna 1 se dataStrin2 for maior que dataString1
 * Retorna -1 se dataStrin2 for menor que dataString1
 * Retorna 0 se ambas sao iguais.
 */
function comparaDatas( dataString1, dataString2 ) {
	dia = dataString1.substring(0,2);
	mes = dataString1.substring(3,5);
	ano = dataString1.substring(6,10);
	var data1 = new Date( ano, mes, dia );
	dia = dataString2.substring(0,2);
	mes = dataString2.substring(3,5);
	ano = dataString2.substring(6,10);
	var data2 = new Date( ano, mes, dia );
	if (  data1 < data2 ) {
		return 1;
	} else if ( data1 > data2){
		return -1;
	} else {
		return 0;
	}
	return false;
}

function redimensionarImagem( imagemId, tamMax ){
	var elemento= document.getElementById( imagemId );
	if ( elemento.width >= tamMax ) {
		elemento.width = tamMax;
	}
}
