//**********************************************************************
//*  FUNÇÃO PARA CABECALHO DO BOX DE MENSAGEM
//**********************************************************************
//*  Definições/Especificações:
//*  
//* Esta funcao recebe tres parametros:
//* 1) Largura
//* 2) Altura
//* 3) Overflow
//*
//**********************************************************************
function BoxAvisoTopo(p1,p2,p3)
{
	var largura = p1;
	var altura = p2;
	var overflow = p3;
	document.write('		<table width='+largura+' border=0 cellspacing=3 cellpadding=3>');
	document.write('			<tr>');
	document.write('			<td>');
	document.write('				<table border=0  width='+largura+' cellpadding=1 cellspacing=1 bgcolor=919B9C>');
	document.write('					<td bgcolor=FFFFFF>');
	document.write('						<table width=100% border=0 cellspacing=0 cellpadding=3>');
	document.write('							<td>');
	document.write('								<table width=100% border=0 cellspacing=3 cellpadding=0 background='+pathgeral+'images/back.gif>');
	document.write('									<tr>');
	document.write('										<td width=6><img src='+pathgeral+'images/esquerda.gif></td>');
	document.write('										<td><img src='+pathgeral+'images/centro.gif></td>');
	document.write('										<td align=right><img src='+pathgeral+'images/direita.gif></td>');
	document.write('									</tr>');
	document.write('									<tr>');
	document.write('										<td valign=top colspan=3>');
	document.write('											<DIV class="TextoBoxAviso" style="{height:'+altura+'px;width:100%;overflow:'+overflow+';}">');

}

//**********************************************************************
//*  FUNÇÃO PARA RODAPE DO BOX DE MENSAGEM
//**********************************************************************
//*  Definições/Especificações:
//*  
//*
//**********************************************************************

function BoxAvisoRodape()
{
	document.write('											</DIV>');
	document.write('										</td>');
	document.write('									</tr>');
	document.write('								</table>');
	document.write('							</td>');
	document.write('						</table>');
	document.write('					</td>');
	document.write('			  </table>');
	document.write('			</td>');
	document.write('			</tr>');
	document.write('		</table>');
}

//**********************************************************************
//*  FUNÇÃO PARA CABECALHO AVANCADO DO BOX DE MENSAGEM
//**********************************************************************
//*  Definições/Especificações:
//*  
//* Esta funcao recebe dez parametros:
//* 1) Largura
//* 2) Altura
//* 3) Overflow
//* 4) Titulo
//* 5) Titulo Link 1
//* 6) URL Link 1
//* 7) Titulo Link 2
//* 8) URL Link 2
//* 9) Titulo Link 3
//* 10) URL Link 3
//*
//**********************************************************************

function BoxAvancadoAvisoTopo(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
{
	var largura = p1;
	var altura = p2;
	var overflow = p3;
	var titulo = p4;
	var URLL1 = p5;
	var TITL1 = p6;
	var URLL2 = p7;
	var TITL2 = p8;
	var URLL3 = p9;
	var TITL3 = p10;
	
	document.write('<table width='+largura+' cellpadding=3 cellspacing=3 border=0>');
	document.write('<tr>');
	document.write('<td>');
	document.write('<table width=100% cellpadding=0 cellspacing=0 border=0>');
	document.write('<tr>');
	document.write('<td>');
	document.write('<table width=100% cellpadding=0 cellspacing=0 border=0>');
	document.write('<td width=21 valign=top>');
	document.write('<img src='+pathgeral+'images/box_med_tit_esq.gif><br>');
	document.write('</td>');
	document.write('<td valign=top>');
	document.write('<table width=100% cellpadding=0 cellspacing=0 border=0>');
	document.write('<tr>');
	document.write('<td height=28 background='+pathgeral+'images/box_med_tit_bkg.gif class=titulobox>');
	document.write(titulo);
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');		

	if (TITL1!="" || TITL2!="" || TITL3!="")
	{
	document.write('<table cellpadding=0 cellspacing=0 border=0 align=right  background='+pathgeral+'images/box_med_link_bkg.gif>');
	document.write('<tr>');
	document.write('<td>');
	document.write('<img src='+pathgeral+'images/box_med_link_esq.gif><br>');
	document.write('</td>');

	if (TITL1!="")
	{
	document.write('<td align=center height=20 class=link_box_geral valign=middle>');
	document.write('<a href='+URLL1+'>'+TITL1+'</a>');
	document.write('</td>');
	}

	if (TITL2!="")
	{
	document.write('<td width=1>');
	document.write('<img src='+pathgeral+'images/box_med_link_sep.gif><br>');
	document.write('</td>');
	document.write('<td align=center height=20 class=link_box_geral valign=middle>');
	document.write('<a href='+URLL2+'>'+TITL2+'</a>');
	document.write('</td>');
	}

	if (TITL3!="")
	{
	document.write('<td width=1>');
	document.write('<img src='+pathgeral+'images/box_med_link_sep.gif><br>');
	document.write('</td>');
	document.write('<td align=center height=20 class=link_box_geral valign=middle>');
	document.write('<a href='+URLL3+'>'+TITL3+'</a>');
	document.write('</td>');
	}
	
	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('<td width=21 valign=top>');
	document.write('<img src='+pathgeral+'images/box_med_tit_dir.gif><br>');
	document.write('</td>');
	}
	else
	{
	document.write('<td width=21 valign=top>');
	document.write('<img src='+pathgeral+'images/box_med_tit_dir_off.gif><br>');
	document.write('</td>');
	}

	document.write('</table>');
	document.write('</td>');
	document.write('</tr>');
	document.write('<tr>');
	document.write('<td style="(border-left:1px solid #91A7B4;border-right:1px solid #91A7B4;padding-left:10px;)" colspan=3 height='+altura+' valign=top class=texto>');

} 

//**********************************************************************
//*  FUNÇÃO PARA RODAPE DO BOX DE MENSAGEM
//**********************************************************************
//*  Definições/Especificações:
//*  
//*
//**********************************************************************

function BoxAvancadoAvisoRodape(p1)
{
	document.write('</td>');
	document.write('</tr>');
	document.write('<tr>');
	document.write('<td>');
	document.write('<table width=100% cellpadding=0 cellspacing=0 border=0>');
	document.write('<td width=20>');
	document.write('<img src='+pathgeral+'images/box_med_rodape_esq.gif><br>');
	document.write('</td>');
	document.write('<td style="(border-bottom:1px solid #91A7B4;)">&nbsp; ');
	document.write('</td>');
	document.write('<td width=20>');
	document.write('<img src='+pathgeral+'images/box_med_rodape_dir.gif><br>');
	document.write('</td>');
	document.write('</table>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</td>');
	document.write('</table>');
}


//**********************************************************************
//*  FUNÇÃO PARA RODAPE 
//**********************************************************************
//*  Definições/Especificações:
//*  
//* Esta funcao recebe dois parametros:
//* 1) Texto 1
//* 2) Nome
//*  
//*
//**********************************************************************

function Rodape(p1,p2)
{	
	var texto = p1;
	var nome = p2;
	
	document.write('<table width=100%  border=0 cellspacing=0 cellpadding=0>');
	document.write('	<tr>');
	document.write('	<td>');
	document.write('		<table width=100%  border=0 cellspacing=0 cellpadding=0  background='+pathgeral+'images/rodape_n1_bkg.gif>');
	document.write('			<td width=15>');
	document.write('			</td>');	
	document.write('			<td height=22 width=270 class=titulobox>');
	document.write('			'+texto+'');
	document.write('			</td>');
	document.write('			<td>&nbsp;');
	document.write('			</td>');
	document.write('			<td width=35>');
	document.write('			<img src='+pathgeral+'images/rodape_n1_icone.gif>');
	document.write('			</td>');
	document.write('			<td width=25% class=titulobox>');
	document.write('			'+nome+'');
	document.write('			</td>		');					
	document.write('		</table>');
	document.write('    </td>');
	document.write('	</tr>');
	document.write('	<tr>');
	document.write('		<td align=center>');
	document.write('		<table width=100%  border=0 cellspacing=0 cellpadding=0  background='+pathgeral+'images/rodape_n1_bkg.gif>');
	document.write('			<td height=30 bgcolor=D4D4D4>');
	document.write('			<img src='+pathgeral+'images/rodape_n2_intranet.gif hspace=10>');
	document.write('			</td>');		
	document.write('		</table>');
	document.write('    </td>');
	document.write('	</tr>');
	document.write('</table>');
}

//**********************************************************************
//*  FUNÇÃO PARA LINHA SUPERIOR 
//**********************************************************************
//*  Definições/Especificações:
//*  
//* Esta funcao recebe dois parametros:
//* 1) Texto 1
//* 2) Nome
//*  
//*
//**********************************************************************

function LinhaSuperior(p1,p2)
{	
	var texto = p1;
	var nome = p2;
	
	document.write('<table width=100%  border=0 cellspacing=0 cellpadding=0>');
	document.write('	<tr>');
	document.write('		<td>');
	document.write('			<table width=100%  border=0 cellspacing=0 cellpadding=0  background='+pathgeral+'images/rodape_n1_bkg.gif>');
	document.write('				<td width=15>');
	document.write('				</td>');	
	document.write('				<td height=22 width=270 class=titulobox>');
	document.write('					'+texto+'');
	document.write('				</td>');
	document.write('				<td>&nbsp;');
	document.write('				</td>');
	document.write('				<td width=35>');
	document.write('					&nbsp;');
	document.write('				</td>');
	document.write('				<td width=25% class=titulobox>');
	document.write('					'+nome+'');
	document.write('				</td>		');					
	document.write('			</table>');
	document.write('   		</td>');
	document.write('	</tr>');
	document.write('</table>');
}

//**********************************************************************
//*  FUNÇÃO PARA ABERTURA DE POP-UP
//**********************************************************************
//*  Definições/Especificações:
//*  
//*  Fazendo a chamada:
//*  <a href="javascript:PopUpHelp('teste.asp')">Texto ou imagem</a>
//*  
//**********************************************************************
function PopUpHelp(strURL)
	{
	window.open(strURL,"","resizable=no,toolbar=no,ontop=yes,status=no,menubar=no,scrollbars=yes,width=350,height=250,left=200,top=200")
	}
function PopUpExplorer(strURL)
	{
	window.open(strURL,"","resizable=no,toolbar=no,ontop=yes,status=no,menubar=no,scrollbars=no,width=720,height=430,left=200,top=200")
	}
function PopUpGenerico(strURL)
	{
	window.open(strURL,"","resizable=no,toolbar=no,ontop=yes,status=no,menubar=no,scrollbars=auto,width=400,height=350,left=200,top=200")
	}
function PopUpDemo(strURL)
	{
	window.open(strURL,"","resizable=no,toolbar=no,ontop=yes,status=no,menubar=no,scrollbars=no,width=800,height=550,left=10,top=10")
	}
function PopUpDemo2(strURL)
	{
	window.open(strURL,"","resizable=yes,toolbar=no,ontop=yes,status=no,menubar=no,scrollbars=no,width=800,height=550,left=10,top=10")
	}
function PopPerfil(strURL)
	{
	window.open(strURL,"","resizable=no,toolbar=no,ontop=yes,status=no,menubar=no,scrollbars=yes,width=720,height=430,left=200,top=200")
	}
function PopOBSPersonagem(strURL,strwidth,strheight)
	{
	window.open(strURL,"","resizable=no,toolbar=no,ontop=yes,status=no,menubar=no,scrollbars=no,width="+strwidth+",height="+strheight+",left=200,top=200")
	}

function PopGenerico(strURL,strwidth,strheight,strscroll)
	{
	window.open(strURL,"","resizable=no,toolbar=no,ontop=yes,status=no,menubar=no,scrollbars="+strscroll+",width="+strwidth+",height="+strheight+",left=200,top=200")
	}

//**********************************************************************
//*  FUNÇÃO PARA HABILITAÇÃO DE ENVELOPE
//**********************************************************************
//*  Definições/Especificações:
//*
//**********************************************************************
function env_click(envelopeid,buttonid) 
	{
	if (envelopeid.style.display == "block") 
		{
		envelopeid.style.display = "none";
		buttonid.src = "/intranet/images/mais.gif";
		}
	else 
		{
		envelopeid.style.display = "block";
		buttonid.src = "/intranet/images/menos.gif";
		}
	}

function env_seta(envelopeid,buttonid) 
	{
	if (envelopeid.style.display == "block") 
		{
		envelopeid.style.display = "none";
		buttonid.src = "/intranet/images/seta_tr_dir.gif";
		}
	else 
		{
		envelopeid.style.display = "block";
		buttonid.src = "/intranet/images/seta_tr_esq.gif";
		}
	}

//**********************************************************************
//*  FUNÇÃO PARA BOTÕES COM ESTILO DO WINDOWS XP
//**********************************************************************
//*  Definições/Especificações:
//*
//**********************************************************************

function button_over(eButton)
	{
	eButton.style.borderBottom = "1px solid #08246B";
	eButton.style.borderLeft = "1px solid #08246B";
	eButton.style.borderRight = "1px solid #08246B";
	eButton.style.borderTop = "1px solid #08246B";
	eButton.style.background = "#B5BED6";
	}

function button_out(eButton)
	{
	eButton.style.borderColor = "";
	eButton.style.background = "";
	}

function button_down(eButton)	
	{
	eButton.style.borderBottom = "buttonhighlight solid 1px";
	eButton.style.borderLeft = "buttonshadow solid 1px";
	eButton.style.borderRight = "buttonhighlight solid 1px";
	eButton.style.borderTop = "buttonshadow solid 1px";
	}

function button_up(eButton)
	{
	eButton.style.borderBottom = "buttonshadow solid 1px";
	eButton.style.borderLeft = "buttonhighlight solid 1px";
	eButton.style.borderRight = "buttonshadow solid 1px";
	eButton.style.borderTop = "buttonhighlight solid 1px";
	eButton = null; 
	}

	
//**********************************************************************
//*  FUNÇÃO PARA MARCAR A LINHA DO MOUSE 
//**********************************************************************
//*  Definições/Especificações:
//*  
//*  Forma de utilização:
//*  
//*  Colocar no TR as seguintes chamadas:
//*  
//*  !----
//*  onMouseOver="mOvr(this,'#d3d3d3');" onMouseOut="mOut(this,'');"
//*  ----!
//*  
//*  As cores devem ser trocadas para englobar a pagina especifica.
//*  
//**********************************************************************

function mOvr(src,clrOver)
	{
	if (!src.contains(event.fromElement))
		{
		src.style.cursor = '';
		src.bgColor = clrOver;
		}
	}
function mOut(src,clrIn)
	{
	if (!src.contains(event.toElement))
		{
		src.style.cursor = '';
		src.bgColor = clrIn;
	}
	}

//**********************************************************************
//*  FUNÇÃO PARA ABERTURA DO CALENDARIO EM ACTIVEX
//**********************************************************************
//*  Definições/Especificações:
//*
//**********************************************************************	
function ShowDateIni()
  {
	var cSearchValue=showModalDialog("/intranet/include/obj_XCalendar.asp",0,"dialogwidth=298px;dialogheight=280px");
	
	if (cSearchValue != -1 && cSearchValue != null && cSearchValue != "")
    {
		document.all.data_ini.value = cSearchValue;
	}
  }

function ShowDateFim()
  {
	var cSearchValue=showModalDialog("/intranet/include/obj_XCalendar.asp",0,"dialogwidth=298px;dialogheight=280px");
	
	if (cSearchValue != -1 && cSearchValue != null && cSearchValue != "")
    {
		document.all.data_fim.value = cSearchValue;
	}
  }
	

//**********************************************************************
//*  FUNÇÃO PARA ABERTURA DA JANELA DE AVISO COM DRAG
//**********************************************************************
//*  Definições/Especificações:
//*
//**********************************************************************	
var dragapproved=false

function drag_dropie()
{
	if (dragapproved==true)
	{
	document.all.showimage.style.pixelLeft=tempx+event.clientX-iex
	document.all.showimage.style.pixelTop=tempy+event.clientY-iey
	return false
	}
}

function initializedragie()
{
	iex=event.clientX
	iey=event.clientY
	tempx=showimage.style.pixelLeft
	tempy=showimage.style.pixelTop
	dragapproved=true
	document.onmousemove=drag_dropie
}

if (document.all)
{
	document.onmouseup=new Function("dragapproved=false")
}

function hidebox()
{
	if (document.all)
		showimage.style.visibility="hidden"
	else if (document.layers)
		document.showimage.visibility="hide"
}



//**********************************************************************
//*  FUNÇÃO PARA ILUMINAR UMA LINHA DE UM TR EM UM TABLE
//**********************************************************************
//*  Definições/Especificações:
//*  
//*  Colocar no TR (incrementar contador 'row' a cada linha):
//*  <TR ID="row1">
//*  
//*  No objeto (pode ser um radio ou o próprio TR):
//*  onclick="highlight('row1','variavel');"
//*  
//*  Obs.: variavel = item escolhido para passar quando for clicado o
//*                   botão de ação na página.
//*  
//**********************************************************************
var ns4 = document.layers? true : false; 
var ie = document.all? true : false; 
var dom = document.getElementById && !document.all ? true : false; 
//stores currently highlighted row id 
var highlightedRow = ''; 
var variavel = ''; 

//gets dom object 
function getObject(nameStr)
{ 
	if (dom) 
		return document.getElementById(nameStr); 
	else if (ie) 
		return document.all[nameStr]; 
	else if (ns4) 
		return document.layers[nameStr]; 
} 

function highlight(rowID,strVariavel)
{ 
	unHighlight(); 
	rowObj = getObject(rowID); 
	rowObj.style.background = '#DCE7EB';
	highlightedRow = rowID; 
	variavel = strVariavel;

} 

function MOSTRAR()
{ 
	alert(variavel) ; 
} 

function unHighlight()
{ 
	if (highlightedRow != '')
		{ 
		rowObj = getObject(highlightedRow); 
		rowObj.style.background = ''; 
		}
}


//**********************************************************************
//*  FUNÇÃO PARA COPIAR O TEXTO SELECIONADO PARA O CLIPBOARD
//**********************************************************************
//*  Definições/Especificações:
//*  
//*  Colocar o texto que poderá ser copiado dentro do seguinte SPAN:
//*  <span id="testCopy">texto</span>
//*  
//*  Para copiar o texto, usar o seguinte comando:
//*  onClick="javascript:copyText(document.all.testCopy);"
//*  
//**********************************************************************
function copyText( obj )
	{
	if (obj.type=="text" || obj.type=="textarea")
		{
		var rng = obj.createTextRange();
		}
		else
		{
		var rng = document.body.createTextRange();
		rng.moveToElementText(obj);
		}
	
	rng.scrollIntoView();
	rng.select();
	
	if (confirm('Deseja copiar o texto selecionado para o Clipboard?')) rng.execCommand("Copy");
	rng.collapse(false);
	rng.select();
	}

//**********************************************************************
//*  FUNÇÃO PARA EXECUTAR UM COMANDO APÓS ESCOLHA DE LINHA DO GRID
//**********************************************************************
//*  
//**********************************************************************
function ExecutaLinkGrid(StrURL)
{ 

	if (variavel == "") 
	{
		alert ("Por favor, selecione uma das linhas acima antes!");
		return false; 

	}
	else 
	{
		
		window.location.href(StrURL);
	}
} 


function decide(url)  {

if (confirm("Você tem certeza que deseja excluir este item?"))  {

location.href=url }

{ } 

} 

//**********************************************************************
//*  FUNÇÃO PARA FORMATAR MASCARA DE ENTRADA NA DIGITACAO DO TEXT FORM
//**********************************************************************
//*  Definições/Especificações:
//*  
//*  Funcionamento:
//*    O terceiro parâmetro marca as posições que serão delimitadas. No exemplo
//*    abaixo ele coloca o delimitador depois da digitação do segundo e do quinto
//*    caractere. Podem ser adiconados quantos divisores forem necessários.
//*
//*	   IMPORTANTE! O "onKeyUp" e "onBlur" devem ser, exatamente, idênticos!
//*  
//*  Exemplo de formatação de data:
//*  <input name="Field2" value="" type="text" 
//*  onKeyUp="javascript:return mask(this.value,this,'2,5','/');" 
//*	 onBlur="javascript:return mask(this.value,this,'2,5','/');" 
//*	 maxlength="10">
//*  
//**********************************************************************
function FormMask(str,textbox,loc,delim){
var locs = loc.split(',');

for (var i = 0; i <= locs.length; i++){
	for (var k = 0; k <= str.length; k++){
	 if (k == locs[i]){
	  if (str.substring(k, k+1) != delim){
	    str = str.substring(0,k) + delim + str.substring(k,str.length)
	  }
	 }
	}
 }
textbox.value = str
}











function setRowWidth(r){

	var c;
	for (var i=0; i < r.length; i++){
		c = r[i];
		c.width = c.clientWidth - parseInt(c.currentStyle.paddingLeft) - parseInt(c.currentStyle.paddingRight);
	}
}
function makeScrollableTable(tbl,strHeight){

	var pNode, w, hdr,i;

	pNode = tbl.parentNode;
	w = document.createElement('<SPAN style="height:' + strHeight + 'px; overflow: auto;">');
	pNode.insertBefore(w, tbl);
	w.appendChild(tbl);

	for (var i=0; i < tbl.tHead.rows.length; i++) setRowWidth(tbl.tHead.rows[i].cells);	
	
	setRowWidth(tbl.tBodies(0).rows[0].cells);

	hdr = tbl.cloneNode(false);
	hdr.id += 'Header';
	hdr.appendChild(tbl.tHead.cloneNode(true));
	tbl.tHead.style.display = 'none';
	pNode.insertBefore(hdr, w);
	w.style.width = w.clientWidth + 50;

	w2 = document.createElement('<table border=0 cellspacing=0 cellpadding=0 id="' + tbl.id + '">');
	w2.id = tbl.id + 'Wrapper';
	pNode.insertBefore(w2, hdr);

	w2.insertRow().insertCell().appendChild(hdr);
	w2.insertRow().insertCell().appendChild(w);

	w2.align = tbl.align;
	tbl.align = hdr.align = 'left';
	hdr.style.borderBottom = tbl.style.borderTop = 'medium none';
}
function init(strHeight){

	if (document.all){

		makeScrollableTable(document.getElementById('tabela'),strHeight);

	}else{
		document.getElementById("tb").style.overflow = "auto";
		document.getElementById("tb").style.height = "' + strHeight + 'px";
	}
} 

