$(document).ready(function()
{
//start of $(document).ready functions

	//xml parsing for "noticias" area
	var xmlDoc;
	loadxml();

	//Fade in of main img
	setTimeout(function (){
		$("#martin .martin_img").animate({opacity:'1'},2500)
	},1500);
	
	//Colorboxes for link "Galeria"
	$(".lightbox1").colorbox({iframe:'true',width:'680px',height:'570px'})
	//Colorboxes for link "Rosario-to-Homilias"
	$(".lightbox2").colorbox({html:'<embed width="95%" height="100%" name="plugin" src="martin/PDFs/biografia.pdf" type="application/pdf" pluginspage="http://get.adobe.com/reader/"/>',width:'80%',height:'80%'})
	$(".lightbox3").colorbox({html:'<embed width="95%" height="100%" name="plugin" src="martin/PDFs/oracion.pdf" type="application/pdf" pluginspage="http://get.adobe.com/reader/"/>',width:'80%',height:'80%'})
	
	//navigation menu
	$("#menu_nav a")
		.css( {backgroundPosition: "-20px 35px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-20px 94px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:200, complete:function(){
			$(this).css({backgroundPosition: "-20px 35px"})
		}})
	})
	
	$("#news .more").live("click",function(){
		var identifier = $(this).attr('id')
		$('#nbody'+identifier).animate({height:'100%'},1500)
		$(this).hide();
	});
	
//end of $(document).ready functions
});

function loadxml()
{
	if ($.browser.msie) {
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = false;
		xmlDoc.load("martin/noticias.xml");
		readXML();
	} else {
		xmlDoc = document.implementation.createDocument("","",null);
		xmlDoc.load("martin/noticias.xml");
		xmlDoc.onload = readXML;
	}
}

function readXML()
{
	var news = document.getElementById('news');
	
	var x = xmlDoc.getElementsByTagName('update');
	
	for (var i=x.length-1;i>=0;i--)
	{
		news.innerHTML += '<p class="title">' + x[i].getElementsByTagName('title')[0].childNodes[0].nodeValue + '</p>';
		news.innerHTML += '<p class="author">' + x[i].getElementsByTagName('author')[0].childNodes[0].nodeValue + '</p>';
		news.innerHTML += '<div class="nbody" id="nbody'+i+'">' + x[i].getElementsByTagName('nbody')[0].childNodes[0].nodeValue; + '</div>';
		news.innerHTML += '<div class="more" id="'+i+'">...ver mas</div>'
		news.innerHTML += '<br/>'
	} 
}

