/******************************************************************
	VERIFICA SE O CLIENTE POSSUI BLOQUEADOR DE POPUP
******************************************************************/

function verificaPopup()
{
	var pop = window.open("about:blank","_blank","width=10,height=10,top=0,left=0");
	var div = '';
	
	div += '<div id="divPopup">';
	div += '  <table width="100%" border="0" cellspacing="0" cellpadding="0">';
	div += '    <tr>';
	div += '      <td height="30">&nbsp;</td>';
	div += '    </tr>';	
	div += '    <tr>';
	div += '      <td><img src="_imagens/bt_antipopup.jpg" width="520" height="180" border="0"></td>';
	div += '    </tr>';
	div += '    <tr>';
	div += '      <td height="30">&nbsp;</td>';
	div += '    </tr>';
	div += '  </table>';
	div += '</div>';
	
	if (null == pop || true == pop.closed)
	{
		h = 1;
	} 
	else 
	{
		h = 0;
		pop.close();
	}
	
	if (h==1)
	{
		document.write(div);
	}
	else
	{
		document.write("");
	}

}


/******************************************************************
	MUDA PÁGINA DA JANELA DE BAIXO
******************************************************************/

function janelaTras(url)
{
	window.opener.location = url;
}


/******************************************************************
	MUDA PÁGINA
******************************************************************/

function mudaPagina(url)
{
	location.href = url;
}


/******************************************************************
	MUDA IMAGEM
******************************************************************/

function trocaImagem(nome, img)
{
	document[nome].src = img;
}


/******************************************************************
	GALERIA DO PRODUTO
******************************************************************/

function galeriaProduto(nome, img, pos, total)
{
	document[nome].src = img;
	document.getElementById("contador").innerHTML = pos+"/"+total;
	document.getElementById("ampatual").value = pos-1;
}


/******************************************************************
	POPUP CENTRALIZADO
******************************************************************/

function abrePopup(pagina,largura,altura,rolagem)
{
	var posX;
	var posY;
	posX = (window.screen.width - largura) / 2;
	posY = (window.screen.height - altura) / 2;
	window.open(pagina,"_blank","width="+largura+",height="+altura+",top="+posY+",left="+posX+",scrollbars="+rolagem+",toolbar=no,location=no,directories=no,menubar=no,resizable=no,menubar=no");
}


/******************************************************************
	POPUP POSIÇÃO PADRÃO
******************************************************************/

function abrePopupMenor(pagina,largura,altura,rolagem)
{
	window.open(pagina,"_blank","width="+largura+",height="+altura+",top=80,left=80,scrollbars="+rolagem+",toolbar=no,location=no,directories=no,menubar=no");
}

/******************************************************************
	REMOVE ACENTOS
******************************************************************/

function removeAcentos(texto) 
{
	str = texto.toUpperCase();
	str = str.replace(new RegExp('[ÁÀÂÃ]','gi'), 'A');
	str = str.replace(new RegExp('[ÉÈÊ]','gi'), 'E');
	str = str.replace(new RegExp('[ÍÌÎ]','gi'), 'I');
	str = str.replace(new RegExp('[ÓÒÔÕ]','gi'), 'O');
	str = str.replace(new RegExp('[ÚÙÛÜ]','gi'), 'U');
	str = str.replace(new RegExp('[Ç]','gi'), 'C');
	str = str.replace(new RegExp('[Ñ]','gi'), 'N');
	
	return str;
} 

/******************************************************************
	CALCULA A IDADE
******************************************************************/

function calcIdade(data, hoje) 
{
	var x = data.split("/");
	var h = hoje.split("/");
	
	anosProvisorio = h[2] - x[2];
	
	if(h[1] < x[1]) 
	{
		anosProvisorio -= 1;
	}
	else if(h[1] == x[1]) 
	{
		if(h[0] < x[0]) 
		{
			anosProvisorio -= 1;
		}
	}
	
	return anosProvisorio;
}


/******************************************************************
	VERIFICA SE O OBJETO É ARRAY
******************************************************************/

function isArray(obj) 
{
    return obj.constructor == Array;
}


/******************************************************************
	GERA ARQUIVO SWF
******************************************************************/

function geraSWF(largura, altura, arquivo, wmode, bgcolor, vars, salign, id)
{
	AC_FL_RunContent(
	  'width', largura,
	  'height', altura,
	  'src', arquivo,
	  'quality', 'high',
	  'align', 'middle',
	  'scale', 'noscale',
	  'wmode', wmode,
	  'id', id,
	  'bgcolor', '#FFFFFF',
	  'flashvars', vars,
	  'menu', 'false',
	  'allowFullScreen', 'false',
	  'allowScriptAccess','sameDomain',
	  'movie', arquivo,
	  'salign', salign
	); 	
}


/******************************************************************
	BUSCA POSIÇÃO DO ESTADO
******************************************************************/

function indexEstado(f, v)
{
	var ok = false;
	var eq = "";
	
	with(document[f])
	{
		for (i=0; i<estado.options.length; i++)
		{
			if (v == estado.options[i].value)
			{
				eq = i;
				ok = true;
			}
		}
	}
	
	return eq;
}

/******************************************************************
	SELECIONE A CIDADE
******************************************************************/

function setaCidade(v)
{
	with(document.formulario)
	{
		cidade.value = v;
		//alert(cidade.value);
	}
}