<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve conter um endereço de email.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve conter um número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve conter um número entre '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é necessário.\n'; }
  } if (errors) alert('Os seguintes erros ocorreram:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function goTo(URLLocation) {
	location = URLLocation;
}

function destaqueItem(action,codDestaque) {
	document.destaquesList.action.value = "updateordemdestaques";
	if (action == "add") {
		document.destaquesList.subaction.value = "destaqueeditor";
	} else if (action == "del") {
		document.destaquesList.subaction.value = "deldestaque";
		document.destaquesList.codDestaque.value = codDestaque;
	} else if (action == "edit") {
		document.destaquesList.subaction.value = "destaqueeditor";
		document.destaquesList.codDestaque.value = codDestaque;	
	} else if (action == "updateinativo") {
		document.destaquesList.action.value = "updateordemdestaquesinativos";
	}
	document.destaquesList.submit();
}

function destaquesUpDown(trObj,nRow,direction) {
	dynTable = document.getElementById("tableDestaques");
	
	if (direction == "cima") {
		// Armazena os valores dos codigos das linhas da tabela.
		mCodigo1 = document.getElementById("codigo" + (nRow - 1)).value;
		mCodigo2 = document.getElementById("codigo" + nRow).value;
		// Armazena os valores dos status das linhas da tabela.
		mStatus1 = document.getElementById("status" + (nRow - 1)).value;
		mStatus2 = document.getElementById("status" + nRow).value;
		// Troca as linhas da atual para cima.
		nLineUp = dynTable.rows[nRow - 1].cells[1].innerHTML;
		nLine = dynTable.rows[nRow].cells[1].innerHTML;
		dynTable.rows[nRow - 1].cells[1].innerHTML = nLine;
		dynTable.rows[nRow].cells[1].innerHTML = nLineUp;
		nLineUp = dynTable.rows[nRow - 1].cells[3].innerHTML;
		nLine = dynTable.rows[nRow].cells[3].innerHTML;
		dynTable.rows[nRow - 1].cells[3].innerHTML = nLine;
		dynTable.rows[nRow].cells[3].innerHTML = nLineUp;
		// Troca os valores dos codigos das linhas da tabela.
		document.getElementById("codigo" + (nRow - 1)).value = mCodigo2;
		document.getElementById("codigo" + nRow).value = mCodigo1;
		// Troca os valores dos status das linhas da tabela.
		document.getElementById("status" + (nRow - 1)).value = mStatus2;
		document.getElementById("status" + nRow).value = mStatus1;
	}
	if (direction == "baixo") {
		// Armazena os valores dos sistemas das linhas da tabela.
		mCodigo1 = document.getElementById("codigo" + nRow).value;
		mCodigo2 = document.getElementById("codigo" + (nRow + 1)).value;
		// Armazena os valores dos status das linhas da tabela.
		mStatus1 = document.getElementById("status" + nRow).value;
		mStatus2 = document.getElementById("status" + (nRow + 1)).value;
		// Troca as linhas da atual para cima.
		nLineDown = dynTable.rows[nRow + 1].cells[1].innerHTML;
		nLine = dynTable.rows[nRow].cells[1].innerHTML;
		dynTable.rows[nRow + 1].cells[1].innerHTML = nLine;
		dynTable.rows[nRow].cells[1].innerHTML = nLineDown;
		nLineDown = dynTable.rows[nRow + 1].cells[3].innerHTML;
		nLine = dynTable.rows[nRow].cells[3].innerHTML;
		dynTable.rows[nRow + 1].cells[3].innerHTML = nLine;
		dynTable.rows[nRow].cells[3].innerHTML = nLineDown;
		// Troca os valores dos codigos das linhas da tabela.
		document.getElementById("codigo" + nRow).value = mCodigo2;
		document.getElementById("codigo" + (nRow + 1)).value = mCodigo1;
		// Troca os valores dos status das linhas da tabela.
		document.getElementById("status" + nRow).value = mStatus2;
		document.getElementById("status" + (nRow + 1)).value = mStatus1;
	}
}

function modulosUpDown(nRow,direction) {
	varDynTable = document.getElementById("dynTable");
	
	if (direction == "cima") {
		// Armazena os valores dos codigos das linhas da tabela.
		mCodigo1 = document.getElementById("codigo" + (nRow - 1)).value;
		mCodigo2 = document.getElementById("codigo" + nRow).value;
		// Troca as linhas da atual para cima.
		nLineUp = varDynTable.rows[nRow - 1].cells[1].innerHTML;
		nLine = varDynTable.rows[nRow].cells[1].innerHTML;
		varDynTable.rows[nRow - 1].cells[1].innerHTML = nLine;
		varDynTable.rows[nRow].cells[1].innerHTML = nLineUp;
		// Troca os valores dos codigos das linhas da tabela.
		document.getElementById("codigo" + (nRow - 1)).value = mCodigo2;
		document.getElementById("codigo" + nRow).value = mCodigo1;
	}
	if (direction == "baixo") {
		// Armazena os valores dos sistemas das linhas da tabela.
		mCodigo1 = document.getElementById("codigo" + nRow).value;
		mCodigo2 = document.getElementById("codigo" + (nRow + 1)).value;
		// Troca as linhas da atual para cima.
		nLineDown = varDynTable.rows[nRow + 1].cells[1].innerHTML;
		nLine = varDynTable.rows[nRow].cells[1].innerHTML;
		varDynTable.rows[nRow + 1].cells[1].innerHTML = nLine;
		varDynTable.rows[nRow].cells[1].innerHTML = nLineDown;
		// Troca os valores dos codigos das linhas da tabela.
		document.getElementById("codigo" + nRow).value = mCodigo2;
		document.getElementById("codigo" + (nRow + 1)).value = mCodigo1;
	}
}

function verificaDestaques(nLine) {
	stringForm = "document.destaquesList.order" + nLine + ".value";
	stringAlert = "order" + nLine + " = " + eval(stringForm) + "\n\n";
	
	stringForm = "document.destaquesList.codigo" + nLine + ".value";
	stringAlert += "codigo" + nLine + " = " + eval(stringForm) + "\n\n";
	
	stringForm = "document.destaquesList.status" + nLine + ".value";
	stringAlert += "status" + nLine + " = " + eval(stringForm) + "\n\n";
	
	alert(stringAlert);
}

function verificaLinks(type,conpagID) {
	document.editorForm.conpagID.value = conpagID;
	if (type == "int") {
		document.editorForm.linkExterno.value = 0;
		document.editorForm.linkNews.value = 0;
		document.editorForm.linkDownload.value = 0;
		document.editorForm.linkGaleria.value = 0;
	} else if (type == "ext") {
		document.editorForm.linkInterno.value = 0;
		document.editorForm.linkNews.value = 0;
		document.editorForm.linkDownload.value = 0;
		document.editorForm.linkGaleria.value = 0;
	} else if (type == "news") {
		document.editorForm.linkInterno.value = 0;
		document.editorForm.linkExterno.value = 0;
		document.editorForm.linkDownload.value = 0;
		document.editorForm.linkGaleria.value = 0;
	} else if (type == "down") {
		document.editorForm.linkInterno.value = 0;
		document.editorForm.linkExterno.value = 0;
		document.editorForm.linkNews.value = 0;
		document.editorForm.linkGaleria.value = 0;
	} else if (type == "galeria") {
		document.editorForm.linkInterno.value = 0;
		document.editorForm.linkExterno.value = 0;
		document.editorForm.linkNews.value = 0;
		document.editorForm.linkDownload.value = 0;
	}
}

function getAbsolutePos(el) {
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent) {
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
};

function resizeWindow(wPx, hPx) {
	if (!wPx || !hPx) {
		if (!document.all) {
			sizeToContent();
			sizeToContent();
		} else {
			var body_height = 0;
			var body = document.body;
			var div = document.createElement("div");
			var tableZoom = document.getElementById("zoomTable");
			body.appendChild(div);
			var pos = getAbsolutePos(div);
			body_height = pos.y;
			resizeTo(tableZoom.clientWidth + 10, body_height);
			var ch = body.clientHeight;
			var cw = body.clientWidth;
			resizeBy(0, body_height - ch);
		}
	} else {
		resizeTo(wPx,hPx);
	}
}

function disabledFields(fieldName, action) {
	eval("document." + fieldName + ".disabled=" + action);
}

function valueFields(fieldName, value) {
	if (value == "") {
		eval("document." + fieldName + ".value=''");
	} else {
		eval("document." + fieldName + ".value=" + value);
	}
}

function inputFocus(formName,fieldName) {
	eval("document." + formName + "." + fieldName + ".focus()");
	eval("document." + formName + "." + fieldName + ".select()");
}

function submitEmail(action) {
	if (action == "save") {
		document.editorForm.action.value = "saveemail";
	} else if (action == "send") {
		document.editorForm.action.value = "sendemail";
	} else if (action == "senderror") {
		document.editorForm.action.value = "sendemailerror";
	} else if (action == "update") {
		document.editorForm.action.value = "updateemail";
	}
}

function View(color) {
	document.getElementById("ColorPreview").style.backgroundColor = '#' + color;
	document.getElementById("ColorHex").value = '#' + color;
}

function Set(color) {
	document.getElementById("Valor").value = '#' + color;
}

function previewEmail() {
	var innerText = xinha_editors.conteudoForm.getHTML();
	document.editorForm.conteudoForm_html.value = innerText;
	
	stringPreview = "email_preview.php?arquivo=" + document.editorForm.template.value;
	MM_openBrWindow(stringPreview,'previewWindow','status=yes,scrollbars=yes,resizable=no,width=650,height=500');
}

function previewEditor() {
	var innerText = xinha_editors.conteudoForm.getHTML();
	document.editorForm.conteudoForm_html.value = innerText;
	
	var templateID = document.editorForm.template.value;
	
	MM_openBrWindow('preview.php?action=formPreview&templateID=' + templateID,'previewWindow','status=yes,scrollbars=yes,resizable=no,width=790,height=500');
}

function habilitaArea(adminObj) {
	admin = adminObj.value;
	if (admin == 1) {
		document.userForm.areas.disabled = false;
	} else {
		document.userForm.areas.disabled = true;
	}
}

function validarSenha(varBool) {
	document.changePass.changePassword.value = varBool;
	
	if (varBool == 1) {
		if (document.changePass.senha1.value == document.changePass.senha2.value) {
			document.changePass.submit();
		} else {
			alert("Os dois campos de senha precisam ser exatamente iguais!");
			document.changePass.senha1.value = "";
			document.changePass.senha2.value = "";
			
			document.changePass.senha1.focus() = "";
			document.changePass.senha1.select() = "";
		}
	} else if (varBool == 0) {
		document.changePass.submit();
	}
}

function desabilitaSenha() {
	if (document.userForm.autopassword.checked) {
		document.userForm.Password1.value = "";
		document.userForm.Password1.disabled = true;
		document.userForm.Password2.value = "";
		document.userForm.Password2.disabled = true;
	} else {
		document.userForm.Password1.disabled = false;
		document.userForm.Password2.disabled = false;
	}
}

var smooth_timer;

function smoothHeight(id, curH, targetH, stepH, mode) {
	diff = targetH - curH;
	
	if (diff != 0) {
		newH = (diff > 0) ? curH + stepH : curH - stepH;
		((document.getElementById) ? document.getElementById(id) : eval("document.all['" + id + "']")).style.height = newH + "px";
		if (smooth_timer) {
			window.clearTimeout(smooth_timer);
		}
		smooth_timer = window.setTimeout( "smoothHeight('" + id + "'," + newH + "," + targetH + "," + stepH + ",'" + mode + "')", 20 );
	} else if (mode != "o") {
		((document.getElementById) ? document.getElementById(mode) : eval("document.all['" + mode + "']")).style.display="none";
	}
}

function servOC(i, href) {
	var trObj = (document.getElementById) ? document.getElementById('ihtr' + i) : eval("document.all['ihtr" + i + "']");
	var ifObj = (document.getElementById) ? document.getElementById('ihif' + i) : eval("document.all['ihif" + i + "']");
	
	if (trObj != null) {
		if (trObj.style.display=="none") {
			trObj.style.display="";
			ifObj.src = href;
			smoothHeight('ihif' + i, 0, 210, 42, 'o');
		} else {
			trObj.style.display = "none";
			ifObj.src = "";
			smoothHeight('ihif' + i, 210, 0, 42, 'ihtr' + i);
		}
	}
}

function abreFieldFrame(nOption) {
	codField = document.getElementById("codField[" + (nOption - 1) + "]").value;
	tipoField = document.getElementById("type[" + (nOption - 1) + "]").value;
	sizeField = document.getElementById("size1[" + (nOption - 1) + "]").value;
	
	if (codField == "") {
		alert("Antes de abrir a edição do campo, é necessário atualizar o formulário para gravar o campo que está adicionando.");
	} else {
		stringURL = "admin.php?action=editformfield&tipo=" + tipoField + "&line=" + nOption + "&cod=" + codField;
		if (sizeField > 0) {
			stringURL += "&size=" + sizeField;
		}
		servOC(nOption, stringURL);
	}
}

function addRowFormTable() {
	varTableObj = document.getElementById("tableForm");
	varBodyTableObj = document.getElementById("bodyTable");
	varRowRodape = document.getElementById("rowRodape");
	nRowsAdd = parseInt(document.getElementById("nField").value);
	nFields = parseInt(document.getElementById("nFields").value);
	nOption = nFields + 1;
	rowsTable = "";
	
	if (nRowsAdd > 0) {
		varLastTR = document.getElementById("line" + nFields);
		varLastTR.cells[0].innerHTML = "";
		if (nFields > 1) {
			varLastTR.cells[0].innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nFields + ",\"baixo\")'><img src='" + defaultSkinDir + "images/seta_baixo.gif' width='8' height='18' border='0' title='Mover para baixo'></a>&nbsp;<a href='javascript:;' onClick='trocaLinhasForm(" + nFields + ",\"cima\")'><img src='" + defaultSkinDir + "images/seta_cima.gif' width='8' height='18' border='0' title='Mover para cima'></a>&nbsp;";
		} else if (nFields == 1) {
			varLastTR.cells[0].innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nFields + ",\"baixo\")'><img src='" + defaultSkinDir + "images/seta_baixo.gif' width='8' height='18' border='0' title='Mover para baixo'></a>&nbsp;";
		}
		
		for (x = 0; x < nRowsAdd; x++) {
			varNewLinha = document.createElement("tr");
			varNewLinha.setAttribute("id", "line" + nOption);
			
			varNewColuna = document.createElement("td");
			varNewColuna.setAttribute("align", "center");
			if (nRowsAdd == 1) {
				varNewColuna.innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"cima\")'><img src='" + defaultSkinDir + "images/seta_cima.gif' width='8' height='18' border='0' title='Mover para cima'></a>";
			} else if ((nRowsAdd > 1) && (x < (nRowsAdd - 1))) {
				varNewColuna.innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"baixo\")'><img src='" + defaultSkinDir + "images/seta_baixo.gif' width='8' height='18' border='0' title='Mover para baixo'></a>&nbsp;<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"cima\")'><img src='" + defaultSkinDir + "images/seta_cima.gif' width='8' height='18' border='0' title='Mover para cima'></a>";
			} else {
				varNewColuna.innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"cima\")'><img src='" + defaultSkinDir + "images/seta_cima.gif' width='8' height='18' border='0' title='Mover para cima'></a>";
			}
			varNewLinha.appendChild(varNewColuna);
			
			varNewColuna = document.createElement("td");
			varNewColuna.innerHTML = "<input type='hidden' id='order" + nOption + "' name='order" + nOption + "' value='" + nOption + "'><input type=checkbox id='required[" + (nOption - 1) + "]' name='required[" + (nOption - 1) + "]' value='on'>";
			varNewLinha.appendChild(varNewColuna);
			
			varNewColuna = document.createElement("td");
			varNewColuna.innerHTML = "<input type='hidden' id='codField[" + (nOption - 1) + "]' name='codField[" + (nOption - 1) + "]'><input type='text' id='titulo[" + (nOption - 1) + "]' name='titulo[" + (nOption - 1) + "]' size='20' value=''>";
			varNewLinha.appendChild(varNewColuna);
			
			varNewColuna = document.createElement("td");
			varNewColuna.innerHTML = "<input type='name' id='name[" + (nOption - 1) + "]' name='name[" + (nOption - 1) + "]' size='10' value=''>";
			varNewLinha.appendChild(varNewColuna);
			
			varNewColuna = document.createElement("td");
			rowsTableNew = "<select id='type[" + (nOption - 1) + "]' name='type[" + (nOption - 1) + "]'>\n";
			rowsTableNew += "	<option value='textarea'>Área de texto\n"
			rowsTableNew += "	<option value='radio'>Botão tipo rádio\n";
			rowsTableNew += "	<option value='checkbox'>Caixa de checagem\n";
			rowsTableNew += "	<option value='select'>Caixa de seleção\n";
			rowsTableNew += "	<option value='hidden'>Campo invisível\n";
			rowsTableNew += "	<option value='password'>Senha\n";
			rowsTableNew += "	<option value='text'>Texto\n";
			rowsTableNew += "	<option value='titulo'>Título (não envia dados)\n";
			rowsTableNew += "	<option value='ENV'>Variável de sistema\n";
			rowsTableNew += "</select>";
			varNewColuna.innerHTML = rowsTableNew;
			varNewLinha.appendChild(varNewColuna);
			
			varNewColuna = document.createElement("td");
			varNewColuna.innerHTML = "<input type=text id='size1[" + (nOption - 1) + "]' name='size1[" + (nOption - 1) + "]' size=2 value=''>";
			varNewLinha.appendChild(varNewColuna);
			
			varNewColuna = document.createElement("td");
			varNewColuna.innerHTML = "<input type=text id='size2[" + (nOption - 1) + "]' name='size2[" + (nOption - 1) + "]' size=2 value=''>";
			varNewLinha.appendChild(varNewColuna);
			
			varNewColuna = document.createElement("td");
			varNewColuna.setAttribute("id", "editDel" + nOption);
			if (document.getElementById("action").value == "updateform") {
				varNewColuna.innerHTML = "<a href='javascript:;' onClick='abreFieldFrame(" + nOption + ");'><img src='" + defaultSkinDir + "images/admin/botao_editar.gif' border='0' hspace='5' vspace='5' align='middle' title='Editar'></a><a href='javascript:;' onClick='delRowFormTable(" + nOption + ");'><img src='" + defaultSkinDir + "images/admin/botao_excluir.gif' border='0' hspace='5' vspace='5' align='middle' title='Excluir'></a>";
			} else if (document.getElementById("action").value == "addform") {
				varNewColuna.innerHTML = "<a href='javascript:;' onClick='delRowFormTable(" + nOption + ");'><img src='" + defaultSkinDir + "images/admin/botao_excluir.gif' border='0' hspace='5' vspace='5' align='middle' title='Excluir'></a>";
			}
			varNewLinha.appendChild(varNewColuna);
			
			varBodyTableObj.insertBefore(varNewLinha, varRowRodape);
			
			if (document.getElementById("action").value == "updateform") {
				varNewLinha = document.createElement("tr");
				varNewLinha.setAttribute("style", "display:none");
				varNewLinha.style.display = "none";
				varNewLinha.setAttribute("id", "ihtr" + nOption);
				
				varNewColuna = document.createElement("td");
				varNewColuna.setAttribute("colSpan", 8);
				rowsTableNew = "<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n";
				rowsTableNew += "<tr>\n";
				rowsTableNew += "<td width='10'></td>\n";
				rowsTableNew += "<td style='border:2px solid #000000'><iframe frameborder='0' width='100%' id='ihif" + nOption + "'></iframe></td>\n";
				rowsTableNew += "</tr>\n";
				rowsTableNew += "</table>\n";
				varNewColuna.innerHTML = rowsTableNew;
				varNewLinha.appendChild(varNewColuna);
				
				varBodyTableObj.insertBefore(varNewLinha, varRowRodape);
			}
			nOption++;
		}
		
		document.getElementById("nFields").value = (nOption - 1);
	} else {
		alert("É necessário digitar um número maior que 0 para acrescentar novos campos.");
	}
	
	document.getElementById("nField").value = "";
}

function delRowFormTable(nRow) {
	varTableObj = document.getElementById("tableForm");
	varBodyTableObj = document.getElementById("bodyTable");
	varRowRodape = document.getElementById("rowRodape");
	nFields = document.getElementById("nFields").value;
	nRows = varTableObj.rows.length;
	nOption = 1;
	actionForm = document.getElementById("action").value;
	
	if (nFields > 1) {
		for (x = 1; x <= nFields; x++) {
			if (x != nRow) {
				required = document.getElementById("required[" + (x - 1) + "]").checked;
				codField = document.getElementById("codField[" + (x - 1) + "]").value;
				titulo = document.getElementById("titulo[" + (x - 1) + "]").value;
				name = document.getElementById("name[" + (x - 1) + "]").value;
				type = document.getElementById("type[" + (x - 1) + "]").value;
				size1 = document.getElementById("size1[" + (x - 1) + "]").value;
				size2 = document.getElementById("size2[" + (x - 1) + "]").value;
				
				varTRLine1 = document.getElementById("line" + x);
				varBodyTableObj.removeChild(varTRLine1);
				
				if (actionForm == "updateform") {
					varTRLine2 = document.getElementById("ihtr" + x);
					varBodyTableObj.removeChild(varTRLine2);
				}
				
				varNewLinha = document.createElement("tr");
				varNewLinha.setAttribute("id", "line" + nOption);
				
				varNewColuna = document.createElement("td");
				varNewColuna.setAttribute("align", "center");
				varNewColuna.innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"baixo\")'><img src='" + defaultSkinDir + "/images/seta_baixo.gif' width='8' height='18' border='0' title='Mover para baixo'></a>&nbsp;<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"cima\")'><img src='" + defaultSkinDir + "/images/seta_cima.gif' width='8' height='18' border='0' title='Mover para cima'></a>";
				varNewLinha.appendChild(varNewColuna);
				
				if (required == true) {
					stringChecked = " checked";
				} else {
					stringChecked = "";
				}
				varNewColuna = document.createElement("td");
				varNewColuna.innerHTML = "<input type='hidden' id='order" + nOption + "' name='order" + nOption + "' value='" + nOption + "'><input type=checkbox id='required[" + (nOption - 1) + "]' name='required[" + (nOption - 1) + "]' value='on'" + stringChecked + ">";
				varNewLinha.appendChild(varNewColuna);
				
				varNewColuna = document.createElement("td");
				varNewColuna.innerHTML = "<input type='hidden' id='codField[" + (nOption - 1) + "]' name='codField[" + (nOption - 1) + "]' value='" + codField + "'><input type='text' id='titulo[" + (nOption - 1) + "]' name='titulo[" + (nOption - 1) + "]' size='20' value='" + titulo + "'>";
				varNewLinha.appendChild(varNewColuna);
				
				varNewColuna = document.createElement("td");
				varNewColuna.innerHTML = "<input type='text' id='name[" + (nOption - 1) + "]' name='name[" + (nOption - 1) + "]' size='10' value='" + name + "'>";
				varNewLinha.appendChild(varNewColuna);
				
				varNewColuna = document.createElement("td");
				varNewSelect = document.createElement("select");
				varNewSelect.setAttribute("id", "type[" + (nOption - 1) + "]");
				varNewSelect.setAttribute("name", "type[" + (nOption - 1) + "]");
				varNewOption = document.createElement("option");
				varNewOption.value = "textarea";
				varNewOption.appendChild(document.createTextNode("Área de texto"));
				varNewSelect.appendChild(varNewOption);
				varNewOption = document.createElement("option");
				varNewOption.value = "radio";
				varNewOption.appendChild(document.createTextNode("Botão tipo rádio"));
				varNewSelect.appendChild(varNewOption);
				varNewOption = document.createElement("option");
				varNewOption.value = "checkbox";
				varNewOption.appendChild(document.createTextNode("Caixa de checagem"));
				varNewSelect.appendChild(varNewOption);
				varNewOption = document.createElement("option");
				varNewOption.value = "select";
				varNewOption.appendChild(document.createTextNode("Caixa de seleção"));
				varNewSelect.appendChild(varNewOption);
				varNewOption = document.createElement("option");
				varNewOption.value = "hidden";
				varNewOption.appendChild(document.createTextNode("Campo invisível"));
				varNewSelect.appendChild(varNewOption);
				varNewOption = document.createElement("option");
				varNewOption.value = "password";
				varNewOption.appendChild(document.createTextNode("Senha"));
				varNewSelect.appendChild(varNewOption);
				varNewOption = document.createElement("option");
				varNewOption.value = "text";
				varNewOption.appendChild(document.createTextNode("Texto"));
				varNewSelect.appendChild(varNewOption);
				varNewOption = document.createElement("option");
				varNewOption.value = "titulo";
				varNewOption.appendChild(document.createTextNode("Título (não envia dados)"));
				varNewSelect.appendChild(varNewOption);
				varNewOption = document.createElement("option");
				varNewOption.value = "ENV";
				varNewOption.appendChild(document.createTextNode("Variável de sistema"));
				varNewSelect.appendChild(varNewOption);
				varNewSelect.value = type;
				varNewColuna.appendChild(varNewSelect);
				varNewLinha.appendChild(varNewColuna);
				
				varNewColuna = document.createElement("td");
				varNewColuna.innerHTML = "<input type=text id='size1[" + (nOption - 1) + "]' name='size1[" + (nOption - 1) + "]' size=2 value='" + size1 + "'>";
				varNewLinha.appendChild(varNewColuna);
				
				varNewColuna = document.createElement("td");
				varNewColuna.innerHTML = "<input type=text id='size2[" + (nOption - 1) + "]' name='size2[" + (nOption - 1) + "]' size=2 value='" + size2 + "'>";
				varNewLinha.appendChild(varNewColuna);
				
				varNewColuna = document.createElement("td");
				varNewColuna.setAttribute("id", "editDel" + nOption);
				if (actionForm == "updateform") {
					varNewColuna.innerHTML = "<a href='javascript:;' onClick='abreFieldFrame(" + nOption + ");'><img src='" + defaultSkinDir + "images/admin/botao_editar.gif' border='0' hspace='5' vspace='5' align='middle' title='Editar'></a><a href='javascript:;' onClick='delRowFormTable(" + nOption + ");'><img src='" + defaultSkinDir + "images/admin/botao_excluir.gif' border='0' hspace='5' vspace='5' align='middle' title='Excluir'></a>";
				} else if (actionForm == "addform") {
					varNewColuna.innerHTML = "<a href='javascript:;' onClick='delRowFormTable(" + nOption + ");'><img src='" + defaultSkinDir + "images/admin/botao_excluir.gif' border='0' hspace='5' vspace='5' align='middle' title='Excluir'></a>";
				}
				varNewLinha.appendChild(varNewColuna);
				
				varBodyTableObj.insertBefore(varNewLinha, varRowRodape);
				
				if (actionForm == "updateform") {
					varNewLinha = document.createElement("tr");
					varNewLinha.setAttribute("style", "display:none");
					varNewLinha.style.display = "none";
					varNewLinha.setAttribute("id", "ihtr" + nOption);
					
					varNewColuna = document.createElement("td");
					varNewColuna.setAttribute("colSpan", 8);
					rowsTableNew = "<table width='100%' cellspacing='0' cellpadding='0' border='0'>\n";
					rowsTableNew += "<tr>\n";
					rowsTableNew += "<td width='10'></td>\n";
					rowsTableNew += "<td style='border:2px solid #000000'><iframe frameborder='0' width='100%' id='ihif" + nOption + "'></iframe></td>\n";
					rowsTableNew += "</tr>\n";
					rowsTableNew += "</table>\n";
					varNewColuna.innerHTML = rowsTableNew;
					varNewLinha.appendChild(varNewColuna);
					
					varBodyTableObj.insertBefore(varNewLinha, varRowRodape);
				}
				
				varSetaTR = document.getElementById("line" + nOption);
				if ((nOption == 1) && (nFields > 2)) {
					varSetaTR.cells[0].innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"baixo\")'><img src='" + defaultSkinDir + "images/seta_baixo.gif' width='8' height='18' border='0' title='Mover para baixo'></a>&nbsp;";
				} else if ((nOption == (nFields - 1)) && (nFields > 2)) {
					varSetaTR.cells[0].innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"cima\")'><img src='" + defaultSkinDir + "images/seta_cima.gif' width='8' height='18' border='0' title='Mover para cima'></a>&nbsp;";
				} else if (nFields > 2) {
					varSetaTR.cells[0].innerHTML = "<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"baixo\")'><img src='" + defaultSkinDir + "images/seta_baixo.gif' width='8' height='18' border='0' title='Mover para baixo'></a>&nbsp;<a href='javascript:;' onClick='trocaLinhasForm(" + nOption + ",\"cima\")'><img src='" + defaultSkinDir + "images/seta_cima.gif' width='8' height='18' border='0' title='Mover para cima'></a>&nbsp;";
				} else {
					varSetaTR.cells[0].innerHTML = "";
				}
				
				nOption++;
			} else {
				varTRLine1 = document.getElementById("line" + x);
				varBodyTableObj.removeChild(varTRLine1);
				
				if (actionForm == "updateform") {
					varTRLine2 = document.getElementById("ihtr" + x);
					varBodyTableObj.removeChild(varTRLine2);
				}
			}
		}
		
		document.getElementById("nFields").value = (nOption - 1);
	} else {
		alert("É necessário ter pelo menos 1 campo dentro do formulário.");
	}
}

function addRowTable() {
	nRowsAdd = parseInt(document.getElementById("addField").value);
	varTableObj = document.getElementById("fieldsTable");
	varBodyTableObj = document.getElementById("bodyTable");
	varRowRodape = document.getElementById("rowRodape");
	nRows = varTableObj.rows.length;
	nOption = (nRows - 5) + 1; // 5 = (1 linha de cabecalho + 4 linhas de rodape)
	
	if (nRowsAdd > 0) {
		for (x = 0; x < nRowsAdd; x++) {
			varNewLinha = document.createElement("tr");
			varNewLinha.setAttribute("id", "trOption" + nOption);
			
			varNewColuna = document.createElement("td");
			varNewColuna.innerHTML = "Opção " + nOption;
			varNewLinha.appendChild(varNewColuna);
			
			varNewColuna = document.createElement("td");
			varNewColuna.innerHTML = "<input type=hidden id='optionID" + nOption + "' name='optionID" + nOption + "'><input type='text' id='option" + nOption + "' name='option" + nOption + "' value='' size='20'> <input type='button' name='excluir' value='Excluir' onclick='delRowTable(" + nOption + ")'>";
			varNewLinha.appendChild(varNewColuna);
		
			varBodyTableObj.insertBefore(varNewLinha, varRowRodape);
				
			nOption++;
		}
		
		document.getElementById("nOptions").value = (nOption - 1);
	} else {
		alert("É necessário digitar um número maior que 0 para acrescentar novos campos.");
	}
}

function delRowTable(nRow) {
	varTableObj = document.getElementById("fieldsTable");
	varBodyTableObj = document.getElementById("bodyTable");
	varRowRodape = document.getElementById("rowRodape");
	nRows = varTableObj.rows.length;
	nOption = 1;
	
	if ((nRows - 1) > 5) {
		for (x = 1; x < (nRows - 4); x++) {
			if (x != nRow) {
				valueOptionID = document.getElementById("optionID" + x).value;
				valueOption = document.getElementById("option" + x).value;
				
				varTROption = document.getElementById("trOption" + x);
				varBodyTableObj.removeChild(varTROption);
				
				varNewLinha = document.createElement("tr");
				varNewLinha.setAttribute("id", "trOption" + nOption);
				
				varNewColuna = document.createElement("td");
				varNewColuna.innerHTML = "Opção " + nOption;
				varNewLinha.appendChild(varNewColuna);
				
				varNewColuna = document.createElement("td");
				varNewColuna.innerHTML = "<input type=hidden id='optionID" + nOption + "' name='optionID" + nOption + "' value='" + valueOptionID + "'><input type='text' id='option" + nOption + "' name='option" + nOption + "' value='" + valueOption + "' size='20'> <input type='button' name='excluir' value='Excluir' onclick='delRowTable(" + nOption + ")'>";
				varNewLinha.appendChild(varNewColuna);
				
				varBodyTableObj.insertBefore(varNewLinha, varRowRodape);
				
				nOption++;
			} else {
				varTROption = document.getElementById("trOption" + x);
				varBodyTableObj.removeChild(varTROption);
			}
		}
		
		document.getElementById("nOptions").value = (nOption - 1);
	} else {
		alert("É necessário ter pelo menos 1 campo para esta opção.");
	}
}

function updatenField(nLine) {
	nOptionsOK = 0;
	nOptions = document.getElementById("nOptions");
	if (nOptions) {
		for (x = 1; x <= nOptions.value; x++) {
			nValue = document.getElementById("option" + x);
			if (nValue) {
				if (nValue.value != "") {
					nOptionsOK++;
				}
			}
		}
		
		if (nOptionsOK > 0) {
			parent.document.getElementById("size1[" + (nLine - 1) + "]").value = nOptionsOK;
		}
	}
}

var arraySelect = new Array();
var waitLoad = 0;
function habilitaLinkEditor(paginaValue, typeConteudo) {
	processiFrame = document.getElementById("processFrame");
	paginaConteudo = document.getElementById("paginaConteudo");
	
	trConteudo = document.getElementById("complemento");
	if (trConteudo) {
		trConteudo.style.display = "none";
	}
	
	trConteudo = document.getElementById("targetSelectTR");
	if (trConteudo) {
		trConteudo.style.display = "none";
	}
	
	for (x = 0; x < paginaValue.length; x++) {
		trConteudo = document.getElementById("categoriaSelect" + paginaValue[x]);
		if (trConteudo) {
			trConteudo.style.display = "none";
			
			trConteudo = document.getElementById("conteudoSelect" + paginaValue[x]);
			if (trConteudo) {
				trConteudo.style.display = "none";
			}
			
			arrayType = new Array("conteudoCat", "conteudo", "noticiaCat", "noticia", "linkCat", "link", "downloadCat", "download", "galeriaCat");
			if (typeConteudo) {
				for (y = 0; y < arrayType.length; y++) {
					if (typeConteudo.constructor.toString().indexOf("Array") == -1) {
						if (typeConteudo != arrayType[y]) {
							if (document.getElementById(arrayType[y])) {
								document.getElementById(arrayType[y]).value = "";
							}
						}
					} else {
						nTypeInArray = 0;
						for (z = 0; z < typeConteudo.length; z++) {
							if (typeConteudo[z] == arrayType[y]) {
								nTypeInArray = 1;
							}
						}
						if (!nTypeInArray) {
							if (document.getElementById(arrayType[y])) {
								document.getElementById(arrayType[y]).value = "";
							}
						}
					}
				}
			} else {
				for (y = 0; y < arrayType.length; y++) {
					if (document.getElementById(arrayType[y])) {
						document.getElementById(arrayType[y]).value = "";
					}
				}
			}
			
			processFrame.src = "";
		} else {
			if (paginaValue[x] == paginaConteudo.value) {
				trConteudo = document.getElementById("complemento");
				if (trConteudo) {
					trConteudo.style.display = "";
				}
				
				trConteudo = document.getElementById("targetSelectTR");
				if (trConteudo) {
					trConteudo.style.display = "";
				}
			}
		}
	}
	
	valueOption = paginaConteudo.value;
	for (y = 0; y < paginaValue.length; y++) {
		if (valueOption == paginaValue[y]) {
			trConteudo = document.getElementById("categoriaSelect" + valueOption);
			if (trConteudo) {
				trConteudo.style.display = "";
				
				processiFrame.src = "admin.php?action=selectCatItemMenu&conpagID=" + valueOption;
			}
		}
	}
}

function habilitaLinkEditorPopup(paginaValue, typeConteudo) {
	processiFrame = document.getElementById("processFrame");
	paginaConteudo = document.getElementById("paginaConteudoLocal");
	
	for (x = 0; x < paginaValue.length; x++) {
		trConteudo = document.getElementById("categoriaSelectLocal" + paginaValue[x]);
		if (trConteudo) {
			trConteudo.style.display = "none";
			
			trConteudo = document.getElementById("conteudoSelectLocal" + paginaValue[x]);
			if (trConteudo) {
				trConteudo.style.display = "none";
			}
			
			arrayType = new Array("conteudoCatLocal", "conteudoLocal", "noticiaCatLocal", "noticiaLocal");
			if (typeConteudo) {
				for (y = 0; y < arrayType.length; y++) {
					if (typeConteudo.constructor.toString().indexOf("Array") == -1) {
						if (typeConteudo != arrayType[y]) {
							if (document.getElementById(arrayType[y])) {
								document.getElementById(arrayType[y]).value = "";
							}
						}
					} else {
						nTypeInArray = 0;
						for (z = 0; z < typeConteudo.length; z++) {
							if (typeConteudo[z] == arrayType[y]) {
								nTypeInArray = 1;
							}
						}
						if (!nTypeInArray) {
							if (document.getElementById(arrayType[y])) {
								document.getElementById(arrayType[y]).value = "";
							}
						}
					}
				}
			} else {
				for (y = 0; y < arrayType.length; y++) {
					if (document.getElementById(arrayType[y])) {
						document.getElementById(arrayType[y]).value = "";
					}
				}
			}
			
			processFrame.src = "";
		}
	}
	
	valueOption = paginaConteudo.value;
	for (y = 0; y < paginaValue.length; y++) {
		if (valueOption == paginaValue[y]) {
			trConteudo = document.getElementById("categoriaSelectLocal" + valueOption);
			if (trConteudo) {
				trConteudo.style.display = "";
				
				processiFrame.src = "admin.php?action=selectCatItemMenu&conpagID=" + valueOption;
			}
		}
	}
}

function selecionaCategoria(tipo, catField) {
	if (waitLoad == 0) {
		catField.value = "";
		alert("As categorias ainda estão sendo processadas. Aguarde mais um pouco...");
	} else {
		trConteudo = document.getElementById("complemento");
		if (trConteudo) {
			trConteudo.style.display = "none";
		}
		
		trConteudo = document.getElementById("targetSelectTR");
		if (trConteudo) {
			trConteudo.style.display = "none";
		}
		
		trConteudo = document.getElementById("conteudoSelect" + tipo);
		trConteudo.style.display = "";
		
		if (tipo == 1) {
			varNewSelect = document.getElementById("conteudo");
		} else if (tipo == 2) {
			varNewSelect = document.getElementById("noticia");
		} else if (tipo == 6) {
			varNewSelect = document.getElementById("link");
		} else if (tipo == 9) {
			varNewSelect = document.getElementById("download");
		}
		varNewSelect.innerHTML = "";
		
		catID = catField.value;
		if (catID != "") {
			if (arraySelect[catID]) {
				for (x = 0; x < arraySelect[catID].length; x++) {
					varNewOption = arraySelect[catID][x];
					varNewSelect.appendChild(varNewOption);
				}
				varNewSelect.value = "";
			} else {
				varNewOption = document.createElement("option");
				varNewOption.value = "";
				varNewOption.appendChild(document.createTextNode("Nenhum item cadastrado nesta categoria"));
				varNewSelect.appendChild(varNewOption);
			}
		} else {
			trConteudo = document.getElementById("conteudoSelect" + tipo);
			trConteudo.style.display = "none";
		}
	}
}

function selecionaCategoriaPopup(tipo, catField) {
	if (waitLoad == 0) {
		catField.value = "";
		alert("As categorias ainda estão sendo processadas. Aguarde mais um pouco...");
	} else {
		trConteudo = document.getElementById("conteudoSelectLocal" + tipo);
		trConteudo.style.display = "";
		
		if (tipo == 1) {
			varNewSelect = document.getElementById("conteudoLocal");
		} else if (tipo == 2) {
			varNewSelect = document.getElementById("noticiaLocal");
		}
		varNewSelect.innerHTML = "";
		
		catID = catField.value;
		if (catID != "") {
			if (arraySelect[catID]) {
				for (x = 0; x < arraySelect[catID].length; x++) {
					varNewOption = arraySelect[catID][x];
					varNewSelect.appendChild(varNewOption);
				}
				varNewSelect.value = "";
			} else {
				varNewOption = document.createElement("option");
				varNewOption.value = "";
				varNewOption.appendChild(document.createTextNode("Nenhum item cadastrado nesta categoria"));
				varNewSelect.appendChild(varNewOption);
			}
		} else {
			trConteudo = document.getElementById("conteudoSelectLocal" + tipo);
			trConteudo.style.display = "none";
		}
	}
}

function habilitaTarget(conteudoID) {
	if (conteudoID != "") {
		trConteudo = document.getElementById("complemento");
		if (trConteudo) {
			trConteudo.style.display = "";
		}
		
		trConteudo = document.getElementById("targetSelectTR");
		if (trConteudo) {
			trConteudo.style.display = "";
		}
	} else {
		trConteudo = document.getElementById("complemento");
		if (trConteudo) {
			trConteudo.style.display = "none";
		}
		
		trConteudo = document.getElementById("targetSelectTR");
		if (trConteudo) {
			trConteudo.style.display = "none";
		}
	}
}

function resetField(IDElement) {
	fieldID = document.getElementById(IDElement);
	fieldID.value = "";
}

function showHideTR(showHide, arrayTR) {
	if (showHide == "show") {
		showHide = "";
	}
	if (arrayTR.constructor.toString().indexOf("Array") == -1) {
		trConteudo = document.getElementById(arrayTR);
		if (trConteudo) {
			trConteudo.style.display = showHide;
		}
	} else {
		for (x = 0; x < arrayTR.length; x++) {
			trConteudo = document.getElementById(arrayTR[x]);
			if (trConteudo) {
				trConteudo.style.display = showHide;
			}
		}
	}
}

function showHideGrupo() {
	trConteudo = document.getElementById("trGrupo");
	checkRestrito = document.getElementById("restrito");
	
	if (trConteudo) {
		if (checkRestrito) {
			if (document.getElementById("usuario").value == 0 && checkRestrito.checked == 1) {
				trConteudo.style.display = "";
			} else {
				trConteudo.style.display = "none";
				document.getElementById("grupo").value = 0;
			}
		} else {
			if (document.getElementById("usuario").value == 0) {
				trConteudo.style.display = "";
			} else {
				trConteudo.style.display = "none";
				document.getElementById("grupo").value = 0;
			}
		}
	}
}

function showHideUsuario() {
	trConteudo = document.getElementById("trUsuario");
	checkRestrito = document.getElementById("restrito");
	
	if (trConteudo) {
		if (checkRestrito) {
			if (document.getElementById("grupo").value == 0 && checkRestrito.checked == 1) {
				trConteudo.style.display = "";
			} else {
				trConteudo.style.display = "none";
				document.getElementById("usuario").value = 0;
			}
		} else {
			if (document.getElementById("grupo").value == 0) {
				trConteudo.style.display = "";
			} else {
				trConteudo.style.display = "none";
				document.getElementById("usuario").value = 0;
			}
		}
	}
}

function showHideUserGrupo() {
	listaEmails = document.getElementById("listaEmails").value;
	
	if (listaEmails != "") {
		trConteudo = document.getElementById("trUsuario");
		if (trConteudo) {
			trConteudo.style.display = "none";
			document.getElementById("usuario").value = 0;
		}
		
		trConteudo = document.getElementById("trGrupo");
		if (trConteudo) {
			trConteudo.style.display = "none";
			document.getElementById("grupo").value = 0;
		}
	} else if (listaEmails == "") {
		trConteudo = document.getElementById("trUsuario");
		if (trConteudo) {
			trConteudo.style.display = "";
		}
		
		trConteudo = document.getElementById("trGrupo");
		if (trConteudo) {
			trConteudo.style.display = "";
		}
	}
}

function hideTRListaEmails() {
	trListaEmails = document.getElementById("trListaEmails");
	trListaEmails.style.display = "none";
	
	trListaEmails = document.getElementById("trListaExcluir");
	trListaEmails.style.display = "none";
	
	showHideUserGrupo();
}

function showHideSelectNews() {
	tipo = document.getElementById("tipo").value;
	
	trConteudoData = document.getElementById("rowData");
	if (trConteudoData) {
		trConteudoData.style.display = "none";
	}
	trConteudoCategoria = document.getElementById("rowCategoria");
	if (trConteudoCategoria) {
		trConteudoCategoria.style.display = "none";
	}
		
	if (tipo == "pordata") {
		trConteudoData.style.display = "";
		trConteudoCategoria.style.display = "none";
	} else if (tipo == "porcategoria") {
		trConteudoData.style.display = "none";
		trConteudoCategoria.style.display = "";
	}
}

function verificaSelectNews() {
	subaction = document.getElementById("subaction").value;
	
	if (subaction == "") {
		tipo = document.getElementById("tipo").value;
		submitForm = false;
		
		if (tipo == "pordata") {
			diaInicio = document.getElementById("diaInicio").value;
			mesInicio = document.getElementById("mesInicio").value;
			anoInicio = document.getElementById("anoInicio").value;
			
			diaFinal = document.getElementById("diaFinal").value;
			mesFinal = document.getElementById("mesFinal").value;
			anoFinal = document.getElementById("anoFinal").value;
			
			dataArray = [diaInicio, mesInicio, anoInicio, diaFinal, mesFinal, anoFinal];
			data1 = "";
			data2 = "";
			if (diaInicio != "" && mesInicio != "" && anoInicio != "") {
				data1 = new Date(anoInicio, mesInicio, diaInicio);
			}
			if (diaFinal != "" && mesFinal != "" && anoFinal != "") {
				data2 = new Date(anoFinal, mesFinal, diaFinal);
			}
			if (data1 != "" || data2 != "") {
				submitForm = true;
			} else {
				alert("É necessário entrar com a data inicial e/ou final para pesquisa.");
			}
		} else if (tipo == "porcategoria") {
			categoria = document.getElementById("categoria").value;
			
			if (categoria != "") {
				submitForm = true;
			} else {
				alert("É necessário selecionar a categoria para pesquisa.");
			}
		} else if (tipo == "naoenviadas") {
			submitForm = true;
		}
	} else {
		submitForm = true;
	}
	
	if (submitForm) {
		document.selectNews.submit();
	}
}

function atualizaRowNoticias(nNews) {
	if (nNews > 1) {
		stringRow = nNews + " notícias selecionadas";
	} else if (nNews == 1) {
		stringRow = nNews + " notícia selecionada";
	} else {
		stringRow = "Selecionar notícias";
	}
	
	textRow = window.opener.document.getElementById("rowNoticias");
	textRow.innerHTML = stringRow;
}

function verificaDigito(thisField, N, nextField) {
	stringField = document.getElementById(thisField).value;

	if (stringField.length == N) {
		document.getElementById(nextField).focus();
		document.getElementById(nextField).select();
	}
}

function viewWatermark(imagem) {
	trWatermark = document.getElementById("TRWatermark");
	imgWatermark = document.getElementById("watermarkIMG");
	
	if (imagem != "") {
		imgWatermark.src = "../images/galeria/marcadagua/" + imagem;
		trWatermark.style.display = "";
	} else {
		imgWatermark.src = "";
		trWatermark.style.display = "none";
	}
}

function verificaArquivo(tipo,action,cod) {
	trArquivo = document.getElementById("arquivopequeno");
	
	if (tipo == 1) {
		trArquivo.style.display = "";
		if (typeof(ftppopupWindow) == "object") {
			ftppopupWindow.close();
		}
	} else {
		trArquivo.style.display = "none";
		if (cod > 0) {
			ftppopupWindow = window.open('../inc/ftp/ftppopup.php?action=' + action + "&cod=" + cod,'ftppopup','status=yes,scrollbars=no,width=350,height=110');
		} else {
			ftppopupWindow = window.open('../inc/ftp/ftppopup.php?action=' + action,'ftppopup','status=yes,scrollbars=no,width=350,height=110');
		}
	}
}

function trocaLinhasForm(order, direction) {
	varBodyTableObj = document.getElementById("bodyTable");
	varTableObj = document.getElementById("tableForm");
	nFields = ["required", "codField", "titulo", "name", "type", "size1", "size2"];
	nFieldsType = ["checkbox", "text", "text", "text", "select", "text", "text"];
	
	if (direction == "baixo") {
		varTRlineObjAtual = document.getElementById("line" + order);
		varTRlineObjDown = document.getElementById("line" + (order + 1));
		
		fieldValues = new Array();
		for (y = 0; y < nFields.length; y++) {
			fieldAtual = nFields[y] + "[" + (order - 1) + "]";
			fieldUp = nFields[y] + "[" + (order) + "]";
			if (nFieldsType[y] == "checkbox") {
				mAtual = document.getElementById(fieldAtual).checked;
				mUp = document.getElementById(fieldUp).checked;
			} else {
				mAtual = document.getElementById(fieldAtual).value;
				mUp = document.getElementById(fieldUp).value;
			}
			
			fieldValues[nFields[y]] = new Array();
			fieldValues[nFields[y]][0] = mAtual;
			fieldValues[nFields[y]][1] = mUp;
		}
		
		for (y = 0; y < nFields.length; y++) {
			fieldAtual = nFields[y] + "[" + (order - 1) + "]";
			fieldUp = nFields[y] + "[" + (order) + "]";
			
			if (nFieldsType[y] == "checkbox") {
				document.getElementById(fieldAtual).checked = fieldValues[nFields[y]][1];
				document.getElementById(fieldUp).checked = fieldValues[nFields[y]][0];
			} else {
				document.getElementById(fieldAtual).value = fieldValues[nFields[y]][1];
				document.getElementById(fieldUp).value = fieldValues[nFields[y]][0];
			}
		}
	} else if (direction == "cima") {
		varTRlineObjAtual = document.getElementById("line" + order);
		varTRlineObjUp = document.getElementById("line" + (order - 1));
		
		fieldValues = new Array();
		for (y = 0; y < nFields.length; y++) {
			fieldAtual = nFields[y] + "[" + (order - 1) + "]";
			fieldUp = nFields[y] + "[" + (order - 2) + "]";
			if (nFieldsType[y] == "checkbox") {
				mAtual = document.getElementById(fieldAtual).checked;
				mUp = document.getElementById(fieldUp).checked;
			} else {
				mAtual = document.getElementById(fieldAtual).value;
				mUp = document.getElementById(fieldUp).value;
			}
			
			fieldValues[nFields[y]] = new Array();
			fieldValues[nFields[y]][0] = mAtual;
			fieldValues[nFields[y]][1] = mUp;
		}
		
		for (y = 0; y < nFields.length; y++) {
			fieldAtual = nFields[y] + "[" + (order - 1) + "]";
			fieldUp = nFields[y] + "[" + (order - 2) + "]";
			
			if (nFieldsType[y] == "checkbox") {
				document.getElementById(fieldAtual).checked = fieldValues[nFields[y]][1];
				document.getElementById(fieldUp).checked = fieldValues[nFields[y]][0];
			} else {
				document.getElementById(fieldAtual).value = fieldValues[nFields[y]][1];
				document.getElementById(fieldUp).value = fieldValues[nFields[y]][0];
			}
		}
	}
}

function openPopup(theURL, winName, features) {
	returnPopup = window.open(theURL, winName, features);
	if (!returnPopup) {
		alert("Uma janela (popup) foi bloqueada. Por favor verifique se\no seu navegador está bloqueando janelas deste site.");
	}
}

function showHidePass(fieldID, showHide, arrayTR) {
	if (showHide == "show") {
		showHide = "";
		document.getElementById(fieldID).value = "none";
	} else {
		document.getElementById(fieldID).value = "show";
	}
	if (arrayTR.constructor.toString().indexOf("Array") == -1) {
		trConteudo = document.getElementById(arrayTR);
		if (trConteudo) {
			trConteudo.style.display = showHide;
		}
	} else {
		for (x = 0; x < arrayTR.length; x++) {
			trConteudo = document.getElementById(arrayTR[x]);
			if (trConteudo) {
				trConteudo.style.display = showHide;
			}
		}
	}
}

function verifyIMGType(fieldObj) {
	imagem = fieldObj.value;
	extensao = imagem.substr(imagem.lastIndexOf(".") + 1, imagem.length);
	
	TRLegendaObj = document.getElementById("TRLegenda");
	TRFonteObj = document.getElementById("TRFonte");
	TRWatermarkSelectObj = document.getElementById("TRWatermarkSelect");
	TRWatermarkObj = document.getElementById("TRWatermark");
	
	if ((extensao == "jpg") || (extensao == "jpeg")) {
		TRLegendaObj.style.display = "";
		TRFonteObj.style.display = "";
		TRWatermarkSelectObj.style.display = "";
		
		marcadaguaObj = document.getElementById("marcadagua");
		if (marcadaguaObj.value != "") {
			TRWatermarkObj.style.display = "";
		}
	} else {
		TRLegendaObj.style.display = "none";
		TRFonteObj.style.display = "none";
		TRWatermarkSelectObj.style.display = "none";
		TRWatermarkObj.style.display = "none";
	}
}
//-->
