function validafinder(x){
	if (x.value!=0){
		window.document.form1.action="/finder.asp";
		window.document.form1.submit();
	}
}

function formatapreco(preco)
{
preco=preco+""
t=preco.length
novopreco=""
x=0
for (i=t-1;i>=0;i--)
{
	if (x==3) {
		novopreco=preco.substring(i,i+1)+"." +novopreco;
		x=1
		}
	else
		{
		novopreco=preco.substring(i,i+1)+novopreco;
		x++;
		}
}
novopreco=novopreco+"$"
return(novopreco)
}
	
function testealg(input)
{
	var alg="0123456789";
	var car="";	
	var flag=true;	
	for (var i=0;(i<input.length && flag);i++)
	{
		car=input.charAt(i);
		if (alg.indexOf(car) == -1) flag=false;
	}	
	return !flag;
}

function verificar()
{
	var sURL = new String(window.location);
	//window.document.pesquisar.action = window.document.pesquisar.action + "?v=pes&pes=" + escape(window.document.pesquisar.pesq.value);
	window.document.pesquisar.v.value = "pes";
	sURL = sURL.substr(0, (sURL.indexOf("urlPesq=") == -1 ? sURL.length : (sURL.indexOf("urlPesq=")-1)));
	window.document.pesquisar.urlPesq.value = sURL;
	return true;
}

function abrirJanela(url, nome)
{
	window.open(url,nome,"location=yes, status=yes, resizable=yes, scrollbars=yes,MenuBar=No,toolbar=no,titlebar=yes")
}

function verdocumento(x)
{
	abrirJanela(x, "");
}

function verproduto(codigo)
{
//	window.name = "servisoft";
	texto="/produto.asp?id="+codigo
	abrirJanela(texto, "servisoftProduto"+codigo);
}

function produtos_onchange(valor){
	switch (valor){
		case "0":
			window.document.pesquisar.action="/finder.asp";
			break;
		case "xcite":
			window.document.pesquisar.action="/customPages/xcite.asp";
			break;
		default:
			//window.document.pesquisar.action="/produtos.asp?v=tp&tp="+valor;
			window.document.pesquisar.action="/produtos.asp";
			window.document.pesquisar.v.value = "tp";
			window.document.pesquisar.tp.value = valor;
			break;
	}
	window.document.pesquisar.submit();
}

function marcas_onchange(valor){
	if (valor == 0){
		window.document.pesquisar.action = "/finder.asp";
		window.document.pesquisar.submit();
	} else {
		//window.document.pesquisar.action = "/produtos.asp?v=m&m="+valor;
		window.document.pesquisar.action = "/produtos.asp";
		window.document.pesquisar.v.value = "m";
		window.document.pesquisar.m.value = valor;
		window.document.pesquisar.submit();
	}
}

function literatura_onchange(valor){
	switch (valor){
		case "-FOLHETOS-":
			window.document.pesquisar.action="/folheto/lista.asp";
			break;
		case "-MEMORIAS-":
			window.document.pesquisar.action="/folheto/tabela_memorias/default.asp";
			break;
		case "0":
			window.document.pesquisar.action="/literatura.asp";
			break;
		default:
			//window.document.pesquisar.action="/literatura.asp?lt=" + valor;
			window.document.pesquisar.action="/literatura.asp";
			window.document.pesquisar.lt.value = valor;
			break;
	}
	window.document.pesquisar.submit();
}

function comoComprar_onchange(x)
{
	var value = x.options[x.selectedIndex].value;
	if (value == "-SEPARADOR-"){
		x.selectedIndex = 0;
	}
	else{
		window.location='/customPages/' + value;
	}
}

function personalizacao_onchange(x)
{
	window.document.pesquisar.action="/interesses.asp";
	window.document.pesquisar.submit();
}

function carrinho_onchange(x)
{
	var value = x;
	if(value == "carrinho"){
		window.open("/loja/carrinho.asp","carrinho");
	} else {
		window.document.pesquisar.action="/interesses.asp";
		window.document.pesquisar.submit();
	}
}

function miFolheto(ref){
	if (typeof(folhetos[ref]) != "undefined")
		return new MenuItem(folhetos[ref].titulo+' > '+folhetos[ref].subTitulo, "javascript:abrirFolheto(\""+ref+"\");", '');
	else
		return new MenuItem('', '', '');
}

function abrirFolheto(ref){
	window.open("/folheto/default.asp?ref="+ref, "", "location=1,toolbar=0,scrollbars=1,resizable=1");
}
