google.load("feeds", "1");     
function initialize() {      
var feed = 
new google.feeds.Feed("http://blog.fattoremamma.com/?feed=rss2");    
feed.setNumEntries(1000);
feed.load(function(result) {        
	if (!result.error) 
	{          
			var link, img, div, divTesto, datanews;
			var container = document.getElementById("feed");          
			var entry; 
			var i=0;
			var postPubblicati=1;
			var newsPubblicate=0;

			while((i < result.feed.entries.length)){ //&& (postPubblicati + newsPubblicate < 4)){
			
			//elaboro la prima notizia disponibile del blog
				entry = result.feed.entries[i];
				var testo = entry.contentSnippet;
				var categoria = new String(entry.categories);
				testo = testo.replace(/\&#8217;/g, '\'');
		//alert(entry.categories);
		//alert(postPubblicati + newsPubblicate);
				if(categoria.indexOf('news')==-1){
				
					if(postPubblicati < 3){
					//creo il link da associare all'immagine	
						link = document.createElement('a');
					//creo l'immagine
						img = document.createElement('img');
					//creo un elemento 'span' per poter assegnare stili diversi al titolo e al testo	
						divTesto = document.createElement('span');
					
					//indico l'id del 'div' nel quale voglio visualizzare il contenuto
						if(postPubblicati==1){
							div = document.getElementById("feed1");
							img.setAttribute('src','images/bott-leggi-blu.gif');
						}else{
							div = document.getElementById("feed2");
							img.setAttribute('src','images/bott-leggi-azzurro.gif');
						}
					//setto gli attributi dell'immagine e del link che vado ad assemblare
						img.setAttribute('border',0);
						img.setAttribute('align','right');
						link.setAttribute('href', entry.link);			
						link.appendChild(img);
					//formatto il titolo	
						div.style.cssText='font-weight:bold';
						div.appendChild(document.createTextNode(entry.title));
						divTesto.appendChild(document.createTextNode("  -"));	

					//formatto il testo
						divTesto.style.cssText ='font-weight:normal';
						divTesto.appendChild(document.createTextNode(testo));			
						div.appendChild(divTesto);
						div.appendChild(link);				
					
					
						postPubblicati ++;
					}
				}//endif
				else{//elaboro l'ultima news inserita
				//alert(entry.categories);
					if(newsPubblicate == 0){
					//creo il link da associare all'immagine	
						link = document.createElement('a');
					//creo l'immagine
						img = document.createElement('img');
					//assegno il div dove visualizzare la news	
						div = document.getElementById("news1");
						img.setAttribute('src','images/bott-news-leggi.gif');
					//setto gli attributi dell'immagine e del link che vado ad assemblare
						img.setAttribute('border',0);
						img.setAttribute('align','right');
						link.setAttribute('href', entry.link);			
						link.appendChild(img);
					//formatto il testo della bews	
						datanews = dateFormat(entry.publishedDate, 'dd-mm-yyyy'); 
						div.appendChild(document.createTextNode(datanews));
						div.appendChild(document.createTextNode(" - "));	
						div.appendChild(document.createTextNode(testo));			
						div.appendChild(document.createElement('br'));
						div.appendChild(document.createElement('br'));
						div.appendChild(link);
						
						newsPubblicate ++;
						}
					}
				//post successivo
				i++ ;
				
			}//end while
	}      
}
); 
	}    google.setOnLoadCallback(initialize);  
	











