
	
	//função para mostrar uma imagem dentro da DIV
	mostraAmbiente = function(imagemm,width,height){

		imagem = document.createElement("img");
		imagem.setAttribute('ambiente',imagemm);
		imagem.setAttribute('width',width);
		imagem.setAttribute('height',height);
		
		//try{
			if( typeof(width)=='undefined' || isNaN(parseInt(width)) ) width = 0;
			if( typeof(height)=='undefined' || isNaN(parseInt(height)) ) height = 0;
			var ambiente = imagem.getAttribute('ambiente');
			var oSpan = document.getElementById('mostraImagem');
			
			if(typeof(oSpan)=='undefined'){
				var oSpan = imagem.nextSibling;
				var method = 1;
			}else{
				var method = 2;
			}

			var id = Math.random()
			
			oSpan.style.zIndex = 123;
			oSpan.style.position = 'absolute';
			oSpan.style.width = '1px';
			oSpan.style.margin = '0 auto';
			oSpan.style.height = '1px';
			oSpan.style.overflow = 'hidden';
			oSpan.innerHTML = ''
			+ 
			'<img style="position:absolute;width:'+width+'px;height:'+height+'px; "id="'+id+'" src="'+ambiente+'" method="'+method+'" />';
			abreImagemAnimada(id);
	

		//}catch(e){
			//alert(e.description +"(Func mostraAmbiente!)");
		//}
	}
	
	//alinha ao centro a DIV que mostra imagens
	var passoAmb = 20;
	var timerAmb = null;
	centerSpan = function(id){

		imagem = document.getElementById( id );
		var method = imagem.getAttribute('method');
		var oSpan = imagem.parentNode;
		oSpan.style.position = 'absolute';
		oSpan.style.float = 'left';
		
		if(method == 1){
			resultTop = (document.body.scrollTop + ((document.documentElement.offsetHeight - oSpan.offsetHeight)/ 2))/1 ;
			resultLeft = (document.body.scrollLeft + ((document.documentElement.offsetWidth - oSpan.offsetWidth)/ 2))/1 ;
		}else{
			 resultTop = (document.documentElement.scrollTop + ((document.documentElement.offsetHeight - oSpan.offsetHeight)/ 2))/1 ;
			 resultLeft = (document.documentElement.scrollLeft + ((document.documentElement.offsetWidth - oSpan.offsetWidth)/ 2))/1 ;
		}

		var Browser;
		var AddTop;
		Browser = navigator.appName;
		if(Browser == "Microsoft Internet Explorer"){		
			AddTop = 0;
		}else{
			AddTop = 200;
		}

		resultForm = parseInt(resultTop)-parseInt(AddTop);
		
		oSpan.style.top = (resultForm)+"px";
		oSpan.style.left = (resultLeft)+"px";

	}
	
	//
	var timerAlpha = null;
	var timerAmb = null;
	abreImagemAnimada2 = function( id ){
		imagem = document.getElementById( id );
		var opacity = imagem.getAttribute('opacity');
		opacity = parseInt(opacity);
		if(isNaN(opacity)) opacity = 0;
		if(opacity<=100)
		{
			imagem.style.filter = 'alpha(opacity='+ opacity +');';
			clearTimeout(timerAlpha);
			timerAlpha = setTimeout("abreImagemAnimada2(" + id + ")",100);
			opacity += 10;
			imagem.setAttribute('opacity',opacity);
		}
		else
		{
			imagem.style.filter = 'none';
			clearTimeout(timerAlpha);
		}
	}
	
	//função que efetua o looping para mostrar a imagem dentro da div
	abreImagemAnimada = function(id){
		imagem = document.getElementById(id);
		oSpan = imagem.parentNode;
		oSpan.style.display = '';
		if( parseInt(oSpan.style.width) < imagem.width){
			var width = parseInt(oSpan.style.width);
			width += passoAmb;
			if( width > imagem.width ) width = imagem.width;
			oSpan.style.width = width + 'px';
		}
		if( parseInt(oSpan.style.height) < imagem.height ){
			var height = parseInt(oSpan.style.height);
			height += passoAmb;
			if( height > imagem.height ) height = imagem.height;
			oSpan.style.height = height + 'px';
		}

		if(parseInt(oSpan.style.width) < imagem.width || parseInt(oSpan.style.height) < imagem.height){
			clearTimeout(timerAmb);
			timerAmb = setTimeout("abreImagemAnimada("+id+")",10);
		}else{
			clearTimeout(timerAmb);
			try{ 
				eval("document.getElementById('mostraImagem').onclick = function (){ fechaImagemAnimada(" + id + "); } "); 
			}catch(e){ 
				alert(e.description+"(Func Abreanimada!)"); 
			}
		}
		
		centerSpan(id);
	}
	
	//função que efetua o looping para fechar a imagem div
	var _fechaImagemAnimada = null;
	fechaImagemAnimada = function(id){
		imagem = document.getElementById( id );
		oSpan = imagem.parentNode;
		if( parseInt(oSpan.style.width) > 1 ){
			var width = parseInt(oSpan.style.width);
			width = width - passoAmb;
			if( width < 1 ) width = 1;
			oSpan.style.width = width + 'px';
		}
		if( parseInt(oSpan.style.height) > 1 ){
			var height = parseInt(oSpan.style.height);
			height = height - passoAmb;
			if( height < 1 ) height = 1;
			oSpan.style.height = height + 'px';
		}
		if(parseInt(oSpan.style.width) > 1 || parseInt(oSpan.style.height) > 1){
			clearInterval(timerAmb);
			timerAmb = setTimeout("fechaImagemAnimada("+id+")",10);
			centerSpan(id);
		}else{
			clearInterval(timerAmb);
			oSpan.style.display = 'none';
		}
	}
	
	//
	AdicionaCarrinho = function(imagem){
		carrinho_impressao = window.open( 'carrinho_impressao.php?' 
			+ '&codigo=' + imagem.getAttribute('codigo') 
			//+ '&uso=' + imagem.getAttribute('uso') 
			+ '&nome=' + imagem.getAttribute('nome') 
			+ '&formato=' + imagem.getAttribute('formato') 
			+ '&tipo=' + imagem.getAttribute('tipo') 
			+ '&pei=' + imagem.getAttribute('pei') 
			, 'carrinho_impressao' , 'width=680,height=550' );
		carrinho_impressao.focus();
		imagem.parentNode.setAttribute('ignore','1');
	}