function question( pergunta )
{
	if ( confirm( pergunta ) ) {
		return true;
	} else {
		return false;
	}
}

// Abre uma janela popup
function popup ( url, nome, largura, altura, posicao, resize, barras ) {
	if ( posicao == 0 ) {
		posleft = 20;
		postop  = ( screen.height ) ? ( screen.height - altura ) / 2 - 50 : 100;
	} else if ( posicao == 1 ) {
		posleft = ( screen.width ) ? ( screen.width - largura ) / 2 : 100;
		postop  = ( screen.height ) ? ( screen.height - altura ) / 2 - 50 : 100;
	} else if (posicao == 2 ) {
		posleft = ( screen.width ) ? ( screen.width - largura ) - 28 : 100;
		postop  = ( screen.height ) ? ( screen.height - altura ) / 2 - 50 : 100;
	}
	opBarras = ( barras ) ? "yes" : "no";
	opResize = ( resize ) ? "yes" : "no";

	settings = 'z-lock=yes, width=' + largura + ', height=' + altura + ', top=' + postop + ', left=' + posleft + ', scrollbars=' + opBarras + ', location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=' + opResize;
	window.open( url, nome, settings );
}

// NOTICIAS -------------------------------
var oldStatus;
var wasSet;
var oldId;
function changeStatus( id, st, url, url2 )
{
	if ( wasSet == true ) {
		if ( id == oldId ) {
			st = oldStatus
		}
	}
	
	var objFrame = document.getElementById( "atualizer" );
	
	//altera imagem...
	document.getElementById( "img_" + id ).src = url + ( st ? "ic_ativo_off.gif" : "ic_ativo_on.gif" );
	
	// Atualiza o status
	oldStatus = ( st ? 0 : 1 );
	wasSet    = true;
	oldId     = id;
	
	// manda pro FRAME a mensagem de do novo status da noticia
	objFrame.src = url2 + "&st=" + oldStatus;
}

// --- Status Pages ---
var oldStatus;
var wasSet;
var oldId;
function changeStatusPg( id, st, url, url2 )
{
	if ( wasSet == true ) {
		if ( id == oldId ) {
			st = oldStatus
		}
	}
	
	var objFrame = document.getElementById( "atualizer" );
	
	//altera imagem...
	document.getElementById( "img_" + id ).src = url + ( st ? "ic_status0.gif" : "ic_status1.gif" );
	
	// Atualiza o status
	oldStatus = ( st ? 0 : 1 );
	wasSet    = true;
	oldId     = id;
	
	// manda pro FRAME a mensagem de do novo status da noticia
	objFrame.src = url2 + "&st=" + oldStatus;
}

// ----------------------------------------

// Galeria --------------------------------
var id;
function triggerMenu( id_menu )
{
	var obj = document.getElementById( id_menu );
	
	// Esconde o id antigo
	hideMenu();
	
	obj.style.display = ( obj.style.display == 'none' ? '' : 'none' );
	id = id_menu;
}

function hideMenu()
{
	if ( id ) {
		document.getElementById( id ).style.display = 'none';
	}
	
}

function showNext( id )
{
	document.getElementById( 'item'+id ).style.display='';
}

function printPic( id )
{
	var obj   = document.getElementById( 'file'+id );
	var addrs = obj.value;
	
	if ( addrs ) {
		addrs = 'file://' + addrs;
		document.getElementById( 'pic'+id ).src = addrs;
	}
}

function cancelImage( id )
{
	var obj = document.getElementById( 'file' + id );
	obj.focus();
	obj.value.replace('C', '');
	
}


var objEditArea; //Uso para compartilhar o objeto que será criptografado diretamente no LT (tpl).
function editPic( id, pTop )
{
	// Trata posicao
	// Cria o numero
	var position  = pTop * 100;
	document.getElementById( 'divEdit' ).style.top  = ( 100 + position );
	
	document.getElementById( 'divEdit' ).style.display = '';
	var obj = document.getElementById( "iframEdit" );
	//obj.src="?show=editPic&id_foto=" + id;
	objEditArea    = obj; 
}

function editPicGo( url )
{
	objEditArea.src = url;
}

function closeEditPic()
{
	parent.document.getElementById( "iframEdit" ).src='';
	parent.document.getElementById('divEdit').style.display = 'none';
}
// -------------------------------------------------------------------------