function MM_controlSound(x, _sndObj, sndFile) { //v3.0
  var i, method = "", sndObj = eval(_sndObj);
  if (sndObj != null) {
    if (navigator.appName == 'Netscape') method = "play";
    else {
      if (window.MM_WMP == null) {
        window.MM_WMP = false;
        for(i in sndObj) if (i == "ActiveMovie") {
          window.MM_WMP = true; break;
      } }
      if (window.MM_WMP) method = "play";
      else if (sndObj.FileName) method = "run";
  } }
  if (method) eval(_sndObj+"."+method+"()");
  else window.location = sndFile;
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  document.location=selObj.options[selObj.selectedIndex].value;
  //eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");

  if (restore) selObj.selectedIndex=0;
}

function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
{
//alert("GenteIRC.com");
return false;
}
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
//alert("GenteIRC.com");
return false;
}
return true;
}

document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;



var brVer = parseInt(navigator.appVersion);
var agt=navigator.userAgent.toLowerCase();
var isNav  = ( (agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1) && (agt.indexOf('compatible') == -1) &&
               (agt.indexOf('opera') == -1) && (agt.indexOf('webtv') == -1) );
var isNav4up = (isNav && (brVer >= 4));
var isIe   = (agt.indexOf("msie") != -1);
var isIe4up = (isIe && (brVer >= 4));

function nokeys(e){
   if (document.layers || isNav4up){     // ***** Netscape
           return false;
   }

   if (document.all || isIe4up){        // ***** MSIE
      return false;
   }

}

if (document.layers || isNav4up){     // ***** Netscape
   //document.captureEvents(Event.MOUSEDOWN | Event.KEYPRESS);
   //document.onkeypress=nokeys;
}

if (document.all || isIe4up){        // ***** MSIE
   //document.onkeydown=nokeys;
}




function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}



function compruebabuscanicks (formi){
  while('' + formi.nick.value.charAt(0)==' ') formi.nick.value=formi.nick.value.substring(1,formi.nick.value.length);
  if (formi.nick.value.length ==0){
    return false;
  }
  return true;
}



function compruebabuscador(formi){
  while('' + formi.ciudad.value.charAt(0)==' ') formi.ciudad.value=formi.ciudad.value.substring(1,formi.ciudad.value.length);

  if ((formi.antiguedad.selectedIndex <1) && (formi.edad.selectedIndex <1) && (formi.sexo.selectedIndex <1) && (formi.pais.selectedIndex <1) && (formi.ciudad.value.length <1)){
    alert ("Debes seleccionar algún parámetro de búsqueda.");
    return false;
  }
  return true; 
}

function juega(letrai){
  document.formahorcado.letra.value=letrai;
  document.formahorcado.submit();
}










var form_enviao=0;
function mi_trim(cadena){
   sp_ini=0;
   do{
     if (cadena.charAt(0) == " "){
       cadena=cadena.substring(1,cadena.length);
     }else{
       sp_ini=1;
     }
   }while (sp_ini==0);     

   sp_ini=0;
   do{
     if (cadena.charAt(cadena.length-1) == " "){
       cadena=cadena.substring(0,cadena.length-1);
     }else{
       sp_ini=1;
     }
   }while (sp_ini==0);     

   return cadena;
}

function compruebaformforo(formi){
  //if ((formi.nick.value=="") || (mi_trim(formi.nick.value)=="")){
  //  alert("Debe indicar el nick");
  //  formi.nick.select();
  //  formi.nick.focus();
  //  return false;
 // }

  //if ((formi.email.value=="") || (mi_trim(formi.email.value)=="")){
  //  alert("Debe indicar el email");
  //  formi.email.select();
  //  formi.email.focus();
  //  return false;
  //}

  //k=isEmail(mi_trim(formi.email.value));
  //if (!k){
  //  alert("Escriba un E-Mail válido.");
  //  formi.email.select();
  //  formi.email.focus();
  //  return (false);
  //}

  if ((formi.titulo.value=="") || (mi_trim(formi.titulo.value)=="")){
    alert("Debe indicar el tema del mensaje");
    formi.titulo.select();
    formi.titulo.focus();
    return false;
  }

  if ((formi.mensaje.value=="") || (mi_trim(formi.mensaje.value)=="")){
    alert("Debe indicar el mensaje");
    formi.mensaje.select();
    formi.mensaje.focus();
    return false;
  }

  if (form_enviao==0){
    form_enviao=1;
    formi.Submit.disabled=true;
    return true;
  }else{
    return false;
  }
}

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}



function compruebaformfotoslocas(theForm){ 
  if (theForm.nick.value == ""){
    alert("Escriba un valor para el campo \"Nick\".");
    theForm.nick.focus();
    return (false);
  }

  if (theForm.nombre.value == ""){
    alert("Escriba un valor para el campo Nombre.");
    theForm.nombre.focus();
    return (false);
  }

  if (theForm.email.value == ""){
    alert("Escriba un valor para el campo email.");
    theForm.email.focus();
    return (false);
  }

  k=isEmail(theForm.email.value)
  if (!k){
    alert("Escriba un E-Mail válido.");
    theForm.email.select();
    theForm.email.focus();
    return (false);
  }

  if (theForm.fotoloca.value == ""){
    alert("Escoja la foto a enviar.");
    theForm.fotoloca.focus();
    return (false);
  }

  return (true);
}


function compruebaformhistorias(formi){
  //if (formi.nick.value ==""){
  //	alert("Debes indicar quien eres.");
  //	formi.nick.focus();
  //	return false;
  //}


 if (formi.titulo.value ==""){
	alert("Debes indicar el título de la historia.");
	formi.titulo.focus();
	return false;
  }

 if (formi.historia.value ==""){
	alert("Debes escribir la historia.");
	formi.historia.focus();
	return false;
  }

  return true;
}


var ventanaNovedad = null;
function  enviatexto(id){
	dire="?tipo=humor&p=imagenmail&id="+id;
	if (ventanaNovedad == null)
	    	ventanaNovedad = window.open(dire,"ventanaNovedad","width=630,height=350,titlebar=1")
  	else if (ventanaNovedad.closed)
    		ventanaNovedad = window.open(dire,"ventanaNovedad","width=630,height=350,titlebar=1")
  	else{
		ventanaNovedad.location=dire;
    		ventanaNovedad.focus();
	}
}



function compruebaformpiropos(formi){
 //if (formi.identificado.value ==0){
//	alert("Debes identificarte como usuario para enviar piropos.\nSolo los usuarios registrados pueden enviar.");
//	return false;
 // }

 //if (formi.de.value ==""){
	//alert("Debes indicar quien eres.");
	//formi.de.focus();
	//return false;
  //}


 if (formi.para.value ==""){
	alert("Debes indicar a quien va dirigido.");
	formi.para.focus();
	return false;
  }

 if (formi.piropo.value ==""){
	alert("Debes indicar el piropo.");
	formi.piropo.focus();
	return false;
  }

  return true;
}



function salta(item){
  //cati=item.options[item.selectedIndex].value;
  //document.saltito.cat.value=cati;<input type=hidden name=cat value="">
  document.saltito.submit();  
}



function compruebaformpostales(formulario)
{
	if (formulario.maild.value==""){
		alert("Debes introducir el mail del destinatario.");
		formulario.maild.focus();
		return false;
	}

	if (formulario.maild.value!="Email oculto" && !isEmail(formulario.maild.value)){
		alert("Debes introducir un email de destino válido.");
		formulario.maild.focus();
		return false;
	}

	if (formulario.mailr.value==""){
		alert("Debes introducir tu mail.");
		formulario.mailr.focus();
		return false;
	}

	if (! isEmail(formulario.mailr.value)){
		alert("Debes introducir un email válido en tu email.");
		formulario.mailr.focus();
		return false;
	}

	return true;
}



function vota(sexo, id, puntos, sesion) {
  dire="secciones/votos/sumames.php?sexo=" + sexo + "&id=" + id + "&puntos="+ puntos +"&SESSID="+sesion;
  window.open(dire,"ventanavotos","width=570,height=300,titlebar=1")
}



var ventanaPuntos = null;
function puntos(){
  if (document.formpuntos.mail.value.length > 0){
    dire="secciones/votos/puntos.php?mail="+document.formpuntos.mail.value;
    if (ventanaPuntos == null)
      ventanaPuntos = window.open(dire,"ventanaPuntos","width=470,height=300,titlebar=1")
    else if (ventanaPuntos.closed)
      ventanaPuntos = window.open(dire,"ventanaPuntos","width=470,height=300,titlebar=1")
    else{
        ventanaPuntos.location=dire;
        ventanaPuntos.focus();
    }
  }
}



var helpWindow2 = null;

function Privacidad() {
  if (helpWindow2 == null)
    helpWindow2 = window.open("secciones/registros/lopd.htm","helpWindow2","width=600,height=400,titlebar=1,scrollbars=yes")
  else if (helpWindow2.closed)
    helpWindow2 = window.open("secciones/registros/lopd.htm","helpWindow2","width=600,height=400,titlebar=1,scrollbars=yes")
  else
    helpWindow2.focus();
}

function CatGenMarked(listas) {   
  var catgen = new Array();
  if (catgen.length==0) return false;
  for (var x=0;x<listas.length;x++) {
    for (y=0;y<catgen.length;y++) {
      if (listas[x].value==catgen[y])
        if (listas[x].checked) {   
          return true;
        }
    }
  }      
       
  return false;
}

function miraespacios(cad){  
    var tienespacios=0;

    for (i=0; i<cad.length; i++){
      if (cad.charAt(i)==" ") tienespacios=1;
    }
    return tienespacios;  
}  



function compruebatufoto1(theForm){ 
  if (theForm.tipo1.value=="tufoto"){
    if (theForm.confoto.options[theForm.confoto.selectedIndex].value==1 &&  theForm.archivo.value == ""){
      alert("Debe escoger la foto a enviar.");
      theForm.archivo.focus();
      return (false);
    }
  }

  if (theForm.nick.value == ""){
    alert("Escriba un valor para el campo \"Nick\".");
    theForm.nick.focus();
    return (false);
  }

  if (theForm.tipo1.value=="tufoto"){
    if (theForm.clave.value == ""){
      alert("Teclee su clave personal.");
      theForm.clave.focus();
      return (false);
    }

    if (theForm.clave2.value == ""){
      alert("Teclee la confirmaión de la clave.");
      theForm.clave2.focus();
      return (false);
    }

    if (!(theForm.clave.value == theForm.clave2.value)){
      alert("Las claves no coinciden, tecleelas de nuevo.");
      theForm.clave.select();
      theForm.clave.focus();
      return (false);
    }
  }

  if (theForm.mailpri.value == ""){
    alert("Escriba un valor para el campo \"Email\".");
    theForm.mailpri.focus();
    return (false);
  }

  k=isEmail(theForm.mailpri.value)
  l=miraespacios(theForm.mailpri.value);
  if (!k || l){
    alert("Escriba un E-Mail válido.");
    theForm.mailpri.select();
    theForm.mailpri.focus();
    return (false);
  }

  if (theForm.mailpri2.value == ""){
    alert("Escriba un valor para el campo \"Confirmar Email\".");
    theForm.mailpri2.focus();
    return (false);
  }

  if (!(theForm.mailpri.value == theForm.mailpri2.value)){
    alert("Los emails no coinciden, tecleelos de nuevo.");
    theForm.mailpri.select();
    theForm.mailpri.focus();
    return (false);
  }

  if (theForm.diad.options[theForm.diad.selectedIndex].value == 0){
    alert("Debes seleccionar tu fecha de nacimiento.");
    theForm.diad.focus();
    return (false);
  }

  if (theForm.mesd.options[theForm.mesd.selectedIndex].value == 0){
    alert("Debes seleccionar tu fecha de nacimiento.");
    theForm.mesd.focus();
    return (false);
  }

  if (theForm.anod.options[theForm.anod.selectedIndex].value == 0){
    alert("Debes seleccionar tu fecha de nacimiento.");
    theForm.anod.focus();
    return (false);
  }

  d = new Date ( theForm.anod.options[theForm.anod.selectedIndex].value, (theForm.mesd.options[theForm.mesd.selectedIndex].value -1), theForm.diad.options[theForm.diad.selectedIndex].value );
  h= new Date();
  dif=(h-d)/1000/60/60/24/360;
  if (dif<16){
    alert("Debes ser mayor de 16 años para registrarte.");
    theForm.diad.focus();
    return (false);
  }
  
  if ((theForm.pais.options[theForm.pais.selectedIndex].value=="")){
    	alert("Debes seleccionar un país.");
	theForm.pais.focus();
	return(false);
  }

  if(theForm.provincia.options.length > 1){
    if ((theForm.provincia.options[theForm.provincia.selectedIndex].value=="")){
     	alert("Debes seleccionar una provincia.");
	theForm.provincia.focus();
	return(false);
    }
  }

  //comprueba que al menos hay señalada una lista de interés de Canalmail
  if (theForm.tipo1.value=="tufoto"){
    var numlistas=0;
    listas = document.formulario.elements['listas[]']; 
    if (listas){
      numlistas=listas.length;
    }

    // Comprueba que ha marcado alguna lista o categoría genérica
    if (!CatGenMarked(listas)){
      for (var k=0;k<numlistas;k++){
        if (listas[k].checked) break;
        if (k==listas.length-1){
          alert("Debe marcar alguna lista de interés.");
	  return false;
        }
      }
    }
  }
  if (theForm.tipo1.value=="tufoto"){
    //informacion para canalmail
    theForm.paisjsp.value=myPaises[theForm.pais.options[theForm.pais.selectedIndex].value];
    if(theForm.provincia.options.length > 1) theForm.provinciajsp.value=myProvincias[theForm.provincia.options[theForm.provincia.selectedIndex].value];

    if(theForm.anod.options[theForm.anod.selectedIndex].value<=1951){
	theForm.fec_ncto.value="'01-01-1951'"
    }else if(theForm.anod.options[theForm.anod.selectedIndex].value<=1966){
	theForm.fec_ncto.value="'01-01-1966'"
    }else if(theForm.anod.options[theForm.anod.selectedIndex].value<=1976){
	theForm.fec_ncto.value="'01-01-1976'"
    }else if(theForm.anod.options[theForm.anod.selectedIndex].value<=1985){
	theForm.fec_ncto.value="'01-01-1985'"
    }else{
	theForm.fec_ncto.value="'01-01-1985'"
    }
    theForm.email.value=theForm.mailpri.value;
    if (theForm.sexo.value==0){
      theForm.sexojsp.value='H';
    }else{
      theForm.sexojsp.value='M';
    }
  }

  if (theForm.tipo1.value=="tufoto"){
    theForm.confoto.disabled=false;
  }
  return (true);
}

function otra(yomismo){
  if ((yomismo.value=="1") ){
    document.formulario.otrared.select();
    document.formulario.otrared.focus();
  }
}

function compruebacambiapass(formi){
  if(formi.clavevieja.value==""){
    alert("Debes introducir la contraseña actual.");
    formi.clavevieja.focus();
    return false;
  }

  if(formi.clavenueva.value==""){
    alert("Debe introducir la clave nueva");
    formi.clavenueva.focus();
    return false;
  }

  if(formi.clavenueva.value != formi.clavenueva2.value){
    alert("Las claves nuevas no coinciden. Verifica que la hayas escrito bien");
    formi.clavenueva.focus();
    return false;
  }

  if(formi.clavenueva.value == formi.clavevieja.value){
    alert("La clave nueva debe ser distinta a la actual.");
    formi.clavenueva.focus();
    return false;
  }

  return true;
}


function compruebaenviapass(){
	if (document.formclaveolvidada.mail.value == ""){
		alert("Debes indicar tu mail para que te recordemos la contraseña.");
		document.formclaveolvidada.mail.focus();
		return false;
	}
	return true;
}


function setPointer(theRow, thePointerColor){

    p=document.getElementById(theRow);
    p.bgColor = thePointerColor;
    return true;
} 

function setPointer2(theRow, thePointerColor)
{
    if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') {
        return false;
    }

    var row_cells_cnt= theRow.cells.length;
    for (var c = 0; c < row_cells_cnt; c++) {
        theRow.cells[c].bgColor = thePointerColor;
    }

    return true;
} // end of the 'setPointer()' function


function compruebaformkedadas(theForm){
  if (theForm.canal.value == "" || theForm.canal.value == "#"){
    alert("Escriba un valor para el campo \"canal\".");
    theForm.canal.focus();
    return (false);
  }

  if ((theForm.red.options[theForm.red.selectedIndex].value== 0 )){
    	alert("Debes seleccionar una red.");
	theForm.red.focus();
	return(false);
  }
  if (theForm.comentario.value == ""){
    alert("Escriba la explicacion de su kedada.");
    theForm.comentario.focus();
    return (false);
  }
}


function favoritos(){
  bookmarkurl="http://www.genteirc.com/"
  bookmarktitle="GenteIRC.com"
  if (document.all)
    window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


function mClk(src){
  if(event.srcElement.tagName=='TD'){
    src.children.tags('A')[0].click();
  }
}



function emoticones(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function chat(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function abreventana(theURL,winName,features) { //v2.0
  //wink=window.open(theURL,winName,features);
  //if(wink==null){
  //  alert("Error abriendo la ventana. Verifica si tienes activo un bloqueador de popups.");
 // }
  wink=window.open(theURL,winName,features);
}






function popupclose(theURL,winName,features) { //v2.0
  //if (theURL != ""){
    window.open(theURL,winName,features);
  //}
}

function compruebaFormAyuda(formi){
	if(formi.consulta.options[formi.consulta.selectedIndex].value=="Escoge tu problema"){
		alert("Debes escoger una opción en \"Tipo de consulta\"");	
		return false;
	}
	if(formi.nick.value=="" || formi.mail.value=="" || formi.problema.value=="" || formi.asunto.value==""){
		alert("Debes rellenar todos los campos");	
		return false;
	}
	k=isEmail(formi.mail.value);
	l=miraespacios(formi.mail.value);
	if (!k || l){
		alert("Escriba un E-Mail válido.");
		formi.mail.select();
		formi.mail.focus();
		return (false);
	}
	return true;
	
}

function midiPlayer(id){
	document.write("<"+"embed name='CS1068863676640' src='http://"+document.location.host+"/fotos/e_fotos_postales/midi/"+id+".mid' loop='true'  autostart='true' hidden='true' width='0' height='0'"+" />");
}

function compruebaConfirmaBaja(){
	if (document.form1.mail.value == ""){
		alert("Debes indicar mail privado para confirmar la baja.");
		document.form1.mail.focus();
		return false;
	}
	if (document.form1.clave.value == ""){
		alert("Debes indicar tu Clave para hacer cambios.");
		document.form1.clave.focus();
		return false;
	}
	return true;
}

function compruebaModificaCambios(){
  if (document.form1.nom_archivo.value == ""){
    alert("Debes seleccionar la foto a enviar.");
    document.form1.nom_archivo.focus();
    return false;
  }
  return true;
}


function compruebaFormContactar(formi){
  if (formi.nombre.value ==""){
    alert ("Escribe tu nombre, por favor");
    formi.nombre.focus();
    return false;
  } 

  if (formi.email.value == ""){
    alert("Escriba su email, por favor");
    formi.email.focus();
    return (false);
  }

  k=isEmail(formi.email.value)
  l=miraespacios(formi.email.value);
  if (!k || l){
    alert("Escriba un E-Mail válido.");
    formi.email.select();
    formi.email.focus();
    return (false);
  }

}

function avisoVotosCreditos(formi, total){
	var puntos=parseInt(formi.puntos.value);
	if(puntos>total ||puntos<0 || isNaN(puntos)){
		alert("La cantidad de votos introducidos no es válida");
		return false;
	}
	if(puntos==total){
		if(confirm("¿Estás seguro que quieres agotar todos tus créditos en esta votación?\r\nSi los gastas todos de golpe, deberás recargar tu cuenta con un SMS para poder participar en la web, ya sea votando, dejando mensajes a los usuarios, o comentando en sus diferentes secciones. Recomendamos que no los gastes todos de una vez.")){
			return true;
		}else{
			return false;		
		}
	}
	return true;
}





function string_create_urls(input){

	return input.replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim,

		'<a href="$&" class="my_link" target="_blank">$&</a>').replace(/([^\/])(www[\S]+(\b|$))/gim,

		'$1<a href="http://$2" class="my_link" target="_blank">$2</a>');

}

function fecha(entry){
	var entrydate=new Date(entry.publishedDate);
	var entrydatestr=checkTime(entrydate.getDate())+"/"+checkTime(entrydate.getMonth()+1)+"/"+entrydate.getFullYear()+" "+checkTime(entrydate.getHours())+":"+checkTime(entrydate.getMinutes());
	return entrydatestr;
}

function checkTime(i){
	if (i<10) 
		{i="0" + i}
	return i
}

function grabThumb(thumbNodes) {
	var ti = 0;
	var node = thumbNodes[ti];
	var thumb = null;
	var attr = node.getAttributeNode("url");
	if (attr != null) {
		thumb = node.getAttributeNode("url").nodeValue;
	} else {
		thumb = node.firstChild.nodeValue;
	}
	return thumb;
};



function loadFlickr(activa) {
	if(userflicker!="" && activa) 
		document.getElementById("div_flicker").style.display='';
	var feedflicker = new google.feeds.Feed("http://api.flickr.com/services/feeds/photos_public.gne?id="+userflicker+"&format=rss2&lang=es_us");
	feedflicker.setNumEntries(50);
	feedflicker.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
	feedflicker.load(function(result) {
	        if (!result.error) {
	        	var html="";
				var container = document.getElementById("flicker");
				entries = result.feed.entries;
				if(result.feed.title!="Las fotos de todos" && result.feed.title!="Everyone's photos"){
					for (var i = 0; i < entries.length; i++) {
						var thumbUrl = null;
						var thumbNodes = google.feeds.getElementsByTagNameNS( entries[i].xmlNode, "http://search.yahoo.com/mrss/", "thumbnail");
						if (thumbNodes && thumbNodes.length > 0) {
							thumbUrl = grabThumb(thumbNodes);
						}
						html+="<li><a href=\""+entries[i].link+"\" target=\"_blank\"><img src=\""+thumbUrl+"\" alt=\"\" /></a></li>";
					}
					container.innerHTML="<ul id=\"listaFotosRanking\">"+html+"</ul>";
				}
				//if(html!="") document.getElementById("div_flicker").style.display='';
	        }else{
	        	document.getElementById("div_flicker").style.display='none';
	        }
	}
	)			
}


function loadYoutube(activa) {
	if(useryoutube!="" && activa) 
		document.getElementById("div_youtube").style.display='';
	
	var feedyt = new google.feeds.Feed("http://www.youtube.com/rss/user/"+useryoutube+"/videos.rss");
	feedyt.setNumEntries(50);
	feedyt.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
	feedyt.load(function(result) {
	        if (!result.error) {
	        	var html="";
				var container = document.getElementById("youtube");
				entries = result.feed.entries;
				for (var i = 0; i < entries.length; i++) {
					var thumbUrl = null;
					var thumbNodes = google.feeds.getElementsByTagNameNS( entries[i].xmlNode, "http://search.yahoo.com/mrss/", "thumbnail");
					if (thumbNodes && thumbNodes.length > 0) {
						thumbUrl = grabThumb(thumbNodes);
					}
					html+="<li><a href=\""+entries[i].link+"\" target=\"_blank\"><img src=\""+thumbUrl+"\" alt=\""+entries[i].title+"\" title=\""+entries[i].title+"\" /></a></li>";
				}
				container.innerHTML="<ul id=\"listaFotosRanking\">"+html+"</ul>";
				//if(html!="") document.getElementById("div_youtube").style.display='';
	        }else{
	        	document.getElementById("div_youtube").style.display='none';
	        }
	}
	)			
}


function loadTwitter(activa) {
	if(usertwitter!="" && activa) 
		document.getElementById("div_twitter").style.display='';
	var feed = new google.feeds.Feed("http://twitter.com/statuses/user_timeline/"+usertwitter+".rss");
	feed.setNumEntries(50);
	feed.load(function(result) {
		if (!result.error) {
			var container = document.getElementById("twitter");
			var entries=result.feed.entries;
			var html="";
			for(var i=0; i<entries.length; i++){
				var entry = entries[i];
				var titulo=String((entry.title)).substring(String(entry.title).indexOf(":")+1);
				html+="<b>"+fecha(entries[i])+"</b><br/>"+string_create_urls(titulo)+"<br/><br/>";
			}
			container.innerHTML=html;
		}else{
			document.getElementById("div_twitter").style.display='none';
		}
	}
	)
}

function loadDelicious(activa) {
	if(userdelicious!="" && activa) 
		document.getElementById("div_delicious").style.display='';
			
	var feeddelicious = new google.feeds.Feed("http://del.icio.us/rss/"+userdelicious);
	feeddelicious.setNumEntries(50);
	feeddelicious.load(function(result) {
		if (!result.error) {
			var container = document.getElementById("delicious");
			var entries=result.feed.entries;
			var html="";
			for(var i=0; i<entries.length; i++){
				var entry = entries[i];
				html+="<li><div class='numero'>"+checkTime(i+1)+"</div><a href=\""+entry.link+"\" target=\"_blank\">"+entry.title+"</a></li>";
			}
			container.innerHTML="<div id=\"historias\"><ul>"+html+"</ul></div>";
		}else{
			document.getElementById("div_delicious").style.display='none';
		}
	}
	)
}

var twitters=new Array();
function cargaTwitters(){
	for (var p in twitters) {
		getLastTwitter(p, twitters[p]);
	}
}

function getLastTwitter(iduser, usertwittermini) {
	if (usertwittermini != "") {
		var contenedor = document.getElementsByName("div_mitwitter" + iduser + "[]");
		for (var i = 0; i < contenedor.length; i++) {
			contenedor[i].style.display = '';
		}
		
		var feed = new google.feeds.Feed("http://twitter.com/statuses/user_timeline/" + usertwittermini + ".rss");
		feed.setNumEntries(1);
		feed.load(function(result){
			if (!result.error) {
				var entries = result.feed.entries;
				var html = "";
				for (var i = 0; i < entries.length; i++) {
					var entry = entries[i];
					//quiero eliminar el principio que es nombre:
					var titulo = String((entry.title)).substring(String(entry.title).indexOf(":") + 1);
					
					html += string_create_urls(titulo);
				//+"  - Enviado el "+fecha(entries[i]);
				}
				var container = document.getElementsByName("div_actual_twitter"+iduser+"[]");
				for (var i = 0; i < container.length; i++) {
					container[i].innerHTML = "<a href=\"http://twitter.com/" + usertwittermini + "\" target=\"_blank\" title=\"Twitter\"><img src=\"/imagenes/twitter_mini.gif\" alt=\"Twitter\" valign=\"center\"/ style=\"border:0\"></a> <small>" + html + "</small>";
				}
			}
			else {
				contenedor = document.getElementsByName("div_mitwitter"+iduser+"[]");
				for (var i = 0; i < contenedor.length; i++) {
					contenedor[i].style.display = 'none';
				}
			}
		})
	}
}


var saveStyle = ['position', 'width', 'height', 'opacity', 'filter', 'top', 'left', 'backgroundColor', 'visibility', 'display'];
var initialElements = [];

function finishFunc(elmentObj , FadeObj){
	//restauramos la posicion del eliminado
	if(initialElements.length>0){
		for (var i = 0; i < saveStyle.length; i++)
			elmentObj.style[saveStyle[i]] = initialElements[elmentObj.id][saveStyle[i]];
	}
	document.getElementById('div_twitter').style.display='none';
	document.getElementById('div_youtube').style.display='none';
	document.getElementById('div_flicker').style.display='none';
	document.getElementById('div_delicious').style.display='none';

	document.getElementById(activo).style.display='';
}
function activa_social(portal){
	if(activo!=portal){
		/*
		var el=document.getElementById(activo);
		initialElements[el.id]=[];
		for (var i = 0; i < saveStyle.length; i++){
			initialElements[el.id][saveStyle[i]] = Spry.Effect.getStyleProp(el, saveStyle[i]);
		}
		var fadeOut = new Spry.Effect.Slide(activo,{horizontal: true, toggle: false, finish:finishFunc});
		activo=portal;
		fadeOut.start();
		*/
		activo=portal;
		finishFunc(document.getElementById(portal) , null);
	}
	return false;
}

google.load("feeds", "1");
google.setOnLoadCallback(cargaTwitters);

