// JavaScript Document
	
	var newspage = 1;
	var storypage = 1;
	

	Event.observe(window, "load", function() {
										   
		
		

//////////////////////////////////////////////////////////////////////////
//	NOTICIAS
//
		
		if (document.getElementById('news_next'))
		{
			updatenews();
			Event.observe('news_next', 'click', function(e) {
	
				newspage++;
				updatenews();
				
			});
		}
		
		if (document.getElementById('news_prev'))
		{
			Event.observe('news_prev', 'click', function(e) {
			
				if (newspage > 1) {
					newspage--;
					updatenews();
				}
	
			});
		}
//////////////////////////////////////////////////////////////////////////
//	HISTORIAS
//

		if (document.getElementById('story_next'))
		{
			
			updatestory();
			Event.observe('story_next', 'click', function(e) {
	
				storypage++;
				updatestory();
				
			});
		}
		
		if (document.getElementById('story_prev'))
		{
		
			Event.observe('story_prev', 'click', function(e) {
			
				if (storypage > 1) {
					storypage--;
					updatestory();
				}
	
			});
			
		}
		
				
	});
	
//////////////////////////////////////////////////////////////////////////
//	NOTICIAS
//
	function updatenews() {

		showLoading('news_content');
		
		var url = 'ajax/noticias.php';
		var pars = 'id=' + newspage; //+ id;
		var target = 'news_content';
		var myAjax = new Ajax.Updater(target, url, {method: 'get',	parameters: pars, onComplete: checknews});
	
	}
	
	function checknews() {
		
		if (Element.empty('news_content')) {
			
			newspage = 1;
			updatenews();
			
		}	
		
	}

//////////////////////////////////////////////////////////////////////////
//	HISTORIAS
//

	function updatestory() {

		showLoading('story_content');
		
		var url = 'ajax/stories.php';
		var pars = 'id=' + storypage; //+ id;
		var target = 'story_content';
		var myAjax = new Ajax.Updater(target, url, {method: 'get',	parameters: pars, onComplete: checkstory});
	
	}
	
	function checkstory() {
		
		if (Element.empty('story_content')) {
			
			storypage = 1;
			updatestory();
			
		}	
		
	}


function confirmBox(Url,Message) {
		  if (confirm(Message)) {
			document.location = Url;
		  }
	}
	
	function clearBox(box) {
		
		Element.update(box,'');
		
	}
	


/*
		FX FUNCTIONS
*/
	
	function showLoading(panel) {
		
		window.status = "Loading...";
		Element.update($(panel), '<img src="layout/loading.gif" />');
		
	}