
document.observe("dom:loaded", function () {
		vLinks = $$(".Fotoevento");
		vLinks.each( function( myItem ) {
			vURL = myItem.readAttribute("href");
			x = new Janela_Evento({top:'center' , left:'center' , width:765 , height:528}, vURL );
			myItem.observe( "click" , PopEventos._triggerAbrir.bindAsEventListener( myItem , x.index ) ) 
			myItem.writeAttribute({"href":"#"});
		})
	} );

var PopEventos = {
	"eventos": [],
	"fundo": null,
	"janelaAtiva": -1,
	"fotoAtiva":-1,
	"Dimensoes":null,
	ScrollTimer:null,
	"cacheImage":null,
	"linkFotos":null,
	"AnimaDesc":null,
	"timerDesc":null,
	"statusDesc":"hide",
	"AnimaProx":null,
	"AnimaFechar":null,
	"timerProx":null,
	"timerFechar":null,
	"statusFechar":null,
	"statusProx":"hide",
	"AnimaAnt":null,
	"timerAnt":null,
	"statusAnt":"hide",
	"cacheImage": new Image(),
	"preLoadImage":null,
	"fecharJanela": function ()
	{
		PopEventos.fadeOutFechar();
		if( PopEventos.fotoAtiva != -1 )
			{
				PopEventos.eventos[ PopEventos.janelaAtiva ].LinkThumbs[PopEventos.fotoAtiva].removeClassName("ativo");
				PopEventos.eventos[ PopEventos.janelaAtiva ].AreaThumb.scrollLeft = 0;
			 }

		PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.stopObserving("mouseover" , PopEventos._overFechar );
		PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.stopObserving("mouseout" , PopEventos._outFechar );

		PopEventos.eventos[ PopEventos.janelaAtiva ].LoadingJanela.setStyle({"visibility":"hidden"})


		if( PopEventos.eventos[ PopEventos.janelaAtiva ].status == "loaded" )
		{
			PopEventos.eventos[ PopEventos.janelaAtiva ].ThumbsArea.setStyle({"visibility":"hidden"})
			PopEventos.eventos[ PopEventos.janelaAtiva ].FotoArea.setStyle({"visibility":"hidden"})
		}

		new PeriodicalExecuter(
		function(pe) {
			vObj = PopEventos.eventos[ PopEventos.janelaAtiva ];

		  	vObj.alturaAtual += -10;
			if( vObj.alturaAtual  < 0 )
				{vObj.alturaAtual = 0; }
			
			
			vTop = vObj.top + parseInt( ( vObj.altura - vObj.alturaAtual )/2 )

			vObj.Janela.setStyle({"top":vTop+"px" , "left": vLeft+"px" , "height":vObj.alturaAtual+"px" })
			
			if( vObj.alturaAtual <= 0 )
			{
				PopEventos.fecharFundo();
				vObj.Janela.setStyle({"display":"none"});
				pe.stop();				
			}
		}, 0.01);

	},
	
	"fecharFundo": function()
	{
		if( this.fundo )
			{this.fundo.style.display="none";} 
	},
	"scrollRight": function() {
		if( PopEventos.ScrollTimer )
			{PopEventos.ScrollTimer.stop()}
		PopEventos.ScrollTimer = new PeriodicalExecuter( function (pe) { PopEventos.eventos[ PopEventos.janelaAtiva ].AreaThumb.scrollLeft += 5; } , 0.05);		
	},
	"scrollLeft": function( event, vID ) {
		if( PopEventos.ScrollTimer )
			{PopEventos.ScrollTimer.stop()}
		PopEventos.ScrollTimer = new PeriodicalExecuter( function (pe) { PopEventos.eventos[ PopEventos.janelaAtiva ].AreaThumb.scrollLeft += -5; } , 0.05);		
	},
	"stopScroll": function( event, vID ) {
		PopEventos.ScrollTimer.stop(); 
	},
	"proximaFoto":function () {
		if( PopEventos.fotoAtiva < ( PopEventos.eventos[ PopEventos.janelaAtiva ].Album.items.length - 1 ))
		{
			PopEventos.showFoto(  ( PopEventos.fotoAtiva + 1 ) );
		}
	},
	"anteriorFoto":function () {
		if( PopEventos.fotoAtiva > 0 )
		{
			PopEventos.showFoto(  ( PopEventos.fotoAtiva - 1 ) );
		}
	},
	"_overFechar": function() 
	{
		if(PopEventos.timerFechar)
			{clearTimeout(PopEventos.timerFechar);}

		if( PopEventos.fotoAtiva > -1 )
		{
			if( PopEventos.statusFechar == "hide" )
				{setTimeout( "PopEventos.fadeInFechar()", 1 )}
		}
	},

	"_outFechar":function (event) {
		PopEventos.timerFechar = setTimeout( "PopEventos.fadeOutFechar()" , 500 );
	},

	"_overFoto":function (event) {
		if( PopEventos.eventos[PopEventos.janelaAtiva].LoadingJanela.getStyle("visibility") == "hidden" )
		{
			
			if(PopEventos.timerDesc)
				{clearTimeout(PopEventos.timerDesc);}

			if( PopEventos.fotoAtiva > -1 )
			{
				if( PopEventos.statusDesc == "hide" )
					{setTimeout( "PopEventos.fadeInDescricao()", 1 )}
			}
		}

	},

	"_outFoto":function (event) {
		PopEventos.timerDesc = setTimeout( "PopEventos.fadeOutDescricao()" , 500 );
	},

	"fadeOutFechar": function () {
		PopEventos.statusFechar = 'hide';
		if( PopEventos.AnimaFechar )
		{
			PopEventos.AnimaFechar.stop();}
			PopEventos.AnimaFechar = new PeriodicalExecuter(
			function (pe) { 
			
				vTop = parseInt( PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.style.top ) ;
				if( isNaN( vTop ) )
					{vTop = 0}
				if( vTop > -28 )
					{vTop += -4}

				if( vTop < -28 )
					{vTop = -28}
				
				PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.setStyle({"top":( vTop + "px")} );


				if( vTop == -28 )
				{	
					pe.stop();
				}
			}
		,0.01);

	},

	"fadeOutDescricao": function () {
		PopEventos.statusDesc = 'hide';
		if( PopEventos.AnimaDesc )
		{
			PopEventos.AnimaDesc.stop();}
			PopEventos.AnimaDesc = new PeriodicalExecuter(
			function (pe) { 
			
				vAltura = parseInt( PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.style.height);

				if( isNaN(vAltura) )
				{ vAltura = 0;}

				if( vAltura > 0 )
					{vAltura += -1;}

				if( vAltura < 0 )
					{vAltura = 0;}
	
				PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.style.height  = vAltura + "px";
				vOpacity = PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.getStyle("opacity");
	
				if( vOpacity >  0 )
					{vOpacity += -0.05}

				if( vOpacity < 0 )
					{vOpacity = 0}
				
				PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.setStyle({"opacity":vOpacity});
	
				if( vOpacity == 0)
				{	
					PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.style.display = 'none'
					pe.stop();
				}
			}
		,0.01);

	},

	"fadeInDescricao": function ()
	{
		PopEventos.statusDesc = "show";
		PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.setStyle({"display":"block","height":"0px","opacity":0});

		PopEventos.AnimaDesc = new PeriodicalExecuter(
			function (pe) { 
				vAltura = parseInt( PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.style.height);
				
				if( vAltura < 26 )
					{vAltura += 1;}

				if( vAltura > 26 )
					{vAltura = 26;}
				
				PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.style.height  = vAltura + "px";
				
				vOpacity = PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.getStyle("opacity");
				if( vOpacity < 0.45 )
					{vOpacity += 0.05}

				if( vOpacity > 0.45 )
					{vOpacity = 0.45}
				
				PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.setStyle({"opacity":vOpacity});

				if( vAltura == 26  && vOpacity == 0.45)
					{pe.stop();}
			}
		,0.01);
	},

	"fadeInFechar": function ()
	{
		PopEventos.statusFechar = "show";
		PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.setStyle({"top":"-28px"});

		PopEventos.AnimaDesc = new PeriodicalExecuter(
			function (pe) { 
				vTop = parseInt( PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.style.top ) ;
				if( isNaN(vTop ) )
					{vTop = 0}
				if( vTop < 0 )
					{vTop += 4}

				if( vTop > 0 )
					{vTop = 0}
				
				PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.setStyle({"top":( vTop + "px")} );

				if( vTop == 0)
					{pe.stop();}
			}
		,0.01);
	},


	"_overEsquerda":function (event) {
		if( PopEventos.eventos[PopEventos.janelaAtiva].LoadingJanela.getStyle("visibility") == "hidden" )
		{
			if( PopEventos.fotoAtiva > 0 )
			{
				if(PopEventos.timerAnt)
					{clearTimeout(PopEventos.timerAnt);}

				if( PopEventos.statusAnt == "hide" )
					{setTimeout( "PopEventos.fadeInLinks('Anterior')", 1 );}				
			}
		}
	},

	"_outEsquerda":function (event) {
		PopEventos.timerAnt = setTimeout( "PopEventos.fadeOutLinks('Anterior')" , 500 );
	},

	"_overDireita":function (event) {
		if( PopEventos.eventos[PopEventos.janelaAtiva].LoadingJanela.getStyle("visibility") == "hidden" )
		{
			if( PopEventos.fotoAtiva < (PopEventos.eventos[ PopEventos.janelaAtiva ].Album.items.length - 1) )
			{
				if(PopEventos.timerProx)
					{clearTimeout(PopEventos.timerProx);}

				if( PopEventos.statusProx == "hide" )
					{setTimeout( "PopEventos.fadeInLinks('Proximo')", 1 )}				
			}
		
			PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.style.display = "block";
		}
	},

	"_outDireita":function (event) {
		PopEventos.timerProx = setTimeout( "PopEventos.fadeOutLinks('Proximo')" , 500 );
	},

	"fadeInLinks": function( linktype ) {
		if( linktype == "Anterior" )
		{
			if( PopEventos.AnimaAnt )
				{PopEventos.AnimaAnt.stop();}

			PopEventos.statusAnt = "show";
			PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.setStyle({"display":"block","left":"-88px","opacity":0});
			PopEventos.AnimaAnt = new PeriodicalExecuter(
				function (pe) { 
					vLargura = parseInt( PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.style.left);
					if( isNaN( vLargura ) )
						{vLargura = 0}

					if( vLargura < 0 )
						{vLargura += 8;}

					if( vLargura > 0  )
						{vLargura = 0;}
				
					PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.style.left  = vLargura + "px";
				
					vOpacity = PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.getStyle("opacity");
					if( vOpacity < 0.45 )
						{vOpacity += 0.05}

					if( vOpacity > 0.45 )
						{vOpacity = 0.45}
					
					PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.setStyle({"opacity":vOpacity});
				
					if( vLargura == 0  && vOpacity == 0.45 )
						{pe.stop();}
				}
			,0.01);
		} else if( linktype == "Proximo" )
		{

			if( PopEventos.AnimaProx )
				{PopEventos.AnimaProx.stop();}
			PopEventos.statusProx = "show";
			PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.setStyle({"display":"block","right":"-88px","opacity":0});
			PopEventos.AnimaProx = new PeriodicalExecuter(
				function (pe) { 
					vLargura = parseInt( PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.style.right);
					if( vLargura < 0 )
						{vLargura += 8;}

					if( vLargura > 0  )
						{vLargura = 0;}
				
					PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.style.right  = vLargura + "px";
				
					vOpacity = PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.getStyle("opacity");
					if( vOpacity < 0.45 )
						{vOpacity += 0.05}

					if( vOpacity > 0.45 )
						{vOpacity = 0.45}
				
					PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.setStyle({"opacity":vOpacity});
				
					if( vLargura == 0  && vOpacity == 0.45 )
						{pe.stop();}
				}
			,0.01);
		} 

	},

	"fadeOutLinks": function( linktype ) {

		if( linktype == "Anterior" )
		{
			if( PopEventos.AnimaAnt )
				{PopEventos.AnimaAnt.stop();}
			PopEventos.statusAnt = 'hide';
			PopEventos.AnimaAnt = new PeriodicalExecuter(
				function (pe) { 
					vLargura = parseInt( PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.style.left);
					if( isNaN(vLargura) )
						{vLargura = 0 }
					if( vLargura >  -88 )
						{vLargura += -4;}

					if( vLargura < -88 )
						{vLargura = -88;}
				
					PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.style.left   = vLargura + "px";
				
					vOpacity = PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.getStyle("opacity");
					if( vOpacity >  0 )
						{vOpacity += -0.05}

					if( vOpacity < 0 )
						{vOpacity = 0}
				
					PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.setStyle({"opacity":vOpacity});
					if( vOpacity == 0 )
					{	
						PopEventos.eventos[ PopEventos.janelaAtiva ].linkAnterior.style.display = 'none'
						pe.stop();
					}
				}
			,0.01);
		} else if( linktype == "Proximo" )
		{
			if( PopEventos.AnimaProx )
				{PopEventos.AnimaProx.stop();}

			PopEventos.statusProx = 'hide';
			PopEventos.AnimaProx = new PeriodicalExecuter(
				function (pe) { 
					vLargura = parseInt( PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.style.right);
					if( vLargura > -88 )
						{vLargura += -4;}

					if( vLargura < -88 )
						{vLargura = -88;}
				
					PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.style.right   = vLargura + "px";
				
					vOpacity = PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.getStyle("opacity");
					if( vOpacity >  0 )
						{vOpacity += -0.05}

					if( vOpacity < 0 )
						{vOpacity = 0}
				
					PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.setStyle({"opacity":vOpacity});
					if( vOpacity == 0 )
					{	
						PopEventos.eventos[ PopEventos.janelaAtiva ].linkProximo.style.display = 'none'
						pe.stop();
					}
				}
			,0.01);
		}



	},

	"showFoto":function( fotoID ) {

		if( PopEventos.fotoAtiva != fotoID )
		{

			if( PopEventos.preLoadImage )
				{PopEventos.preLoadImage.stop();}

			//PopEventos.fadeOutLinks("Anterior");
			//PopEventos.fadeOutLinks("Proximo");
			//PopEventos.fadeOutDescricao();
		
			if( PopEventos.fotoAtiva != -1 )
				{PopEventos.eventos[ PopEventos.janelaAtiva ].LinkThumbs[PopEventos.fotoAtiva].removeClassName("ativo")}

			PopEventos.fotoAtiva = fotoID;
			PopEventos.eventos[ PopEventos.janelaAtiva ].LinkThumbs[PopEventos.fotoAtiva].addClassName("ativo")
			vFoto = PopEventos.eventos[ PopEventos.janelaAtiva ].Album.items[ fotoID ];

			PopEventos.eventos[ PopEventos.janelaAtiva ].FotoDescricao.update( vFoto.descricao );
			PopEventos.eventos[ PopEventos.janelaAtiva ].LoadingImagem.setStyle({"visibility":"visible"});
			PopEventos.cacheImage.src = vFoto.foto; 

			if( PopEventos.ScrollTimer )
				{PopEventos.ScrollTimer.stop()}

			PopEventos.ScrollTimer = new PeriodicalExecuter(
				function (pe) {

					if( PopEventos.fotoAtiva < 2 )
						{vScrollTo = 0;}
					else
						{vScrollTo =  (PopEventos.fotoAtiva - 2)*114;}
					vCurScroll = PopEventos.eventos[ PopEventos.janelaAtiva ].AreaThumb.scrollLeft;

					if( vCurScroll < vScrollTo )
						{PopEventos.eventos[ PopEventos.janelaAtiva ].AreaThumb.scrollLeft += 5;}
					else
						{PopEventos.eventos[ PopEventos.janelaAtiva ].AreaThumb.scrollLeft += -5;}

					vDiff = PopEventos.eventos[ PopEventos.janelaAtiva ].AreaThumb.scrollLeft - vScrollTo;
					if( vDiff < 5 && vDiff > -5 )
					{
						PopEventos.eventos[ PopEventos.janelaAtiva ].AreaThumb.scrollLeft = vScrollTo;
						pe.stop();
					}
				 }
			 , 0.05);

			PopEventos.preLoadImage = new PeriodicalExecuter(
				function (pe) {

					if( PopEventos.cacheImage.complete )
					{
						vFoto = PopEventos.eventos[ PopEventos.janelaAtiva ].Album.items[ PopEventos.fotoAtiva ];
						PopEventos.eventos[ PopEventos.janelaAtiva ].Imagem.src = PopEventos.cacheImage.src;					
						PopEventos.eventos[ PopEventos.janelaAtiva ].LoadingImagem.setStyle({"visibility":"hidden"});
						//PopEventos.fadeInDescricao();
						//PopEventos.timerDesc = setTimeout( "PopEventos.fadeOutDescricao()" , 3000 );
						pe.stop();	
					}
				}
			, 0.3)
			
		}
	},
	"_clickfoto":function( event, fotoID ) {
		PopEventos.showFoto( fotoID )
	}, 
	"abrirFundo": function ()
	{

		this.Dimensoes = document.viewport.getDimensions()
		vbody = document.getElementsByTagName("body")[0];
		vDim = $(vbody).getDimensions();						
		if( this.Dimensoes.height < vDim.height )
			{this.Dimensoes.height = vDim.height }
		if( this.Dimensoes.width < vDim.width )
			{this.Dimensoes.width = vDim.width }


		if( this.fundo )
			{ this.fundo.style.display = "block"; }
		else {
			x = new Element( "div" , {"class":"fundo_janela"} )
			this.fundo = vbody.appendChild(x);
			this.fundo.style.display = "block";
			this.fundo.style.height = this.Dimensoes.height + "px";
			this.fundo.style.width = this.Dimensoes.width + "px";
		}
	},
	"_triggerAbrir":function( e , vID ) 
	{
		PopEventos.abrir_janela( vID );
	},  
	"abrir_janela": function( vID )
	{
		PopEventos.janelaAtiva = vID;
		PopEventos.fotoAtiva = -1;
		PopEventos.eventos[ PopEventos.janelaAtiva ].Janela.style.display = "block";
		PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.setStyle({"top":"-28px"});
		PopEventos.eventos[ PopEventos.janelaAtiva ].LoadingJanela.setStyle( {"visibility":"hidden"} );

		PopEventos.abrirFundo();
		new PeriodicalExecuter(
		function(pe) {
		
			vObj = PopEventos.eventos[ PopEventos.janelaAtiva ];
			vJanela = PopEventos.eventos[ PopEventos.janelaAtiva ].Janela;
		  	vObj.larguraAtual += 5;
			if( vObj.larguraAtual > vObj.largura ) 
				{vObj.larguraAtual = vObj.largura;}

		  	vObj.alturaAtual += 5;
			if( vObj.alturaAtual > vObj.altura ) 
				{vObj.alturaAtual = vObj.altura;}			
			
			vTop = vObj.top + parseInt( ( vObj.altura - vObj.alturaAtual )/2 )
			vLeft = vObj.left + parseInt( ( vObj.largura - vObj.larguraAtual )/2 )


			vJanela.setStyle({"top":vTop+"px" , "left": vLeft+"px" , "height":vObj.alturaAtual+"px" , "width":vObj.larguraAtual+"px" })
			
			if(  vObj.larguraAtual == vObj.largura && vObj.alturaAtual == vObj.altura )
			{
				if( vObj.status == "not-loaded" )
				{
					vObj.LoadingJanela.setStyle( {"visibility":"visible"} );
					PopEventos.loadingTrigger = setTimeout( "PopEventos.eventos[ " + PopEventos.janelaAtiva  + "].carregarURL()" , 1);
					PopEventos.fadeInFechar();
				} else if( vObj.status == "loaded" ) {

					PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.setStyle({"top":"0px"});
					PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.observe("mouseover" , PopEventos._overFechar );
					PopEventos.eventos[ PopEventos.janelaAtiva ].BotaoFechar.observe("mouseout" , PopEventos._outFechar );
					PopEventos.eventos[PopEventos.janelaAtiva].ThumbsArea.setStyle({"visibility":"visible"})
					PopEventos.eventos[PopEventos.janelaAtiva].FotoArea.setStyle({"visibility":"visible"})
					PopEventos.eventos[PopEventos.janelaAtiva].LoadingJanela.setStyle({"visibility":"hidden"})
					PopEventos.showFoto(0);				
				} else {
					vObj.LoadingJanela.setStyle( {"visibility":"visible"} );
					PopEventos.fadeInFechar();
				}


				pe.stop();				
			}
		}, 0.01);
	}

}

var Janela_Evento = new Class.create( {
	initialize: function( vOptions , vURL )
	{

		this.status = "not-loaded";
		this.index = PopEventos.eventos.length;
		this.URL = vURL + "&requestID=" + this.index;

		PopEventos.eventos.push( this );

		if( PopEventos.Dimensoes == null )
		{
			PopEventos.abrirFundo();
			PopEventos.fecharFundo();
		}
		
		x = new Element( "div" , {"class":"popWindow","id":("PopWindow-" + this.index)} );
		vbody = document.getElementsByTagName("body")[0];

		vbody.insert( x );
		this.altura = vOptions.height;
		this.largura = vOptions.width;
		this.scrollTimer = null

		this.Janela = $( "PopWindow-" + this.index );

		x = new Element( "div" , {"class":"loading" } ).update("<img src='PopWindow/loadinfo.net.gif' ><img src='PopWindow/blank.gif' width='1' height='" + this.altura + "px'>");
		x.setStyle( { lineHeight:(this.altura+"px") } ); 

		this.LoadingJanela = x;
		this.Janela.insert( x );

		x = new Element( "a" , {"class":"fechar", "href":"#" } );
		x.observe( "click" , PopEventos.fecharJanela );
		this.BotaoFechar = x;
		this.Janela.insert( x );


		if( vOptions.top == "top" )
			{ this.top = 0;}
		else if( vOptions.top == "bottom" )
			{ this.top = PopEventos.Dimensoes.height - vOptions.height ;}
		else if( vOptions.top == "center" )
			{ this.top = parseInt( (PopEventos.Dimensoes.height/2) - (vOptions.height/2));}
		else 
			{this.top = parseInt(vOptions.top)}

		if( vOptions.left == "left" )
			{ this.left = 0;}
		else if( vOptions.left == "right" )
			{ this.left = PopEventos.Dimensoes.width - vOptions.width;}
		else if( vOptions.left == "center" )
			{ this.left = parseInt( (PopEventos.Dimensoes.width/2) - (vOptions.width/2) );}
		else 
			{this.top = parseInt(vOptions.width)}

		this.larguraAtual = 0;
		this.alturaAtual = 0;


		
	},
	"abrir": function( )
	{
		PopEventos.abrir_janela( this.index );
	},
	"carregarURL": function()
	{
		this.status = "loading"

		//alert(this.URL)
		
		new Ajax.Request(this.URL, {
			requestHeaders:{"IDChamada":this.index},
			method: 'get',
			onSuccess: function(transport) {
				//alert("carregadddo")
				vObj = transport.responseJSON;
				
				PopEventos.eventos[ vObj.IDchamada ].Album = vObj;
				PopEventos.eventos[ vObj.IDchamada ]._montarHTML();

			},
			onFailure: function( transport ) {
					vURL = transport.request.url;
					vPos = vURL.search(/requestID=/i)
					//alert( transport.responseText );
					if( vPos != -1 )
					{
						vRequest = vURL.slice( vPos + 10 , vURL.length );
						vPos = vRequest.search("&")
						if(  vPos != -1 )
							{vRequest = vRequest.slice( 0 , vPos );}
						vRequest = parseInt( vRequest );
						PopEventos.eventos[ vRequest ].LoadingJanela.update("Não foi possível carregar as fotos do Evento");
					}

				}

		});

	},
	"_montarHTML":function() {
		//alert("oiiooiioio");
		vDivFotoGrande = new Element( "div" , {"class":"div-FotoGrande" } );
		vDivFotoGrande.setStyle({"visibility":"hidden"});
		vDivFotoGrande.observe("mouseover" , PopEventos._overFoto )
		vDivFotoGrande.observe("mouseout" , PopEventos._outFoto )
		vDivFotoGrande.observe("mouseover" , PopEventos._overFechar )
		vDivFotoGrande.observe("mouseout" , PopEventos._outFechar )


		x = new Element( "img" , {"class":"foto-principal","src":this.Album.items[0].foto} );
		this.Imagem = x;
		vDivFotoGrande.insert( x );

		x = new Element( "div" , {"class":"area-descricao" } );
		this.FotoDescricao = x;
		vDivFotoGrande.insert( x );

		x = new Element( "div" , {"class":"loading" } ).update("<img src='PopWindow/loadinfo.net.gif'><img src='PopWindow/blank.gif' height='397px' width='1' >");
		x.setStyle( { lineHeight:"397px", "height":"397px", "visibility":"hidden"} ); 
		this.LoadingImagem = x;
		vDivFotoGrande.insert( x );
		vtext = "";
		dummyText = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>"
		for( i = 0; i < 18 ; i ++ )
			{vtext = vtext + dummyText;}
	
		x = new Element( "div" , {"class":"area-esquerda" } );
		vLink = new Element( "a" , {"class":"PopEvento-linkAnterior","href":"#"} ).update(" < ");
		x.insert( vLink )
		vLink.observe( "click" , PopEventos.anteriorFoto )
		x.insert(vtext);
		x.observe("mouseover" , PopEventos._overEsquerda )
		x.observe("mouseout" , PopEventos._outEsquerda )

		this.linkAnterior = vLink;
		vDivFotoGrande.insert( x );

		x = new Element( "div" , {"class":"area-direita" } );
		vLink = new Element( "a" , {"class":"PopEvento-linkProximo","href":"#"} ).update(" > ");

		x.insert( vLink )
		vLink.observe( "click" , PopEventos.proximaFoto )

		x.insert( vtext);
		x.observe("mouseover" , PopEventos._overDireita )
		x.observe("mouseout" , PopEventos._outDireita )

		this.linkProximo = vLink;
		vDivFotoGrande.insert( x );


		vDivThumbs = new Element( "div" , {"class":"div-Thumbs"});
		vDivThumbs.setStyle({"visibility":"hidden"});

		x = new Element( "a" , {"class":"previous","href":"#" } );
		x.observe( "mouseover" , PopEventos.scrollLeft )
		x.observe( "mouseout" , PopEventos.stopScroll )
		vDivThumbs.insert(x);

		x = new Element( "a" , {"class":"next","href":"#" } );
		x.observe( "mouseover" , PopEventos.scrollRight );
		x.observe( "mouseout" , PopEventos.stopScroll );
		vDivThumbs.insert(x);


		ScrollThumb = new Element( "div" , {"class":"scrollThumb"} );
		this.AreaThumb = ScrollThumb;

		x = new Element( "p" );
		x.setStyle({"width":((this.Album.items.length*169) + "px" )} );
		for( i = 0 ; i < this.Album.items.length ; i ++ )
		{
				//alert(i);
			vLink = new Element( "a" , {"href":"#","class":"PopEventos-Thumb"} );
			vImg = new Element( "img" , {"src":this.Album.items[i].thumb} );
			vLink.insert(vImg);			
			x.insert( vLink );
			vLink.observe("click", PopEventos._clickfoto.bindAsEventListener( vLink, i ) );
		}
		ScrollThumb.insert(x)
		vDivThumbs.insert(ScrollThumb);
		
		this.Janela.insert( vDivThumbs );

		this.Janela.insert( vDivFotoGrande );

		this.LinkThumbs = $("PopWindow-" + PopEventos.janelaAtiva ).select("a.PopEventos-Thumb").entries();
		this.ThumbsArea = vDivThumbs;
		this.FotoArea = vDivFotoGrande;
		setTimeout(	"PopEventos.eventos[" + this.index + "]._checkIMGLoad()", 1 );

	},
	"_checkIMGLoad":function()
	{
		vImagens = PopEventos.eventos[this.index].Janela.select("img");
		if( vImagens.all( function (eachIMG) { return eachIMG.complete } ) )
		//if( true )
		{

			if( this.index == PopEventos.janelaAtiva )
			{
				PopEventos.showFoto(0);
				this.BotaoFechar.setStyle({"top":"0px"});
				this.BotaoFechar.observe("mouseover" , PopEventos._overFechar );
				this.BotaoFechar.observe("mouseout" , PopEventos._outFechar );
				this.ThumbsArea.setStyle({"visibility":"visible"})
				this.FotoArea.setStyle({"visibility":"visible"})
				this.LoadingJanela.setStyle({"visibility":"hidden"})
			}			
			this.status = "loaded";
		}else {
			window.status = "nao carregou"
			setTimeout(	"PopEventos.eventos[" + this.index + "]._checkIMGLoad()", 1000 );
		}
	}
	
} );
