// ### troca imagens sem layer ###

// check if the browser is Navigator 3 or higher:
agent = navigator.userAgent;
browserVer = 2;
if (agent.substring(0,7) == "Mozilla")
{
    if (parseInt(agent.substring(8,9)) >= 3) {browserVer = 1;}
}

if (navigator.appName == "Netscape")
{
	layerStyleRef="layer.";
	layerRef="document.layers";
	styleSwitch="";
	visibleVar="show";
}
else
{
	layerStyleRef="layer.style";
	layerRef="document.all";
 	styleSwitch=".style";
	visibleVar="visible";
}

if (browserVer == 1) {
 
 on1 = new Image;
 on2 = new Image;
 on3 = new Image;
 on4 = new Image;
 on5 = new Image;
 on6 = new Image;
 
 off1 = new Image;
 off2 = new Image;
 off3 = new Image;
 off4 = new Image;
 off5 = new Image;
 off6 = new Image;

var pastaon = Array();
var pastaoff = Array();
var iCount = Array();

	for (var iNum = 0; iNum < 30; iNum++) {
		pastaon[iNum] = new Image;
		pastaoff[iNum] = new Image;
		pastaon[iNum].src="img/ico_folder_open.gif"
		pastaoff[iNum].src="img/ico_folder_close.gif"
		iCount[iNum] = 1
	}

var editoron = Array();
var editoroff = Array();
var editorname = Array();
editorname[0] = "editor_undo"
editorname[1] = "editor_redo"
editorname[2] = "editor_cut"
editorname[3] = "editor_copy"
editorname[4] = "editor_paste"
editorname[5] = "editor_selectall"
editorname[6] = "editor_bold"
editorname[7] = "editor_italic"
editorname[8] = "editor_under"
editorname[9] = "editor_aleft"
editorname[10] = "editor_center"
editorname[11] = "editor_aright"
editorname[12] = "editor_nlist"
editorname[13] = "editor_blist"
editorname[14] = "editor_ileft"
editorname[15] = "editor_iright"
editorname[16] = "editor_hr"
editorname[17] = "editor_wlink"
editorname[18] = "editor_img"
editorname[19] = "editor_justify"

for (var iNum = 0; iNum < 20; iNum++) {
	editoron[iNum] = new Image;
	editoroff[iNum] = new Image;
	editoron[iNum].src="../img/"+editorname[iNum]+"_on.gif"
	editoroff[iNum].src="../img/"+editorname[iNum]+"_off.gif"
}

}

function troca(atual, novo)
{
	if (browserVer == 1) { 
		eval('document.images["'+atual+'"].src='+novo+'.src');
	}
}



function trocaclick(atual, novo, num)
{
	if (browserVer == 1) { 
		if (iCount[num] > 0) {
			eval('document.images["'+atual+'"].src='+novo+'.src');
			iCount[num] = -1
			} else {
			eval('document.images["'+atual+'"].src='+atual+'.src');
			iCount[num] = 1
		}
	}
}

// Show Layers
function sL(layerName){
	eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
}
// Hide Layers
function hL(layerName){
	eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
}

iFlag = 1
function boL(layerName){
	if (iFlag > 0) {
	sL(layerName)
	iFlag = -1
	} else {
	hL(layerName);
	iFlag = 1
	}
}

// Rollover dos menus
var clrOver
var clrIn

function mOvr(src) {
 if (!src.contains(event.fromElement)) {
  src.style.cursor = 'hand';
  src.bgColor = clrOver;
  src.color = 'black'
 }
}
function mOut(src) {
 if (!src.contains(event.toElement)) {
  src.style.cursor = 'default';
  src.bgColor = clrIn;
 }
}
function mClk(src) {
 if(event.srcElement.tagName=='TD'){
  src.children.tags('A')[0].click();
 }
}

// Acende-apaga spans
function showspan(spa)
{
	if (eval(spa+".style.display") == "")
	{
		eval(spa+".style.display='none'")
	} else {
		eval(spa+".style.display=''")
	}
}

function showspanprof()
{
	if (document.form.profissao.selectedIndex == 1 || document.form.profissao.selectedIndex == 7) {
		if (document.form.profissao.selectedIndex == 1) {
			a.style.display=''
			b.style.display='none'
		}
		if (document.form.profissao.selectedIndex == 7) {
			a.style.display='none'
			b.style.display=''
		}
	} else {
		a.style.display='none'
		b.style.display='none'
	}
}

function showspansub()
{
	if (document.form.categoria.selectedIndex == 1) {
		espec.style.display=''
	} else {
		espec.style.display='none'
	}
}



function wopen(page,largura,altura,rolagem)
{
	if (largura==null || largura=="" && altura==null || altura=="") {
		largura = 450
		altura  = 300
	}
	if (rolagem==null) {
		rolagem = "yes"
	}
	window.open(page,"evento","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+rolagem+",resizable=no,copyhistory=no,width="+largura+",height="+altura+",top=50,left=170")
}

//check all
var checkflag = "false";
function checkboxes(field) {
	if (checkflag == "false") {
	for (i = 0; i < field.length; i++) {
	field[i].checked = true;}
	checkflag = "true";
	return "Apagar Todos"; }
	else {
	for (i = 0; i < field.length; i++) {
	field[i].checked = false; }
	checkflag = "false";
	return "Selecionar Todos"; }
}

// Função para limitar tamanho do texto no campo Mensagem
function contTexto(campoMsg, campoContador, limiteMax){
	if (campoMsg.value.length > limiteMax)
		campoMsg.value = campoMsg.value.substring(0, limiteMax);
	else
		// Atualiza o campo contador se o número de caracteres ainda não chegou no limite
		campoContador.value = limiteMax - campoMsg.value.length;
}