/* 
Este arquivo é a coletanea de funcoes asp para o ambiente internet do WEBGEN

REGRAS PARA UTILIZACAO DESTE ARQUIVO
 
 --> As funcoes devem estar em ordem alfabetica
 --> Somentes funcoes utilizadas no ambiente INTERNET podem estar neste arquivo
 --> É obrigatorio o preenchimento do cabecalho para identificar a funcao

/*===========================================================================================
  NOME:  nome da funcao
  OBJETIVO: objetivo da funcao e sua funcionalidade

============================================================================================*/


//Constantes javascript utilizadas nas ações dos botões nas páginas de listagem. Utilizado na function submeter(acao) 
var ADICIONAR	        = 0;
var ADICIONARENQUETE    = 1;
var DETALHAR			= 2;
var EDITAR				= 3;
var EXCLUIR				= 4;
var AJUDAR				= 5;
var ORDENAR				= 6;
var HABILITAR			= 7;
var ANEXAR				= 8;
var LISTARPERMISSAO		= 9;
var RESTRINGIRPERMISSAO = 10;
var RESTRINGIR			= 11;
var ATIVARAGRUPAMENTO   = 12;
var PERMITIR			= 13;
var VOLTAR				= 14;
var AREANOTICIA         = 15;
var ATIVAR              = 18;
var VISUALIZAR_NOTICIA  = 19;
var UPLOAD			    = 20;
var LISTARITENSENQUETE  = 21;
var FECHAR				= 22 ;
// Constantes para a paginacao
var PAGINA_ESPECIFICA   = 16;
var ALTERAR_IPP         = 17;
var AREABANNER         = 18;
var ADICIONARIMAGEM         = 19;
var EXCLUIRIMAGEM         = 20;
var EDITARIMAGEM         = 21;
var EXIBIRALBUM         = 22;
var EXCLUIRGALERIA        = 23;
var EDITARGALERIA        = 24;
var ORDENARIMAGEM    = 25;
var ORDENARGALERIA   =26;
function eventoItem(Funcionalidade,CodigoItem)
  {
    var doc;
	doc= document.form1;
   switch(Funcionalidade)
      {
      case EXCLUIRIMAGEM:
			if (!confirm('Deseja mesmo excluir a imagem do album?')) return(false);
			doc.action = 'excluiralbum.asp?chkitem=' + CodigoItem; 
	        break;
	  case EXIBIRALBUM:	
			doc.action='AtivarAlbum.asp?chkitem=' + CodigoItem;
			break;
					
	  }
	  
	doc.submit();  
  }



function selecionarTodos(objImg, objCheck) {
	var imgSelTodos  = "bt_check_on.jpg";
	var imgNenhumSel = "bt_check_off.jpg";
	var pChecked;
	var src, posImage
	
	if (objCheck == null)
	{
		alert("Nenhum item na lista.");
		return false;
	}
	src = objImg.src
	posImage = src.indexOf(imgSelTodos)
	
	if (posImage>0) {
		src = src.substring(0, posImage) + imgNenhumSel
		pChecked = true;
	}
	else {
		posImage = src.indexOf(imgNenhumSel)
		src = src.substring(0, posImage) + imgSelTodos
		pChecked = false;
	}
	
	objImg.src = src
	
	if (objCheck.length == null) {
		objCheck.checked = pChecked;
	}
	else {
	
		for (var i=0;i<objCheck.length;i++) {
			objCheck[i].checked = pChecked;
		}
	}
	
}

/* USADOS NO FORMULÁRIO COM 'CHECK ITENS' */
function verTodosMarcados(objCheck) {
	var countMarcados = 0;
	if (objCheck == null) {
		alert(MSG_NENHUM_ITEM);
		return false;
	}
	if (objCheck.length != null){
		for (var i=0;i<objCheck.length;i++) {
			if (objCheck[i].checked) {
				countMarcados = countMarcados + 1;
				}
			}
	}
	if (countMarcados>1) {
		alert(MSG_SELECIONAR_UM_ITEM);
		return false;
		}
	return true;
} //verTodosMarcados


function verTodosMarcadosAlbum(objCheck,funcionalidade) 
  {
	var countMarcados = 0;
	if (objCheck == null) {
		switch(funcionalidade)
        {
  	    case EDITARGALERIA:
			alert(MSG_NENHUM_ITEM_EDITAR_GALERIA);
			return false;
		}
	}
	if (objCheck.length != null){
		for (var i=0;i<objCheck.length;i++) {
			if (objCheck[i].checked) {
				countMarcados = countMarcados + 1;
				}
			}
	}
	if (countMarcados>1) {
	  switch(funcionalidade)
        {
  	    case EDITARGALERIA:
			alert(MSG_SELECIONAR_UM_ITEM_EDITAR_GALERIA);
			return false;
		}
		
		}
	return true;
} //verTodosMarcados

function verAlgunMarcadoAlbum(objCheck,funcionalidade)
{
	var existe = false;
	
		if (objCheck == null) 
		{
			switch(funcionalidade)
			{
				case EXCLUIRGALERIA:
					alert(MSG_NENHUM_ITEM_EXCLUIR_GALERIA);
					return false;
				case EDITARGALERIA:
					alert(MSG_NENHUM_ITEM_EDITAR_GALERIA);
					return false;	
				case EXCLUIRIMAGEM:
					alert(MSG_NENHUM_ITEM_EXCLUIR_ALBUM);
					return false;
				case EXIBIRALBUM:
					alert(MSG_NENHUM_ITEM_EXIBIR_ALBUM);
					return false;
			}	
		}
	if (objCheck.length == null) 
	{
		existe = objCheck.checked;
	}
	else 
	{
		for (var i=0;i<objCheck.length;i++) 
		{
			if (objCheck[i].checked) 
			{
				existe=true;
				break;
			}
		}
	}
	
	if (!existe) 
	{
		switch(funcionalidade)
		{
			case EXCLUIRGALERIA:
				alert(MSG_SELECIONAR_ITEM_EXCLUIR_GALERIA);
				return false;
			case EDITARGALERIA:
				alert(MSG_SELECIONAR_ITEM_EDITAR_GALERIA);
				return false;
			case EXCLUIRIMAGEM:
				alert(MSG_SELECIONAR_ITEM_EXCLUIR_ALBUM);
				return false;
			case EXIBIRALBUM:
				alert(MSG_SELECIONAR_ITEM_EXIBIR_ALBUM);
				return false;
		}	
	 
	return true;
	} //verAlgunMarcado
	
	
//	return false;
	//}
	if (objCheck.length == null) 
	{
		existe = objCheck.checked;
	}
	else 
	{
		for (var i=0;i<objCheck.length;i++) 
		{
			if (objCheck[i].checked) 
			{
				existe=true;
				break;
			}
		}
	}
	
	if (!existe) 
	{
		switch(funcionalidade)
		{
			case EDITARGALERIA:
				alert(MSG_SELECIONAR_ITEM_EDITAR_GALERIA);
				return false;
			case EXCLUIRIMAGEM:
				alert(MSG_SELECIONAR_ITEM_EXCLUIR_ALBUM);
				return false;
			case EXIBIRALBUM:
				alert(MSG_SELECIONAR_ITEM_EXIBIR_ALBUM);
				return false;
		}	
	}
	return true;
} //verAlgunMarcado


function verAlgunMarcado(objCheck){
	var existe = false;
	
	if (objCheck == null) {
		alert(MSG_NENHUM_ITEM);
		return false;
	}
	if (objCheck.length == null) {
		existe = objCheck.checked;
	}
	else {
		for (var i=0;i<objCheck.length;i++) {
			if (objCheck[i].checked) {
				existe=true;
				break;
				}
			}
	}
	
	if (!existe) {
		alert(MSG_SELECIONAR_ITEM);
		return false;
	}
	return true;
} //verAlgunMarcado,Album





// Retorna o valor do checkbox que está selecionado
function valorChecado(check) {
  
  if (check.length == null){
   return check.value;
  }

  else
  {
     var tam   = check.length;
     for(i=0 ; i < tam ; i++){
       if (check[i].checked)
         return check[i].value;
     } //for
   } //if
   
  return 0;
} //valorChecado

function EhNumero(){
	var codigo;
	codigo = event.keyCode; 
	
	//O Código 46 é correspondente ao ponto(.) usado para casas decimais.
	//O Código 58 é correspondente ao dois pontos(:) para campos Hora.
	// 13 - <ENTER>
	// 46 - .
	// 58 - :
	if (codigo == 13) {
		return true;
	}
	
	if(codigo < 48 || codigo > 57){
		alert("Esse campo só aceita números !");
		event.keyCode = 0;
		return false;
	}
}

function setaStatus(sString)
 {
	 //alert(sString);
	 window.status=sString;
	 return true; //sString;
 }
 

//Nome da funcao :Replace
// Descricao da funcao:	substitui valor antigo de uma determina string por um valor novo
//Desenvolvido por:	 Edson Gomes
function replace(texto, antigo, novo)
{
  var t_resto   = texto; 
  var t_retorno = ''; 
  var pos_ini   = 0; 
  var pos       = t_resto.indexOf(antigo);
  while(pos > -1) 
	{
    pos_ini   = pos + novo.length;
		if (navigator.appName != "Netscape")
	    t_resto = t_resto.replace(antigo, novo); 
		else
			t_resto = t_resto.substr(0, pos) + novo + t_resto.substr(pos + antigo.length);
		t_retorno = t_retorno + t_resto.substr(0, pos_ini);
		t_resto   = t_resto.substr(pos_ini); 
		pos       = t_resto.indexOf(antigo); 
  }//while
  t_retorno = t_retorno + t_resto; 
  return t_retorno; 
}//replace

function jsTrim(pStr)
{
	var i;
	var strAux;
	var PosIni,PosFim;
	
	//PROCURA A PRIMEIRA POSIÇÃO VÁLIDA DIFERENTE DE ESPAÇO EM BRANCO
	i=0;
	while ((i < pStr.length) && (pStr.charAt(i)==" "))
	{
		i++;
	}
	PosIni = i;
	
	//PROCURA A ULTIMA POSIÇÃO VÁLIDA DIFERENTE DE ESPAÇO EM BRANCO
	i = pStr.length-1;
	while ((i >= 0) && (pStr.charAt(i)==" "))
	{
		i--;
	}
	PosFim = i + 1;
	
	// TESTA SE OS VALORES SE CRUZARAM
	if (PosIni < PosFim)
	{
		strAux = pStr.substring(PosIni,PosFim);
	}
	else
	{
		strAux = "";
	}
	return strAux;
}

function exibeResultado(CO_ENQUETE,DE_ENQUETE) 
{
	window.open ("ResultadoEnquete.asp?CO_ENQUETE="+ CO_ENQUETE + "&DE_ENQUETE=" + DE_ENQUETE, null,"SCROLLBARS=yes, RESIZABLE=no, TOOLBAR=no, STATUS=no, MENUBAR=no, WIDTH=400, HEIGHT=300, TOP=" + String(window.screen.Height/2 - 450) +  ", LEFT=" + String(window.screen.Width/2 - 200));
}
		
/* ABRE UM POPUP */
function popUp(sUrl, iLargura, iAltura, bScroll, nomeJanela){
 
 if (iLargura == 0) window.screen.width/2;
 if (iAltura  == 0) window.screen.height/2;
 
/* 
if (sUrl.indexOf(".rpt") > -1)
    nomeJanela = ""; //Janela com nome branco para permitir a exibição de várias
else
    nomeJanela = "detalhar";
*/
 
 return window.open (sUrl , nomeJanela,
                     "SCROLLBARS=" + bScroll + ", RESIZABLE=no, TOOLBAR=no, STATUS=no, MENUBAR=no, WIDTH=" + iLargura +
                     ", HEIGHT=" +  iAltura + ", TOP=30, LEFT=100");

} //popUp

function abrirNovaJanela(url, largura, altura, comScroll, dimencionavel ){
    var winopt;
    
    winopt = "SCROLLBARS=" +  (comScroll ? "yes" : "no");
    
    winopt = winopt + ",RESIZABLE=" +  (dimencionavel ? "yes" : "no");
    
    winopt = winopt + 
             ",TOOLBAR=no,STATUS=no,MENUBAR=no" + 
             ",WIDTH="     + largura +
             ",HEIGHT="    + altura +
             ",TOP=30,LEFT=100";
    window.open(url , "_blank", winopt);    
                    
}

//Verifica se a enquete da internet já foi selecionado uma do itens da enquete
function respondido(form) 
{
	var i = 0;
	while(i < form.length)
	{
		if (((form.elements(i).type=='radio') || (form.elements(i).type=='checkbox'))&& (form.elements(i).checked))
		{
			var j = 0;
			var CO_ITEM_ENQUETE = "";
			while(j < form.length)
			{
				if (((form.elements(j).type=='radio') || (form.elements(j).type=='checkbox'))&& (form.elements(j).checked))
				{
					CO_ITEM_ENQUETE = CO_ITEM_ENQUETE + form.elements(j).value + ","
				}	
				j = j + 1;
			}
			window.open ("ResultadoEnquete.asp?CO_ENQUETE=" + form.CO_ENQUETE.value + "&DE_ENQUETE=" + form.DE_ENQUETE.value + "&CO_ITEM_ENQUETE=" + CO_ITEM_ENQUETE + "&VOTAR=SIM", null,"SCROLLBARS=yes, RESIZABLE=no, TOOLBAR=no, STATUS=no, MENUBAR=no, WIDTH=340, HEIGHT=405, TOP=" + String(window.screen.Height/2 - 450) +  ", LEFT=" + String(window.screen.Width/2 - 200));
			return false;
		}
		i = i + 1;
	}
	alert("É necessário selecionar um item da enquete.");
	return false;
}

function validarBusca(mens)
{
	var doc = document.formbusca;
	if(doc.CO_BUSCA.value == "")
	{
		alert(mens);
		doc.CO_BUSCA.focus();
		return (false);
	} 
	doc.submit();
}

/* ABRE UM POPUP */
function windowPopUp(sUrl , iLargura, iAltura, bScroll ){
   var nomeJanela;
	
	if (iLargura == 0) window.screen.width/2;
	if (iAltura  == 0) window.screen.height/2;
	
	
	if (sUrl.indexOf(".rpt") > -1)
	   nomeJanela = ""; //Janela com nome branco para permitir a exibição de várias
	else
	   nomeJanela = "detalhar";
	   
	return window.open (sUrl , nomeJanela,
	                    "SCROLLBARS=" + bScroll + ", RESIZABLE=no, TOOLBAR=no, STATUS=no, MENUBAR=no, WIDTH=" + iLargura +
	                    ", HEIGHT=" +  iAltura + ", TOP=30, LEFT=100");
} //windowPopUp

function comercio() {

	window.open('../int_interface/Comercio.asp','Comercio','SCROLLBARS=no, RESIZABLE=no, TOOLBAR=no, STATUS=no, MENUBAR=no, WIDTH=650, HEIGHT=500');
   
}

//Mostra um popup com a versão do WEBGEN que esta sendo utilizado
function sobre()
{
	window.open('../int_interface/sobre.asp','sobre','SCROLLBARS=no, RESIZABLE=no, TOOLBAR=no, STATUS=no, MENUBAR=no, WIDTH=350, HEIGHT=150');
}

function submeter(sLingua)
{
	var doc = document.form;
	doc.changeLanguage.value = sLingua;
	doc.submit();
}

//Descrição: Função que abre o popup screen para o chat
//Desenvolvida por : Edson Gomes
// Data : 05/06/2003
function janelaChat()
{
		
	theURL="../int_chat/principal.asp"
	wname ="CHROMELESSWIN"
	W=4;
	H=2;
	windowCERRARa 		= "../int_imagens/close_a.gif"
	windowCERRARd 		= "../int_imagens/close_d.gif"
	windowCERRARo 		= "../int_imagens/close_o.gif"
	windowNONEgrf 		= "../int_imagens/none.gif"
	windowCLOCK		= "../int_imagens/clock.gif"
	windowREALtit		= "  PBT"
	windowTIT 	    	= "<font face=verdana size=1>  CHAT PBT</font>"
	windowBORDERCOLOR   	= "#000000"
	windowBORDERCOLORsel	= "#999999"
	windowTITBGCOLOR    	= "#999999"
	windowTITBGCOLORsel 	= "#333333"
	openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, 
					windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit , 
					windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel)
					
}
//CRIA A JANELA
function openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit , windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel) {

	var windowW = W;
	var windowH = H;
	var windowX = Math.ceil( (window.screen.width  - windowW) / 2 );
	var windowY = Math.ceil( (window.screen.height - windowH) / 2 );

	if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4) 
		isie=true
	else											     
		isie=false

	if (isie) 
	{ H=H+20+2; W=W+2; }

	s = ",width="+W+",height="+H;
   
	if (isie && (navigator.userAgent.toLowerCase().indexOf("win")!=-1) ) {

var dowin = theURL != "" ? true : false;

var chromeTIThtml = '\n' +
'<html>																							'+ '\n'+
'<head>                                                                                                                                                                         	'+ '\n'+
'<title>&nbsp;CHROMELESS WINDOWS / TITLEBAR</title>                                                                                                                      		'+ '\n'+
'<style type="text/css">                                                                                                                                                        	'+ '\n'+
'#mywindowTITLE 	{ position: absolute; left:   0px; top:   0px; width: 100%; height: 22px; z-index: 1; background-color: '+windowTITBGCOLOR+'; clip:rect(0,100%,22,0); }         '+ '\n'+
'#mywindow 		{ position: absolute; left:   0px; top:   0px; width: 100%; height: 22px; z-index: 2;                            	      clip:rect(0,100%;22,0); }         '+ '\n'+
'#mywindowCLOSE 	{ position: absolute; left: -22px; top: -22px; width: 11px; height: 11px; z-index: 3;                            	      clip:rect(0,11,11,0);   }         '+ '\n'+
'#mywindowCLOCK 	{ position: absolute; left: -22px; top: -22px; width: 11px; height: 11px; z-index: 3;                            	      clip:rect(0,11,11,0);   }         '+ '\n'+
'</style>                                                                                                                                                                       	'+ '\n'+
'<script language="javascript">																				'+ '\n'

if ( theURL != "" ) {

chromeTIThtml = chromeTIThtml + 
'	theURL 	    	    = "'+theURL			+'"                                                                                                                             '+ '\n'+
'	windowCERRARa 	    = "'+windowCERRARa		+'"                                                                                                                             '+ '\n'+
'	windowCERRARd 	    = "'+windowCERRARd		+'"                                                                                                                             '+ '\n'+
'	windowCERRARo 	    = "'+windowCERRARo		+'"                                                                                                                             '+ '\n'+
'	windowCLOCK         = "'+windowCLOCK            +'"                                                                                                                             '+ '\n'+
'	windowBORDERCOLOR   = "'+windowBORDERCOLOR	+'"                                                                                                                             '+ '\n'+
'	windowBORDERCOLORsel= "'+windowBORDERCOLORsel	+'"                                                                                                                             '+ '\n'+
'	windowTITBGCOLOR    = "'+windowTITBGCOLOR	+'"                                                                                                                             '+ '\n'+
'	windowTITBGCOLORsel = "'+windowTITBGCOLORsel	+'"                                                                                                                             '+ '\n'

} else {

chromeTIThtml = chromeTIThtml + 
'	theURL="about:blank"                                                                                                                                                            '+ '\n'+
'	windowCERRARa 		= "img/close_a.gif"                                                                                                                                     '+ '\n'+
'	windowCERRARd 		= "img/close_d.gif"                                                                                                                                     '+ '\n'+
'	windowCERRARo 		= "img/close_o.gif"                                                                                                                                     '+ '\n'+
'	windowCLOCK         	= "img/clock.gif"                                                                                                                             		'+ '\n'+
'	windowTIT 	    	= "<font face=verdana size=1>&nbsp; window title</font>"                                                                                               '+ '\n'+
'	windowBORDERCOLOR   	= "#000000"                                                                                                                                             '+ '\n'+
'	windowBORDERCOLORsel	= "#FF8A00"                                                                                                                                             '+ '\n'+
'	windowTITBGCOLOR    	= "#d7dcd9"                                                                                                                                             '+ '\n'+
'	windowTITBGCOLORsel 	= "#ffffff"                                                                                                                                             '+ '\n'

}

chromeTIThtml = chromeTIThtml + 
'var windowCERRARImg_a = new Image(); windowCERRARImg_a.src = windowCERRARa;                                                                                                            '+ '\n'+
'var windowCERRARImg_d = new Image(); windowCERRARImg_d.src = windowCERRARd;                                                                                                            '+ '\n'+
'var windowCERRARImg_o = new Image(); windowCERRARImg_o.src = windowCERRARo;                                                                                                            '+ '\n'+
'var windowCLOCKImg    = new Image();    windowCLOCKImg.src = windowCLOCK;                                                                                                              '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'function mouseSTATUS() {                                                                                                                                                               '+ '\n'+
'	this.x       = null;                                                                                                                                                            '+ '\n'+
'	this.y       = null;                                                                                                                                                            '+ '\n'+
'	this.bt      = "up";                                                                                                                                                            '+ '\n'+
'	this.oldx    = null;                                                                                                                                                            '+ '\n'+
'	this.oldy    = null;                                                                                                                                                            '+ '\n'+
'	this.dx      = null;                                                                                                                                                            '+ '\n'+
'	this.dy      = null;                                                                                                                                                            '+ '\n'+
'	this.screeny = null;                                                                                                                                                            '+ '\n'+
'	this.screenx = null;                                                                                                                                                            '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	this.element = null;                                                                                                                                                            '+ '\n'+
'	this.event   = null;                                                                                                                                                            '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'var mouse = new mouseSTATUS();                                                                                                                                                         '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'function actualizateMouseSTATUS(e) {                                                                                                                                                   '+ '\n'+
'	if (!e) var e = event                                                                                                                                                           '+ '\n'+
'	if ( (e.type=="mousedown" || e.type=="mouseup") && e.button!=1) return true                                                                                                     '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	var x=e.x+document.body.scrollLeft                                                                                                                                              '+ '\n'+
'	var y=e.y+document.body.scrollTop                                                                                                                                               '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	mouse.x   = x;                                                                                                                                                                  '+ '\n'+
'	mouse.y   = y;                                                                                                                                                                  '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	     if ( e.type == "mousedown" ) mouse.bt = "down";                                                                                                                            '+ '\n'+
'	else if ( e.type == "mouseup" )   mouse.bt = "up";                                                                                                                              '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'	if (window.event) {                                                                                                                                                             '+ '\n'+
'		mouse.screenx=window.event.screenX;                                                                                                                                     '+ '\n'+
'		mouse.screeny=window.event.screenY;                                                                                                                                     '+ '\n'+
'	} else {                                                                                                                                                                        '+ '\n'+
'		mouse.screenx=-1;                                                                                                                                                       '+ '\n'+
'		mouse.screeny=-1;                                                                                                                                                       '+ '\n'+
'	}                                                                                                                                                                               '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'function initMouseEvents() {                                                                                                                                                           '+ '\n'+
'	document.onmousedown = actualizateMouseSTATUS                                                                                                                                   '+ '\n'+
'	document.onmousemove = actualizateMouseSTATUS                                                                                                                                   '+ '\n'+
'	document.onmouseup   = actualizateMouseSTATUS                                                                                                                                   '+ '\n'+
'	document.onselectstart = selectstart                                                                                                                                            '+ '\n'+
'	document.ondragstart   = new Function("actualizateMouseSTATUS(event); return false;")                                                                                           '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'                                                                                                                                                                                       '+ '\n'+
'function selectstart(){                                                                                                                                                                '+ '\n'+
'	if ( event.srcElement.tagName != "INPUT" && event.srcElement.tagName != "TEXTAREA") { return false; }                                                                           '+ '\n'+
'	else { mouse.bt="up"; return true; }                                                                                                                                            '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'																							'+ '\n'+
'initMouseEvents()                                                                                                                                                                      '+ '\n'+
'																							'+ '\n'+
'var mywindowbt    ="up";                                                                                                                                                               '+ '\n'+
'var wincloseSTATUS="up";                                                                                                                                                               '+ '\n'+
'																							'+ '\n'+
'var ofx=0;                                                                                                                                                                             '+ '\n'+
'var ofy=0;                                                                                                                                                                             '+ '\n'+
'var opx=0;                                                                                                                                                                             '+ '\n'+
'var opy=0;                                                                                                                                                                             '+ '\n'+
'var px=0;                                                                                                                                                                              '+ '\n'+
'var py=0;                                                                                                                                                                              '+ '\n'+
'																							'+ '\n'+
'var wcpx1=-1, wcpy1=-1;                                                                                                                                                                '+ '\n'+
'var wcpx2=-1, wcpy2=-1;                                                                                                                                                                '+ '\n'+
'																							'+ '\n'+
'var wclosechanged = false;                                                                                                                                                             '+ '\n'+
'																							'+ '\n'+
'function initToMoveWin() {                                                                                                                                                             '+ '\n'+
'		if (wincloseSTATUS=="up" && ( mywindowbt=="up" || mywindowbt=="over") ) {                                                                                               '+ '\n'+
'					                                                 												'+ '\n'+
'				if ( parent.mainloaded ) document.all["mywindowCLOCK"].style.visibility = "hidden";                                                 			'+ '\n'+
'					                                                 												'+ '\n'+
'				document.all["mywindowCLOCK"].style.pixelLeft=document.body.clientWidth-36 										'+ '\n'+
'				document.all["mywindowCLOCK"].style.pixelTop =4                                                                         				'+ '\n'+
'					                                                 												'+ '\n'+
'				wcpx1 = document.all["mywindowCLOSE"].style.pixelLeft=document.body.clientWidth-18                                                                      '+ '\n'+
'				wcpy1 = document.all["mywindowCLOSE"].style.pixelTop =4                                                                                                 '+ '\n'+
'				wcpx2 = wcpx1 + 11 - 1                                                                                                                                  '+ '\n'+
'				wcpy2 = wcpy1 + 11 - 1                                                                                                                                  '+ '\n'+
'				if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2) {                                                                    '+ '\n'+
'					if (wclosechanged == false) {                                                                                                                   '+ '\n'+
'						document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_o.src                                                     '+ '\n'+
'						wclosechanged = true                                                                                                                    '+ '\n'+
'					}                                                                                                                                               '+ '\n'+
'						                                                                                                                                        '+ '\n'+
'				} else if (wclosechanged == true) {                                                                                                                     '+ '\n'+
'					document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_d.src                                                             '+ '\n'+
'					wclosechanged = false                                                                                                                           '+ '\n'+
'				}                                                                                                                                                       '+ '\n'+
'		}                                                                                                                                                                       '+ '\n'+
'																							'+ '\n'+
'		     if (   mouse.y <= 22 && mouse.y >= 1   && mywindowbt == "up"   && mouse.bt =="up"    ) { mywindowbt = "over" }                                                     '+ '\n'+
'		else if ( ( mouse.y  > 22 || mouse.y <  1 ) && mywindowbt == "over" && mouse.bt =="up"    ) { mywindowbt = "up"   }                                                     '+ '\n'+
'		else if (   mouse.y <= 22 && mouse.y >= 1   && mywindowbt == "over" && mouse.bt == "down" ) {                                                                           '+ '\n'+
'			self.window.focus();                                                                                                                                            '+ '\n'+
'	                                                                                                                                                                                '+ '\n'+
'			if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2 ) {                                                                           '+ '\n'+
'				wincloseSTATUS="down"                                                                                                                                   '+ '\n'+
'				document.all["mywindowCLOSE"].document.images["closewin"].src=windowCERRARImg_a.src                                                                     '+ '\n'+
'			} else {                                                                                                                                                        '+ '\n'+
'				document.all["mywindowTITLE"].style.backgroundColor = windowTITBGCOLORsel                                                                               '+ '\n'+
'				document.body.style.borderColor    = windowBORDERCOLORsel                                                                                               '+ '\n'+
'				parent.chromewinb.document.bgColor = windowBORDERCOLORsel                                                                                               '+ '\n'+
'				parent.chromewinl.document.bgColor = windowBORDERCOLORsel                                                                                               '+ '\n'+
'				parent.chromewinr.document.bgColor = windowBORDERCOLORsel                                                                                               '+ '\n'+
'				ofx =  mouse.x;                                                                                                                                         '+ '\n'+
'				ofy =  mouse.y;                                                                                                                                         '+ '\n'+
'				opx =  mouse.x;                                                                                                                                         '+ '\n'+
'				opy =  mouse.y;                                                                                                                                         '+ '\n'+
'			}	                                                                                                                                                        '+ '\n'+
'			mywindowbt="down";                                                                                                                                              '+ '\n'+
'		}                                                                                                                                                                       '+ '\n'+
'		else if ( mouse.bt =="up" && mywindowbt == "down" ) {                                                                                                                   '+ '\n'+
'			mywindowbt="up";                                                                                                                                                '+ '\n'+
'			ofx=0;                                                                                                                                                          '+ '\n'+
'			ofy=0;                                                                                                                                                          '+ '\n'+
'			opx=0;                                                                                                                                                          '+ '\n'+
'			opy=0;                                                                                                                                                          '+ '\n'+
'																							'+ '\n'+
'			if ( mouse.x >= wcpx1 && mouse.x <= wcpx2 && mouse.y >= wcpy1 && mouse.y <= wcpy2 && wincloseSTATUS=="down" ) { top.window.close() }                            '+ '\n'+
'																							'+ '\n'+
'			wincloseSTATUS="up"                                                                                                                                             '+ '\n'+
'		                                                                                                                                                                        '+ '\n'+
'			if ( document.all["mywindowTITLE"] ) {                                                                                                                          '+ '\n'+
'				document.all["mywindowTITLE"].style.backgroundColor = windowTITBGCOLOR                                                                                  '+ '\n'+
'				document.body.style.borderColor   = windowBORDERCOLOR                                                                                                   '+ '\n'+
'				parent.chromewinb.document.bgColor= windowBORDERCOLOR                                                                                                   '+ '\n'+
'				parent.chromewinl.document.bgColor= windowBORDERCOLOR                                                                                                   '+ '\n'+
'				parent.chromewinr.document.bgColor= windowBORDERCOLOR                                                                                                   '+ '\n'+
'			}                                                                                                                                                               '+ '\n'+
'																							'+ '\n'+
'		}                                                                                                                                                                       '+ '\n'+
'		else if ( mywindowbt == "down" && wincloseSTATUS == "up") {                                                                                                             '+ '\n'+
'			var m_scrx = mouse.screenx;                                                                                                                                     '+ '\n'+
'			var m_scry = mouse.screeny;                                                                                                                                     '+ '\n'+
'			opx = px + ofx - m_scrx;                                                                                                                                        '+ '\n'+
'			opy = py + ofy - m_scry;                                                                                                                                        '+ '\n'+
'			px = m_scrx - ofx;                                                                                                                                              '+ '\n'+
'			py = m_scry - ofy;                                                                                                                                              '+ '\n'+
'			top.window.moveTo(px , py);                                                                                                                                     '+ '\n'+
'		}                                                                                                                                                                       '+ '\n'+
'	setTimeout("initToMoveWin()",50);                                                                                                                                               '+ '\n'+
'}                                                                                                                                                                                      '+ '\n'+
'</script>                                                                                												'+ '\n'+
'</head>                                                                                                                                                                        	'+ '\n'+
'<body TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 scroll=no style="border: 1px solid '+ windowBORDERCOLOR +'; overflow: hidden; margin: 0pt;" bgcolor='+windowTITBGCOLOR+'>  '+ '\n'+
'<div id=mywindow><img src="'+windowNONEgrf+'" width=100% height=20></div>                                                                                                             	'+ '\n'+
'<div id=mywindowTITLE>'+ '<table width=100% height=20 border=0 cellpadding=0 cellspacing=0><tr><td valign=middle align=left>'+windowTIT+'</td></tr></table>' +'</div>                  '+ '\n'+
'<div id=mywindowCLOSE><img name=closewin src="'+ windowCERRARd +'" border=0 width=11 height=11></div>                                                                                  '+ '\n'+
'<div id=mywindowCLOCK><img name=clockwin src="'+ windowCLOCK   +'" border=0 width=11 height=11></div>                                                                                  '+ '\n'+
'</body>                                                                                                                                                                        	'+ '\n'+
'<script>initToMoveWin();</script>																			'+ '\n'+
'</html>                                                                                                                                                                        	'+ '\n'

var chromeFRMhtml = '' +
'<HTML>																		'+ '\n'+
'<HEAD>                                                                         								'+ '\n'+
'<TITLE>'+ windowREALtit +'</TITLE>                                          									'+ '\n'+
'</HEAD>                                                                        								'+ '\n'+
'<script> 																	'+ '\n'+
'mainloaded = false																'+ '\n'+
'function generatetitle() { 															'+ '\n'+
'	if( window.frames["chromewint"] && window.frames["chromewinl"] && window.frames["chromewinb"] && window.frames["chromewinr"] ) {	'+ '\n'+
'		chromewint.document.open();													'+ '\n'+
'		chromewint.document.write( "'+ quitasaltolinea(chromeTIThtml) +'" );								'+ '\n'+
'		chromewint.document.close();													'+ '\n'+
'		chromewinl.document.bgColor="'+ windowBORDERCOLOR +'"										'+ '\n'+
'		chromewinb.document.bgColor="'+ windowBORDERCOLOR +'"										'+ '\n'+
'		chromewinr.document.bgColor="'+ windowBORDERCOLOR +'"										'+ '\n'+
'	} else {																'+ '\n'+
'		setTimeout("generatetitle()",200)												'+ '\n'+
'	}																	'+ '\n'+
'}																		'+ '\n'+
'generatetitle()																'+ '\n'+
'</script>																	'+ '\n'+
'<frameset border=0 framespacing=0 frameborder=0 rows="22,100%,1" onload="mainloaded=true" onreadystatechange="generatetitle()">		'+ '\n'+
'	<frame name=chromewint src="about:blank" scrolling=no noresize>  									'+ '\n'+
'	<frameset border=0 framespacing=0 frameborder=0 cols="1,100%,1">        								'+ '\n'+
'		<frame name=chromewinl src="about:blank" scrolling=no noresize> 								'+ '\n'+
'		<frame name=main       src="'+theURL+'">                   									'+ '\n'+
'		<frame name=chromewinr src="about:blank" scrolling=no noresize> 								'+ '\n'+
'	</frameset>                                                             								'+ '\n'+
'	<frame name=chromewinb src="about:blank" scrolling=no noresize>         								'+ '\n'+
'</frameset>                                                                    								'+ '\n'+
'</HTML>                                                                        								'

		splashWin = window.open( "" , wname, "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0"+s);

		//splashWin.resizeTo( Math.ceil( W )       , Math.ceil( H ) );
		//plashWin.moveTo  ( Math.ceil( windowX ) , Math.ceil( windowY ) );

		splashWin.document.open();
		splashWin.document.write( chromeFRMhtml );
		splashWin.document.close();

	}
	else    {
		var splashWin = window.open(theURL, wname, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1"+s, true);
	}

	splashWin.focus();
}                                                                               
                                                                                
function quitasaltolinea(txt) {

  var salida = txt.toString()
  var re     = /\\/g; var salida = salida.replace(re, "\\\\");
  var re     = /\//g; var salida = salida.replace(re, "\\\/");
  var re     = /\"/g; var salida = salida.replace(re, "\\\"");
  var re     = /\'/g; var salida = salida.replace(re, "\\\'");
  var re     = /\n/g; var salida = salida.replace(re, "\\n");
  var re     = /  /g; var salida = salida.replace(re, "");
  var re     = /\t/g; var salida = salida.replace(re, "");
  var re     = /\r/g; var salida = salida.replace(re, "");

  return salida

}
/* usado no click da imagem, corpo e/ou título de uma notícia */
function mostrarConteudo(CO_TOPICO){
	document.location.href = '../int_interface/Default_Exibir_Conteudo.asp?CO_TOPICO=' + CO_TOPICO;
} //mostrarConteudo

/********************************************************************************
 * Autor : Alysson Barros
 * Última modificação :	11/07/2001			Responsável : Autor
 * Alterado por : Tonicley Barbosa de Araújo
 *
 * Verifica se um email é válido.
 * Parâmetro : objeto, O campo de Email - usar o this.
 *
 * retorno : retorna TRUE caso o campo seja um email válido, caso contrário
 *           retorna FALSE e seta o focus no campo de Email.
 *******************************************************************************/
function validaEmail(objeto) {
        var email = objeto.value;
        var s = new String(email);
        var retorno = true;

        // Se o email for vazio, retorne verdadeiro.
        if (email == "") return true;

        // { } ( ) < > [ ] | \ /
        if ((s.indexOf("{")>=0) || (s.indexOf("}")>=0) || (s.indexOf("(")>=0) || (s.indexOf(")")>=0) || (s.indexOf("<")>=0) || (s.indexOf(">")>=0) || (s.indexOf("[")>=0) || (s.indexOf("]")>=0) || (s.indexOf("|")>=0) || (s.indexOf("\"")>=0) || (s.indexOf("/")>=0))
                retorno = false;
        // & * $ % ? ! ^ ~ ` ' "
        if ((s.indexOf("&")>=0) || (s.indexOf("*")>=0) || (s.indexOf("$")>=0) || (s.indexOf("%")>=0) || (s.indexOf("?")>=0) || (s.indexOf("!")>=0) || (s.indexOf("^")>=0) || (s.indexOf("~")>=0) || (s.indexOf("`")>=0) || (s.indexOf("'")>=0) )
                retorno = false;
        // , ; : = #
        if ((s.indexOf(",")>=0) || (s.indexOf(";")>=0) || (s.indexOf(":")>=0) || (s.indexOf("=")>=0) || (s.indexOf("#")>=0) )
                retorno = false;
        // procura se existe apenas um @
        if ( (s.indexOf("@") < 0) || (s.indexOf("@") != s.lastIndexOf("@")) )
                retorno = false;
        // verifica se tem pelo menos um ponto após o @
        if (s.lastIndexOf(".") < s.indexOf("@"))
                retorno = false;
		// verifica se existe pelo menos um caracter antes do @
		if (s.substr(0,1) == '@')
                retorno = false;

		if (!retorno){
                objeto.focus();
                objeto.select();
                alert("Email Incorreto!");
        }

        return retorno;
}

function leiaMais(codigo){
	popUp('../int_interface/LeiaMais.asp?CO_NOTICIA=' + codigo, 340, 405,'yes','leiaMais');
} //leiaMais


function paginaExterna(codigo){
	popUp('../int_interface/LeiaMais.asp?CO_NOTICIA=' + codigo, 340, 405,'no','leiaMais');
} //leiaMais



//função usada no evento onKeyUp
function limitaTxtArea(TextArea, tamanhoMaximo){
	
	if (TextArea.value.length > tamanhoMaximo)
	{
		return(TextArea.value = TextArea.value.substr(0, tamanhoMaximo));
	}
		
	return(true);

}
// Data - 25/07/2003
// Autor - Edson Gomes
// Descrição Função especifica para o campo de "página específica" da paginação, cujo o valor somente pode ser numero ou a tecla <ENTER> para poder submeter a pagina.
// Essa função recebe como parametro o evento 'event' do onkeypress e retorna um valor booleano (true ou false);
function verificaNumero( teclapress){
 var charCode = (navigator.appName == "Netscape") ? teclapress.which : teclapress.keyCode;	  
  if(charCode != 13 && (charCode < 48 || charCode > 57))
   		return(false);
	else
		return(true);	 
}

/* após o login no "passaport", recarregar todas as páginas envolvidas */
function recarregar(url){

	//não é popup
	if( !EhPopup() ) {
		document.location.reload();
		return true;
	}	

	//é um frame
	if(window.parent.topo != null){
		window.parent.opener.document.location.reload();
		window.parent.top.document.location.reload();
		document.location.target = 'botton';
	}	
	else{
		window.opener.document.location.reload();
	}	
	document.location.href = url;

	return;
	
} //recarregar

function EhPopup(){
	var retorno;
	retorno = (window.opener != null);
	if (window.parent.top != null){
		retorno = (window.parent.opener != null);
	}
	return retorno;
	
} //EhPopup

function addItemCarrinho(iCodigoItem)
{
	window.location='/int_interface/Default_Produto.asp?PAGINA_PRODUTO=0&CATEGORIA=0&OPERACAO=S&CODIGO_PROD=' + iCodigoItem;
}
// para fechar um popup
function fechar(){
	self.close();
	window.opener.focus();
} //fechar
