﻿/*/////////////////////////////////////////////////////////////
Combo Box code for Uguu~
Uses JS to dynamically load various functions inside the same widget.
Also includes the code for the DJ Box.
VERY specific user-unfriendly code.  But enough talk. Have at you!

Author: Nosgoroth (nosgoroth.com)
/////////////////////////////////////////////////////////////*/

////////////////Here there be user variables/////////////////
/////////////It's dangerous to go alone! Take this!/////////////

//Starting from 1, default combo box mode. Will show on page load. Djbox autoplays when it loads, so do NOT set it to its index (2).
var navbar_index = 1;
//Starting from 0, the index of the playlist that will autoplay
var defaultplindex = 1;
//Show corcho option (index number nine)
var showcorcho = true;
//Show a random qoute before the navbar
var showquote = true;
//Show options (index number eight)
var showcomboopts = false;
//Show a "not implemented" message in options menu.
var options_nonimplemented = true;
//Force corcho to show on page load. Overrides the setting of navbar_index.
var forcecorcho = true;
//Use a dropdown box to choose playlists. On false it uses a list of playlists with some dynamic javascript. Recommended true.
var ddmplselect = true;

//The notice. Escape html characters.
var corcho_string = "<p><strong>&iexcl;Bienvenidos a Uguu~!</strong> Tomad asiento, colocad vuestras bandejas en posici&oacute;n vertical y subid el volumen de vuestros altavoces.</p>";

//C'mon. Guess. I dare ya.
var quotes = 		[
					["Listen or be shot. Fail to listen and be shot again.", "Primer Mandamiento de la iglesia Nanohaista"],
					["Call me a devil... it just means I'll have to use my hellish powers to get you to listen!", "Takamachi Nanoha"],
					["Strawberry milk! Strawberry milk! Strawberry milk! Strawberry milk!", "Todo el mundo"],
					["All we have to do is find a t-t-t-time machine.", "Sakata Gintoki"],
					["Si no eres un poco egoísta no alcanzarás la felicidad.", "Katsura Hinagiku, que debería aplicarselo"],
					["The key point is whether or not the potential gains are proportional to the dangers.", "Craft Lawrence"],
					["<a href='http://uguu.es/blog/wp-content/plugins/wordspew/wordspew_archive.php?idfrom=1249575836&idto=1249575936'>ya ha empezao haruhi?</a>", "Eternal, llegando tarde al final del verano"],
					["From a foreigner's perspective, you're the foreigner. From an alien's perspective, you're the alien", "Gintama"],
					["Hace falta sacrificar algo para obtener algo a cambio. Este es el principio básico de la alquimia, el intercambio equivalente.",""],
					["I'm in despair! Being quoted has left me in despair!","Itoshiki Nozomu"],
					["I am the man that will pierce the heavens!","Simon"],
					["Don't believe in yourself! Believe in me who believes in you!","Kamina"],
					["Just according to keikaku*.","Yagami Light (*keikaku means plan)"],
					["Good Naruto, you look kinda cool.","Mala traducción + mal dibujo"],
					["NAMI, OMAE WA ORE NO NAKAMA DA!","Monkey D. Luffy"],
					["I have no interest in ordinary humans. If there are any aliens, time travelers, sliders, or espers here, come join me. That is all.","Suzumiya Haruhi"],
					["The world has not yet heard our answer.","Dragon"],
					["You rich bastards.","Haruhi"],
					["Sore wa himitsu desu~","Sore mo himitsu desu"],
					["¿Quieres ver a mi hija? Espera, tengo fotos.","Maes Hughes"],
					["We have entered an endless recursion of time.","Koizumi Itsuki, otra vez"],
					["No hay peces en este estanque, ¿verdad?",""],
					["Eh, soy el doctor Rodney McCay. Para lo improbable tardo segundos. ¿Para lo imposible? Minutos.",""],
					["42",""],
					];

//Highlighted posts
var nav_destarray = [
					["/blog/category/otros/recopilatorios-musicales-de-temporada/","<strong>Recopilaciones de OP/EDs de temporadas</strong>"],
					["/blog/category/otros/season-post/","Otros posts de temporada"],
					//["/blog/2009/05/28/premios-jukebox-p2k9-inauguracion-y-primer-enfrentamiento/","Torneo Jukebox primavera 2009"],
					//["/blog/2009/05/08/kanjimon-el-tutorial-de-inicio/","Kanjimon edici&oacute;n Uguu~ (tutorial)"],
					["/blog/haruhi-chan-churuya-san/","Todos los cap&iacute;tulos de Haruhi-chan y Churuya-san"],
					];

//Special posts and in-site links
var nav_sparray = 	[
					["http://uguu-web.com/wiki","<strong>Wikiyaki</strong>"],
					["/blog/categorias/","<strong>Categor&iacute;as</strong>"],
					["http://www.uguu-web.com/wiki/index.php?title=FAQ#Preguntas_y_respuestas","FAQ"],
					//["/blog/lista-de-emoticonos/","Lista de emoticonos"],
					["/blog/reviews/","Lista de reviews"],
					["/blog/posts-populares-top-100/","TOP100 posts populares"],
					["/blog/posts-impopulares-top-25/","TOP25 posts menos vistos"],
					//["/blog/useronline/","Usuarios online ahora"],
					["/blog/plugins-de-wordpress-en-uso/","Plugins activos"],
					["/img/system2/mainheader/gallery.php","Galer&iacute;a de cabeceras"],
					["/img/system/mainheader/gallery.php","Galer&iacute;a de cabeceras antiguas"],
					//["/bin/collabtweet/","Collabtweet (s&oacute;lo editores)"],
					["/foro/","Uguu~ foro (en desuso)"],
					];
					
//Blogroll. Leave link string empty to create a category separation.
var nav_blogroll = 	[
					["","Descarga y visionado:"], /////////////
					["http://tokyotosho.info","Tokyo Toshokan"],
					["http://mangahelpers.com","Mangahelpers"],
					["http://crunchyroll.com","Crunchyroll"],
					["http://anime-stop.webs.com/","Anime-stop"],
					["http://www.youtube.com/FMABrotherhood","Canal de Youtube de FMA Brotherhood"],
					["","Informaci&oacute;n:"], ///////////
					["http://www.animenewsnetwork.com/","Anime News Network - ANN"],
					["http://www.moetron.com/","Moetron"],
					["http://zepy.momotato.com/","Canned Dogs"],
					["http://www.misiontokyo.com/","Misi&oacute;n Tokyo"],
					["http://saoblog.laventanadesaouri.com/","La ventana de Saouri"],
					["","Enlaces varios:"], ////////////
					["http://www.vandal.net/foro/15/mangaanime/","Foro de anime de Vandal"],
					["http://xkcd.com","xkcd"],
					["","P&aacute;ginas amigas:"], ///////////
					["http://www.reinayu.net/","Reina Yu (Yunita en jap&oacute;n)"],
					["http://www.graffit.info/","Graffit"],
					["http://papayasigh.wordpress.com/","Papayas y empanadas"],
					["http://thunderboxbeta.blogspot.com/","Thunderbox.beta"],
					["","Uguu~ en los intertubos"], ///////////
					["http://twitter.com/UguuOnline","Uguu~ en Twitter (@UguuOnline)"],
					["http://twitter.com/Mitheor","@Mitheor en Twitter"],
					["http://twitter.com/Nosgoroth","@Nosgoroth en Twitter"],
					["http://mitheor.com/blog","Blog de Mitheor"],
					["http://blog.nosgoroth.com","Blog de Nosgoroth"],
					];
					
//Array of playlists. Elements are label, playlist url, playlist folder url.
//   Leave playlist url empty to create a category.
//   Leave playlist folder url empty to omit folder option for that playlist.
var playlistarray =	[
					["temporadas 2010",
						'',
						''],
					["invierno 2010",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=invierno2010',
						'http://www.uguu-web.com/luffink/musica/invierno2010/'],
					["primavera 2010",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=primavera2010',
						'http://www.uguu-web.com/luffink/musica/primavera2010/'],
					
					["temporadas 2009",
						'',
						''],
					["invierno 2009",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=invierno',
						'http://www.uguu-web.com/luffink/musica/invierno/'],
					["primavera 2009",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=primavera2009',
						'http://www.uguu-web.com/luffink/musica/primavera2009/'],
					["verano 2009",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=verano2009',
						'http://www.uguu-web.com/luffink/musica/verano2009/'],
					["oto&ntilde;o 2009",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=otono2009',
						'http://www.uguu-web.com/luffink/musica/otono2009/'],

					["torneos jukebox",
						'',
						''],
					["2009",
						'http://uguu-web.com/luffink/musica/_playlists/jukebox2009.xml',
						''],

					["espec&iacute;ficas",
						'',
						''],
					["one piece ost",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=_albums/one_piece_ost',
						'http://www.uguu-web.com/luffink/musica/_albums/one_piece_ost/'],
					["gintama",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=_albums/gintama',
						'http://www.uguu-web.com/luffink/musica/_albums/gintama/'],
					["macross frontier",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=_albums/MacrossF',
						'http://www.uguu-web.com/luffink/musica/_albums/MacrossF/'],
					["s.haruhi no gensou",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=_albums/Suzumiya_Haruhi_no_Gensou',
						'http://www.uguu-web.com/luffink/musica/_albums/Suzumiya_Haruhi_no_Gensou/'],
					["k-on! ost",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=_albums/k-on_ost',
						'http://www.uguu-web.com/luffink/musica/_albums/k-on_ost/'],
					["shikata akiko",
						'http://uguu-web.com/luffink/musica/_playlists/shikata_akiko.xml',
						''],
					["basquash!",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=_albums/Basquash',
						'http://www.uguu-web.com/luffink/musica/_albums/Basquash/'],
					["ttgl lagann-hen",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=_albums/ttgl_lagann-hen',
						'http://www.uguu-web.com/luffink/musica/_albums/ttgl_lagann-hen/'],
					["twewy",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=_albums/TWEWY',
						'http://www.uguu-web.com/luffink/musica/_albums/TWEWY/'],
					
					["otros",
						'',
						''],
					["instrumental",
						'http://files.nosgoroth.com/playlist.php?subdir=music/nosgoplaylist',
						'http://files.nosgoroth.com/music/nosgoplaylist/'],
					["vocaloid",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=vocaloid',
						'http://www.uguu-web.com/luffink/musica/vocaloid/'],
					["remixes",
						'http://www.uguu-web.com/luffink/playlist.php?subdir=remixes',
						'http://www.uguu-web.com/luffink/musica/remixes/'],
					["varios",
						'http://www.uguu-web.com/playlist.php?subdir=Media/Audio',
						'http://www.uguu-web.com/Media/Audio/'],
					];











///////////////////One-time changes//////////////////



//Width and height of the popup djbox player.
var playerpopupwidth = 375;
var playerpopupheight = 375;

//Tweetboard user
var tb_defaultuser = "nosgoroth";

//The html to embed the calendar.
var calendarstring = '<iframe src="https://www.google.com/calendar/embed?showTitle=0&amp;showNav=0&amp;showDate=0&amp;showPrint=0&amp;showTabs=0&amp;showCalendars=0&amp;showTz=0&amp;mode=AGENDA&amp;height=250&amp;wkst=2&amp;hl=es&amp;bgcolor=%23F2F4FC&amp;src=8elp2dffrbbecckt2gba3r4b5s%40group.calendar.google.com&amp;color=%23AB8B00&amp;ctz=Europe%2FMadrid" style=" border-width:0 " width="275" height="250" frameborder="0" scrolling="no"></iframe>';



//Translation changes

//Item names for combo navbar options.
var combonavbar_itemnames = [
							"", //NULL (0)
							"nada", //1
							"dj box", //2
							"event", //3
							"posts", //4
							"links", //5
							"", //NOT USED (6)
							"", //NOT USED (7)
							"opts", //8
							"msg", //9
							];

//////////////////////////////////////////////////////////
///////////////////Here there be dragons///////////////////
////////////////No user variables from now on////////////////

/////////////Not my functions//////////////////////////////

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    };
  }
}

function geturltext(url) {
        var req = new XMLHttpRequest();
        if (!req) {
            throw new Error('XMLHttpRequest not supported');
        }
        if (!(/^http/).test(url)) { // Allow references within or below the same directory (should fix to allow other relative references or root reference; could make dependent on parse_url())
            url = that.window.location.href + '/' +url;
        }
        req.open("GET", url, false);
        req.send(null);
        return req.responseText;
    };

///////My common functions////////////////////////////////

function uguu_cboxopthilight(index,bgcolor,textcolor) {
	if (bgcolor) { combonavbar_itemnames[index] = "<span style='background-color:"+bgcolor+"'>" + combonavbar_itemnames[index] + "</span>"; }
	if (textcolor) { combonavbar_itemnames[index] = "<span style='color:"+textcolor+"'>" + combonavbar_itemnames[index] + "</span>"; }
}

function nCreateLink(link,label) {
	return "<span style='cursor:pointer;' onclick='"+link+"'>"+label+"</span>";
}

///////////////////MAIN CODE////////////////////////////

///////////////First run vars
var ispopup = false;
var tb_isloaded = false;
if (showcorcho && forcecorcho) { navbar_index=9; }
quote_index = Math.floor(Math.random() * quotes.length);

function uguu_openpopup() {
	URL="http://uguu.es/blog/djbox/";
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+playerpopupwidth+",height="+playerpopupheight+"');");

}
//Hide 
function uguu_hidevideosidebar() {
	document.getElementById('videosidebarfooter').innerHTML = "";
	document.getElementById('videosidebarmain').innerHTML = "";
}
//Handles the dropdown menu action for playlists. A shorthand funcion.
function uguu_ddmplhandler() {
	var index = document.djboxddform.ddmmenu.options[document.djboxddform.ddmmenu.selectedIndex].value;
	if (playlistarray[index][1]!="") { uguu_showvideosidebar(index); }
}
//Shows the footer. Can be called in expanded or contracted mode. Current is the current playlist's index.
function uguu_showvideofooter(current,expand) {	
	var code = "";
	var temp = "";
	if (ddmplselect) {
		code = "<form name='djboxddform'><small>Playlist: <select name='ddmmenu'>";
		for (var i=0; i<playlistarray.length; i++) {
			code = code + "<option ";
			if (i==current) {
				code = code + "selected ";
			}
			if (playlistarray[i][1]=="") { temp="-----"+playlistarray[i][0]+"-----"; } else { temp="&nbsp;&nbsp;&nbsp;"+playlistarray[i][0]; }
			code = code + "value='"+i+"'>"+temp+"</option>";
		}
		code = code + "</select><input type='button' value='cargar' onclick='uguu_ddmplhandler();' /></small></form>";
		defaultplindex=current;
	} else {
		if (expand) {
			code = "<small>Playlists: ";
			for (var i=0; i<playlistarray.length; i++) {
				if (playlistarray[i][1]!="") {
					if (i==current) {
						code = code + "<strong>"+playlistarray[i][0]+"</strong>";
					} else {
						code = code + "<span onclick='uguu_showvideosidebar("+i+");'>"+playlistarray[i][0]+"</span>";
					}
					if (i!=(playlistarray.length-1)) {
						code = code + " | ";
					}
				}
			}
			code = code + " [<span onclick='uguu_showvideofooter("+current+",false);'>menos</span>]";
			code = code + "</small><br/>";
		} else {
			if (!current) { current=0; }
			code = "<small>Reproduciendo playlist "+current+" (<strong>"+playlistarray[current][0]+"</strong>) [<span onclick='uguu_showvideofooter("+current+",true);'>m&aacute;s</span>]</small><br/>";
			defaultplindex=current;
		}
	}
	
	var plcalltemp=playlistarray[current][1];
	plcalltemp=plcalltemp.replace("%3F","?");
	plcalltemp=plcalltemp.replace("%3D","=");
	var str_opts = "<small>[ ";
	if (ispopup) {
		str_opts += nCreateLink('window.close();',"cerrar");
		str_opts = str_opts + " | <a href='http://uguu.es/blog'>uguu~</a>";
	} else {
		str_opts += nCreateLink('uguu_navbar_showcontent(1);',"cerrar");
		str_opts += " | "+nCreateLink('uguu_openpopup(); uguu_navbar_showcontent(1);',"popup");
	}
	if (playlistarray[current][2]!="") { str_opts = str_opts + " | <a href='"+playlistarray[current][2]+"'>carpeta</a>"; }
	str_opts = str_opts + " | <a href='http://blog.nosgoroth.com/autogenerando-una-playlist-para-un-directorio/'>c&oacute;digo</a>";
	str_opts = str_opts + " | <a href='http://uguu.es/blog/2009/04/23/season-jukebox-musica-en-la-barra-lateral/'>m&aacute;s info</a> ]</small><br/>";
	
	var str_powered = "<small><span style='color:grey'>powered by flash, php, javascript & luffink</span></small><br/>";
	
	document.getElementById('videosidebarfooter').innerHTML = code + str_opts + str_powered;
}
//Loads the footer with the playlist list contracted and loads the flash player
function uguu_showvideosidebar(current) {
	uguu_showvideofooter(current,false);
	uguu_loadsidebarflashplayer(playlistarray[current][1]);
}
//Loads the flash player. Takes the playlist location as parameter.
function uguu_loadsidebarflashplayer(playlistcall) {
	var playerwidth=0;
	var plheight=0;
	var plcalltemp=playlistcall;
	if (ispopup) {
		playerwidth=playerpopupwidth-50;
		plheight=playerpopupheight-125;
	} else {
		playerwidth=275;
		plheight=155;
	}
	plcalltemp=plcalltemp.replace("?","%3F");
	plcalltemp=plcalltemp.replace("=","%3D");

	document.getElementById('videosidebarmain').innerHTML = "<small>Cargando el reproductor...<br/>Si el reproductor no carga comprueba que tengas flash instalado y que no uses un navegador anticuado como IE6.<br/>---</small><br/>";
	var sidebarfplayer = new SWFObject("http://uguu.es/blog/wp-content/plugins/flash-video-player/mediaplayer/player.swf","n0s",playerwidth,50+plheight,"7");
	sidebarfplayer.addParam("allowfullscreen","true");
	sidebarfplayer.addParam("allowscriptaccess","always");
	sidebarfplayer.addParam("wmode","opaque");
	sidebarfplayer.addParam("bgcolor","#F2F4FC");
	sidebarfplayer.addVariable("id","n0s");
	sidebarfplayer.addVariable("controlbar","bottom");
	sidebarfplayer.addVariable("height",50+plheight);
	sidebarfplayer.addVariable("playlist","bottom");
	sidebarfplayer.addVariable("playlistsize",plheight);
	sidebarfplayer.addVariable("skin","http://uguu.es/blog/wp-content/plugins/flash-video-player/skins/overlay/overlay.swf");
	sidebarfplayer.addVariable("width",playerwidth);
	sidebarfplayer.addVariable("autostart","true");
	sidebarfplayer.addVariable("bufferlength","1");
	sidebarfplayer.addVariable("displayclick","play");
	sidebarfplayer.addVariable("icons","true");
	sidebarfplayer.addVariable("linktarget","_blank");
	sidebarfplayer.addVariable("mute","false");
	sidebarfplayer.addVariable("quality","false");
	sidebarfplayer.addVariable("repeat","list");
	sidebarfplayer.addVariable("resizing","true");
	sidebarfplayer.addVariable("shuffle","true");
	sidebarfplayer.addVariable("stretching","uniform");
	sidebarfplayer.addVariable("volume","100");
	sidebarfplayer.addVariable("plugins", "googlytics-1");
	sidebarfplayer.addVariable("backcolor","0xF2F4FC");
	sidebarfplayer.addVariable("frontcolor","0x0066BB");
	sidebarfplayer.addVariable("lightcolor","0x2434A6");
	sidebarfplayer.addVariable("aboutlink","http://www.longtailvideo.com/players/");
	sidebarfplayer.addVariable("file",plcalltemp);
	sidebarfplayer.write("videosidebarmain");
}
//Show the navbar
function uguu_navbar_show() {
	var code = "";
	for (var i=0; i<combonavbar_itemnames.length; i++) {
		if (combonavbar_itemnames[i]!="") {
			if (i==8 && !showcomboopts) { continue; }
			if (i==9 && !showcorcho) { continue; }
			if (code=="") {
				code = "<small>[ ";
			} else {
				code += " | ";
			}
			if (navbar_index==i) {
				code += "<strong>"+combonavbar_itemnames[i]+"</strong>";
			} else {
				code += nCreateLink('uguu_navbar_showcontent('+i+');',combonavbar_itemnames[i]);
			}
		}
	}
	code = code + " ]</small>";
	if (showquote) { code = uguu_getquote() + code; }
	if (ispopup) { code = ""; }
	document.getElementById('lists_navbar').innerHTML = code;
}
//Show the combo content as specified by the navbar
function uguu_navbar_showcontent(index) {
	var code = "";
	var i = 0;
	navbar_index = index;
	
	if (ispopup) { navbar_index=2; }
	
	uguu_navbar_show();
	
	if (navbar_index==1) {
		uguu_hidevideosidebar();
		document.getElementById('lists_content').innerHTML = "";
	} else if (navbar_index==2) {
		code = "";
		document.getElementById('lists_content').innerHTML = code;
		uguu_showvideosidebar(defaultplindex);
	} else if (navbar_index==3) {
		uguu_hidevideosidebar();
		code = calendarstring;
		document.getElementById('lists_content').innerHTML = code;
	} else if (navbar_index==4) {
		uguu_hidevideosidebar();
		code = code + "<br/><br/>Posts destacados:<ul>";
		for (i=0; i<nav_destarray.length; i++) {
			code = code + "<li><a href='"+nav_destarray[i][0]+"'>"+nav_destarray[i][1]+"</a></li>";
		}
		code = code + "</ul><br/>P&aacute;ginas especiales:<ul>";
		for (i=0; i<nav_sparray.length; i++) {
			code = code + "<li><a href='"+nav_sparray[i][0]+"'>"+nav_sparray[i][1]+"</a></li>";
		}
		code = code + "</ul>";
		document.getElementById('lists_content').innerHTML = code;
	} else if (navbar_index==5) {
		uguu_hidevideosidebar();
		code = code + "<br/><ul>";
		for (i=0; i<nav_blogroll.length; i++) {
			if (nav_blogroll[i][0]=="") {
				code += "</ul><br/>"+nav_blogroll[i][1]+"<ul>";
			} else {
				code += "<li><a href='"+nav_blogroll[i][0]+"'>"+nav_blogroll[i][1]+"</a></li>";
			}
		}
		code = code + "</ul><p><small>Pod&eacute;is sugerir nuevos enlaces o reportar enlaces rotos en el grit&oacute;metro de aqu&iacute; abajo.</small></p>";
		document.getElementById('lists_content').innerHTML = code;
	} else if (navbar_index==6) {
		uguu_hidevideosidebar();
		code = code + "<?php jal_democracy(); ?>";
		document.getElementById('lists_content').innerHTML = code;
	} else if (navbar_index==8) {
		uguu_hidevideosidebar();
		if (options_nonimplemented) {
			code = code + "<small><br/>No implementado a&uacute;n.";
			code += "<br/>"+nCreateLink("uguu_navbar_showcontent(1);","&laquo; Ocultar mensaje");
			code = code + "</small>";
		} else {
			code = code + "<small>";
			code += "<br/>Comportamiento de la combo box al cargar la p&aacute;gina:";
			//So yeah, the cookie function doesn't even exist yet.
			code += "<br/>"+nCreateLink("uguu_navbar_setcookie(99);","&laquo; Comportamiento normal");
			code += "<br/>"+nCreateLink("uguu_navbar_setcookie(1);","&laquo; Cerrada");
			code += "<br/>"+nCreateLink("uguu_navbar_setcookie(3);","&laquo; Abrir calendario");
			code += "<br/>"+nCreateLink("uguu_navbar_setcookie(4);","&laquo; Mostrar posts destacados y p&aacute;ginas especiales");
			code += "<br/><br/>Al seleccionar la dj box:";
			code += "<br/>"+nCreateLink("uguu_navbar_setcookie(1);","&laquo; Cargar en la combo box (default)");
			code += "<br/>"+nCreateLink("uguu_navbar_setcookie(2);","&laquo; Abrir en un popup");
			code += "<br/><br/>Comportamiento del Tweetboard:";
			code += "<br/>"+nCreateLink("uguu_navbar_setcookie(1);","&laquo; Cargar al inicio (default)");
			code += "<br/>"+nCreateLink("uguu_navbar_setcookie(2);","&laquo; No cargar");
			code += "<br/>"+nCreateLink("uguu_load_tweetboard("+tb_defaultuser+");","&laquo; Cargar ahora");
			code += "<br/><br/>(En desarrollo; aun no funciona)";
			code = code + "</small>";
		}
		airingwarning();
		document.getElementById('lists_content').innerHTML = code;
	} else if (navbar_index==9) {
		uguu_hidevideosidebar();
		code = corcho_string;
		code = code + "<small>";
		code += nCreateLink("uguu_navbar_showcontent(1);","&laquo; Ocultar mensaje");
		code = code + "<br/>";
		code += nCreateLink("uguu_navbar_showcontent(2);","&laquo; Escuchar m&uacute;sica");
		code = code + "<br/>";
		code += nCreateLink("uguu_navbar_showcontent(3);","&laquo; Ver el calendario de eventos");
		code = code + "<br/>";
		code += nCreateLink("uguu_navbar_showcontent(4);","&laquo; Ver posts destacados y p&aacute;ginas especiales");
		code = code + "<br/>";
		code += nCreateLink("uguu_navbar_showcontent(5);","&laquo; Ver lista de enlaces externos");
		code = code + "</small>";
		document.getElementById('lists_content').innerHTML = code;
	}
}

function uguu_load_tweetboard(tbuser) {
	var thescript = document.createElement('script');
	thescript.setAttribute('type','text/javascript');
	thescript.setAttribute('src','http://tweetboard.com/tb.js?v=1.0&user='+tbuser);
	document.getElementsByTagName('body')[0].appendChild(thescript);
}

function uguu_getquote() {
	quotetext = '"'+quotes[quote_index][0]+'"';
	if (quotes[quote_index][1]!="") { quotetext = quotetext + ' - <span style="font-size:0.9em; font-style:italic;">'+quotes[quote_index][1]+'</span>'; }
	quotetext = "<div style='background-color:#fffff5; border:1px dotted gray; width:98%;' bgcolor='#ffffff'><span style='font-size:0.9em;'>"+quotetext+"</span></div>";
	return quotetext;
}

function airingwarning() {
	var filecontents = geturltext("http://uguu.es/lib/rssparse/rsswrap.php?rssurl=http://www.mahou.org/Showtime/Showtime.rss&id=mahou");

	listlen=0;
	code="";
	code+="Series de emisión inminente:";
	code+="<div style='background-color:#e1ffe0; border:1px dotted black; width:98%;' bgcolor='#ffffff'><ul>";
	
	s=filecontents.split('\n');
	for(i=0;i<s.length;i++){
		text=s[i];
		if (!(/list is blank/gi).test(text) && !(/cache update/gi).test(text) && (/[^\s]/).test(text)) {
			title = text.replace(/.*-(\s+)(.+?) Station:.*/gi,"$2");
			time = text.replace(/(.*?)\s+-.*/gi,"$1");
			station = text.replace(/(.+)Station:(\s+)(.+?)(\s+)Airtime.*/gi,"$3");
			if (time=="") { time="Ahora"; }
			code+="<li>"+title+" ("+time+", "+station+")</li>";
			listlen++;
		}
	}
	code+="</ul></div><br/>";
	//code+="</ul>";
	if (listlen==0) { code=""; }
	document.getElementById('combo_airing').innerHTML = code;
}


function run_every_minute() {
	//airingwarning();
}


function run_every_5minutes() {
	
}

//Specify events on page load.
var interval1;
var interval5;
addLoadEvent(function() {
///////////////CODE TO RUN ON PAGE LOAD///////////////
uguu_cboxopthilight(1,false,"gray");
uguu_cboxopthilight(8,false,"gray");
//////////////////////////////////////////////////////////
uguu_navbar_showcontent(navbar_index); //Start the combo box; better not comment this
//airingwarning();
interval1 = setInterval(run_every_minute, 60*1000);
interval5 = setInterval(run_every_5minutes, 5*60*1000);
//uguu_load_tweetboard(tb_defaultuser);
//if (confirm("El gritómetro no funciona; estamos arreglándolo. Disculpad las molestias.\n\n¿Visitar el feed de twitter de Uguu para ver el estado de la migración?")) {window.location.href="http://twitter.com/uguuonline";}
//////////////////////////////////////////////////////////
});
////////////////////////CODE END////////////////////////
