// JavaScript Document
$(document).ready(function (){
$.extend({
		 ArtigoGaleria:{
			 	 
				 data:[],
				 
				 index:0,
				 
				 limit:0,
				 
				 start:function(){
					this.loadData();
					this.addClickAction();					
				 },
				 
				 loadData:function(){
					 if (typeof(ObjectArtigoFotosPlus) == 'object'){
						 this.data=ObjectArtigoFotosPlus;
						 this.limit=this.data.length -1;
					 }
				 },
				 
				 addClickAction:function (){
					 $('#art_desc_prev').click(function(){
						$.ArtigoGaleria.prev();
						return false;				
					  });
					 
 					 $('#art_desc_next').click(function(){
                        $.ArtigoGaleria.next();
						return false;				
					  });
				 },
				 
				 change:function (){					 
					 var src='/galeria/'+this.data[this.index].image_id+'/402x501/';
					 var title=decodeURIComponent(this.data[this.index].image_description);
					 var desc=decodeURIComponent(this.data[this.index].image_title);
					 $('#art_img_id').attr({'src':src,'alt': title,'title': title});
					 $('#art_desc_title').html(title);
					 $('#art_desc_resume').html(desc);
					 if (typeof(pageTracker)=='object'){pageTracker._trackPageview();}
					 var random_number="bust="+(Math.round(Math.random()*10000000000));
					 $('#iframemrec').attr({'src': 'http://ads.iol.pt/html.ng/Site=superstars&Local=other&PagePos=7&adsize=300x250&type=0300x0250-0000&'+random_number});
				     
				 },
				 
				 next:function (){
					 this.index++;
					 if (this.index>this.limit){this.index=0;}
					 this.change();
				 },
				 
				 prev:function (){
 					 this.index--;
					 if ( this.index<0){ this.index= this.limit;}
					 this.change();
				 }
			 }
		 });	

$.ArtigoGaleria.start();
});	
