/*

* oculta o obj

*/

function hide(obj){

	obj.style.display = "none";

}



/*

* mostra o obj passado por id

*/

function show(id){

	var obj = document.getElementById(id);

	obj.style.display = "";

}





/*

* faz um overlay no obj

*/

function overlay(obj){

	obj.style.background = "#EFEFEF";

}





/* 

* retira o overlay do obj

*/

function _overlay(obj){

	obj.style.background = "#ffffff";

}





/*

* coloca o campo passado pelo id em Focu

*/

function setFocus(id){

	var obj = document.getElementById(id);

	obj.focus();

}





/*

* muda o background do obj selecionado

*/

function selected(obj){

	obj.style.background = "#EFEFEF";

}





/*

* retira o background do obj

*/

function _selected(obj){

	obj.style.background = "transparent";

}





/*

* rola a página até o element

*/

function scrollTo(element){

	var obj = document.getElementById(element);

	obj.scrollIntoView();

}





/*

* abre uma popUp com os parametros passados

*/

function popUp(url, titulo, width, height, target){	

	

	if(target!=null)

		var janela = window.open(url, target, titulo,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');

	else

		var janela = window.open(url, titulo,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');

	

	janela.resizeTo(width, height);

}





/*

* executa o método em looping através dos segundos

*/

function reload(metodo, segundos){

	setTimeout(metodo, (segundos*1000)); /* x 1000, milisegundos */

}





/* verifica se é um email válido */

function is_mail(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;

    }

}





/*

* cria uma mascara para campos input

*/

// onkeypress=mascara(this, "(99)9999-9999", event);

function mascara(objeto, sMask, evtKeyPress) {



	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;





	if(document.all) { // Internet Explorer

	    nTecla = evtKeyPress.keyCode;

	} else if(document.layers) { // Nestcape

	    nTecla = evtKeyPress.which;

	} else {

	    nTecla = evtKeyPress.which;

	    if (nTecla == 8) {

	        return true;

	    }

	}



    sValue = objeto.value;



    // Limpa todos os caracteres de formatação que

    // já estiverem no campo.

    sValue = sValue.toString().replace( "-", "" );

    sValue = sValue.toString().replace( "-", "" );

    sValue = sValue.toString().replace( ".", "" );

    sValue = sValue.toString().replace( ".", "" );

    sValue = sValue.toString().replace( "/", "" );

    sValue = sValue.toString().replace( "/", "" );

    sValue = sValue.toString().replace( ":", "" );

    sValue = sValue.toString().replace( ":", "" );

    sValue = sValue.toString().replace( "(", "" );

    sValue = sValue.toString().replace( "(", "" );

    sValue = sValue.toString().replace( ")", "" );

    sValue = sValue.toString().replace( ")", "" );

    sValue = sValue.toString().replace( " ", "" );

    sValue = sValue.toString().replace( " ", "" );

    fldLen = sValue.length;

    mskLen = sMask.length;



    i = 0;

    nCount = 0;

    sCod = "";

    mskLen = fldLen;



    while (i <= mskLen) {

      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))

      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))



      if (bolMask) {

        sCod += sMask.charAt(i);

        mskLen++; }

      else {

        sCod += sValue.charAt(nCount);

        nCount++;

      }



      i++;

    }



    objeto.value = sCod;



    if (nTecla != 8) { // backspace

      if (sMask.charAt(i-1) == "9") { // apenas números...

        return ((nTecla > 47) && (nTecla < 58)); } 

      else { // qualquer caracter...

        return true;

      } 

    }

    else {

      return true;

    }

}









/* ******************************************************************************* *

* retira o link da div, utilizado para o flash de graficos						   *

* ******************************************************************************** */

function unlink(width, height){

	

	/* verifica se ja nao possui a div unlink */

	var unlink = document.getElementById("unlink");

	

	if( unlink != null ){

		unlink.style.width = width;

		unlink.style.height = height;

		unlink.style.display = "";

		unlink.style.position = "absolute";

	}

}
