// Copyright 2002 AgênciaClick


// Basics

function Print(){
	window.print()
}

function blurValue(f,nm){
	if(f.value=='')f.value=nm
}

function focusValue(f,nm){
	if(f.value==nm)f.value=''
}


function rePosiciona(){
var diffY = 0
	if(is.ie) diffY = d.body.scrollTop
	else diffY = self.pageYOffset
	if(diffY>y1) diffY += 100
	else diffY = y1
	if(isDef('caracteristicasDL')) caracteristicasDL.mTo(null,diffY)
}

function showCaracteristicas(fot,tit,txt){
	rePosiciona()
	strCaracteristicas=''+
	'<table border=0 cellspacing=0 cellpadding=0><tr>'+
		'<td class="bg-branco"><img src=<%=request.getContextPath()%>/img/bd_cx_esq_top_g.gif width=8 height=8></td>'+
		'<td height=8 class="bg-cx-top-g"><spacer type=block height=8 width=1></td>'+
		'<td class="bg-branco"><img src=<%=request.getContextPath()%>/img/bd_cx_dir_top_g.gif width=8 height=8></td>'+
	'</tr><tr>'+
		'<td class="bg-cx-esq-g"><spacer type=block height=1 width=8></td>'+
		'<td width=175 valign=top class="bg-branco">'+
		((fot!='')?'<center><img src=<%=request.getContextPath()%>/img/'+fot+'.jpg width=97 height=98 border=1 class="border-bege-1"></center><br>':'')+
		'<span class="line-height-2"><b class="font-roxo-1">'+tit+'</b></span><br>'+
		'<span class="line-height-3"><span class="font-cinza-1">'+txt+'</span></span></td>'+
		'<td class="bg-cx-dir-g"><spacer type=block height=1 width=8></td>'+
	'</tr><tr>'+
		'<td class="bg-branco"><img src=<%=request.getContextPath()%>/img/bd_cx_esq_bot_g.gif width=8 height=8></td>'+
		'<td height=8 class="bg-cx-bot-g"><spacer type=block height=8 width=1></td>'+
		'<td class="bg-branco"><img src=<%=request.getContextPath()%>/img/bd_cx_dir_bot_g.gif width=8 height=8></td>'+
	'</tr></table>'
	caracteristicasDL.write(strCaracteristicas)
	caracteristicasDL.sh()
}

function showCaracteristicasComparacao(fot,tit,txt){
	rePosiciona()
	strCaracteristicas=''+
	'<table border=0 cellspacing=0 cellpadding=0><tr>'+
		'<td class="bg-branco"><img src=<%=request.getContextPath()%>/img/bd_cx_esq_top_comparacao_g.gif width=8 height=8></td>'+
		'<td height=8 class="bg-cx-top-comparacao-g"><spacer type=block height=8 width=1></td>'+
		'<td class="bg-branco"><img src=<%=request.getContextPath()%>/img/bd_cx_dir_top_comparacao_g.gif width=8 height=8></td>'+
	'</tr><tr>'+
		'<td class="bg-cx-esq-comparacao-g"><spacer type=block height=1 width=8></td>'+
		'<td width=175 valign=top class="bg-branco">'+
		((fot!='')?'<center><img src=<%=request.getContextPath()%>/img/'+fot+'.jpg width=111 height=111 border=1 class="border-bege-1"></center><br>':'')+
		'<span class="line-height-2"><b class="font-roxo-1">'+tit+'</b></span><br><br>'+
		'<span class="line-height-3"><span class="font-cinza-1">'+txt+'</span></span><br><img src=<%=request.getContextPath()%>/img/px.gif width=1 height=10></td>'+
		'<td class="bg-cx-dir-comparacao-g"><spacer type=block height=1 width=8></td>'+
	'</tr><tr>'+
		'<td class="bg-branco"><img src=<%=request.getContextPath()%>/img/bd_cx_esq_bot_comparacao_g.gif width=8 height=8></td>'+
		'<td height=8 class="bg-cx-bot-comparacao-g"><spacer type=block height=8 width=1></td>'+
		'<td class="bg-branco"><img src=<%=request.getContextPath()%>/img/bd_cx_dir_bot_comparacao_g.gif width=8 height=8></td>'+
	'</tr></table>'
	caracteristicasDL.write(strCaracteristicas)
	caracteristicasDL.sh()
}

function hideCaracteristicas(){
	caracteristicasDL.hd()
}


// Funcoes para produtos relacionados a foto

var menuArr = new Array()

function meuMenu(id){
	this.id = id
	this.time = null
	this.acende = acende
	this.apagaTime = apagaTime
	this.apaga = apaga
	menuArr[menuArr.length] = this
}

function acende(){
	for (var i=0;i<menuArr.length;i++){
		if(menuArr[i].id!=this.id)menuArr[i].apaga()
	}
	clearTimeout(this.time)
	eval(this.id+'DL').sh()
}

function apaga(){
	eval(this.id+'DL').hd()
}

function apagaTime(){
	this.time = setTimeout(this.id+'.apaga()',1000)
}
function popNewsletter() {
	Session("origemNewsletter") = "S";
	window.open('cadastro?action=buscarLogin&pop=true&urlReturn=consultarDadosCadastrais&urlReturnPop=catalogo?controleNewsletter=S&redirectPop=true&followWorkflow=false','login','left=0,top=0,width=576,height=529,scrollbars=0');
}
// Get object position
function getObjPos(o){
var l = o.offsetLeft;
var t = o.offsetTop;
var S = '.offsetParent';
while( eval('o' + S ) ) {
l += eval('o' + S ).offsetLeft;
t += eval('o' + S ).offsetTop;
S +='.offsetParent';
}
return [l,t];
}

// put the banner at the right place
function posBanner(){
var posA = document.getElementById('posA');
var posB = document.getElementById('posB');

var pA = getObjPos(posA);
var pB = getObjPos(posB);

if(pA[1] < pB[1]) {
premiosDL.mTo(600,pB[1]+15);
posB.style.height=75;
}else{
premiosDL.mTo(600,pA[1]-65);
}
}

/*
Funcao protótipo para tirar espaços de um texto
Utilizar da seguinte forma:
var palavra = "esse é um teste   ";
palavra.trim();
*/
String.prototype.trim = function() {
  var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}


function troca(indice) {
    document.getElementById('IMAGEMCOR').src= CORES[indice];
    document.getElementById('NOMECOR').innerText=NOMES[indice];
    document.getElementById('DESCRICAOCOR').innerText=DESCRICOES[indice];
}
