// <!--
var nav = navigator.userAgent.toLowerCase();
var bIsIE = ie = (nav.indexOf("msie") != -1);
var bIsFirefox = ff = (nav.indexOf("firefox") != -1);
var bIsOpera = opera = (nav.indexOf("opera") != -1);
var bIsSafari = safari = (nav.indexOf("safari") != -1);
var bIsNetscape = netscape = (nav.indexOf("netscape") != -1);
var versao = VersaoNavegador();

function VersaoNavegador() {
	var versao = null;
	if(ie) {
		var inicio = nav.indexOf("msie") + 5;
		var fim = nav.indexOf(".", inicio);
		versao  = nav.substring(inicio, fim);
		versao  = parseInt(versao);
	} else if (ff) {
		var inicio = nav.indexOf("firefox/") + 8;
		var fim = nav.indexOf(".", inicio);
			fim = nav.indexOf(".", fim+1);
		versao  = nav.substring(inicio, fim);
		versao  = parseFloat(versao);
	} else if (opera) {
		var inicio = nav.indexOf("opera/") + 6;
		var fim = nav.indexOf(" (", inicio);
		versao  = nav.substring(inicio, fim);
		versao  = parseFloat(versao);
	}
	return versao;
}

function abreM(url,janela,scroll) {
	W = eval(screen.width)-10;
	H = eval(screen.height)-54;
	window.open(url,janela,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scroll+",resizable=no,copyhistory=no,width="+W+",height=" +H+ ",top=0,left=0");
}

function abrePop(url) {
	W = eval(screen.width)-100;
	H = eval(screen.height)-200;
	window.open(url,'',"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width="+W+",height=" +H+ ",top=0,left=0");
}

function limpaForm(valor) {
	try {
		with(window.event.srcElement)
		{
			/*if(event.keyCode==34||event.keyCode==39){
			 alert("Por favor, não utilize apóstrofos em sua consulta !!!");
			 event.returnValue=false;
			}*/
			if(event.keyCode==40||event.keyCode==41){
			 alert("Por favor, não utilize parênteses em sua consulta !!!");
			 event.returnValue=false;
			}
			if(event.keyCode==91||event.keyCode==93){
			 alert("Por favor, não utilize colchetes em sua consulta !!!");
			 event.returnValue=false;
			}
		}
	} catch (err) {}

	c = valor.value;
	if(c.indexOf("-")!=-1||c.indexOf("(")!=-1||c.indexOf(")")!=-1||c.indexOf("[")!=-1||c.indexOf("]")!=-1) {
		while(c.indexOf("-")!=-1) c = c.replace("-"," ");
		//while(c.indexOf("'")!=-1) c = c.replace("'",""); 
		while(c.indexOf("(")!=-1) c = c.replace("("," "); 
		while(c.indexOf(")")!=-1) c = c.replace(")"," "); 
		while(c.indexOf("[")!=-1) c = c.replace("["," "); 
		while(c.indexOf("]")!=-1) c = c.replace("]"," "); 
		valor.value = c;
	}			 
}			
	
// posiciona , mostra e esconde as layers 
function MostraEventos(evento, sObj, sTop) {
	 x = eval("lay" + sObj);
	 if(sTop) x.style.posTop = sTop;
	 x.style.visibility = evento;
}
function pop(caminho, modo, tamanho) {
	if(modo == "estoque" || modo == "estoque_vitrine")
		window.open(caminho, modo, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=490,height=460,top=60,left=40')
	else
		window.open(caminho,'',tamanho);
}
function popH(caminho) {
	window.location.href = caminho;
}
function dirNitem(n) {
	var nitem = new String(n);
	return nitem.substring(nitem.length-3) + "/" + nitem;
}

// Restada a posição TOP do objeto indicado
function getTop(obj) {
	var y = 0;
	if (obj.offsetParent) {
		y = obj.offsetTop;
		while(obj = obj.offsetParent) y += obj.offsetTop;
	}
	return y;
}

// Restada a posição LEFT do objeto indicado
function getLeft(obj) {
	var x = 0;
	if (obj.offsetParent) {
		x = obj.offsetLeft;
		while(obj = obj.offsetParent) x += obj.offsetLeft;
	}
	return x;
}

function validaPesquisaFrete() {
	with(document.form_frete) {
		if(EntCEP.value == "") {
			alert("O campo CEP deve ser preenchido.");
			EntCEP.focus();
		} else if(EntCEP.value.length < 6) {
			alert("O campo CEP está incompleto.");
			EntCEP.focus();
		} else {
			var cep = EntCEP.value;
			var l = document.getElementById("layerPrincipal");
			l.innerHTML = "<p align='center'><br><img src='/imagem/comum/loading.gif' align='absmiddle'><font size='2' face='Verdana'> Carregando...</font></p>";
			l.style.width = 300;
			l.style.height = 200;
			
			ReposicionarLayer();
			CarregaConteudoLayerPrincipal('/scripts/home/frete/frete_layer_retorno.asp', 'EntCEP='+cep);
		}
		return false;
	}
}

function comprar(nitem) {
	location.href = "/scripts/home/basket/basket.asp?nitem="+nitem;
}

//-->
