function showdate(date){
	var mydate=new Date(date);
    var year = mydate.getYear();
    if (year < 1000)
     year += 1900;
    var day = mydate.getDay();
    var month = mydate.getMonth();
    var daym = mydate.getDate();
    if (daym < 10)
     daym = "" + daym;
    var dayarray = new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
    var montharray = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
    return dayarray[day] + ", " + daym + " de " + montharray[month] + " del " + year;
   }


$(document).ready(function(){
		Shadowbox.init({
			overlayColor : "#ffffff",
				overlayOpacity : 0.5
		});
		$("#videoLC span.hover").css("opacity","0");
		// on mouse over
		$("#videoLC span.hover").hover(function () {
			// animate opacity to full
			$(this).stop().animate({
				opacity: 1
			}, "slow");
		},
		// on mouse out
		function () {
			// animate opacity to nill
			$(this).stop().animate({
				opacity: 0
			}, "slow");
		});	
		
		var rssA = new Array(); 
		$.jGFeed('http://www.elblogdellorenteycuenca.com/feed/',function(feeds){  
		  if(!feeds){    
			  
			  return false;  
			}
		  	var entry = feeds.entries[0];
		  	rssA[0]={blog:'Corporativo', date:entry.publishedDate, url:'http://www.elblogdellorenteycuenca.com/', link:entry.link, titulo:entry.title };
		  	$.jGFeed('http://www.dmasillorenteycuenca.com/feed/',function(feeds){  
				  if(!feeds){    
					  
					  return false;  
					}
				  	var entry = feeds.entries[0];
				  	rssA[1]={blog:'d+i', date:entry.publishedDate, url:'http://www.dmasillorenteycuenca.com/', link:entry.link, titulo:entry.title };
				  	$.jGFeed('http://www.blogdeasuntospublicos.com/feed/',function(feeds){  
						  if(!feeds){    
							  
							  return false;  
							}
						  	var entry = feeds.entries[0];
						  	rssA[2]={blog:'AAPP', date:entry.publishedDate, url:'http://www.blogdeasuntospublicos.com/', link:entry.link, titulo:entry.title };
						  	$.jGFeed('http://www.comunicacionyenergia.com/feed/',function(feeds){  
								  if(!feeds){    
									  
									  return false;  
									}
								  	var entry = feeds.entries[0];
								  	rssA[3]={blog:'Comunicación & Energía', date:entry.publishedDate, url:'http://www.comunicacionyenergia.com/', link:entry.link, titulo:entry.title };
								  	$.jGFeed('http://comunicareneres.com/feed/',function(feeds){  
										  if(!feeds){    
											  
											  return false;  
											}
										  	var entry = feeds.entries[0];
										  	rssA[4]={blog:'Reestructuraciones', date:entry.publishedDate, url:'http://comunicareneres.com/', link:entry.link, titulo:entry.title };
										  	$.jGFeed('http://www.comunicacionyrse.com/rss',function(feeds){  
												  if(!feeds){    
													  
													  return false;  
													}
												  	var entry = feeds.entries[0];
												  	rssA[5]={blog:'RSE', date:entry.publishedDate, url:'http://www.comunicacionyrse.com/', link:entry.link, titulo:entry.title };
												  	$.jGFeed('http://www.llyconline.com/feed/',function(feeds){  
														  if(!feeds){    
															  
															  return false;  
															}
														  	var entry = feeds.entries[0];
														  	rssA[6]={blog:'Online', date:entry.publishedDate, url:'http://www.llyconline.com/', link:entry.link, titulo:entry.title };
														  	rssA.sort(function(a, b){
														  		 var dateA=new Date(a.date), dateB=new Date(b.date);
														  		 return dateA-dateB ;//sort by date ascending
														  		});
																 for(var i=6; i>2; i--){
																	$("#divB"+i).find("a.aBlogsH").attr('href', rssA[i]["url"]);
															  		$("#divB"+i).find("a.aBlogsH").text("Blog " + rssA[i]["blog"]);
															  		$("#divB"+i).find("span").text(showdate(rssA[i]["date"]));
															  		$("#divB"+i).find("a.aBlogs1").attr('href', rssA[i]["link"]);
															  		$("#divB"+i).find("a.aBlogs1").text(rssA[i]["titulo"]);
															  		$("#divB"+i+" > div").removeClass("dLoading");
															  		$("#divB"+i+" > div *").fadeIn('slow');
																 }	
														}, 1);
												}, 1);
										}, 1);
								}, 1);
						}, 1);
				}, 1);
		}, 1);

	
	}); 

