   // When the page is ready
   $(document).ready(function(){
	//Contact
	$("form").submit(function(){

		var str = $("form").serialize();

  		  $.ajax({
   	      type: "POST",
 		  url: "contacto/contact.php",
 		  data: str,
 		  success: function(msg){
    
		  $("#note").ajaxComplete(function(event, request, settings){

		  if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
		  {
			result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
			$("#fields").hide();
		  }
		  else
		  {
			result = msg;
		  }

		  $(this).html(result);

		  });

		  }

 		  });

		  return false;

	});
							  
	// 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");
    
}