var zebra = "";
function processaFormSistema(modo) {
	switch (modo) {
		case 1:
			document.getElementById('FormDados').style.display = 'none';
			document.getElementById('FormResults').style.display = 'inline';
			document.getElementById('FormResults').innerHTML = '<p align="center" style="padding: 30px">Aguarde enquanto as informa&ccedil;&otilde;es s&atilde;o processadas...</p>';
			break;
		case 2:
			document.getElementById('FormDados').style.display = 'inline';
			document.getElementById('FormResults').style.display = 'none';
			document.getElementById('FormResults').innerHTML = '';
			break;
	}	
}

function SelectAll(obj,el)
{
	var acao = el.checked
 	var table =document.getElementById(obj);
 	var select = table.getElementsByTagName('input');
 	for(var i = 0; i < select.length; i++){
 		if(select[i].type == "checkbox" && select[i].name != "checkAll"){
 			select[i].checked = acao;
 		}
 	}

}

function GetCodChecked(obj,el)
{
	var valores = '';
	var acao = el.checked
 	var table =document.getElementById(obj);
 	var select = table.getElementsByTagName('input');
 	for(var i = 0; i < select.length; i++){
 		if(select[i].type == "checkbox" && select[i].checked  && select[i].name != "checkAll"){
 			valores +=  select[i].value+"|";
 		}
 	}

	return valores;
}

function addArquivo(idTabela){
	var tabela = document.getElementById(idTabela);
	
	if(!document.getElementById("content")){
		var tabelaContent =  document.createElement("table");
		tabelaContent.width = "100%";
		tabelaContent.className = "arquivos"
		var content = document.createElement("tbody");
		content.id = "content";
		tabelaContent.appendChild(content)
		tabela.appendChild(tabelaContent);
	}else{
		var content = document.getElementById("content");
	}
	
	
	var newFields = document.createElement("input");
	newFields.type = "file";
	newFields.name = "mensagem[]";
	//newFields.style.width = "100%";
	tr = document.createElement("tr");
	if(zebra == ""){
		zebra = 'zebra';
	}else{
		zebra = '';
	}
	tr.className = zebra;
	td = document.createElement("td");
	tdVazia = document.createElement("td");
	
	var btnExclui = document.createElement("a");
	btnExclui.appendChild(document.createTextNode("Remover"));
	btnExclui.className = "remove";
	btnExclui.style.fonteSize = "10px";
	btnExclui.href = "#";
	btnExclui.onclick = function(){removeArquivo(this);}
	
	tdExclui = document.createElement("td");
	tdExclui.appendChild(btnExclui);
	
	
	newFields.size = "100"
	//tdVazia.appendChild(document.createTextNode("Arquivo: "));
	td.appendChild(newFields);
	

	//tr.appendChild(tdVazia);
	tr.appendChild(td);
	tr.appendChild(tdExclui);
	content.appendChild(tr);
}

function removeArquivo(elemento){
	
	var recebe = elemento.parentNode.parentNode.parentNode;
	elemento.parentNode.parentNode.parentNode.removeChild(elemento.parentNode.parentNode);
	if(recebe.getElementsByTagName('tr').length <= 0 ){
		recebe.parentNode.parentNode.removeChild(recebe.parentNode);
	}
} 
