var DOWNLOADOPEN = ""
function closeDownload(idProd){
	$('btFechar'+idProd).style.display = "none";
	$('download'+idProd).style.display = "none";
}

function showDownload(idProd){
	if(DOWNLOADOPEN != "" && DOWNLOADOPEN != idProd){
		closeDownload(idProd)
	}	
	$('btFechar'+idProd).style.display = "block";
	$('download'+idProd).style.display = "block";
	DOWNLOADOPEN = idProd;
}

var galeria = {
	'opened': false,
	'show': function(foto){
		this.opened = true;
		mensure.load();

		var DS = {x:mensure.widthVisible(), y:mensure.heightTotal()};
		$('blockbg').style.height = DS.y + 'px';
		if (!is_ie) {
			$('blockbg').style.width = (DS.x - 17) + 'px';
		} else {
			$('blockbg').style.width = DS.x + 'px';
		}
		setAlpha('blockbg', 80);
		$('blockbg').style.display = 'block';
		
		$('fotoGrande').style.display = "block";
		$('contentfotogrande').style.display = "none";

		this.alinha();
		
		var imgLoader = new Image();
		imgLoader.onload = function(){
			$('contentfotogrande').src = this.src;
			$('contentfotogrande').style.display = "block";
		}		
		imgLoader.src = foto
	},
	'alinha' : function(){
		if(!this.opened) return;
		var SC = {x:mensure.posScrollX(), y:mensure.posScrollY()};
		var VS = {x:mensure.widthVisible(), y:mensure.heightVisible()};
		var SZ = {x:$('fotoGrande').offsetWidth, y:$('fotoGrande').offsetHeight};
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		$('fotoGrande').style.top = (newY+SC.y)+"px";
		$('fotoGrande').style.left = (newX+SC.x)+"px";
	},
	'hide': function(){
		this.opened = false;
		$('fotoGrande').style.top = "-1000px";
		$('fotoGrande').style.lef = "-1000px";
		$('fotoGrande').style.display = "none";
		$('blockbg').style.display = 'none';
	}
}

acoesInit = function(e){
	mostraFlash("banner", "/media/swf/banner.swf?secao=produtos", 980, 196);
}

addEvent(window, "load", function(e){acoesInit(e)});
addEvent(window, "resize", function(e){galeria.alinha()});



function imprimir(slug){
	window.open('/produto/impressao/'+slug+'/','popup','width=600,height=350,scrollbars=1');	
}


selecionaSegmentoOrcamento = function(atividade){
	var ld = new selectLoader();
	ld.load('segmento','/segmentoAtividadeOrcXML/?atividade='+atividade+"&");
}

