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 );
}

function logUser()
{
	//login = obj.login.value;
	//senha = obj.password.value;
	login = document.getElementById('login').value;
	senha = document.getElementById('senha').value; 
	
	if ( login == "" || senha == "" ) {
		alert("Os campos Login e Senha não foram preenchidos corretamente");
	} else {
		document.f_user.submit();
		document.getElementById('login').value='';
		document.getElementById('senha').value='';
		//obj.submit();
		//obj.login.value = '';
		//obj.password.value = '';
	}
}

function checkFormContact()
{
	var obj = document.f;
	var nome = obj.nome.value;
	var email = obj.email.value;
	var mensagem = obj.mensagem.value;
	
	if ( nome == "" || email == "" || mensagem == "" ) {
		alert("Todos os campos precisam ser preenchidos corretamente");
		return false;
	} else {
		if ( isValidEmail(email) ) {
			obj.submit();
		} else {
			alert('Email inválido');
			obj.email.focus();
			obj.email.select();
			
			return false;
		}
	}
}

//Validacao de email
function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

}

// ----------------------------------------------------//
// SISTEMA ------------------------

function hideData()
{
	
	document.getElementById('otherInfo').style.display = 'none';
}

function toggleInfo()
{
	var obj = document.getElementById('otherInfo');
	
	obj.style.display = ( obj.style.display == '' ? "none" : "" );
}

function doAction(link)
{
	document.getElementById('iframe').src = link;
	//alert( document.getElementById('iframe').src );
}

// Funcao para checar se um email é valido ou nao.
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
                }
    }else{
        return false;
        }
}
