<!--
function excluir(texto,url)
{
	if(window.confirm(texto)) location.href = url;
}
function editar(url)
{
	location.href = url;
}
function navigationButton(formulario,subpage)
{
	document.forms[formulario].subpage.value = subpage;
	if(validaFormulario(formulario))
		document.forms[formulario].submit();
}
function navigationTab(area,subpage)
{
	location.href = "?page="+area+"&subpage="+subpage;
}
fieldsReturns = new Array();
function abreCamada(vetor,pagina)
{
	/*
	@ vetor:
	  [vetor de campos a retornar], pagina q vai abrir
	  Ex.: ['form1.nome','form1.idRegistro']
	@ pagina
	  Nome da página que será aberta
	  Ex.: 'pagina.php'
	Nesse caso a chamada seria assim:
	abreCamada(['form1.nome','form1.idRegistro'],'pagina.php')
	*/
	fieldsReturns = vetor;
	document.getElementById("divBuscaRegistro").style.display = "block";
	window.frameMeioRegistro.location.href = pagina;
	
}
function abreCamadaItem(pg)
{
	document.getElementById("divCamadaItem").style.display = "block";
	window.frameCamadaItem.location.href = pg;
}
function retornaDados()
{
	//[vetor de campos a retornar], pagina q vai abrir
	var i=0;
	for(i=0;i<arguments.length;i++)	
	{		
		el       = eval("document."+fieldsReturns[i]);
		el.value = arguments[i];
	}
	fieldsReturns = new Array();
	window.frameMeioRegistro.location.href = "about:blank";
	fechaCamadaRegistro();
}


function fechaCamadaRegistro()
{
	window.frameMeioRegistro.location.href = "about:blank";
	document.getElementById("divBuscaRegistro").style.display = "none";
}
function fechaCamadaRegistroItem()
{
	window.frameCamadaItem.location.href = "about:blank";
	document.getElementById("divCamadaItem").style.display = "none";
}
String.prototype.trim      = function() { return this.replace(/^\s+|\s+$/g, ""); };
function cellColor(elemento,classe)
{
	elemento.className = classe; 
}

function colorCell(act,cell)
{
	cell.style.backgroundColor = (act == 'over')?"#FFFFFF":"#EAEAEA";
	cell.style.cursor          = "pointer";
}

function validaFormulario(formulario)
{
	for(i=0 ; i < document.forms[formulario].elements.length ; i++)
	{
		if(!document.forms[formulario].elements[i].getAttribute("validacao")) continue;
		if(document.forms[formulario].elements[i].getAttribute("validacao") == "" || document.forms[formulario].elements[i].getAttribute("validacao") == "undefined") continue;		
		validacaoFormulario = document.forms[formulario].elements[i].getAttribute("validacao").split(";");
		
		for(j=0 ; j<validacaoFormulario.length ; j++)
		{
			if(validaParametro(document.forms[formulario].elements[i],validacaoFormulario[j]) == false) return false;
		}
	}
	return true;
}
function validaParametro(elemento,parametro)
{
	var dadosRecebidos = parametro.split(":");
	dadosRecebidos[1]  = String(dadosRecebidos[1]);
	switch(dadosRecebidos[0].toLowerCase())
	{
		case "requirido":
			if(elemento.value.trim() == "")
			{
				if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
					window.alert(dadosRecebidos[1]);
				else
					window.alert("O campo "+elemento.name+" é obrigatório.");
				elemento.focus();
				return false;
			}
		break;
		case "numerico":
			if(elemento.value.trim() != "")
			{
				if(isNaN(elemento.value.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' deve ser numérico.');
					elemento.focus();
					return false;
				}
			}
		break;
		
		case "dinheiro":
			if(elemento.value.trim() != "")
			{				
				if(isNaN(elemento.value.trim().replace(/,/gi,".")))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+" não é um valor numérico. \n Por favor use ponto(.) ou virgula(,), para seperar somente centavos.");
					elemento.focus();
					return false;
				}
			}
		break;
		
		case "email":
			if(elemento.value.trim() != "")
			{
				if (elemento.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' deve ser um e-mail válido.');
					elemento.focus();
					return false;
				}
			}
		break;
		
		case "cpf":
			if(elemento.value.trim() != "")
			{
				if(!verifyCPF(elemento.value.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' deve ser um CPF válido.');
					elemento.focus();
					return false;
				}
			}
		break;
		
		case "cnpj":
			if(elemento.value.trim() != "")
			{
				if(!verifyCNPJ(elemento.value.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' deve ser um CNPJ válido.');
					elemento.focus();
					return false;
				}
			}
		break;
		
		case "cpfcnpj":
			if(elemento.value.trim() != "")
			{
				if(!verifyCPF(elemento.value.trim()))
				{
					if(!verifyCNPJ(elemento.value.trim()))
					{
						if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
							window.alert(dadosRecebidos[1]);
						else
							window.alert("O campo "+elemento.name+' deve ser um CPF ou CNPJ válido.');
						elemento.focus();
						return false;
					}
				}
			}
		break;
		case "ano4":
			if(elemento.value.trim() != "")
			{
				if(elemento.value.trim().length != 4)
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' deve possuir 4 digitos.');
					elemento.focus();
					return false;
				}
				if(isNaN(elemento.value.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' deve ser numérico.');
					elemento.focus();
					return false;
				}
			}
		break;
		
		
		
		
		case "data":
			if(elemento.value.trim() != "")
			{
				var dia = elemento.value.charAt(0)+""+elemento.value.charAt(1);
				var mes = elemento.value.charAt(3)+""+elemento.value.charAt(4);
				var ano = elemento.value.charAt(6)+""+elemento.value.charAt(7)+""+elemento.value.charAt(8)+""+elemento.value.charAt(9);
				if(Number(dia)>31 || isNaN(dia.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' está com o dia inválido.');
					elemento.focus();
					return false;
				}
				if(Number(mes)>12 || isNaN(mes.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' está com o mês inválido.');
					elemento.focus();
					return false;
				}				
				if(Number(ano)<=1900 || isNaN(ano.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' está com o ano inválido.');
					elemento.focus();
					return false;
				}				
			}
		break;
		case "hora":
			if(elemento.value.trim() != "")
			{
				var hora = elemento.value.charAt(0)+""+elemento.value.charAt(1);
				var minu = elemento.value.charAt(3)+""+elemento.value.charAt(4);
				if(Number(hora)>23 || isNaN(hora.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' está com a hora inválida.');
					elemento.focus();
					return false;
				}
				if(Number(minu)>59 || isNaN(minu.trim()))
				{
					if(dadosRecebidos[1] != "" && dadosRecebidos[1] != "undefined")
						window.alert(dadosRecebidos[1]);
					else
						window.alert("O campo "+elemento.name+' está com o minuto inválido.');
					elemento.focus();
					return false;
				}				
			}
		break;
	}
	return true;
}
function verifyCPF(cpfK)
{
	    
		s = cpfK;
				
		s = s.replace(/[.]+/g,'');
		s = s.replace(/[-]+/g,'');
		if((s == "11111111111") || (s == "22222222222") || (s == "33333333333") || (s == "44444444444") ||
		(s == "55555555555") || (s == "66666666666") ||	(s == "77777777777") || (s == "88888888888") ||
	    (s == "99999999999") || (s == "00000000000") || (s.length != 11)) 
		{
   			return false;
	    }	
		
		var i; 
        var c = s.substr(0,9); 
        var dv = s.substr(9,2); 
        var d1 = 0; 
        for (i = 0; i < 9; i++) 
        { 
            d1 += c.charAt(i)*(10-i); 
        } 
            if (d1 == 0) 
               return false; 
             
        d1 = 11 - (d1 % 11); 
        if (d1 > 9) d1 = 0; 
        if (dv.charAt(0) != d1) 
            return false; 
        
        d1 *= 2; 
        for (i = 0; i < 9; i++) 
        { 
            d1 += c.charAt(i)*(11-i); 
        } 
        d1 = 11 - (d1 % 11); 
        if (d1 > 9) d1 = 0; 
        if (dv.charAt(1) != d1) 
            return false; 
return true;
}

function verifyCNPJ(cnpjK)
{
	var cnpj = cnpjK;  
	var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;  
	digitos_iguais = 1;  
	for (var i=0; i < cnpj.length - 1; i++)  
	{
		if (cnpj.charAt(i) != cnpj.charAt(i + 1)) 
		{  
		digitos_iguais = 0;  
		break;  
		}  
	}
	if (!digitos_iguais) 
	{  
		tamanho = cnpj.length - 2  
		numeros = cnpj.substring(0,tamanho);  
		digitos = cnpj.substring(tamanho);  
		soma = 0;  
		pos = tamanho - 7;  
		
		for (var i=tamanho; i >= 1; i--) 
		{  
			soma += numeros.charAt(tamanho - i) * pos--;  
			if (pos < 2) 
			{  
			pos = 9;  
			}  
		}  
		resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;  
		if (resultado != digitos.charAt(0)) 
		{  
			return false;  
		}  
		
		tamanho = tamanho + 1;  
		numeros = cnpj.substring(0,tamanho);  
		soma = 0;  
		pos = tamanho - 7;  
		
		for (i = tamanho; i >= 1; i--) 
		{  
			soma += numeros.charAt(tamanho - i) * pos--;  
			if (pos < 2)
			{  
				pos = 9;  
			}  
		}  
		resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;  
		if (resultado != digitos.charAt(1)) 
		{  
			return false;  
		}  
	
	return true;  
	}	
	else  
	return false;  
   
}
function getCheckedValue(radioObj) 
{
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++)
	{
		if(radioObj[i].checked)
		{
			return radioObj[i].value;
		}
	}
	return "";
}
function bucaRegistroPessoa(pagina,offset)
{
	var c = document.formLista.celulaBusca.value;//celula onde buscar
	var v = document.formLista.valorBusca.value;//valor da busca
	
	var lst = getCheckedValue(document.formLista.listaPessoa);	
	
	carregaResultado(pagina+"?celulaBusca="+c+"&valorBusca="+v+"&offset="+offset+"&listaPessoa="+lst);
}
function bucaRegistro(pagina,offset)
{//antes de mandar buscar o registro ele analisa se os dados nao estaum vazio
	var c = document.formLista.celulaBusca.value;//celula onde buscar
	var v = document.formLista.valorBusca.value;//valor da busca
	carregaResultado(pagina+"?celulaBusca="+c+"&valorBusca="+v+"&offset="+offset);
}
function carregaResultado(pagina)
{
	if((ajax = new Ajax()) == null){ alert('Navegador não suporta AJAX'); return; }
    
	document.getElementById("divCarregandoDados").style.visibility = "visible";
	ajax.onreadystatechange = interacaoAjaxDetalhes;
	ajax.open("GET", pagina, true);
	ajax.send(null);	
}
function interacaoAjaxDetalhes()
{
	switch(Number(ajax.readyState))
	{//readyState que pode ter cinco valores:
	
		case 0://0 (não iniciado) 
			//document.getElementById(outroCombo).options[0].innerHTML = "Carregando|   ";
		break;
		case 1://1 (carregando)
			//document.getElementById(outroCombo).options[0].innerHTML = "Carregando||  ";
		break;
		case 2://2 (carregado) 
			//document.getElementById(outroCombo).options[0].innerHTML = "Carregando||| ";
		break;
		case 3://3 (interativo) 
			//document.getElementById(outroCombo).options[0].innerHTML = "Carregando||||";
		break;
		case 4://4 (concluído)
			document.getElementById("divCarregandoDados").style.visibility = "hidden";
			dadosDetalhes();
		break;

	}
}
function dadosDetalhes()
{
	if(ajax.responseText)
	{
		var resultadoTexto   = ajax.responseText;
		document.getElementById("divLista").innerHTML = resultadoTexto;
	}
	else
	{
		document.getElementById("divLista").innerHTML = "<center><font color='#ff0000'>Sem resultado(s) para a busca.</font></center>";
	}
}




var curDiv = "";
function loadAjax(div,pagina)
{
	if((ajax = new Ajax()) == null){ alert('Navegador não suporta AJAX'); return; }
    
	curDiv = div;
	document.getElementById("divLoadingData").style.visibility = "visible";
	ajax.onreadystatechange = ajaxStates;
	ajax.open("GET", pagina, true);
	ajax.send(null);	
}
function ajaxStates()
{
	switch(Number(ajax.readyState))
	{//readyState que pode ter cinco valores:
	
		case 0://0 (não iniciado) 
			//document.getElementById(outroCombo).options[0].innerHTML = "Carregando|   ";
		break;
		case 1://1 (carregando)
			//document.getElementById(outroCombo).options[0].innerHTML = "Carregando||  ";
		break;
		case 2://2 (carregado) 
			//document.getElementById(outroCombo).options[0].innerHTML = "Carregando||| ";
		break;
		case 3://3 (interativo) 
			//document.getElementById(outroCombo).options[0].innerHTML = "Carregando||||";
		break;
		case 4://4 (concluído)
			document.getElementById("divLoadingData").style.visibility = "hidden";
			loadResult();
		break;

	}
}
function loadResult()
{
	if(ajax.responseText)
	{
		var resultadoTexto   = ajax.responseText;
		document.getElementById(curDiv).innerHTML = resultadoTexto;
		if(curDiv == "centerProductsLayer")
			loadAjax("layerBox","includeBox.php");	
		
	}
	else
	{
		document.getElementById(curDiv).innerHTML = "<center><font color='#ff0000'>Sem resultados.</font></center>";
	}
}



-->