//########################//########################
// Função para iniciarmos o Ajax no browser do cliente.
function openAjax() {
	var ajax;
	try{
		ajax = new XMLHttpRequest(); // XMLHttpRequest para browsers decentes, como: Firefox, Safari, dentre outros.
	}catch(ee){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS
		}catch(e){
			try{
				ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS
			}catch(E){
				ajax = false;
			}
		}
	}
	return ajax;
}

//#VERIFICA IE OU FIREFOX#####################################################################################################
var UA = navigator.userAgent;
var display
//alert(UA);
//document.write(UA);
if (UA.indexOf('MSIE') > -1) {    
	display = "block";
} else if (UA.indexOf('Firefox') > -1) {    
	display = "table-row";
} else if (UA.indexOf('Chrome') > -1) {  	
	display = "table-row";
}



// Função para trocar titulo quando uzar ajax
function trocatitulo(titulo,id){
	var exibe = document.getElementById(id);
	exibe.innerHTML = titulo;
}

//#######################################################################################
//Desabilitar o botão direito
var message="ANGELUS Indústria de Produtos Odontológicos S/A. \n\n Todos os direitos reservados © Copyright \n\n sac@angelus.ind.br";
///////////////////////////////////
function clickIE() {
	if (document.all) {
		(message);
		return false;
	}
}
function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if (e.which==2||e.which==3) {
			(message);
			return false;
		}
	}
}
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
}else{
	document.onmouseup=clickNS;
	document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("alert(message); return false")
//#######################################################################################

// Função Para utilizar ajax geral
function ajaxinteligente(arquivo,querystring, id) {
	if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
		var exibeResultado = document.getElementById(id); // div que exibirá o resultado da busca.
		//alert(arquivo + ' ' + id);
		if(arquivo != "" && arquivo != null) { // Verifica se o campo não está vazio, ou se foi digitado no mínimo três caracteres.
			var ajax = openAjax(); // Inicia o Ajax.
			ajax.open("GET", arquivo + '?rnd=' + Math.random() + querystring, true); // Envia o termo da busca como uma querystring, nos possibilitando o filtro na busca.
			ajax.setRequestHeader("Content-Type", "text/html; charset=iso-8859-1");
			//alert(querystring);
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					exibeResultado.innerHTML = "<br /><div  style=\"background:#ffffff; width:125px;  border:solid 1px #666666; padding:2px; margin:2px; font: 11px; bold Arial, Helvetica, sans-serif; color:#666666;\"><img src=\"./imagens/loading.gif\"  align=\"absmiddle\">Carregando...</div>";
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						//resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						//resultado = unescape(resultado); // Resolve o problema dos acentos
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = "Erro: ";
					}
				}
			}
			ajax.send(null); // submete
		} 
	}
}


function selectdrop(sel_name, abbr_name)
{
	if(abbr_name!=''){
		if(sel_name.length > 0){
			var maxIndex = sel_name.length;
				for(var i=0; i<maxIndex; i++){
					if(abbr_name== sel_name.options[i].value){
						sel_name.selectedIndex = i;
						break;
					}
				}
			}
		}
	return true;    
}

// Função que realiza a busca instantânea de produtos
function buscaprodutos(coddep,idiomab,dep) {
	if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
		var termo = coddep; // Pega o termo digitado no campo de texto.
		var exibeResultado = document.getElementById('resultadoBuscaprodutos'); // div que exibirá o resultado da busca.
		if(termo != "" && termo != null) { // Verifica se o campo não está vazio, ou se foi digitado no mínimo três caracteres.
			var ajax = openAjax(); // Inicia o Ajax.
			ajax.open("GET", "buscaprodutos.asp?dep=" + dep + "&idiomab=" + idiomab + "&coddep=" + termo, true); // Envia o termo da busca como uma querystring, nos possibilitando o filtro na busca.
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					if(idiomab == "2") {
						exibeResultado.innerHTML = "Loading...";
					} else if (idiomab == "3") {
						exibeResultado.innerHTML = "Cargando...";
					}else{
						exibeResultado.innerHTML = "Carregando...";
					}
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						resultado = unescape(resultado); // Resolve o problema dos acentos
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = "Erro: ";
					}
				}
			}
			ajax.send(null); // submete
		} 
	}
}

// Função que realiza a busca instantânea das publicacoes dos produtos
function buscaconteudoprodutos(codc,idiomab) {
	if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
		var termo = codc; // Pega o termo digitado no campo de texto.
		var exibeResultado = document.getElementById('resultadoConteudoproduto'); // div que exibirá o resultado da busca.
		if(termo != "" && termo != null) { // Verifica se o campo não está vazio, ou se foi digitado no mínimo três caracteres.
			var ajax = openAjax(); // Inicia o Ajax.
			ajax.open("GET", "buscaconteudoprodutos.asp?codc=" + termo, true); // Envia o termo da busca como uma querystring, nos possibilitando o filtro na busca.
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					if(idiomab == "2") {
						exibeResultado.innerHTML = "Loading...";
					} else if (idiomab == "3") {
						exibeResultado.innerHTML = "Cargando...";
					}else{
						exibeResultado.innerHTML = "Carregando...";
					}
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						resultado = unescape(resultado); // Resolve o problema dos acentos
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = ""; // Entra aqui se houver algum problema ou se o conteúdo vier vazio!
					}
				}
			}
			ajax.send(null); // submete
		} 
	}
}



// Função que realiza a busca instantânea das fotos
function buscafotos(codigo_galeria,codigo_foto,idiomab) {
	if(document.getElementById) { // Para os browsers complacentes com o DOM W3C.
		var termo = codigo_galeria; // Pega o termo digitado no campo de texto.
		var exibeResultado = document.getElementById('foto'); // div que exibirá o resultado da busca.
		if(termo != "" && termo != null) { // Verifica se o campo não está vazio, ou se foi digitado no mínimo três caracteres.
			var ajax = openAjax(); // Inicia o Ajax.
			ajax.open("GET", "buscafotos.asp?galeria=" + codigo_galeria + "&foto=" + codigo_foto, true); // Envia o termo da busca como uma querystring, nos possibilitando o filtro na busca.
			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando...
					if(idiomab == "2") {
						exibeResultado.innerHTML = "Loading...";
					} else if (idiomab == "3") {
						exibeResultado.innerHTML = "Cargando...";
					}else{
						exibeResultado.innerHTML = "Carregando...";
					}
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						resultado = unescape(resultado); // Resolve o problema dos acentos
						exibeResultado.innerHTML = resultado;
					} else {
						exibeResultado.innerHTML = ""; // Entra aqui se houver algum problema ou se o conteúdo vier vazio!
					}
				}
			}
			ajax.send(null); // submete
		} 
	}
}
//FIM AJAX
//########################//########################


//@@@@@@@----------------------------------------------------------------------------------------------------------
function ajaxchat(){
	//window.top.location.href='chat/ajax-chatonline.asp?rnd=' + Math.random() ;
		var head = document.getElementsByTagName('head').item(0);
		var escript = document.createElement('script');
		escript.setAttribute('src', 'chat/ajax-chatonline.asp?rnd=' + Math.random() + '');
		head.appendChild(escript);
}
//@@@@@@@----------------------------------------------------------------------------------------------------------




// Mascara para Data
// Instrução de chamada no <input>:
// onkeypress="FormataData(this,event)"
function FormataData(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = Campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;
	if( tecla != 9 && tecla != 8 ) 	{
		if( tam > 2 && tam < 5 )
			Campo.value = vr.substr( 0, tam - 2 ) + '/' + vr.substr( tam - 2, tam );
		if( tam >= 5 && tam <= 10 )
			Campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 );
	}
}


//########################//########################
//Texto na barra de status
function wiper()
{
        if (stcnt > -1) str = wmsg[stcnt]; else str = wmsg[0];
        if (stcnt-- < -40) stcnt=31;
        status = str;
        clearTimeout(timeID);
        timeID = setTimeout("wiper()",100);
}

msg = "ANGELUS";
timeID = 10;
stcnt = 16;
wmsg = new Array(33);
wmsg[0]=msg;
blnk = "                                                               ";
for (i=1; i<32; i++)
	{
		b = blnk.substring(0,i);
		wmsg[i]="";
		for (j=0; j<msg.length; j++) wmsg[i]=wmsg[i]+msg.charAt(j)+b;
	}
//wiper()
//########################//########################			






//########################
//Função para o menu
window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}
//########################

//##########################################################################
//FUNÇÃO PARA REDIMENSIONAR A JANELA NO TAMANHO DA IMAGEM QUE ESTÁ ABRINDO
function reSizeImage() {
	//Pego o tamanho da tela Horizontal e Vertical
	var valorW = screen.width;
	var valorH = screen.height;
	//Pego o tamanho da imagem Horizontal e Vertical
	var width = document.getElementById('imagem').width;
	var height = document.getElementById('imagem').height;
	//Variavel que identifica se a imagem eh maior que a tela
	var estouro = false;
	//Se o tamanho Horizontal da imagem for maior que o tamanho da tela
	if ( width > valorW ) {
		//Calculo o tamanho vertical da imagem proporcional ao tamanho da tela
		height = retornaProporcional( width, height, valorW );
		width = valorW;
		//Redimensiono a imagem para o tamanho da tela
		//Diminuo um pouco a imagem para que ela seja exibida completa
		//Windows XP deixa uma barra maior na parte inferior do popup
		document.getElementById('imagem').width = width - 12;
		document.getElementById('imagem').height = height - 60;
		estouro = true;
	}
	//Se o tamanho Vertical da imagem for maior que o tamanho da tela
	if ( height > valorH ) {
		//Calculo o tamanho horizontal da imagem proporcional ao tamanho da tela
		width = retornaProporcional( height, width, valorH );
		height = valorH;
		//Redimensiono a imagem para o tamanho da tela
		//Diminuo um pouco a imagem para que ela seja exibida completa
		//Windows XP deixa uma barra maior na parte inferior do popup
		document.getElementById('imagem').width = width - 12;
		document.getElementById('imagem').height = height - 60;
		estouro = true;
	}
	if ( !estouro ) {
		width += 12;
		height += 60;
	}
	window.resizeTo(width+20,height+60);
	self.focus();
};

function doTitle(title) {
	//Altero o Titulo da janela
	document.title = title;
}

function retornaProporcional( x, y, valor ) {
	var retorno;
	//Calculo um valor proporcional para y de acordo com x e valor
	retorno = new Number( y / ( x / valor ) );
	return retorno.toFixed(0);
}

function openWindow(theURL,winName,winWidth,winHeight,features) {
  features = features+',width='+winWidth+',height='+winHeight+',top=0,left=0';
  window.open(theURL,winName,features);
}
//FIM REDIMENSIONA
//##########################################################################


// JavaScript
function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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 IrAoCorreio()
{
  open('http://www.correios.com.br/servicos/cep/cep_default.cfm','IrAoCorreio','location=no,resize=no, width=730,height=400,left=18,top=18,maximized=0,scrollbars=1');
}

/************************************************
* function verificaDataform
* Verifica se um campo data é válido.
* Input: Campo do formulário que contém a data
* Esta função pega o campo diretamente, pois assim
* pode dar uma resposta melhor ao usuário.
*************************************************/

function verificaDataform(data){
	var Date = new String(data);
	Day = "";
	Month = "";
	Year = "";
	i =  0;
	for (i=0;(i<Date.length) && (Date.charAt(i) != '/');i++)
		Day = Day + Date.charAt(i);
	i++;
	for (;(i<Date.length) && (Date.charAt(i) != '/');i++)
		Month = Month + Date.charAt(i);
	i++;
	for (;(i<Date.length);i++)
		Year = Year + Date.charAt(i);
	for(i=0;i<Date.length;i++){
		NroAsc = asc(Date.substring(i,i+1))
		if (!(NroAsc>=48 && NroAsc<=57) || !(NroAsc = 47) )  {
			return false;
		}
	}
	if(!isNumeric(Month)) {
		return false;
	}
	if (eval(Month) > 12){
		return false;
	}
	if(!isNumeric(Day)) {
		return false;
	}
	if (eval(Day) > 31){
		return false;
	}
	if(!isNumeric(Year)) {
		return false;
	}
	if(eval(Year) < 1900) {
		return false;
	}
	return true;
}


/************************************************
* function verificaCPF
* Verifica se um CPF é válido
* Input: cpf a ser verificado
************************************************/

function verificaCPF(cpf)
{
	var dac = "", inicio = 2, fim = 10, soma, digito, i, j
	for (j=1;j<=2;j++) {
		soma = 0
		for (i=inicio;i<=fim;i++) {
			soma += parseInt(cpf.substring(i-j-1,i-j))*(fim+1+j-i)
		}
		if (j == 2) { soma += 2*digito }
		digito = (10*soma) % 11
		if (digito == 10) { digito = 0 }
		dac += digito
		inicio = 3
		fim = 11
	}
	return (dac == cpf.substring(cpf.length-2,cpf.length))
}

/************************************************
* function verificaCGC
* Verifica se um CGC é válido
* Input: cgc a ser verificado
************************************************/

function verificaCGC(scgc) {
	cgc = trimtodigits(scgc);
	if ((cgc.indexOf("-") != -1) || (cgc.indexOf(".") != -1) || (cgc.indexOf("/") != -1)){
		return( false )
	}
	var df, resto, dac = ""
	df = 5*cgc.charAt(0)+4*cgc.charAt(1)+3*cgc.charAt(2)+2*cgc.charAt(3)+9*cgc.charAt(4)+8*cgc.charAt(5)+7*cgc.charAt(6)+6*cgc.charAt(7)+5*cgc.charAt(8)+4*cgc.charAt(9)+3*cgc.charAt(10)+2*cgc.charAt(11)
	resto = df % 11
	dac += ( (resto <= 1) ? 0 : (11-resto) )
	df = 6*cgc.charAt(0)+5*cgc.charAt(1)+4*cgc.charAt(2)+3*cgc.charAt(3)+2*cgc.charAt(4)+9*cgc.charAt(5)+8*cgc.charAt(6)+7*cgc.charAt(7)+6*cgc.charAt(8)+5*cgc.charAt(9)+4*cgc.charAt(10)+3*cgc.charAt(11)+2*parseInt(dac)
	resto = df % 11
	dac += ( (resto <= 1) ? 0 : (11-resto) )
	return (dac == cgc.substring(cgc.length-2,cgc.length))
}

/************************************************
* function verificaEmail
* Verifica se um email é válido
* Input: email a ser verificado
************************************************/

function verificaEmail(email) {
	var s = new String(email);
	// { } ( ) < > [ ] | \ /
	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) )
		return false;
	if (vogalAcentuada(email))
		return 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) )
		return false;
	// , ; : = #
	if ((s.indexOf(",")>=0) || (s.indexOf(";")>=0) || (s.indexOf(":")>=0) || (s.indexOf("=")>=0) || (s.indexOf("#")>=0) )
		return false;
	// procura se existe apenas um @
	if ( (s.indexOf("@") < 0) || (s.indexOf("@") != s.lastIndexOf("@")) )
		return false;
	// verifica se tem pelo menos um ponto após o @
	if (s.lastIndexOf(".") < s.indexOf("@"))
		return false;
	return true;
}

/************************************************
* function verificaCEP
* Verifica se o CEP está no formato correto
* Input: CEP a ser verificado
************************************************/

function verificaCEP (cep) {
	s = new String(cep);
	if ((s.length > 9) || (s.length < 5))
		return false;
	if (!isInteger(cep))
		return false;
	return true;
}

/************************************************
* function isInteger
* Verifica se um campo é inteiro, inclui dígitos de 0 a 9, vírgula, ponto, espaços e -
* Input: campo a ser verificado
************************************************/

function isInteger(s){
	var i;
	if (isEmpty(s)) 
		return false;
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (!isNumber(c)) return false;
	}
	return true;
}

/************************************************
* function isNumeric
* Verifica se um campo é numérico. Se contém apenas dígitos de 0 a 9
* Input: campo a ser verificado
************************************************/

function isNumeric(s){
	var i;
	if (isEmpty(s)) 
		return false;
	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}

/************************************************
* function warnInvalid
* Gera um alert para o usuário e volta o foco para
* o campo que está com problema
* Input: theField - campo do formulário com problema
*        warnText - texto a ser mostrado no alert
************************************************/

function warnInvalid (theField, warnText)
{   theField.focus()
	theField.select()
	alert(warnText)
	return false
}

// Verifica se o caracter é um dígito de 0 a 9
function isDigit (c)
{ return ((c >= "0") && (c <= "9")) }

// Verifica se uma string tem vogais acentuadas
function vogalAcentuada(s) {
	ls = s.toLowerCase();
	if ((ls.indexOf("á")>=0) || (ls.indexOf("à")>=0) || (ls.indexOf("ã")>=0) || (ls.indexOf("â")>=0) || (ls.indexOf("é")>=0) || (ls.indexOf("í")>=0) || (ls.indexOf("ó")>=0) || (ls.indexOf("õ")>=0) || (ls.indexOf("ô")>=0) || (ls.indexOf("ú")>=0) || (ls.indexOf("ü")>=0))
		return true;
}

// Gera uma string com os caracteres básicos na sequência de códigos ASC
function makeCharsetString(){
	var astr
	astr = ' !"#$%&\'()*+,-./0123456789:;<=>?@'
	astr+= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	astr+= '[\]^_`abcdefghijklmnopqrstuvwxyz'
	astr+= '{|}~'
	return astr
}

// Retorna o código ASC do caracter passada por parâmetro
function asc(achar){
	var n=0;
	var ascstr = makeCharsetString()
	for(i=0;i<ascstr.length;i++){
		if(achar==ascstr.substring(i,i+1)){
			n=i;
			break;
		}
	}
	return n+32
}

//Remove todos os caracteres excetos 0-9
function trimtodigits(tstring){
  s=""; 
  ts=new String(tstring);
  for (x=0;x<ts.length;x++){
   ch=ts.charAt(x);
	if (asc(ch)>=48 && asc(ch)<=57){
	  s=s+ch;
	}
  }
  return s;
}
/*inicio */


// Retorna o código ASC do caracter passada por parâmetro
function asc(achar){
	var n=0;
	var ascstr = makeCharsetString()
	for(i=0;i<ascstr.length;i++){
		if(achar==ascstr.substring(i,i+1)){
			n=i;
			break;
		}
	}
	return n+32
}
// Gera uma string com os caracteres básicos na sequência de códigos ASC
function makeCharsetString(){
	var astr
	astr = ' !"#$%&\'()*+,-./0123456789:;<=>?@'
	astr+= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	astr+= '[\]^_`abcdefghijklmnopqrstuvwxyz'
	astr+= '{|}~'
	return astr
}

// Verifica se uma string tem vogais acentuadas
function vogalAcentuada(s) {
	ls = s.toLowerCase();
	if ((ls.indexOf("á")>=0) || (ls.indexOf("à")>=0) || (ls.indexOf("ã")>=0) || (ls.indexOf("â")>=0) || (ls.indexOf("é")>=0) || (ls.indexOf("í")>=0) || (ls.indexOf("ó")>=0) || (ls.indexOf("õ")>=0) || (ls.indexOf("ô")>=0) || (ls.indexOf("ú")>=0) || (ls.indexOf("ü")>=0))
	return true;
}

// Verifica se o caracter pode fazer parte de um número: 0-9 , . ( ) - e espaço
function isNumber (c) { 
	return ((c >= "0") && (c <= "9") || (c=="-") || (c=="(") || (c==")") || (c==" ") || (c==".") || (c==",")) 
}

// Verifica se o caracter é um dígito de 0 a 9
function isDigit (c) { 
	return ((c >= "0") && (c <= "9")) 
}

/************************************************
* function checkField
* Verificação básica de um campo de formulário por "coisas bobas": & < > | \ /
* Input: campo a ser verificado
************************************************/

function checkField(s) {
	if ((s.indexOf("&")>=0) || (s.indexOf("<")>=0) || (s.indexOf(">")>=0) || (s.indexOf("|")>=0) || (s.indexOf("\"")>=0) || (s.indexOf("/")>=0) )
		return false;
	return true;
}

/************************************************
* function isEmpty
* Verifica se um campo está vazio
* Input: campo a ser verificado
************************************************/

function isEmpty(s) {
	return ((s == null) || (s.length == 0));
}


/************************************************
* function warnInvalid
* Gera um alert para o usuário e volta o foco para
* o campo que está com problema
* Input: theField - campo do formulário com problema
*        warnText - texto a ser mostrado no alert
************************************************/

function warnInvalid (theField, warnText)
{   theField.focus()
	theField.select()
	alert(warnText)
	return false
}

/************************************************
* function warnInvalid_SelectBox
* Gera um alert para o usuário e volta o foco para
* o campo que está com problema
* Esta função é específica para ser usada com campos Select, para outros campos, usar a warnInvalid
* Input: theField - campo do formulário com problema
*        warnText - texto a ser mostrado no alert
************************************************/
function warnInvalid_SelectBox (theField, s)
{
	theField.focus();
	alert(s);
	return false;
}

function openCentered(theURL,winName,winWidth,winHeight,features) {
  var w = (screen.width - winWidth)/2;
  var h = (screen.height - winHeight)/2 - 60;
  features = features+',width='+winWidth+',height='+winHeight+',top='+h+',left='+w;
  window.open(theURL,winName,features);
}


		
function toggleDisplay(sID){

		//PRELOAD
	transimg = new Image; 
	transimg.src = 'imgsite/menu_seta_abaixo.gif';
	transimg2 = new Image; 
	transimg2.src = 'imgsite/menu_seta_direita.gif';
	if (document.getElementById)
	{
		if (document.getElementById(sID).style.display == "none") {
			document.getElementById("img"+sID).src = transimg.src;
			document.getElementById(sID).style.display = "block";
			//alert("if");
			//document.getElementById("img"+sID).src = "imgsite/menu_setacima.gif";
			setCookie(sID, "1");
		}
		else {
			//alert("else");
			document.getElementById("img"+sID).src = transimg2.src;
			document.getElementById(sID).style.display = "none";
			//document.getElementById("img"+sID).src = "imgsite/menu_setabaixo.gif";
			deleteCookie(sID);
		}
	}
	else
	{
		alert('Your browser does not allow for dynamic javascript and is not standards-compliant.\nPlease update your browser to use our site and have it function correctly.');
	};

}

function toggleDisplayGeral(sID){

	//PRELOAD
	if (document.getElementById)
	{
		if (document.getElementById(sID).style.display == "none") {
			document.getElementById(sID).style.display = "block";
			//alert("if");
			//document.getElementById("img"+sID).src = "imgsite/menu_setacima.gif";
			setCookie(sID, "1");
		}
		else {
			//alert("else");
			document.getElementById(sID).style.display = "none";
			//document.getElementById("img"+sID).src = "imgsite/menu_setabaixo.gif";
			deleteCookie(sID);
		}
	}
	else
	{
		alert('Your browser does not allow for dynamic javascript and is not standards-compliant.\nPlease update your browser to use our site and have it function correctly.');
	};

}

function setCookie(name, value, expires, path, domain, secure) {
		  var curCookie = name + "=" + escape(value) +
		  ((expires) ? "; expires=" + expires.toGMTString() : "") +
		  ((path) ? "; path=" + path : "") +
		  ((domain) ? "; domain=" + domain : "") +
		  ((secure) ? "; secure" : "");
		  document.cookie = curCookie;
 }
 function getCookie(name) {
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
		} else
		begin += 2;
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		end = dc.length;
		return unescape(dc.substring(begin + prefix.length, end));
 }
 function deleteCookie(name, path, domain) {
		if (getCookie(name)) {
			   document.cookie = name + "=" + 
			   ((path) ? "; path=" + path : "") +
			   ((domain) ? "; domain=" + domain : "") +
			   "; expires=Thu, 01-Jan-70 00:00:01 GMT";
			   //history.go(0);
		}
 }
 function fixDate(date) {
		var base = new Date(0);
		var skew = base.getTime();
		if (skew > 0) date.setTime(date.getTime() - skew);
 }
 
//==============================================================
//Função que verifica se algum dos RadioButton's foi selecionado
//==============================================================
function verificaRadio(obj1)
{
	var ok = false;
	for (i = 0; i < obj1.length; i++)	
	{ 
		if (obj1[i].checked) { ok = true; }
	}
	if (!ok) { return true; }
	else { return false; }
}
//==============================================================


// -----------------------------------------------------------------------------------

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
