/*
Softlib Web v1.0 - Biblioteca de recursos UI
© 16-02-2004 Leonardo Cidral

Email: leonardo@softin.com.br || @saochico.com
skype: lcidral
ICQ: 2440246 ou 2921304
Empresa: Softin Sistemas Ltda.
web: www.softin.com.br

* Este script pode ser usado e modificado livremente

FUNÇÕES:
	- STRZERO_JS [15/04/2004]
	- APENAS NUMERICOS [16/02/2004];
	- MASCARA TELEFONE [16/02/2004];
	- MASCARA DATA [16/02/2004];
	- MASCARA hora [16/02/2004];
	- MASCARA CPF [16/02/2004];
	- MASCARA CNPJ [16/02/2004];
	- MASCARA CEP [16/02/2004];
	- VALIDA CGC [16/02/2004];
	- MASCARA MOEDA [27/06/2005]
	- Validação de data [13/07/2005]
	- VALIDAÇÃO DE EMAIL [05/07/2005]
	- Função para abrir pup-up [06/07/2005]
	- Função para abrir DialogBox [11/07/2005]
	- Maxtext v1.0 - limita qtd caracteres textarea [14/07/2005]
	- Função para retornar a página anterior [18-01-2005]
	- Lembrar senha





Compatibilidade:
	IE 6.0 +
*/

//identifica qual o browser que o cadáver está utilizando
function Browser()
{
	d=document;
	this.agt=navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.dom=(d.getElementById)?1:0;
	this.ns=(d.layers);
	this.ns4up=(this.ns && this.major >=4);
	this.ns6=(this.dom&&navigator.appName=="Netscape");
	this.op=(window.opera? 1:0);
	this.ie=(d.all);
	this.ie4=(d.all&&!this.dom)?1:0;
	this.ie4up=(this.ie && this.major >= 4);
	this.ie5=(d.all&&this.dom);
	this.win=((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("16bit")!=-1));
	this.mac=(this.agt.indexOf("mac")!=-1);
};
var oBw = new Browser();

//substitui document.getElementById por getObj
function getObj(id,d){
	var i,x;
	if(!d) d=document;
	if(!(x=d[id])&&d.all) x=d.all[id];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][id];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=getObj(id,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(id);
	return x;
};

//CARREGA OS FABRICANTES DO SEGMENTO X
function busca_cidades(obj) {
	var nm_objeto = "sg_uf";
	var sg_uf = obj.value;
	var url = "admin.php?pg=ferramentas&prod=combo_cidades&sg_uf="+sg_uf;

	//get("cd_cidade").focus();

    //limpa o select
	remove_tudo("cd_cidade");

	set_carregando(true);

    //Monta a url com a uf
    xmlhttp.open("GET", url, true);

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){

            //limpa o select
            var c=getObj("cd_cidade");
            while(c.options.length>0)c.options[0]=null;

            //Transforma a lista de cidades JSON em Javascript
            var ObjFabr=xmlhttp.responseXML;

			//pega a tag XML
			var dataArray   = ObjFabr.getElementsByTagName("cidades");

			//total de elementos contidos na tag cidade
			if(dataArray.length > 0) {
				//percorre o arquivo XML paara extrair os dados
				adiciona("Todos","","cd_cidade");
				for(var i = 0 ; i < dataArray.length ; i++) {
					var item = dataArray[i];
					//contéudo dos campos no arquivo XML
					var cd_cidade =  item.getElementsByTagName("cd_cidade")[0].firstChild.nodeValue;
					var nm_cidade =  item.getElementsByTagName("nm_cidade")[0].firstChild.nodeValue;

					adiciona(nm_cidade,cd_cidade,"cd_cidade");
				}
			}
        }
    }

    xmlhttp.send(null)
	set_carregando(false);

	return false;
}

/*
preenche com zeros na frente da string digitada
<input name="telefone" type="text" size="16" maxlength="14" onBlur="strzero_js(this.value,6);" value="">
*/
function strzero_js(num, tam)    {
	while (num.length < tam) {
		num = "0"+num;
	}
	return num;
}

//mascara de campo
// src = bico
// mask = ##---##
function formatar(src, mask) {
	//alert(src);
	return false;

	var i = src.value.length; // 4
	var saida = mask.substring(0,1); //
	var texto = mask.substring(i)
	if (texto.substring(0,1) != saida)
	{
		src.value += texto.substring(0,1);
	}
}

/*
formata campo no formato nr. telefone
<input name="telefone" type="text" size="16" maxlength="14" onKeyDown="Mascarar_Telefone(this,10,event);" value="">
compatível com: IE
*/
function Mascarar_Telefone(objeto,tammax,teclapres) {
	var tecla = "";
	var tecla = teclapres.keyCode ? teclapres.keyCode : teclapres.which ? teclapres.which : teclapres.charCode;

	vr = objeto.value;
	vr = vr.replace( "(", "" );
	vr = vr.replace( ")", "" );
	vr = vr.replace( " ", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;
	if (tam < tammax && tecla != 8) {
		tam = vr.length + 1 ;
	}
	if (tecla == 8 ) {
		tam = tam - 1 ;
	}
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
		if ( tam <= 4 ) {
	 		objeto.value = vr;
		}
	 	if ( (tam > 4) && (tam <= 8) ) {
	 		objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam ) ;
		}
	 	if ( (tam >= 9) && (tam <= 10) ) {
			objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam) ;
		}
	}
}

/*
formata hora
<input name="hora" type="text" class="formulario" size="5" maxlength="5" onKeyPress="Mascara_Hora(window.event.keyCode,this);">
*/
function Mascara_Hora(caracter,campo) {
	var tecla = caracter.keyCode ? caracter.keyCode : caracter.which ? caracter.which : caracter.charCode;
	//campo = eval (objeto);
	separador = ':';
	conjunto1 = 2;

	retorno = apenas_numeros(caracter, campo);

	if (campo.value.length == conjunto1 && tecla != 8){
		campo.value = campo.value + separador;
	}
	return retorno;
}

/*
formata campo para data
<input type="text" name="data" style="width: 80px" maxlength="10" size="9" onKeyPress="Mascarar_Data(window.event.keyCode,this);" value="">
*/
function Mascarar_Data(keypress, objeto) {
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 2 ) {
	 		campo.value = campo.value;
	 		campo.value = campo.value + '/';
		}
		if (campo.value.length == 5 ) {
	 		campo.value = campo.value;
	 		campo.value = campo.value + '/';
		}
	}
}

/*
marcara campo para CPF
<input name="cpf" type="text" size="16" maxlength="14" onKeyPress="Mascarar_CPF(window.event.keyCode,this);">
*/
function Mascarar_CPF(keypress, objeto) {
	campo = eval (objeto);
	if (campo.value.length == 3 ) {
		campo.value = campo.value;
		campo.value = campo.value + '.';
	}
	if (campo.value.length == 7 ) {
		campo.value = campo.value;
		campo.value = campo.value + '.';
	}
	if (campo.value.length == 11 ) {
		campo.value = campo.value;
		campo.value = campo.value + '-';
	}
}

/*
formata campo para CNPJ
<input name="cnpj" type="text" class="formulario" size="21" maxlength="18" onKeyPress="Mascarar_CNPJ(window.event.keyCode,this);">
*/
function Mascarar_CNPJ(keypress, objeto) {
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 2 ) {
			campo.value = campo.value;
			campo.value = campo.value + '.';
		}
		if (campo.value.length == 6 ) {
			campo.value = campo.value;
			campo.value = campo.value + '.';
		}
		if (campo.value.length == 10 ) {
			campo.value = campo.value;
			campo.value = campo.value + '/';
		}
		if (campo.value.length == 15 ) {
			campo.value = campo.value;
			campo.value = campo.value + '-';
		}
	}
}

/*
FORMATA CAMPO PARA 00000-000
<input name="cep" type="text" size="11" maxlength="9" onKeyPress="Mascarar_CEP(window.event.keyCode,this);" value="">
*/
function Mascarar_CEP(keypress, objeto) {
	campo = eval (objeto);
	caracteres = '1234567890';
	if ((caracteres.search(String.fromCharCode (keypress)) == -1) || (keypress == 36) || (keypress == 41) || (keypress == 46) || (keypress == 94) || (keypress == 124)) {
		event.returnValue = false;
	}
	else {
		if (campo.value.length == 5 ) {
	 		campo.value = campo.value;
	 		campo.value = campo.value + '-';
		}
	}
}

/*
validação de email
validar_email(string) - função retorna true ou false
*/
function validar_email(email) {
	if(email.length < 6) {
		return false;
	}
	var x = 0;
	for (var c=0;c<email.length;c++) {
		if (email.substring(c,c+1) == '@') {
			x = c;
		}
	}
	var y = 0;
	if (x > 0) {
		for (c=x;c<email.length;c++) {
			if (email.substring(c,c+1)=='.') {
				y = c;
				var valida = 1;
			}
		}
		if (y > 0) {
			var dominio = '';
			for (c=x;c<y;c++) {
				dominio = dominio + email.substring(1,c);
			}
		}
	}
	else {
		return false;
	}
	if (y <= x+2){
		return false;
	}
	if (valida == 1){
		return true;
	}
}

/*
Formata número tipo moeda usando o evento onKeyDown
<input type="text" name="texto" size="20" onKeyPress="return(currencyFormat(this,'.',',',event));">
*/
function currencyFormat(fld, milSep, decSep, e) {
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13)
		return true; // Entra

	key = String.fromCharCode(whichCode); // Comece o valor chave do c?digo chave
	if (strCheck.indexOf(key) == -1) return true; // Chave inv?lida
	len = fld.value.length;
	for(i = 0; i < len; i++)
		if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
			aux = '';
		for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
				aux += key;
			len = aux.length;
			if (len == 0) fld.value = '';
			if (len == 1) fld.value = '0'+ decSep + '0' + aux;
			if (len == 2) fld.value = '0'+ decSep + aux;
			if (len > 2) {
				aux2 = '';
			for (j = 0, i = len - 3; i >= 0; i--) {
				if (j == 3) {
					aux2 += milSep;
				j = 0;
			}
			aux2 += aux.charAt(i);
			j++;
		}
		fld.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
			fld.value += aux2.charAt(i);
			fld.value += decSep + aux.substr(len - 2, len);
		}
	return false;
}

/*
Valida data
MODO DE USAR:
<input type="text" name="nomedocampo" id="nomedocampo" maxlength="10" onBlur="valida_data(this);">
*/
function valida_data( edit ) {
	if (edit.value != '') {
		var parte = edit.value.split( "/" ); /* Retira da string os '/' formando um array com o seguinte formato: array( 'dia', 'mes', 'ano' ); */
											 /* alimenta as variáveis com os valores respectivos ao ano, mes e dia */
		var ano = parte[ 2 ];
		var mes = parte[ 1 ];
		var dia = parte[ 0 ];

		/* reune em uma única string o ano, mes e dia */
		var dataUm = ( ano + mes + dia );

		/* adverte o usuário caso o dia seja 0 */
		if ( dia == 0 ) {
			alert( "Favor preecher o dia!" );
			edit.value = "";
			edit.focus();
			return false;
		}

		/* adverte o usuário caso o mes seja 0 */
		if ( mes == 0 ) {
			alert( "Favor preencher o mês!" );
			edit.value = "";
			edit.focus();
			return false;
		}

		/* verifica se o mes esta na faixa dos meses que contem 31 dias */
		if ( mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12 ) {
			/* adverte o usuário se o mesmo tiver informado um dia superior a 31 */
			if ( dia < 1 || dia > 31 ) {
				alert( "O mês " + mes + " tem apenas 31 dias" );
				edit.value = "";
				edit.focus();
				return false;
			}
		}

		/* verifica se o mes esta na faixa dos meses que contem 30 dias */
		if ( mes == 11 || mes == 9 || mes == 6 || mes == 4 ) {
			/* adverte o usuário caso dia informado esteja fora da faixa para este condição */
			if ( dia < 1 || dia > 30 ) {
				alert( "O mês " + mes + " tem apenas 30 dias" );
				edit.value = "";
				edit.focus();
				return false;
			}
		}

		/* verifica se o ano e bissexto */
		bissexto = ( ( ano % 4 ) == 0 ) ? true : false;

		/* se o ano e bissexto e o mes e fevereiro */
		if ( ( mes == 2 ) && ( bissexto ) ) {
			/* adverte o usuário caso tenha informado um dia maior que 29 e menor que 1 */
			if ( dia < 1 || dia > 29 ) {
				alert( "O ano " + ano + " é bissexto e o mês 2 possui 29 dias" );
				edit.value = "";
				edit.focus();
				return false;
			}
		}

		/* se o ano nao for bissexto e o mes for fevereiro */
		if ( ( mes == 2 ) && ( !bissexto ) ) {
			if ( dia < 1 || dia > 28 ) {
				alert( "O ano " + ano + " não é bissexto e o mês 2 possui 28 dias" );
				edit.value = "";
				edit.focus();
				return false;
			}
		}

		/* adverte o usuário caso o ano esteja vazio */
		if ( ano == 0 ) {
			alert("Favor preencher o Ano!");
			edit.value = "";
			edit.focus();
			return false;
		}

		/* se a data naum formar um numero valido [ caracteres em branco pr ex tornariam a data invalida ] */
		if ( isNaN( dataUm ) ) {
			alert("Data incorreta!");
			edit.value = "";
			edit.focus();
			return false;
		}

		/* adverte o usuário caso o ano informa esteja fora da faixa real do processso */
		if ( ano < 1900 || ano > 3079 ) {
			alert( "Verifique o ano!" );
			edit.value = "";
			edit.focus();
			return false;
		}

		dataDois = new Date( ano, mes-1 , dia );

		if ( mes < 1 || mes > 12 ) {
			alert( "Mês incorreto, favor verificar!" );
			edit.value = "";
			edit.focus();
			return false;
		}
		else return true;
	}
}

/*
Compara data
MODO DE USAR:
<input type="text" name="nomedocampo" id="nomedocampo" maxlength="10" onBlur="compara_data(this,document.getElementById('dt_final');">
*/
function compara_data(data1,data2){

	if (data1.value != '' && data2.value != ''){
		/*Explode data inicial*/
		var parteData1 = data1.value.split( "/" );
		var dataInicial = parteData1[ 2 ];
		dataInicial += parteData1[ 1 ];
		dataInicial += parteData1[ 0 ];

		/*Explode data final*/
		var parteData2 = data2.value.split( "/" );
		var dataFinal = parteData2[2];
		dataFinal += parteData2[1];
		dataFinal += parteData2[0];

		if (dataInicial > dataFinal){
			alert("A data inicial é maior que a data final. Confira!");
		}
	}
}

/*
limita campo apenas para entrada de números
COMO UTILIZAR:
<input type="text" name="xxx" onKeyPress="return apenas_numeros(event,this);">
Compatível com: IE
*/
function apenas_numeros(caracter,campo) {
	retorno = false;
	var tecla = caracter.keyCode ? caracter.keyCode : caracter.which ? caracter.which : caracter.charCode;
	if(tecla > 47 && tecla < 58 || tecla == 46 || tecla == 8) { // numeros de 0 a 9 e o ponto
		retorno = true;
	} else if (tecla == 44) {
		campo.value = campo.value + '.';
		retorno = false;
	}
	//else if (tecla == 13) $(campo).blur();
	return retorno;
}

//valida CPF
function valida_CPF(s) {
	var i;
	s = limpa_string(s);

	if (s == '11111111111' || s == '22222222222' || s == '33333333333' || s == '44444444444' || s == '555555555555' || s == '66666666666' || s == '77777777777' || s == '88888888888' || s == '99999999999') {
		return false;
	}

	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)	{
		d1 += c.charAt(i)*(10-i);
	}

	if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1) {
		return false;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++) {
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)	{
		return false;
	}
	return true;
}

//valida CNPJ
function valida_CGC(s) {
	valida_CNPJ(s);
}
function valida_CNPJ(s) {
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
	if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
	return true;
}

function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";

	for (var i=0; i<S.length; i++)    {
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)    {
			temp=temp+digito    }
	}
	return temp
}
// cgc


/////////// COMBO BOX ////////
function adiciona(nome,codigo,objeto) {
	linha = document.createElement("OPTION");
	linha.text=nome;
	linha.value=codigo;
	if (oBw.ie) document.getElementById(objeto).add(linha);
	else document.getElementById(objeto).appendChild(linha);
}

//APAGA TODOS OS VALORES DO OBJETO OPTION
function remove_tudo(objeto) {
	var c=getObj(objeto);
    while(c.options.length>0)c.options[0]=null;
}

// função não utilizada
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return "";
	}

	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);

	if(TRIM_VALUE==""){
		return "";
	} else {
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";

	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
	iTemp = iTemp-1;

	} //End While
	return strTemp;
} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);

	if(v_length < 1){
		return "";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function
/////////// COMBO BOX ////////////////

/*
pop-up
<a href="#" onClick="abre_janela('descricao/acrilica/economico.htm','nome_janela',155,350,0); return false;">
*/
function abre_janela(arquivo,nm_janela,h,l,rolagem) {
	var x = ((screen.width-l)/2);
	var y = ((screen.height-h)/2);
	r_janela = window.open(arquivo, nm_janela, 'toolbar=no,location=no,directories=no,status=no,scrollbars=' + rolagem + ',resizable=no,menubar=no,width='+l+',height='+h+',top=' + y + ',left=' + x );
	r_janela.focus();
}

//dialogbox
/*
function abre_dialog(arquivo,h,w,edge,center,help,resizable,status) {
	var x = ((screen.width-l)/2);
	var y = ((screen.height-h)/2);
	window.showModalDialog(arquivo,"Dialog Box Arguments # 1","dialogHeight: "+h+"px; dialogWidth: "+w+"px; dialogTop: "+x+"px; dialogLeft: "+y+"px; edge: "+edge+"; center: "+center+"; help: "+help+"; resizable: "+resizable+"; status: "++";");
}
*/


/*
Maxtext v1.0 - The <textarea> "maxlength" enforcer!
© 2002 Robert K. Davis

This script may be used freely as long as these
credits are included in their entirety.

	Instructions:

	Simply add the following code within
	your <textarea> tag, and change "255"
	to the maximum number of characters
	that you want to allow:

	onblur="maxtext(255,this)"
	onkeydown="textstatus(255,this)"
	onkeyup="textstatus(255,this)"

Exmeplo:
<textarea name="ds_motivo_bloqueio" cols="32" rows="4" id="ds_motivo_bloqueio" onkeydown="textstatus(255,this);maxtext(255,this);" onkeyup="textstatus(255,this);maxtext(255,this);">{$ds_motivo_bloqueio}</textarea>
*/

// Begin window status update
function textstatus(x,thefield){
	var thelength = thefield.value.length;
	window.status=thelength+' de '+x+' caracteres permitidos.';
}

// Begin field length check
function maxtext(x,thefield){
	var thelength = thefield.value.length;
	if(thelength>x){
		alert('Somente '+x+' caracteres são permitidos!\n\n'+(thelength-x)+' serão removidos.');
		thetrimmedvalue = thefield.value.substring(0,x);
		thefield.value = thetrimmedvalue;
		textstatus(x,thefield);
	}
	else{
		textstatus(x,thefield);
	}
}
/* End Maxtext v1.0 */


function voltar() {
	getObj("bt_voltar").value = "Aguarde...";
	getObj("bt_voltar").disabled = true;
	history.back();
}

function lembrar_senha() {
	edUsuario = getObj("edUsuario").value;
	if (!validar_email(edUsuario)) {
		getObj("edUsuario").select();
		alert("Endereço de email incorreto!");
	} else {
		window.location = "?pg=lembrar_senha&prod=curriculo&ds_email="+edUsuario;
	}
}


// marca e desmarca todos os checkboxes
// no final executa função verif_cbox
// para atualizar o campo marcados (oculto)
function on_off() {
	d = document.form;
	e = d.length;
	alert(e);
	return false;

	for (i=0; i < e; i++) {
		elemento = getObj(i);
		alert(elemento);

		/*
		if (elemento.name.substr(0,3) == "cb_") {
			if (todos.checked==true) {
				elemento.checked=true;
			} else {
				elemento.checked=false;
			}
		}
		*/
	}
}

// Exibe ou oculta um elemente
// Testado: Não
// Exemplo:
function viewElement( str_element, boo_status ) {
	// Recupera o elemento
	obj = getObj( str_element );
	if ( boo_status )
		obj.style.display = '';
	else
		obj.style.display = 'none';
}

// Retorna a largura da tela
function getWindowWidth() {
	return iens6 ? ( ieBox ? ( document.body.clientWidth  + document.body.scrollLeft ) : ( document.documentElement.clientWidth + document.documentElement.scrollLeft ) ) : window.innerWidth;
}

// Retorna a altura da tela
// Testato: Não
// Exemplo:
function getWindowHeight() {
	if ( iens6 ) {
		if ( ieBox )
			teste = document.body.clientHeight + document.body.scrollTop;
		else
			teste = document.documentElement.clientHeight + document.documentElement.scrollTop;
	} else
		teste = window.innerHeight;

	return teste;
}

// Esta função coloca o foco no primeiro campo text que existir na tela
function loadFocus() {
	var obj = document.forms;

	for ( x = 0; x < obj.length; x++ ) {
		var objetos = obj[x].length;

		for ( i = 0; i < objetos; i++ ) {
			if ( ( ( obj[x].elements[i].type == 'text' ) || ( obj[x].elements[i].type == 'textarea' ) || ( obj[x].elements[i].type == 'password' ) ) && ( obj[x].elements[i].disabled == false ) ) {
				obj[x].elements[i].focus();
				return true;
			}
		}
	}
	return false
}

// Esta função desativa todos os controles do formulário
function disabledControls() {
	var obj = document.forms;

	for ( x = 0; x < obj.length; x++ ) {
		var objetos = obj[x].length;

		for ( i = 0; i < objetos; i++ )
			if ( obj[x].elements[i].type != 'button' )
				obj[x].elements[i].disabled = true;
	}
}

/*==================================================
  Cookie functions
  ==================================================*/
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

//aciona o ícone na área de localização
//informa algum processo em andamento
function set_carregando(status) {
	img_src = getObj("img_carregando").src;
	if (status) {
		getObj("img_carregando").src = img_src.replace("carregando_stop.gif","carregando_play.gif");
	} else {
		getObj("img_carregando").src = img_src.replace("carregando_play.gif","carregando_stop.gif");
	}
}

function editor() {
	editor_generate("DS_EMKT",config);
}


//Seleciona todos os checkbox
function CheckAll() {
	for (var i=0;i<document.form1.elements.length;i++) {
		var x = document.form1.elements[i];
		if (x.name == "imprime[]") {
			x.checked = document.form1.sel_todos.checked;
		}
	}
}

//Seleciona todos os checkbox
function CheckAllo() {
	for (var i=0;i<document.form_vavt.elements.length;i++) {
		var x = document.form_vavt.elements[i];
		if (x.name == "imprime[]") {
			x.checked = document.form_vavt.sel_todos.checked;
		}
	}
}

//Seleciona a linha todo do table para selecionar o checkbox
function marca_ckeck(imprimir){
	var chk = imprimir.getElementsByTagName("input");
	chk[0].checked = !chk[0].checked;
}

function fechamento_ativo(){

}
