function abrePop800(url,idJanela,scrol){
	javascript:MM_openBrWindow(url,'pop'+idJanela,'menubar=no,status=yes,scrollbars='+scrol+',width=790,height=530,top=0,left=0');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function fecharJanelaJS(){
	window.close();
}

function imprimir(){
	window.print();
}

function avisoLogin(){
	alert('Para enviar seu lance neste Lote é necessário possuir cadastro e estar logado em nosso site.\n\nCaso ainda não possua cadastro, efetue-o agora mesmo acessando a opção cadastre-se no topo da página.\n\nPara se logar em nosso site, acesse a opção login no topo da página.');
}

function avisoMinhaConta(){
	alert('Para acessar é necessário possuir cadastro e estar logado em nosso site.\n\nCaso ainda não possua cadastro, efetue-o agora mesmo acessando a opção cadastre-se.\n\nPara se logar em nosso site, acesse a opção login.');
}

function avisoLoginEfetuado(){
	alert('Você ja esta logado.\n\nPara acessar como outro usuário você deve primeiro encerrar esta seção clicando na opção sair e em seguida selecionar a opção login novamente e efetuar um novo login.');
}

function trimJS(str){
str=str.replace(/\s+/g," "); // elimina sequências de espaços
// (\t\r\n ) por um espaço em branco
str=str.replace(/^ /,""); //inicio de linha
str=str.replace(/ $/,""); //fim de linha
return str;
}

// url_encode version 1.0  
function url_encode(str) {  
	var hex_chars = "0123456789ABCDEF";  
	var noEncode = /^([a-zA-Z0-9\_\-\.])$/;  
	var n, strCode, hex1, hex2, strEncode = "";  

	for(n = 0; n < str.length; n++) {  
		if (noEncode.test(str.charAt(n))) {  
			strEncode += str.charAt(n);  
		} else {  
			strCode = str.charCodeAt(n);  
			hex1 = hex_chars.charAt(Math.floor(strCode / 16));  
			hex2 = hex_chars.charAt(strCode % 16);  
			strEncode += "%" + (hex1 + hex2);  
		}  
	}  
	return strEncode;  
}  

// url_decode version 1.0  
function url_decode(str) {  
	var n, strCode, strDecode = "";  

	for (n = 0; n < str.length; n++) {  
		if (str.charAt(n) == "%") {  
			strCode = str.charAt(n + 1) + str.charAt(n + 2);  
			strDecode += String.fromCharCode(parseInt(strCode, 16));  
			n += 2;  
		} else {  
			strDecode += str.charAt(n);  
		}  
	}  

	return strDecode;  
}

function browser () {
	var b = navigator.appName;
	var v = this.version = navigator.appVersion;
	var ua = navigator.userAgent.toLowerCase();	
	this.v = parseInt(v);
	this.safari = ua.indexOf("safari")>-1;	// always check for safari & opera 
	this.opera = ua.indexOf("opera")>-1;	// before ns or ie
	this.ns = !this.opera && !this.safari && (b=="Netscape");
	this.ie = !this.opera && (b=="Microsoft Internet Explorer");
	this.gecko = ua.indexOf('gecko')>-1; // check for gecko engine
	if (this.ns) {
		this.ns4 = (this.v==4);
		this.ns6 = (this.v>=5);	
		this.b = "Netscape";
	}else if (this.ie) {
		this.ie4 = this.ie5 = this.ie55 = this.ie6 = false;
		if (v.indexOf('MSIE 4')>0) {this.ie4 = true; this.v = 4;}
		else if (v.indexOf('MSIE 5')>0) {this.ie5 = true; this.v = 5;}
		else if (v.indexOf('MSIE 5.5')>0) {this.ie55 = true; this.v = 5.5;}
		else if (v.indexOf('MSIE 6')>0) {this.ie6 = true; this.v = 6;}
		this.b = "MSIE";
	}else if (this.opera) {
		this.v=parseInt(ua.substr(ua.indexOf("opera")+6,1)); // set opera version
		this.opera6=(this.v>=6);
		this.opera7=(this.v>=7);
		this.b = "Opera";
	}else if (this.safari) {
		this.ns6 = (this.v>=5);	// ns6 compatible correct?
		this.b = "Safari";
	}
	this.dom = (document.createElement && document.appendChild && document.getElementsByTagName)? true : false;
	this.def = (this.ie||this.dom);
	this.win32 = ua.indexOf("win")>-1;
	this.mac = ua.indexOf("mac")>-1;
	this.other = (!this.win32 && !this.mac);
	this.supported = (this.def||this.ns4||this.ns6||this.opera)? true:false;
};

function AddOptionNav(objSelect,text,value,objClassName){
	if(nav.ie){
		var oOption = document.createElement("OPTION");
		oOption.value=value;
		oOption.text=text;
		if(objClassName!=""){
			oOption.className=objClassName;
		}
		objSelect.add(oOption);
	}else{
		var oOption = new Option(text,value,false,false);
		if(objClassName!=""){
			oOption.className=objClassName;
		}
		
		if(oOption){
			objSelect.options[objSelect.options.length] = oOption;
		}
	}
}

function validaData(pStr)
{
	var reDate1 = /^\d{1,2}\/\d{1,2}\/\d{1,4}$/;
	var reDate2 = /^[0-3]?\d\/[01]?\d\/(\d{2}|\d{4})$/;
	var reDate3 = /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[0-2])\/(19|20)?\d{2}$/;
	var reDate4 = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
	var reDate5 = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
	var reDate = reDate4;

	pFmt="5";
	eval("reDate = reDate" + pFmt);
	if (reDate.test(pStr)) {
		return true;
	} else if (pStr != null && pStr != "") {
		return false;
	}
}

function validaEmail(pStr)
{
	var reEmail1 = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	var reEmail2 = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	var reEmail3 = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	var reEmail = reEmail3;
	
	pFmt='1';
	
	eval("reEmail = reEmail" + pFmt);
	if (reEmail.test(pStr)) {
		return true;
	} else if (pStr != null && pStr != "") {
		return false;
	}
}

function eLetrasNumeros(pStr)
{
	var reDigits = /^[A-Za-z\d]+$/;
	if (reDigits.test(pStr)) {
		return true;
	} else if (pStr != null && pStr != "") {
		return false;
	}
}

function eNumeros(pStr)
{
	var reDigits = /^\d+$/;
	if (reDigits.test(pStr)) {
		return true;
	} else if (pStr != null && pStr != "") {
		return false;
	}
}

function validaNumero(p){
	var tecla;
	if(nav.ie){
		tecla = event.keyCode;
	}
	else{
		tecla = event.which;
	}
	
	if((((tecla) > 47) && ((tecla) < 58))){
		return(true);
	}
	else{
		return(false);
	}
}

function cnpj(pcgc)
{
// verifica o tamanho

	pcgc=pcgc.toString().replace(".","");
	pcgc=pcgc.toString().replace(".","");
  	pcgc=pcgc.toString().replace("-","");
	pcgc=pcgc.toString().replace("-","");
  	pcgc=pcgc.toString().replace("/","");
   
if (pcgc.length != 14) {
sim=false

}
else {sim=true}

if (sim ) // verifica se e numero
{
for (i=0;((i<=(pcgc.length-1))&& sim); i++)
{
val = pcgc.charAt(i)
// alert (val)
if
((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") &&
(val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
}
if (sim) // se for numero continua
{
m2 = 2
soma1 = 0
soma2 = 0
for (i=11;i>=0;i--)
{
val = eval(pcgc.charAt(i))
// alert ("Valor do Val: "+val)
m1 = m2
if (m2<9) { m2 = m2+1}
else {m2 = 2}
soma1 = soma1 + (val * m1)
soma2 = soma2 + (val * m2)
} // fim do for de soma

soma1 = soma1 % 11
if (soma1 < 2) { d1 = 0}
else { d1 = 11- soma1}

soma2 = (soma2 + (2 * d1)) % 11
if (soma2 < 2) { d2 = 0}
else { d2 = 11- soma2}
// alert (d1)
// alert (d2)
if ((d1==pcgc.charAt(12)) && (d2==pcgc.charAt(13)))
{ return true; }
else 
return false;
}
}
return false;
}


function cpf(pcpf)
{
   	pcpf=pcpf.toString().replace(".","");
	pcpf=pcpf.toString().replace(".","");
  	pcpf=pcpf.toString().replace("-","");
	pcpf=pcpf.toString().replace("-","");
  	pcpf=pcpf.toString().replace("/","");

if (pcpf.length != 11) 
	{
	sim=false;
	}
	else 
	{
		if(pcpf=='00000000000' || (pcpf=='11111111111') || (pcpf=='22222222222') || (pcpf=='33333333333') || (pcpf=='44444444444') || (pcpf=='55555555555') || (pcpf=='66666666666') || (pcpf=='77777777777') || (pcpf=='88888888888') || (pcpf=='99999999999'))
		{
			sim=false;
		}
		else
		{
			sim=true;
		}
	}

if (sim ) // valida o primeiro digito
{
for (i=0;((i<=(pcpf.length-1))&& sim); i++)
{
val = pcpf.charAt(i)
if

((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4")

&& (val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
}

if (sim)
{
soma = 0
for (i=0;i<=8;i++)
{
val = eval(pcpf.charAt(i))
soma = soma + (val*(i+1))
}

resto = soma % 11
if (resto>9) dig = resto -10
else dig = resto
if (dig != eval(pcpf.charAt(9))) { sim=false }
else // valida o segundo digito
{

soma = 0
for (i=0;i<=7;i++)
{

val = eval(pcpf.charAt(i+1))
soma = soma + (val*(i+1))
}

soma = soma + (dig * 9)
resto = soma % 11
if (resto>9) dig = resto -10
else dig = resto
if (dig != eval(pcpf.charAt(10))) { sim = false }
else sim = true
}
}
}

if (sim) { 
return true; }
else
return false;
}

function validaTecla(p){
	var tecla;
	if(nav.ie){
		tecla = event.keyCode;
	}
	else{
		tecla = event.which;
	}
	
	if(((tecla>96) && (tecla<123)) || ((tecla>64) && (tecla<91)) || (((tecla) > 47) && ((tecla) < 58))){
		return(true);
	}
	else{
		return(false);
	}
}

function get_numero(n){
	return tiravirgula(tiraponto(n));
}

function tiraponto(s){
   var trocaP = /\./g;
	while (s.search(trocaP) != -1){
		s=s.replace(trocaP,"");
	}
   
   return(s);
}
	
function tiravirgula(s){
	var trocaV = /,/g;
	var vold=s;
	var vezes=-1;
	while (s.search(trocaV) != -1){
		s=s.replace(trocaV,'.');
		vezes=1;
	}
	
	return(parseFloat(s));
}

function valida_numero(ConteudoCampo){
	if ((((event.keyCode) > 47) && ((event.keyCode) < 58))){
		return(true);
	}else{
		return(false);
	}
}

function saltaCampo(atual,camponext,e,t){
	if(nav.ie){
		if(document.form1.elements[atual].value.length==t){
			document.form1.elements[camponext].focus();
		}
	}else{
		
	}
}

var nav=new browser();