$(document).ready(function(){
	/* SETTINGS -- change these to suit your needs */
	/* RSS URLs *must* be on the same server as this file */
	var maxRSSItems = 5; // max number of items to display for each tab
	var noticiasURL = 'http://forums.tvxqperu.com/index.php?act=rssout&id=5';
	var imagenesURL = 'http://forums.tvxqperu.com/index.php?act=rssout&id=4';
	var videosURL = 'http://forums.tvxqperu.com/index.php?act=rssout&id=3';

	/* DO NOT EDIT BELOW HERE unless you know what you're doing! */
	/* TIME SWITCHER */
	var date = new Date();
	var hour = date.getHours();
	var time;

	if (hour >= 4 && hour < 12)
		time = 'morning';
	else if (hour >= 12 && hour < 20)
		time = 'afternoon';
	else
		time = 'night';

	$('body').attr('class', '').addClass(time);

	/* nav */
	$('#nav li').each(function(){
		var li = $(this);
		var span = li.find('span');

		li.mouseenter(function(){
			span.fadeIn();
		});
		li.mouseleave(function(){
			span.fadeOut();
		});
	});

	/* tabs */
	$('#informacion').tabs();

	$('#noticias, #imagenes, #videos').append('<ul></ul>');
	var noticiasList = $('#noticias ul');
	var imagenesList = $('#imagenes ul');
	var videosList = $('#videos ul');

	var num = 0;
	$.ajax({
		async: false,
		contentType: 'xml',
		url: noticiasURL,
		success: function(rss){
			$(rss).find('item').each(function(){
				if (num < maxRSSItems)
				{
					noticiasList.append('<li><a href="' + $(this).find('link').text() + '">' + $(this).find('title').text() + '</a></li>');
					num++;
				}
			});
		}
	});
	num = 0;
	$.ajax({
		async: false,
		contentType: 'xml',
		url: imagenesURL,
		success: function(rss){
			$(rss).find('item').each(function(){
				if (num < maxRSSItems)
				{
					imagenesList.append('<li><a href="' + $(this).find('link').text() + '">' + $(this).find('title').text() + '</a></li>');
					num++;
				}
			});
		}
	});
	num = 0;
	$.ajax({
		async: false,
		contentType: 'xml',
		url: videosURL,
		success: function(rss){
			$(rss).find('item').each(function(){
				if (num < maxRSSItems)
				{
					videosList.append('<li><a href="' + $(this).find('link').text() + '">' + $(this).find('title').text() + '</a></li>');
					num++;
				}
			});
		}
	});
});
