//Lightbox BR3 V5
//Necessário usar a última versão do Jquery *http://jquery.com/

function lightbox(arquivo){
			 $('body').append(function(){
									   
					var posicaoclique;
					var posicaorealtop;
					var alturabody = $('body').height();
					
					$("*",this).click(function (e) {
					  posicaoclique = $(this).offset();
					  e.stopPropagation();
					  	//alert(this.tagName + " coords ( " + posicaoclique.left + ", " + + " )")
					});
									   
									   
					$(this).append('<div id="lightbox"></div>');
					
					$('#lightbox').css('height',''+alturabody+'px');
					
					$('#lightbox').append('<div id="lt_fundo" onClick="fecharlt();"></div><div id="box_lightbox"><div id="box_fechar"><img src="/lightbox/img/close.png" style="border:0; cursor:pointer;" onClick="fecharlt();"/></div></div>');
						//inicio do pre-loading image e ajuste da caixa branca
								$('<img />').attr('src',arquivo).load(function(){
									$('#box_lightbox').append($(this));
									var aleturaimg = $(this).height();
									var larguraimg = $(this).width();
									var meiodivalt = 0-(aleturaimg / 2);
									var meiodivlarg = 0-(larguraimg / 2);
									posicaorealtop = posicaoclique.top - 20;
									
									$('#box_lightbox').css('top',''+posicaorealtop+'px');
									$('#box_lightbox').css('left','50%');
									$('#box_lightbox').css('margin-top', meiodivalt+'px');
									$('#box_lightbox').css('margin-left', meiodivlarg+'px');
									$('#box_lightbox').css('display','none');
									
									$('#box_lightbox').slideToggle("slow");				
								});
						//---------------------------------------------------
			 });
			 
			
	}
	
	
	function lightboxarq(arquivo,largura,nivel){
			 $('body').append(function(){
									   
					var posicaoclique;
					var posicaorealtop;
					var alturabody = $('body').height();
					
					$("*",this).click(function (e) {
					  posicaoclique = $(this).offset();
					  e.stopPropagation();
					  	//alert(this.tagName + " coords ( " + posicaoclique.left + ", " + + " )")
					});
									   
					$(this).append('<div id="lightbox"></div>');
					
					
					alturabodyfn = alturabody +800
					$('#lightbox').css('height',''+alturabodyfn+'px');
					$('#lightbox').css('z-index','100');

					
					$('#lightbox').append('<div id="lt_fundo" onClick="fecharlt();"></div><div id="box_lightbox"><div id="box_fechar"><img src="lightbox/img/close.png" style="border:0; cursor:pointer;" onClick="fecharlt();"/></div><div id="infobox"></div><div style="text-align:center; margin-top:10px; padding-top:10px;"><input name="slidebt" type="button" class="bt_iniciar_app" id="slidebt" style="display:;margin:0 auto;" onClick="ROTACAOSLIDE();" value="Iniciar Apresenta&ccedil;&atilde;o / Slide Show" /><input type="button" name="sliderbtstop" id="sliderbtstop" value="Parar apresenta&ccedil;&atilde;o" style="display:none; margin:0 auto;" onClick="PARAR();"  class="bt_iniciar_app"/></div>');
						//inicio das infos para abertura do arquivo
								
									$('#infobox').load(arquivo,function(){
										var meiodivlarg = 0-(largura / 2);
										posicaorealtop = posicaoclique.top - 200;
										$('#box_lightbox').css('width',largura);
										$('#box_lightbox').css('top','10%');
										$('#box_lightbox').css('left','50%');
										$('#box_lightbox').css('top',''+posicaorealtop+'px');
										$('#box_lightbox').css('margin-left', meiodivlarg+'px');
										$('#box_lightbox').css('z-index',nivel);
										$('#box_lightbox').css('min-height','535px');
										$('#box_lightbox').css('display','none');
										
										$('#box_lightbox').slideToggle("slow");	
									});
								
										
						//---------------------------------------------------
			 });
	}
	
	function fecharlt(){
		$('#lightbox').remove();
	}




function CALL_AJAX2(){
	   var idgal =  window.document.getElementById('proximogal').value;
	   
	   
	   document.getElementById('infobox').innerHTML= 'Carregando...';
	   
		if (window.XMLHttpRequest)
		  {// codigo para IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// codigo para o IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		  xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4)
			{
			document.getElementById('infobox').innerHTML= xmlhttp.responseText;
			}
		  }
		xmlhttp.open('GET','ajax_files/cobertura.asp?idfoto='+idgal+'',true);
		
		xmlhttp.send();
		
		if(idgal == '' || idgal == null){
		   PARAR();
		}
}




