
	function deleteFile(pagina){
		if (confirm('Você deseja realmente excluir o arquivo?')){
			document.getElementById('erros').style.display = 'none';
			document.getElementById('divcarregando').style.display = '';
			document.getElementById('ifrRotinas').src = pagina;
		}
	}
	
	function attachFile(arquivo,campo){
		var campoFile = window.opener.document.getElementById(campo);
		var campoDSBFile = window.opener.document.getElementById(campo + '_dsb');
		if (campoFile){
			campoFile.value = arquivo;
			if (campoDSBFile){
				campoDSBFile.value = arquivo;	
			}
		}
		window.close();
	}
	
	function colorOver(id){
		if (document.getElementById(id)){
			document.getElementById(id).style.backgroundColor = '#F1F1F1';
		}
	}

	function colorOut(id,color){
		if (document.getElementById(id)){
			document.getElementById(id).style.backgroundColor = color;
		}
	}
	
	function sourceFile(pathUploader,Linguagem,pathFiles,idcampo){
		var pagina = pathUploader + '/' + Linguagem + '/upload.' + Linguagem + '?pasta=' + pathFiles + '&idcampo=' + idcampo;
		window.open(pagina,'UPLOAD','top=0px,left=0px,width=800px,height=600px');
	}
	
	function addFiles(id,pathUploader,Linguagem,pathFiles,campo,limite){
		var objAttch = document.getElementById(id);
		var limite = parseInt(limite);
		document.getElementById(id).style.display = '';
		if (objAttch){
			var nrNodes = objAttch.childNodes.length;
			nrNodes++;
			if (nrNodes <= limite){
				var idDiv = id + nrNodes;
				var div = document.createElement('DIV');
				div.id = idDiv;
				div.style.marginBottom = '5px';
				div.innerHTML = "<img src=\"" + pathUploader + "/img/attach.gif\">&nbsp;<input name=\"" + campo + "\" id=\"" + campo + nrNodes + "\" type=\"hidden\" /><input style=\"width:225px;\" id=\"" + campo + nrNodes + "_dsb\" type=\"text\" disabled=\"disabled\" />&nbsp;<a id='link_source_" + nrNodes + "' href=\"javascript:sourceFile('" + pathUploader + "','" + Linguagem + "','" + pathFiles + "','" + campo + nrNodes + "');\">Anexar Arquivo</a>&nbsp;<a id='link_delete_" + nrNodes + "' href=\"javascript:deleteAttch('" + id + "','" + campo + "'," + nrNodes + ",'" + pathUploader + "','" + Linguagem + "','" + pathFiles + "'," + limite + ");\">Excluir</a>";
				document.getElementById(id).appendChild(div);
				if (nrNodes == limite){
					if (document.getElementById('AdicionarAttch')){
						document.getElementById('AdicionarAttch').style.display = 'none';
					}
				}else{
					if (document.getElementById('ExcluirTodos')){
						document.getElementById('ExcluirTodos').style.display = '';
					}
				}
			}
		}
	}
	
	function deleteFiles(id){
		var objAttch = document.getElementById(id);
		if (objAttch){
			objAttch.innerHTML = '';
			document.getElementById('ExcluirTodos').style.display = 'none';
			document.getElementById('AdicionarAttch').style.display = '';
			document.getElementById(id).style.display = 'none';
		}
	}
	
	function deleteAttch(idUploader,campo,id,pathUploader,Linguagem,pathFiles,Limit){
		var intLimit = parseInt(Limit);
		if (intLimit != 1){
			var objAttchs = document.getElementById(idUploader);
			var objAttch = document.getElementById(campo + id);
			objAttchs.removeChild(objAttch);
			var nrNodes = objAttchs.childNodes.length;
			var y = 0;
			for (x=0;x<nrNodes;x++){
				y++;
				objAttchs.childNodes[x].id = idUploader + y;
				document.getElementById(campo + y).childNodes[2].id = campo + y;
				document.getElementById(campo + y).childNodes[3].id = campo + y + '_dsb';
				document.getElementById(campo + y).childNodes[5].id = 'link_source_' + y;
				document.getElementById(campo + y).childNodes[7].id = 'link_delete_' + y;
				document.getElementById('link_source_' + y).href = "javascript:sourceFile('" + pathUploader + "','" + Linguagem + "','" + pathFiles + "','" + campo + y + "');";
				document.getElementById('link_delete_' + y).href = "javascript:deleteAttch('" + idUploader + "','" + campo + "'," + y + ",'" + pathUploader + "','" + Linguagem + "','" + pathFiles + "')";
			}
			if (nrNodes == 0){
				document.getElementById(idUploader).style.display = 'none';
				if (document.getElementById('ExcluirTodos')){
					document.getElementById('ExcluirTodos').style.display = 'none';
				}
			}
			if (document.getElementById('AdicionarAttch')){
				document.getElementById('AdicionarAttch').style.display = '';
			}
		}else{
			if (document.getElementById(campo + '1')){
				document.getElementById(campo + '1').value = '';
				document.getElementById(campo + '1_dsb').value = '';
			}
		}
	}
	
	function LoadForm(tmpForm){
		document.getElementById('erros').style.display = 'none';
		document.getElementById('divcarregando').style.display = '';
		document.getElementById('form').submit();
	}
	
	function captureActiveFile(id){
		var active = window.opener.document.getElementById(id).value;
		if (active != ''){
			if (document.getElementById(active)){
				document.getElementById(active).style.border = 'solid 6px #009900';
			}
		}
	}

