 // When the page is ready
   $(document).ready(function(){
	// Open the students.xml file
	$.get("noticias/noticias.xml",{},function(xml){
      	
		// Build an HTML string
		myHTMLOutput = '';
	 	myHTMLOutput += '<div class="box"><div class="box-header"></div><div class="box-content">';
	  	
		// Run the function for each news item tag in the XML file
		$('noticia',xml).each(function(i) {
			tituloNoticia = $(this).find("titulo").text();
			fechaNoticia = $(this).find("fecha").text();
			contenidoNoticia = $(this).find("contenido").text();
			
			// Build row HTML data and store in string
			mydata = BuildNoticiaHTML(tituloNoticia,fechaNoticia,contenidoNoticia);
			myHTMLOutput = myHTMLOutput + mydata;
		});
		myHTMLOutput += '</div> <div class="box-footer"></div></div> <!-- Box --> ';
		
		// Update the DIV called Content Area with the HTML string
		$("#noticias").append(myHTMLOutput);
		addiconExtenders();
		swapImagesCycle();
	});
	
     
   });   
   
   function BuildNoticiaHTML(tituloNoticia,fechaNoticia,contenidoNoticia){
	
	// Build HTML string and return
	output = '';
	output += '<div class="box-content-item"><div class="box-content-item-header">';
	output += '<h2>'+ fechaNoticia + '&nbsp;&nbsp;<span class="darkOrange">' +tituloNoticia+ '</span></h2></div>';
	output += ' <div class="clear"></div>';
	output += ' <div class="box-content-item-content">'+ contenidoNoticia +'</div>';
	output += '</div>';
	return output;
}

function addiconExtenders()
	{
		$(".box-content-item .box-content-item-content").hide();
     $(".box-content-item-header")
       .append("<a href=''><img class=\"expandIcon {src: 'images/minus.png'}\" src='images/plus.png' width='14' height='14' alt='expandir'></a>");
	   
	 $(".box-content-item-header a").click(function(event){
       $(this).parent("div").siblings(".box-content-item-content").toggle();
       
       // Stop the link click from doing its normal thing
       return false;
     });
	}
	
function swapImagesCycle()
{
	$('#homeSlideshow').cycle();
	$.swapImage(".swapImage");
	$.swapImage(".expandIcon", true, true, "click");
    
}
	