var SS_submit = false;

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_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj){ if(obj.value==x) obj.value = newText };
}

function checkUpdate(genID, categoriaID, insert) {
	if(insert == "true" && SS_submit == false) location.href = "news_update.asp?categoriaID=" + categoriaID + "&genID=" + genID;
}

function keepFocus() {
  window.focus();
}

function openWindow(page, name, elements) {
  window.open(page, name, elements);
}

function SS_RemoveFormatTags(memo)
{
	// remover todos os tags de formatação de texto
	memo = memo.replace(/<span[\w\d\s'=:\.;#\-\/"%]*>|<\/span>/gi,"");
	memo = memo.replace(/<font[\w\d\s'=:\.;#\-\/"%]*>|<\/font>/gi,"");
	memo = memo.replace(/<b [\w\d\s'=:\.;#\-\/"%]*>/gi,"<b>");
	memo = memo.replace(/<\?[\w\d\s'=:\.;#\-\/"%]*>|<o:p>|<\/o:p>/gi, "");
	memo = memo.replace(/<\w\w\d:[\w\d\s'=:\.;#\-\/"%]*>|<\/\w\w\d:[\w\d\s'=:\.;#\-\/"%]*>/gi, "");
	memo = memo.replace(/<p[\w\d\s'=:\.;#\-\/"%]*>/gi,"<p>");
	memo = memo.replace(/<table[\w\d\s'=:\.;#\-\/"%]*>/gi,"<table bordercolor=\"#7C9DAD\" width=\"100%\" border=1 cellpadding=2 cellspacing=0>");
	memo = memo.replace(/<td[\w\d\s'=:\.;#\-\/"%]*>/gi,"<td class=\"normal\" valign=\"top\">");
	memo = memo.replace(/<ul[\w\d\s'=:\.;#\-\/"%]*>|<ul>/gi,"<ul class=\"normal\">");
	return(memo);
}

function SS_FormFormatData(formData) {
	var data = formData.value;
	if(String(data) != "") {
		var dia = data.substr(0,2);
		var mes = data.substr(3,2);
		var ano = data.substr(6,4);
		var res = mes + "-" + dia + "-" + ano;
		if(data.indexOf(":") != -1) {
			var h = data.substr(11,2);
			var m = data.substr(14,2);
			res += " " + h + ":" + m;
		}
		formData.value = res;
	}
	return(true);
}

function ConfRemocao_JS(PagRemover)
{
	var msg="Confirma a remoção?"
	
	if (confirm(msg))
		location.href = PagRemover;
}
