
function enviandoForm(id) {
	var form = document.getElementById(id);
	var nome;
	var id_field;
	var field;
	for (i=0;i<form.length;i++) {
		field = form.elements[i];
		nome = field.getAttribute("name");
	 	field.disabled = true;
	}
	chamaLoad();
}

function chamaLoad() {
	var barLoad = document.getElementsByTagName('body').item(0);
	barLoad.style.overflow = "hidden";
	document.getElementById('janelaLoading').style.display = "block";
	exibirBgBodyLoad();	
}

function fechaLoad() {
	var barLoad = document.getElementsByTagName('body').item(0);	
	barLoad.style.overflow = "";	
	document.getElementById('janelaLoading').style.display = "none";
	removerDivsLoading();
}

// retorna id do elemento
function gEi(ID) {
	return document.getElementById(ID);
}

// retorna tag do elemento
function gEs(tag) {
	return document.getElementsByTagName(tag);
}
// cria uma div com id bgBody do mesmo tamanho da página com fundo preto com opacidade
function exibirBgBodyLoad() {
	var tagBody = gEs('body').item(0);
	var sizesPage = getPagina();
	var bgBodyLoad = document.createElement('div');
	bgBodyLoad.setAttribute('id','bgBodyLoading');
	bgBodyLoad.style.height = arrayPageSize[1] + 'px';
	bgBodyLoad.style.width = arrayPageSize[0] + 'px';
	if (!gEi('bgBodyLoading')) {
		tagBody.insertBefore(bgBodyLoad, tagBody.firstChild);
	}	
}

// Esta função elimina da página o fundo criado sobre o body
function removerDivsLoading() {
	var bgBodyLoad = gE('bgBodyLoading');
	if(bgBodyLoad){
		bgBodyLoad.parentNode.removeChild(bgBodyLoad);
	}
}	

// Pega o tamanho real da página
function getPagina(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

}

// passar o no e o valor caso seja vazio.
function validaNoXml(no,valor)
{
	if (no.firstChild == null) 
		return valor; 
	else 
	{
		if (!document.all && no.childNodes.length > 1) {
			var texto = '';
			for (c = 0; c < no.childNodes.length; c++)
            {
                texto += no.childNodes[c].data;
            }
			return texto;
		}
		else
		return no.firstChild.nodeValue;
	}
}

