function quebralinha(val)
{
	var valor = document.getElementById(val).value;
	if(valor.length >= 1) 
	{
		if(valor.length%60 == 0)
		{
			valor += "\n";
		} 
		document.getElementById(val).value = valor;
	}
}

function checkMail(mail)
{
	var er = RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if(er.test(mail) == false)
	return false;
	else
	return true;
}

// Alterações realizadas em 28-01-2008 por Alessandro Rocha.
// Imprime as informações dos formularios tanto no IE como no Firefox.
// O parâmetro "divMostrar" é utilizado no Indicadores para exibir o cabeçalho do resultado
// porém pode ser utilizado em qualquer sistema de precise de tal funcionalidade.
// Esta função trabalha em conjunto com a função "EqualizaForm".
function divPrint1(strNomeDiv, divMostrar, noticias)
{
	if(strNomeDiv == 'undefined') { alert("informe a div a ser impressa");return false; }
	if(noticias != "" && noticias == "noticia")
	document.getElementById('noticias').style.display='block';
	
	var browser = navigator.appName;

	//janela=AbreJanela(null,true);
	janela=window.open("","","directories=no,height=390,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no,width=800,top=10,left=65");
	e = document.getElementById(strNomeDiv).innerHTML;


	if(browser != "Microsoft Internet Explorer")
	{
		janela.document.writeln("<body><style>table,td,tr {font-family:arial;font-size:12px;}</style><form>");
		if (document.all)
		{
			if(divMostrar != "")
			janela.document.writeln( eval("document.all."+divMostrar+".innerHTML"));
		} else {
			if(divMostrar != "")
			{
				e1=document.getElementById(divMostrar);
				janela.document.writeln(e1.innerHTML);
			}
		}
		e = document.getElementById(strNomeDiv).innerHTML;
		janela.document.writeln(e);
		
		if( janela.document.getElementById("imprimir") != null )
		{
			janela.document.getElementById("imprimir").style.display='none';
		}
		if(noticias != "" && noticias == "noticia")
		document.getElementById('noticias').style.display='none';
		EqualizaForm(janela);

	} else {
		janela.document.writeln("<body onload=window.print();window.close()><style>table,td,tr {font-family:arial;font-size:12px;}</style>");
		//janela.document.writeln("<style>p {color:red;}</style>");
		if (document.all)
		{
			if(divMostrar != "")
			janela.document.writeln( eval("document.all."+divMostrar+".innerHTML"));
		} else {
			if(divMostrar != "")
			{
				e1=document.getElementById(divMostrar);
				janela.document.writeln(e1.innerHTML);
			}
		}
		if(noticias != "" && noticias == "noticia")
		document.getElementById('noticias').style.display='none';
		janela.document.writeln(e);
		janela.document.writeln("<script>document.getElementById('imprimir').style.display='none';</script>");
	}
	janela.document.writeln("</form></body>");
	janela.location.reload(true);
	return true;
}

function EqualizaForm(janela)
{
	for (var i=0;i<document.forms.length;i++)
	{
		var nItensForm=document.forms[i].length;
		for (var j=0;j<nItensForm;j++ )
		{
			var tipo = document.forms[i].elements[j].type;
			if (tipo=='select-one')
			janela.document.forms[i].elements[j].selectedIndex=document.forms[i].elements[j].selectedIndex;
			else if (tipo=='radio' || tipo=='checkbox')
			janela.document.forms[i].elements[j].checked=document.forms[i].elements[j].checked
			else if (tipo=='text' || tipo=='textarea')
			janela.document.forms[i].elements[j].value=document.forms[i].elements[j].value;
		}
	}
	janela.self.print();
	janela.window.close();
	return true;
}
//---------------------------------------------------------------
