﻿
var plM,plC,plD,plCp,plEL,plET;
var prM,prC,prD;
var glMensNuevos='',glMensAtaq='';
var glAtaquesVisGen='';
var glAliMarca='';
var glCompisMarca='';
var glNivelGO=0;
var glCronoRecursos=0;
var glEnVacaciones=0;
var glVotaOgarena=0;
var glDenuncias=0;
var glEstiloMarco=0;
var glTimeouts=new Array();
var glVerAvatares=0;
var glServerMinutTZ=0;
var glStaticWeb='';
var glContadores=0;
var glInterfaz=0;
var glNoticiasMarca='';
var glForo='http://s227990857.mialojamiento.es/foro';
var glNick='', glTop='';

function globalCompletado() { // Llamada por los contadores al acabarm, si linkCanc=JS
  glContadores--;
  if (glContadores) document.title=L_EVENTOS + " : " +formatNum(glContadores);
  else document.title=L_EVENTOS + ' : ' + L_COMPDO;
}
  

function enVacas() { return (glEnVacaciones!=0); }

function verAvatares() { return glVerAvatares; }

function skinSP(nombre,w,h) {
  if (typeof(w)=="undefined") w=50;
  if (typeof(h)=="undefined") h=50;
  if (!skin) return '<p style="'+(w ? 'width: '+w+'px; ':'')+(h ? 'height: '+h+'px; ':'')+'border-style: solid; border-color: #808080;">&nbsp;</p>';
  var ht;
  if (nombre=="asteroide") ht=glStaticWeb+"images/asteroide.gif";
  else ht=skin+'/planeten/small/s_'+nombre+'.jpg';
  return '<img src="'+ht+'"'+(w ? ' width="'+w+'"':'')+(h ? ' height="'+h+'"':'');
}

function skinP(nombre,w,h) {
  if (typeof(w)=="undefined") w=75;
  if (typeof(h)=="undefined") h=75;
  if (!skin) return '*'; // Devolver vacío, problemas con el overlib
  var ht;
  if (nombre=="asteroide") ht=glStaticWeb+"images/asteroide.gif";
  else ht=skin+'/planeten/'+nombre+'.jpg';
  return '<img src='+ht+(w>0 ? ' width='+w:'')+(h>0 ? ' height='+h:'')+'>';
}

function popup(url, width, height, name)
{
	if (!name) { name = '_popup'; }
	window.open(url.replace(/&amp;/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes,width=' + width);
	return false;
}

function donar(bHTML) {
  if (typeof(bHTML)=="undefined") bHTML=false;
  var ht='<tr><th>'+LX_DONATXT+'</th></tr>\
<tr><th align="center">\
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">\
<input name="cmd" value="_s-xclick" type="hidden">\
<input name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----" type="hidden">\
<input src="'+glStaticWeb+'images/paypal.gif" name="submit" alt="PayPal / VISA" border="0" type="image">\
<img alt="" src="https://www.paypal.com/es_ES/i/scr/pixel.gif" border="0" height="1" width="1" id="imgPaypal">\
</form>\
<a href='+glForo+'/../sepomo.html" target="_blank" onclick="return popup(\''+glForo+'/../sepomo.html\',400,250,\'sepomo\');"><img src="'+glStaticWeb+'images/sms.gif" alt="Donar por SMS"></a><br>\
<a href="'+glForo+'/viewtopic.php?f=8&amp;t=6622" target="_blank" alt="Preguntas frecuentes">FAQ</a>\
</th></tr>';
  if (bHTML) return ht;
  else {
    document.getElementById('divContent').innerHTML='<br><br><br><br><br><table width=300>'+ht+'</table>';
    return false;
  }
}
  
function skinImg(nombreExt,txt,w,h,subDir,alt) {
  if (typeof(w)=="undefined") w=0;
  if (typeof(h)=="undefined") h=0;
  if (typeof(txt)=="undefined") txt='';
  if (typeof(subDir)=="undefined") subDir='images';
  if (typeof(alt)=="undefined") alt="";
  if (alt) alt=' alt="'+alt+'" title="'+alt+'"';
  if (subDir) subDir+='/';
  if (!skin) {
    if (txt) txt='<em>'+txt+'</em>';
    if (!w) {
      return '<span style="border-style: solid; border-color: #808080;"'+alt+'>'+(txt>'' ? txt:'&nbsp;')+'</span>';
    } else {
      return '<span style="width: '+w+'px; height: '+h+'px; border-style: solid; border-color: #808080;"'+alt+'>'+(txt>'' ? txt:'&nbsp;')+'</span>';
    }
  }
  if (!w) {
    return '<img border="0" src="'+skin+'/'+subDir+nombreExt+'"'+alt+'>';
  } else {
    return '<img border="0" src="'+skin+'/'+subDir+nombreExt+'" width="'+w+'" height="'+h+'"'+alt+'>';
  }
}

function skinGid(gid,mini,mastags) {
  var w=120,h=120,src;
  if (typeof(mastags)=="undefined") mastags="";
  if (mini) w=h=50;
  if (!skin) return '<p style="'+(w ? 'width: '+w+'px; ':'')+(h ? 'height: '+h+'px; ':'')+'border-style: solid; border-color: #808080;">&nbsp;</p>';
  if (gid==130 || gid==220 || gid==222 || gid==223 || gid>600 || (gid>=70 && gid<=99)) src=glStaticWeb+"images/"+gid+".gif";
  else src=skin+"/gebaeude/"+gid+".gif";
  return '<img border="0" src="'+src+'"'+(w ? ' width="'+w+'"':'')+(h ? ' height="'+h+'"':'')+(mastags ? ' '+mastags+' ':'')+'>';
}

function skinEM(dest) {
  return '<a href="writemessages.php?idUni='+idUni+'&messageziel='+dest+'">'+skinImg('m.gif','EM',0,0,"img",L_EM)+'</a>';
}

function haha(z1,ajax) {
  if (typeof(ajax)=="undefined") ajax=false;
  if (ajax) {
    ajaxAbre(z1.options[z1.selectedIndex].value);
  } else {
    eval("document.location='"+z1.options[z1.selectedIndex].value+"'");
  }
}

function ajaxAbre(u) {
  document.getElementById("ajax").innerHTML=
      "<iframe frameborder=1 src=\""+u+"\"></iframe>";
}

function votado(fool) {
  if (typeof(fool)=="undefined") {
    ajaxAbre("votaOgarena.php?idUni="+idUni);
  } else {
    ajaxAbre("votaOgarena.php?idUni="+idUni+"&fool");
  }
}

function gidName(gid) {
    return getGidTxt(gid);
}

function gidTipo(gid) {
	var i;
	i=getIGid(gid);
	if (i<0) {
			return "GID desconocido";
	} else {
		return gidsInfo[i][1];
	}
}

function formatNum(a,decs) {
  var stDecs="";
  var n=a;
	var t,r="",i;
  if (typeof(decs)=="undefined") decs=0;
  if (decs>0) {
    var d=Math.abs(n)-Math.floor(Math.abs(n));
    t=""+d;
    t=t.substr(2,decs);
    while (t>"") {
      stDecs+=L_MILES+t.substr(0,3);
      t=t.substr(3);
    }
    if (stDecs.length>1) stDecs=L_DECIMAL+stDecs.substr(1);
    else stDecs="";
  }
	if (n>0) n=Math.floor(n);
	else n=Math.ceil(n);
	t=(""+n).replace(/ /g,'');
	while (t>"") {
		i=t.length-3;
		if (i<0) i=0;
		r=t.substr(i,3) + (r=="" ? "":L_MILES) +r;
		t=t.substr(0,i);
	}
	if (r.substr(0,2)=='-'+L_MILES) r='-' + r.substr(2);
	return r+stDecs;
}

function formatNumColor(a) {
	if (a>=0) {
		return "<font color=lime>"+formatNum(a)+"</font>";
	}
	return "<font color=red>"+formatNum(a)+"</font>";
}

Date.prototype.format = function(format) {
	var returnStr = '';
	var replace = Date.replaceChars;
	for (var i = 0; i < format.length; i++) {
		var curChar = format.charAt(i);
		if (replace[curChar]) {
			returnStr += replace[curChar].call(this);
		} else {
			returnStr += curChar;
		}
	}
	return returnStr;
};

Date.replaceChars = {
	shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
	longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
	shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
	longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
	
	// Day
	d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); },
	D: function() { return Date.replaceChars.shortDays[this.getDay()]; },
	j: function() { return this.getDate(); },
	l: function() { return Date.replaceChars.longDays[this.getDay()]; },
	N: function() { return this.getDay() + 1; },
	S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); },
	w: function() { return this.getDay(); },
	z: function() { return "Not Yet Supported"; },
	// Week
	W: function() { return "Not Yet Supported"; },
	// Month
	F: function() { return Date.replaceChars.longMonths[this.getMonth()]; },
	m: function() { return (this.getMonth() < 11 ? '0' : '') + (this.getMonth() + 1); },
	M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; },
	n: function() { return this.getMonth() + 1; },
	t: function() { return "Not Yet Supported"; },
	// Year
	L: function() { return "Not Yet Supported"; },
	o: function() { return "Not Supported"; },
	Y: function() { return this.getFullYear(); },
	y: function() { return ('' + this.getFullYear()).substr(2); },
	// Time
	a: function() { return this.getHours() < 12 ? 'am' : 'pm'; },
	A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; },
	B: function() { return "Not Yet Supported"; },
	g: function() { return this.getHours() % 12 || 12; },
	G: function() { return this.getHours(); },
	h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); },
	H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
	i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
	s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
	// Timezone
	e: function() { return "Not Yet Supported"; },
	I: function() { return "Not Supported"; },
	O: function() { return (this.getTimezoneOffset() < 0 ? '-' : '+') + (this.getTimezoneOffset() / 60 < 10 ? '0' : '') + (this.getTimezoneOffset() / 60) + '00'; },
	T: function() { return "Not Yet Supported"; },
	Z: function() { return this.getTimezoneOffset() * 60; },
	// Full Date/Time
	c: function() { return "Not Yet Supported"; },
	r: function() { return this.toString(); },
	U: function() { return this.getTime() / 1000; }
};

function formatT(a) {
  var d,h,m,s;
  var t,tD,tH,tM,tS;
  d=Math.floor(a/86400);
  a-=d*86400;
  h=Math.floor(a/3600);
  a-=h*3600;
  m=Math.floor(a/60);
  s=Math.floor(a-m*60);
  tD=''; if (d>0) tD=d + " "+(d==1 ? L_DIA:L_DIAS)+",";
  tH=''; if (h>0 || (d>0 && (m>0 || s>0))) tH=h + " "+(h==1 ? L_HORA:L_HORAS)+",";
  tM=''; if (m>0 || ((d>0 || h>0) && (s>0))) tM=m + " "+(m==1 ? L_MINUTO:L_MINUTOS)+",";
  tS=''; if (s>0 || d+h+m+s==0) tS=s+" "+(s==1 ? L_SEGUNDO:L_SEGUNDOS)+",";
  t=tD+tH+tM+tS;
  if (t>'') {
    if (t.substr(t.length-1,1)==',') {
      t=t.substr(0,t.length-1);
    }
  }
  t=t.replace(/ /g,'&nbsp;');
  return t;
}

function formatT00(xA) {
  var d,h,m,s,t,a=xA;
  d=Math.floor(a/86400);
  a-=d*86400;
  h=Math.floor(a/3600);
  a-=h*3600;
  m=Math.floor(a/60);
  s=Math.floor(a-m*60);
  t=d>0 ? d+"d":"";
  t+=(h<10 ? "0":"")+h+":"+(m<10 ? "0":"")+m+":"+(s<10 ? "0":"")+s;
  return t;
}

function formatD(a,bServer) {
    var d=new Date();
    var fIni=new Date(2000,1,1);
    if (typeof(bServer)=="undefined") bServer=false;
    if (a<fIni.getTime()/1000) {
      a+=d.getTime()/1000;
      d.setTime(a*1000);
    } else {
      if (bServer) d.setTime((a+d.getTimezoneOffset()*60+glServerMinutTZ*60)*1000);
      else d.setTime(a*1000);
    }
    return d.toString();
}

function formatDcorta(a,bServer,base) {
    var ahora=new Date();
    var anyo=ahora.getFullYear();
    var d=new Date();
    var h,m,s;
    var r;
    if (typeof(bServer)=="undefined") bServer=false;
    if (typeof(base)=="undefined") d=new Date();
    else d.setTime(base.getTime());
    if (a=="") return "";
    a=parseInt(a);
    var fIni=new Date(2000,1,1);
    if (a<fIni.getTime()/1000) {
      a+=d.getTime()/1000;
      d.setTime(a*1000);
    } else {
      if (bServer) d.setTime((a+d.getTimezoneOffset()*60+glServerMinutTZ*60)*1000);
      else d.setTime(a*1000);
    }
    h=d.getHours();
    m=d.getMinutes();
    s=d.getSeconds();
    if (anyo==d.getFullYear()) r= d.format(L_FECCORT1);
    else r=d.format(L_FECCORT2);
    return r;
}

function contador(divId,secsFin,linkOk,linkCanc,autoRefr,bAjax) {
    var t=contadorSub(secsFin,linkOk,linkCanc,autoRefr,bAjax);
    try {
		  document.getElementById(divId).innerHTML=t;
		} catch (ex) { return; } // ha 'volao' el div
    var ahora=new Date(),fin=new Date();
    fin.setTime(secsFin*1000);
    if (!(ahora>=fin)) {
      glTimeouts[divId]=setTimeout("contador('"+divId+"',"+secsFin+",'"+linkOk+"','"+linkCanc+"',"+autoRefr+","+bAjax+")",1000);
    }
}

function contadorSub(secsFin,linkOk,linkCanc,autoRefr,bAjax) {
    var ahora=new Date(),fin=new Date();
    fin.setTime(secsFin*1000);
    if (ahora>=fin) {
        if (linkCanc=="JS") globalCompletado();
        if (linkOk>"") {
            if (autoRefr) {
              if (bAjax) { document.getElementById("ajax").innerHTML="<iframe frameborder=1 src=\""+linkOk+"\"></iframe>"; }
              else document.location.href=linkOk;
              return "Completado";
            } else {
              if (bAjax) return "<a href='#' onclick='"+linkOk+"'><font color=green>"+L_COMPDO+"</font></a>"
              else return "<a href='"+linkOk+"'><font color=green>"+L_COMPDO+"</font></a>";
            }
        } else {
            return L_COMPDO;
        }
    } else {
        var t=formatT00(secsFin-(ahora.getTime())/1000)+((linkCanc=='' || linkCanc=='JS') ? '':"<br><a href='"+linkCanc+"'><font color=red>"+L_CANCELAR+"</font></a>");
        return t;
    }
}

function mkCounter(divId,secsFin,linkOk,linkCanc,autoRefr,bAjax,bCheckVacas) {
		var fIni=new Date(2000,1,1),ahora= new Date();
		autoRefr=typeof(autoRefr)=="undefined" ? 0:(autoRefr ? 1:0);
		bAjax=typeof(bAjax)=="undefined" ? 0:(bAjax ? 1:0);
		if (secsFin<fIni.getTime()/1000) secsFin+=(ahora.getTime()/1000);
		if (typeof(bCheckVacas)=="undefined") bCheckVacas=0;
		if (bCheckVacas && glEnVacaciones) {
      return "<div id='"+divId+"'>"+contadorSub(secsFin,'','')+"</div>";
    } else {
      var llamada="contador('"+divId+"',"+secsFin+",'"+linkOk+"','"+linkCanc+"',"+autoRefr+","+bAjax+")";
      glTimeouts[divId]=setTimeout(llamada,500);
      return "<div id='"+divId+"'>"+contadorSub(secsFin,'','')+"</div>";
    }
}

function cola() {
    var ahora=new Date(),ah2F,bl2F=0,i,iOp;
    var bCambio=false;
    var sel=document.getElementById("selCola");
    var txt=document.getElementById("divCola");
    if (!sel) return;
    for (i=0;i<colaGids.length;i++) {
        if (!colaOps[i]) {
            sel.options[sel.length]=new Option(colaNums[i]+" "+gidName(colaGids[i]),i);
            colaOps[i]=1;
        }
    }
    ah2F=(colaFin.getTime()-ahora.getTime())/1000;
    for (i=colaGids.length-1;i>=0;i--) {
        stat=0;
        if (ah2F<bl2F) { // Ya pasado
            stat=-1;
        }
        bl2F+=colaT[i];
        if (!stat) {
            if (ah2F<bl2F) { // En produccion
                txt.innerHTML=L_ACTUAL+": " + gidName(colaGids[i])+" "+formatT00(ah2F-(bl2F-colaT[i]));
                txt.innerHTML+="<br>"+L_TTOTAL+": "+formatT00(ah2F);
                stat=1;
            } else {
                stat=2; // en espera
            }
        }
        if (stat!=colaOps[i]) bCambio=true;
        colaOps[i]=stat;
    }
    if (bCambio) {
        for (;sel.length;) sel.options[0]=null;
        for (i=iOp=0;i<colaGids.length;i++) {
            if (colaOps[i]>0) {
                sel.options[sel.length]=new Option(colaNums[i]+" "+gidName(colaGids[i])+" "+(colaOps[i]==1 ? "("+L_ENPROD+")":"("+L_ENESPERA+")"),iOp++);
            }
            bl2F-=colaT[i];
        }
    }
    if (sel.length) {
        glTimeouts[divId]=setTimeout("cola();",1000);
    } else {
        txt.innerHTML=L_PRODCOMP;
    }

}

function mkCola() {
    var html="",llamada="cola()";
    html='<div id="divCola"></div><select id="selCola" size="6" style="width: 100%;"></select>';
    return html;
}

var vistaMini=0;
var glHbase=new Array();
var glHprod=new Array();
var glHcapacidad=new Array();
var glHhora;
var glHpintado=new Array();

function contadorRecursos() {
  var ahora=new Date;
  var secs=(ahora-glHhora)/1000;
  if (glHpintado.length<3) { glHpintado[0]=glHbase[0]; glHpintado[1]=glHbase[1]; glHpintado[2]=glHbase[2]; }
  for (r=0;r<3;r++) {
    if (glHprod[r]>0 && glHbase[r]<glHcapacidad[r]) {
      a=glHbase[r]+glHprod[r]/3600.0*secs;
      b=false;
      if (a>glHcapacidad[r]) { b=true; a=glHcapacidad[r]; }
      a=Math.round(a);
      if (a!=glHpintado[r]) {
        switch (glInterfaz) {
          case 0: x=r==0 ? 'M':r==1 ? 'C':'D';
                  document.getElementById('header'+x).innerHTML=(b ? '<font color=red>':'') + formatNum(a)+(b ? '</font>':'');
                  break;
          case 1: x=r==0 ? 'metal':r==1 ? 'crystal':'deuterium';
                  document.getElementById('resources_'+x).innerHTML=(b ? '<font color=red>':'') + formatNum(a)+(b ? '</font>':'');
                  break;
        }
        glHpintado[r]=a;
      }
    }
  }
}

var glSepomo="",glSepomoSecs=0;

function sepoTick(bCancel) {
  if (typeof(bCancel)=="undefined") bCancel=false;
  if (bCancel) {
    glSepomoSecs=0;
    document.getElementById("sms").style["display"]="none";
    ajaxAbre('sepomoBar.php?idUni='+idUni+'&ocultar');
  } else {
    if (glSepomoSecs) {
      glSepomoSecs--;
      if (!glSepomoSecs) {
        document.getElementById("sms").style["display"]="none";
      } else {
        document.getElementById("smstd4").innerHTML=glSepomoSecs;
      }
    }
  }
}
      
function parseSepomo(t) {
  var txt="";
  var urlForm='<a href="'+glForo+'/../sepomo.html" target="_blank" onclick="return popup(\''+glForo+'/../sepomo.html\',400,250,\'sepomo\');"><img src="'+glStaticWeb+'images/info2.gif" height=18 width=18 title="Formulario completo" alt="Cambiar"></a>';
//  alert(t);
  try {
    i=t.indexOf("enviar")+7;
    j=t.indexOf("via",i);
    palabra=t.substring(i,j);
    i=t.indexOf("al",j)+3;
    j=t.indexOf(".",i);
    num=t.substring(i,j);
    i=t.indexOf('<I>')+3; if (i<5) i=t.indexOf('<i>')+3;
    j=t.indexOf('</I>',i); if (j<5) j=t.indexOf('</i>',i);
    precio=t.substring(i,j);
    //alert(t.substring(i));
    precio=precio.replace('<BR>',' ').replace('<br>',' ');
    precio=precio.replace('*El precio del mensaje es  de ','');
    precio=precio.replace('*El precio del mensaje es de ','');
    i=t.indexOf('selected="selected"');
    if (i<1) i=t.indexOf('selected');
    if (i>1) {
      i=t.indexOf('>',i)+1;
      j=t.indexOf('<',i);
      pais=t.substring(i,j);
      txt="SMS desde "+pais+"&nbsp;"+urlForm+" al "+num+" con "+palabra+" +texto ("+precio+")";
      //alert(precio);
    } else {
//      alert(palabra + ':'+num+':'+precio);
//      alert(t.substring(j));
    }
    
  } catch (ex) { /* alert('ex');*/  }
  if (txt=="") txt="Servicio SMS (no disponible en tu pais&nbsp;"+urlForm+")";
  if (glSepomo!="INFO") txt="Recibido SMS : <b>"+glSepomo+"</b><br>"+txt;
  document.getElementById("smstd2").innerHTML=txt;
  document.getElementById("smstd3").innerHTML='<a href="javascript:sepoTick(1)"><img width=16 height=16 src="'+glStaticWeb+'images/cancel.gif" alt="[X]"></a><br><div id=smstd4></div>';
  document.getElementById("sms").style["display"]="block";
  sepoTick();
  setInterval("sepoTick()",1000);
}
  
  
function onload() {
  o=document.getElementById('smssub');
  if (o) {
    t=o.innerHTML;
    if (t.indexOf('multiform_img/pixel.gif')<1) {
      // Explorer no devuelve el contenido del div.innerhtml hecho de la manera de arriba. 
      // Alternativa chunga: Recorrer tablas buscando al que contiene 'sepomo'
      var t2="";
      var doc=document.getElementsByTagName('table');
      for (i= 0; i < doc.length; i++){
        t=doc[i].innerHTML;
//        alert(t);
        if (t.indexOf('multiform_img/pixel.gif')>0 && t.indexOf('pais_nuevo')>0) {
//          alert(t);
          t2=t;
          doc[i].style["display"]="none";
          i=doc.length;
        }
      }
      t=t2;
    }
//    alert(t);
    if (t) {
      parseSepomo(t);
    }
  }
  if (typeof OLonLoad_handler!="undefined") OLonLoad_handler(false);
}

var glPlanetas=new Array();

function nombrePlaneta(cp) {
  for (i=0;i<glPlanetas.length;i++) 
    if (glPlanetas[i][0]==cp) return glPlanetas[i][1];
  return '';
}

function pintaGlobal1(msgError,bPubli) {
  clearTimeouts(); // Por si es una llamada de ajax, borrar contadores previos
  if (typeof(bPubli)=="undefined") bPubli=false;
  if (typeof(msgError)=="undefined") msgError="";
	gl=document.getElementById("global");
	if (gl != null) {
	  if (gl.innerHTML=='') {
      if (bPubli) {
        document.write('<div id=smssub style="display: none;"><script language="JavaScript" src="http://www.sepomo.com/multiform/multiform.php?id_client=AAD9C&edicion=1"></script></div>');
//        document.write('<table style="display: none;"><tr><td id=smssub style="d_isplay: none;"><script language="JavaScript" src="http://www.sepomo.com/multiform/multiform.php?id_client=AAD9C&edicion=1"></script></td></tr></table>');
        //setTimeout("onload()",5000);
      }
	    t='\
<div id=sms style="display: none; position: fixed; height: 50px; width:80%; bottom: 10px; right: 10px; z-index : 1;">\
<table width="100%" style="background-image: url('+glStaticWeb+'images/grad50.png); background-repeat: repeat-x; font-family: sans-serif; font-size: larger; font-style: oblique; color: Red;"><tr>\
<th id=smstd1 width=1px  align=center style="background-image: url('+glStaticWeb+'images/grad50.png); background-repeat: repeat-x; font-family: sans-serif; font-size: larger; font-style: oblique; color: Red;"><img src="'+glStaticWeb+'images/logo1_4.png" width=40px height=40px></th>\
<th id=smstd2 width=100% align=center style="background-image: url('+glStaticWeb+'images/grad50.png); background-repeat: repeat-x; font-family: sans-serif; font-size: larger; font-style: oblique; color: Red;">Centro</th>\
<th id=smstd3 width=1    align=right  style="background-image: url('+glStaticWeb+'images/grad50.png); background-repeat: repeat-x; font-family: sans-serif; font-size: larger; font-style: oblique; color: Red;"></th></tr>\
</table>\
</div>\
<div style="display: none;" width="1%" height="0%" id="ajax" name="ajax" frameborder="0">Ajax Ready</div>\
<iframe frameborder=0 width="120px" height="0%" name="ifAjax"></iframe>\
\
<div id="boxBG">\
</div>\
<div id="siteFooter"><div class="content"><div class="fleft textLeft">\
<tr><td colspan=2 align=center><a href="ogarena.es" target="_blank">ogArena</a></div><div class="fright textRight">\
<a href="noticias.php?idUni='+idUni+'">Noticias</a>&nbsp;&nbsp;|&nbsp;&nbsp;\
<a href="http://ogarena.es/foro" target="_blank">Foro</a>&nbsp;&nbsp;|&nbsp;&nbsp;\
<a href="http://ogarena.es/foro/viewtopic.php?f=9&t=12" target="_blank">Reglamento</a></div></div></div>\
';
      gl.innerHTML=t;
    }
  }
}

function pintaGlobal(msgError,bPubli) {
  if (glInterfaz==1) return pintaGlobal1(msgError,bPubli);
  clearTimeouts(); // Por si es una llamada de ajax, borrar contadores previos
  if (typeof(bPubli)=="undefined") bPubli=false;
  if (typeof(msgError)=="undefined") msgError="";
	gl=document.getElementById("global");
	if (gl != null) {
	  if (gl.innerHTML=='') {
      if (bPubli) {
        document.write('<div id=smssub style="display: none;"><script language="JavaScript" src="http://www.sepomo.com/multiform/multiform.php?id_client=AAD9C&edicion=1"></script></div>');
//        document.write('<table style="display: none;"><tr><td id=smssub style="d_isplay: none;"><script language="JavaScript" src="http://www.sepomo.com/multiform/multiform.php?id_client=AAD9C&edicion=1"></script></td></tr></table>');
        //setTimeout("onload()",5000);
      }
	    t='\
<div id=sms style="display: none; position: fixed; height: 50px; width:80%; bottom: 10px; right: 10px; z-index : 1;">\
<table width="100%" style="background-image: url('+glStaticWeb+'images/grad50.png); background-repeat: repeat-x; font-family: sans-serif; font-size: larger; font-style: oblique; color: Red;"><tr>\
<th id=smstd1 width=1px  align=center style="background-image: url('+glStaticWeb+'images/grad50.png); background-repeat: repeat-x; font-family: sans-serif; font-size: larger; font-style: oblique; color: Red;"><img src="'+glStaticWeb+'images/logo1_4.png" width=40px height=40px></th>\
<th id=smstd2 width=100% align=center style="background-image: url('+glStaticWeb+'images/grad50.png); background-repeat: repeat-x; font-family: sans-serif; font-size: larger; font-style: oblique; color: Red;">Centro</th>\
<th id=smstd3 width=1    align=right  style="background-image: url('+glStaticWeb+'images/grad50.png); background-repeat: repeat-x; font-family: sans-serif; font-size: larger; font-style: oblique; color: Red;"></th></tr>\
</table>\
</div>\
\
<table width="100%" border=0>\
<tr>\
	<td style="vertical-align: top; background-color: transparent;" width="1%" >\
	  <br><br><br><br><br>';
    	if (glEstiloMarco==0) t+='<div id="divLeftMenu" style="width: 120px;"></div>';
    	else t+='<div id="divLeftMenu" style="position: fixed; width: 120px; height: 100%; top: 60px; left: 0;"></div>\
    		<div id="spacerv" style="width: 120px; height: 100%;"></div>';
/*		  if (glNivelGO) {
		    t+='\
		<div style="display: none;" height="1%" id="ajax" name="ajax" frameborder="1">Ajax Ready</div>\
		<iframe frameborder=0 width="0%" height="0%" name="ifAjax"></iframe>';
		  } else {*/
		    t+='\
		<div style="display: none;" width="1%" height="0%" id="ajax" name="ajax" frameborder="0">Ajax Ready</div>\
		<iframe frameborder=0 width="120px" height="0%" name="ifAjax"></iframe>';
//		  }
		  t+='\
	</td>\
	<td width="100%" style="vertical-align: top; background-color: transparent;" align="center">\
	  <table width=750>\
	    <tr><td style="background-color: transparent;">';
	    if (glEstiloMarco==0) t+='<div id="divHeader"></div>';
	    if (glEstiloMarco==1) t+='<div id="divHeader" align="center" style="position: fixed; width: 100%; height: 1px; top: 0; left: 60;"></div><div id="spacer" align="center" style="width: 100%; height: 60px; "></div>';
	    if (glEstiloMarco==2) t+='<div id="divHeader" align="center" style="position: fixed; width: 120; height: 100%; top: 60; right: 0;"></div>';
	    if (msgError) {
	      t+='<center><font color=red>'+L_ERROR+':';
	      if (msgError.substr(0,2)=='E_') t+=eval('L_'+msgError);
	      else t+=msgError;
	      t+='/font></center>';
	    }
    	t+='<div id="divContent" align="center"></div>';
    	if (bPubli) t+='<br><br><br><br>';
    	t+='\
    	</td>\
      </tr>\
    </table>\
	</td>\
</tr>\
';
      gl.innerHTML=t;
    }
  }
}

function header(pantalla,planetas,skinPar,extraPar) {
	var planOpt,i,cp,plan,t;
	var toks,cpSelected,m,c,d,mo,bMR,bCR,bDR,en,eT;
	var cpPrev=0,cpNext=0;
  var bAjax=(pantalla=="b_building") || (pantalla=="galaxy") || (pantalla=="flotten") || (pantalla=="flottenAJAX") || (pantalla=="overview") || (pantalla=="messages");

  if (typeof(extraPar)=="undefined") extraPar=""; 
	glHhora=new Date();
	toks=planetas.split('|');
	glNivelGO=parseInt(toks[29]);
	glInterfaz=parseInt(toks[40]);
	glNick=toks[42];
	glTop=formatNum(toks[43]);
	pintaGlobal("",toks[37]>"");
	
	cpSelected=parseInt(toks[0]);
	glHbase[0]=plM=m=parseInt(toks[2]);
	glHbase[1]=plC=c=parseInt(toks[3]);
	glHbase[2]=plD=d=parseInt(toks[4]);
	plEL=en=parseInt(toks[5]);
	plET=eT=parseInt(toks[6]);
	mo=0;
	bMR=toks[7]=='1';
	bCR=toks[8]=='1';
	bDR=toks[9]=='1';
	if (typeof(skinPar)=="undefined") skin=toks[10];
  else skin=skinPar;
	idUni=toks[11];
	nombreUni=toks[12];
	imagenPlan=toks[13];
	toks[14]=toks[14].split('.');
	glMensNuevos=toks[14][0];
	if (toks[14][1]>'0') {
	  if (glMensNuevos=='') glMensNuevos='0';
	  glMensNuevos+='+<a href="messages.php?idUni='+idUni+'&carpeta=2" title="'+L_MENSBEL+'"><font color=red>'+toks[14][1]+'</font></a>';
	}
	vistaMini=parseInt(toks[15]);
	glAliMarca=toks[25]=='0' ? '':' ('+toks[25]+')';
	glCompisMarca=toks[26]=='0' ? '':' ('+toks[26]+')';
	glNivelGO=parseInt(toks[29]);
	glEnVacaciones=parseInt(toks[30]);
	glAtaquesVisGen=toks[31];
	glVotaOgarena=parseInt(toks[32]);
	glVerAvatares=parseInt(toks[33]);
	glDenuncias=parseInt(toks[34]);
	glServerMinutTZ=parseInt(toks[35]);
	if (glSepomo=toks[38]) glSepomoSecs=parseInt(toks[37]);
	else glSepomoSecs=0;
	glStaticWeb=toks[39]+'/';
	glNoticiasMarca=parseInt(toks[41]);
	if (glNoticiasMarca) glNoticiasMarca=' ('+formatNum(glNoticiasMarca)+')';
	else glNoticiasMarca='';
	
  var futuro=new Array();
	for (i=0;i<3;i++) {
	    glHcapacidad[i]=parseInt(toks[16+i]);
	    futuro[i]=parseInt(toks[19+i]);
	    glHprod[i]=parseInt(toks[22+i]);
	}
	planOpt=""; planOpt1="";
	for (i=0;i<toks.length-1;i++) {
	  if (toks[i]=='-' && toks[i+1]=='') break;
	}
	plCp=cpSelected;
	cp=0;
	for (i+=2;i<toks.length;i+=4) {
	    if (!toks[i]) break;
	    if (parseInt(toks[i])==cpSelected) cpPrev=cp;
      if (cp==cpSelected) cpNext=toks[i];
			cp=toks[i];
			plan=toks[i+1];
			j=plan.indexOf(' [');
			nombre=plan.substr(0,j);
			coords=plan.substr(j+1);
			glPlanetas[glPlanetas.length]=new Array();
			glPlanetas[glPlanetas.length-1][0]=parseInt(cp);
			glPlanetas[glPlanetas.length-1][1]=plan;
			glPlanetas[glPlanetas.length-1][2]=toks[i+3];
			if ((""+pantalla).indexOf('?')<1) {
			  tt=pantalla+".php?idUni="+idUni;
			} else {
			  tt=pantalla+"&idUni="+idUni;
			}
			if (bAjax) tt+='&ajax';
			tt+=extraPar;
			valor=toks[i+2];
			if (valor>'') valor=" ("+valor+")";
			planOpt+="<option value="+tt+"&cp="+cp+(cpSelected==cp ? " SELECTED":"")+">"+plan+valor+"</option>";
			planOpt1+='<div class="smallplanet"><a href="#" class="planetlink  tips reloadTips" title="|<B> '+plan+'">\
'+skinSP(imagenPlan)+'\
<span class="planet-name">'+nombre+'</span>\
<span class="planet-koords">'+coords+'</span>\
</a>\
<a class="constructionIcon tips reloadTips" title="|Fábrica de Robots">\
<img src="img/icons/wrench.gif" height="12" width="12" /></a>\
</div>';

	}
	if (bAjax) {
	  uNext="javascript:ajaxAbre('"+pantalla+'.php?idUni='+idUni+'&cp='+cpNext+"&ajax')";
	  uPrev="javascript:ajaxAbre('"+pantalla+'.php?idUni='+idUni+'&cp='+cpPrev+"&ajax')";
	} else {
	  uNext=pantalla+'.php?idUni='+idUni+'&cp='+cpNext+extraPar;
	  uPrev=pantalla+'.php?idUni='+idUni+'&cp='+cpPrev+extraPar;
	}
	t="";
if (glInterfaz==1) {
  t='\
<div id="box"><a name="anchor"></a><div id="info">\
  <div id="playerName">Jugador: <span class="textBeefy">'+glNick+'</span></div>\
  <div id="bar">\
    <ul>\
      <li><a class="ajax_thickbox" accesskey="" href="compis.php?idUni='+idUni+'">Amigos</a></li>\
      <li><a href="#" onclick="popup(\'index.php?page=notices&session=116840626807&notice_id=\',\'Notice\',\'auto\',\'no\',\'0\',\'0\',\'no\',\'690\',\'470\',\'no\');" accesskey="">Notas</a></li>\
      <li><a href="estadisticas.php?idUni='+idUni+'" accesskey="">Clasificación</a> ('+glTop+')</li>\
      <li><a class="ajax_thickbox" href="suche.php?idUni='+idUni+'" accesskey="">Búsqueda</a></li>\
      <li><a href="options.php?idUni='+idUni+'" accesskey="">Opciones</a></li>\
      <li><a href="universos.php" accesskey="">Salir</a></li>\
    </ul>\
  </div>\
  <div id="OGameClock">03.11.2009 <span>09:25:26</span></div>\
  <ul id="resources">\
  	<li id="metal_box" class="metal tips reloadTips" title="'+L_CAPACIDA+': ' +formatNum(glHcapacidad[0])+' '+L_PREVISTO+': '+formatNum(prM=futuro[0])+' '+L_PRODUCC+': '+formatNum(glHprod[0])+'" '+(bMR ? 'color="#FF0000"':"")+'>\
      <img src="i1/images/ressourcen_metall.gif" /><span class="value"><span id="resources_metal" class=""><font '+(bMR ? ' color="#FF0000"':"")+'>'+formatNum(m)+'</font></span></span></li>\
  	<li id="crystal_box" class="crystal tips reloadTips" title="'+L_CAPACIDA+': ' +formatNum(glHcapacidad[1])+' '+L_PREVISTO+': '+formatNum(prC=futuro[1])+' '+L_PRODUCC+': '+formatNum(glHprod[1])+'" '+(bCR ? 'color="#FF0000"':"")+'>\
      <img src="i1/images/ressourcen_kristal.gif" /><span class="value"><span id="resources_crystal" class=""><font '+(bCR ? ' color="#FF0000"':"")+'>'+formatNum(c)+'</font></span></span></li>\
  	<li id="deuterium_box" class="deuterium tips reloadTips" title="'+L_CAPACIDA+': ' +formatNum(glHcapacidad[2])+' '+L_PREVISTO+': '+formatNum(prD=futuro[2])+' '+L_PRODUCC+': '+formatNum(glHprod[2])+'" '+(bDR ? 'color="#FF0000"':"")+'>\
      <img src="i1/images/ressourcen_deuterium.gif" /><span class="value"><span id="resources_deuterium" class=""><font '+(bDR ? ' color="#FF0000"':"")+'>'+formatNum(d)+'</font></span></span></li>\
  	<li id="energy_box" class="energy tips reloadTips"> \
      <img src="i1/images/ressourcen_energie.gif" /><span class="value"><span id="resources_energie" class=""><font '+(en<0 ? 'color="#FF0000"':"")+'>'+formatNum(en)+'</font>/'+formatNum(eT)+'</span></span></li>\
  	<li id="darkmatter_box" class="darkmatter tips reloadTips">\
      <img src="i1/images/ressourcen_DM.gif" /><span class="value"><span id="resources_dm" class="">xD</span></span></li>\
 </ul>\
</div>\
';
t+='<div id="divLeftMenu"></div>';
t+='<div id=inhalt><div id=divContent></div></div>';
t+='<div id="rechts"><div id="norm"><div id="myWorlds">\
<div id="countColonies"><p class="textCenter tips" title="|Número de posibles planetas"><span>1/1</span> Planetas</p></div>\
'+planOpt1+'\
</div>\
</div></div>';
t+='</div>'; // box

  document.getElementById("boxBG").innerHTML=t;
 
} else { 
	if (glEstiloMarco>0) t+='<table><tr><td class=c>';
	t+=' \
	  <table class="header">\
    <tr class="header"> \
     <td rowspan="3" class="header">'+skinSP(imagenPlan)+'</td>\
     <td rowspan="3" class="header">\
      <table class="header">\
		  <tr><td colspan=2 class="header"><select size="1" name=selectorPlaneta onchange="haha(this'+(bAjax ? ',1':'')+')">\
'+planOpt	+'	\
			  		  </select>\
			</td></tr><tr><td align="left" class="header">'+(cpPrev ? '<a href="'+uPrev+'">&lt;&lt;</a>':' ')+'</td>\
										<td align="right" class="header">'+(cpNext ? '<a href="'+uNext+'">&gt;&gt;</a>':' ')+'</td>\
				</tr></table>\
     </td>\
	    \
		     <td align="center" width="85" class="header">\
		      '+skinImg('metall.gif',L_R1,42,22)+'\
		     </td>\
		     \
		     <td align="center" width="85" class="header">\
		      '+skinImg('kristall.gif',L_R2,42,22)+'\
		     </td>\
		     \
		     <td align="center" width="85" class="header">\
		      '+skinImg('deuterium.gif',L_R3,42,22)+'\
		     </td>\
	     		     \
		     <td align="center" width="85" class="header">\
		      <img border="0" src="http://uni40.ogame.com.es/game/img/dm_klein_2.jpg" width="42" height="22">\
		     </td>	     \
	        		     \
		     <td align="center" width="85" class="header">\
		      '+skinImg('energie.gif',L_R4,42,22)+'\
		     </td>\
	    </tr>\
\
	    <tr class="header">\
	     <td align="center" class="header" width="85"><i><b><font color="#ffffff">'+L_R1+'</font></b></i></td>\
	     <td align="center" class="header" width="85"><i><b><font color="#ffffff">'+L_R2+'</font></b></i></td>\
	     <td align="center" class="header" width="85"><i><b><font color="#ffffff">'+L_R3+'</font></b></i></td>\
	     <td align="center" class="header" width="85"><i><b><font color="#ffffff">'+L_R5+'</font></b></i></td>	\
	          \
	     <td align="center" class="header" width="85"><i><b><font color="#ffffff">'+L_R4+'</font></b></i></td>\
	    </tr>\
	    <tr class="header">\
	     <td align="center" class="header" width="90"> \
	     <font title="'+L_CAPACIDA+': ' +formatNum(glHcapacidad[0])+' '+L_PREVISTO+': '+formatNum(prM=futuro[0])+' '+L_PRODUCC+': '+formatNum(glHprod[0])+'" '+(bMR ? 'color="#FF0000"':"")+"><span id=headerM>"+formatNum(m)+'</span></font></td>\
	     <td align="center" class="header" width="90"> \
	     <font title="'+L_CAPACIDA+': ' +formatNum(glHcapacidad[1])+' '+L_PREVISTO+': '+formatNum(prC=futuro[1])+' '+L_PRODUCC+': '+formatNum(glHprod[1])+'" '+(bCR ? 'color="#FF0000"':"")+"><span id=headerC>"+formatNum(c)+'</span></font></td>\
	     <td align="center" class="header" width="90"> \
	     <font title="'+L_CAPACIDA+': ' +formatNum(glHcapacidad[2])+' '+L_PREVISTO+': '+formatNum(prD=futuro[2])+' '+L_PRODUCC+': '+formatNum(glHprod[2])+'" '+(bDR ? 'color="#FF0000"':"")+"><span id=headerD>"+formatNum(d)+'</span></font></td>\
	     <td align="center" class="header" width="90"><font>xD</font></DIV></td>\
	        \
	     <td align="center" class="header" width="90"><font '+(en<0 ? 'color="#FF0000"':"")+">"+formatNum(en)+'</font>/'+formatNum(eT)+'</td>\
</tr>\
</table>\
';
  if (glEstiloMarco>0) t+='</td></tr></table>';
  document.getElementById("divHeader").innerHTML=t;
}
  if (!glCronoRecursos)
    glCronoRecursos=setInterval("contadorRecursos()",1000);
  leftmenu(nombreUni,toks[27].substr(1),parseInt(toks[28]),pantalla);

  return(cpSelected);
}

function leftmenu1(uniName,version,secsUni,activo) {
  var t;
  function lmsuf(activo,actual) { return (activo==actual || activo==actual+'AJAX') ? 'b':'a'; }
  function lmsel(activo,actual) { return (activo==actual || activo==actual+'AJAX') ? ' selected':''; }
  if (typeof activo=="undefined") activo="";
  var h=/*glStaticWeb+*/"i1/images/";
  t='['+activo+']<br>';
  t+='<div id="links"><ul id="menuTable">';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_overview_'+lmsuf(activo,'overview')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'overview')+'" href="overview.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">'+L_VISGEN+((glAtaquesVisGen>'' && glAtaquesVisGen!='0')  ? ' (<font color=red>'+glAtaquesVisGen+'</font>)':'')+'</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><a href="produccion.php?idUni='+idUni+'" class=""><img class=mouseSwitch rel="'+h+'navi_ikon_resources_'+lmsuf(activo,'produccion')+'.gif" width="38" height="29" src="'+h+'navi_ikon_resources_'+lmsuf(activo,'produccion')+'.gif"></a></span>';
  t+=   '<a class="menubutton '+lmsel(activo,'b_building')+'" href="b_building.php?idUni='+idUni+'&p=p" accesskey="r" target="_self"><span class="textlabel">'+L_RECURSOS+'</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_station_'+lmsuf(activo,'b_building')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'b_building')+'" href="b_building.php?idUni='+idUni+'&p=i" accesskey="v" target="_self"><span class="textlabel">Instalaciones</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_trader_'+lmsuf(activo,'comercio')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'comercio')+'" href="comercio.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">Mercader</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_research_'+lmsuf(activo,'investigacion')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'investigacion')+'" href="investigacion.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">Investigación</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_shipyard_'+lmsuf(activo,'hangar')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'hangar')+'" href="hangar.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">Hangar</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_defense_'+lmsuf(activo,'defensa')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'defensa')+'" href="defensa.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">Defensa</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_fleet1_'+lmsuf(activo,'flotten')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'flotten')+'" href="flotten.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">Flota</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_galaxy_'+lmsuf(activo,'galaxy')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'galaxy')+'" href="galaxy.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">Galaxia</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_network_'+lmsuf(activo,'allianzen')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'allianzen')+'" href="allianzen.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">Alianza</span></a></li>';
  t+='<li class="menubutton_table"><span class="menu_icon"><img src="'+h+'navi_ikon_premium_'+lmsuf(activo,'xx')+'.gif" width="38" height="29"></span><a class="menubutton '+lmsel(activo,'xx')+'" href="defensa.php?idUni='+idUni+'" accesskey="v" target="_self"><span class="textlabel">xx</span></a></li>';
  
  return t;
}

function leftmenu(uniName,version,secsUni,activo) {
		var t='';
		if (glInterfaz==1) t=leftmenu1(uniName,version,secsUni,activo);
		else {
		if (glEstiloMarco==1) t='<table height="100%" style="background-color: transparent;"><tr><td><table><tr><th>';
		t+=' \
<table width="110" cellspacing="0" cellpadding="0">\
 <tr>\
    <td class="header" align="center"><span title="'+L_VERSION+' '+version+'">ogArena</span><br><a href="leyes.php?idUni='+idUni+'">'+uniName+'</a>'+
    (secsUni ? mkCounter("cntUni",secsUni,"universos.php",'',true):'') +
    '</th>\
 </tr>\
 <tr>\
  <td class="header">'+skinImg('ogame-produktion.jpg',L_PRODUCC,0,0,"gfx")+'</td>\
 </tr>\
\
   <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="overview.php?idUni='+idUni+'" accesskey="v">'+L_VISGEN+((glAtaquesVisGen>'' && glAtaquesVisGen!='0')  ? ' (<font color=red>'+glAtaquesVisGen+'</font>)':'')+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
   <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="imperio.php?idUni='+idUni+'" accesskey="I">'+L_IMPERIO+'</a>\
    </font></div>\
  </td>\
 </tr>\
 \
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="b_building.php?idUni='+idUni+'" accesskey="e">'+L_EDIFS+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="produccion.php?idUni='+idUni+'" accesskey="r">'+L_RECURSOS+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="investigacion.php?idUni='+idUni+'" accesskey="i">'+L_INVESTIG+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="hangar.php?idUni='+idUni+'" accesskey="h">'+L_HANGAR+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="flotten.php?idUni='+idUni+'" accesskey="u">'+L_FLOTAMAY+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="techtree.php?idUni='+idUni+'" accesskey="t">'+L_TECNOL+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="galaxy.php?idUni='+idUni+'" accesskey="g">'+L_GALAX+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="defensa.php?idUni='+idUni+'" accesskey="d">'+L_DEFENS+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="comercio.php?idUni='+idUni+'" accesskey="i">'+L_COMERCIO+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>'+skinImg('info-help.jpg',L_INFOHELP,0,0,"gfx")+'</td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="allianzen.php?idUni='+idUni+'" accesskey="a">'+L_ALIANZAS+glAliMarca+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
  <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
    <a href="'+glForo+'" target="_blank" accesskey="1" >'+L_FORO+'</a>\
   </font></div>\
  </td>\
 </tr>\
\
  <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
    <a href="noticias.php?idUni='+idUni+'" accesskey="n" >'+L_NOTICIAS+glNoticiasMarca+'</a>\
   </font></div>\
  </td>\
 </tr>\
\
  <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
    <a href="'+glForo+'/irc.php" target="_blank" accesskey="1" >IRC</a>\
   </font></div>\
  </td>\
 </tr>\
 \
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
  <a href="estadisticas.php?idUni='+idUni+'&u=-1" accesskey="k">'+L_ESTADIST+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
  <a href="pranger.php?idUni='+idUni+'" accesskey="b">'+L_BLOQUEOS+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
  <a href="records.php?idUni='+idUni+'" >'+L_RECORDS+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="suche.php?idUni='+idUni+'" accesskey="b">'+L_BUSCAR+'</a>\
    </font></div>\
  </td>\
 </tr>\
'+(glNivelGO==0 ? '': '\
 <tr>\
  <th><font color="FF8900">'+L_NIVELGO+' '+glNivelGO+'</font></th>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="procesos.php?idUni='+idUni+'">Info Procesos</a>\
    </font></div>\
  </td>\
 </tr>\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="multis.php?idUni='+idUni+'">Multis</a>\
    </font></div>\
  </td>\
 </tr>\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="push.php?idUni='+idUni+'">Pushing</a>\
    </font></div>\
  </td>\
 </tr>\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="javascript:showAjax();">ver Ajax</a>\
    </font></div>\
  </td>\
 </tr>\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="denuncias.php?idUni='+idUni+'" accesskey="a">'+L_DENUNCS+(glDenuncias==0 ? '':'('+glDenuncias+')')+'</a>\
    </font></div>\
  </td>\
 </tr>\
')+'\
 <tr>\
  <td>'+skinImg('user-menu.jpg',L_USUARIO,0,0,"gfx")+'\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="messages.php?idUni='+idUni+'" accesskey="m">'+L_MENSAJES+((glMensNuevos>'' && glMensNuevos!='0')  ? ' ('+glMensNuevos+')':'')+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="messages.php?idUni='+idUni+'&carpeta=8" accesskey="n">'+L_NOTAS+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="compis.php?idUni='+idUni+'" accesskey="c">'+L_LISTACOM+glCompisMarca+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="options.php?idUni='+idUni+'" accesskey="o">'+L_OPCIONES+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 \
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="universos.php" accesskey="s">'+L_SALIR+'</a>\
    </font></div>\
  </td>\
 </tr>\
\
 <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="http://asturcon3.homeip.net/fogarena/viewtopic.php?f=9&t=12" target="_blank" accesskey="6" >'+L_REGLAS+'</a>\
   </font></div>\
  </td>\
 </tr>\
<tr>\
  <th><font color="FF8900">'+L_CONTRIB+'</font></th>\
 </tr>\
  '+(!glVotaOgarena ? '':' <tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="http://dagame.es/top/in.php?wid=50" onclick="votado()" target="_blank">'+L_VOTAOG+'</a>\
   </font></div>\
  </td>\
 </tr>')+'\
<tr>\
  <td>\
   <div align="center"><font color="#FFFFFF">\
     <a href="#" onclick="javascript: return donar();" accesskey="d" >'+L_DONANES+'</a>\
   </font></div>\
  </td>\
 </tr>\
 </table>\
	';
	if (glEstiloMarco>0) t+='</th></tr></table></td></tr></table>';
	t="<div id='menu' style='width: 120px; position: relative; background-image: none;'>"+t+"</div>";
  }
	document.getElementById("divLeftMenu").innerHTML=t;
}

var cuentaCarsUndo;

function cuentaCars(idT,maxch) {
  if (document.getElementById(idT).value.length > maxch) {
    document.getElementById(idT).value = cuentaCarsUndo;
  } else {
    cuentaCarsUndo = document.getElementById(idT).value;
  }
  document.getElementById(idT+"_N").innerHTML=document.getElementById(idT).value.length;
}

function wikiGid(gid,titulo,cp,mastags) {
  if (titulo=="" || titulo===undefined) titulo=gidName(gid);
  if (typeof(mastags)=="undefined") mastags="";
  var xCp='';
  if (typeof(cp)!="undefined") if (cp) xCp='&cp='+cp;
  return '<a href="infos.php?idUni='+idUni+xCp+'&gid='+gid+'"'+(mastags ? " "+mastags+" ":"")+'>'+titulo+'</a>';
}

function urlDenunciar(cp,idJuga,idAli,idMens,tit) {
  var u;
  if (typeof tit=="undefined") tit="";
  u='<a href=writemessages.php?idUni='+idUni+'&denunciar=1';
  if (cp>0)
    u+="&cpDenu="+cp;
  else if (idJuga>0)
    u+="&idJugaDenu="+idJuga;
  else if (idAli>0)
    u+="&idAliDenu="+idAli;
  else if (idMens>0)
    u+="&idMensDenu="+idMens;
  else return '';
  var t= tit ? "title='"+tit+"' ":"";
  u+=' ><img height=16 width=16 '+t+'src='+glStaticWeb+'images/denunciar.png></a>';
  return u;
}

function getIGid(gid) {
  var i;
	for (i=0;i<gidsInfo.length;i++) 
	  if (gidsInfo[i][0]==gid) return i;
	return -1;
}

function getNextGid(gid,offs,estandarGids) {
  var i=getIGid(gid);
  if (typeof(estandarGids)=="undefined") estandarGids=1;
  do {
    if (i==-1) return i;
    i+=offs;
    if (i<0 || i>=gidsInfo.length) return -1;
  } while ((estandarGids && !gidsInfo[i][6]) || gidsInfo[i][6]==2);
  return gidsInfo[i][0];
}

function gidPuntos(gid,xN) {
  var i=getIGid(gid);
  if (i==-1) return 0;
  var factor=gidsInfo[i][5];
  var m=gidsInfo[i][2],c=gidsInfo[i][3],d=gidsInfo[i][4];
  var tM=0,tC=0,tD=0;
  var tipo=gidsInfo[i][1];

	if (tipo=='I') factor=3;
	else if (tipo=='N') factor=0;

	if (!factor) {
		tM=m*xN; tC=c*xN; tD=d*xN;
	} else if (factor==3) {
		p=Math.pow(2,xN)-1;
		tM=Math.floor(m*p);
		tC=Math.floor(c*p);
		tD=Math.floor(d*p);
	} else {
		var n=0;
		while (n<xN) {
			n++;
			if (factor>0 && factor<=2) {
				var p=Math.pow(factor,n-1);
				tM+=Math.floor(m*p);
				tC+=Math.floor(c*p);
				tD+=Math.floor(d*p);
			} else if (factor==3) {
				var p=Math.pow(2,n)-1;
				tM+=Math.floor(m*p);
				tC+=Math.floor(c*p);
				tD+=Math.floor(d*p);
			}
		}
	}
	return Math.floor((tM+tC+tD)/1000);
}

function benchLinks()
{
  for (i=0;i<document.links.length;i++) {
    lnk=document.links[i];
    if (lnk.href.indexOf("idUni=")>0 && lnk.href.substr(0,5)=='http:') {
      lnk.href="javascript:envia('"+lnk.href+"');";
    }
  }
}

function envia(lnk) {
  document.location.href=lnk+"&bench="+document.URL+"&benchJS="+benchJS+"&benchclick="+(new Date()).getTime();
}

function objX(o) {
  var p,x=0;
  while (o) {
    x+=o.offsetLeft;
    o=o.offsetParent;
  };
  return(x);
}

function objY(o) {
  var p,y=0;
  while (o) {
    y+=o.offsetTop;
    o=o.offsetParent;
  };
  return(y);
}

function clearTimeouts() {
  for (key in glTimeouts) { 
    clearTimeout(glTimeouts[key]);
  }
  while (glTimeouts.length) glTimeouts.pop();
}

function showAjax() {
  try {
    o=document.getElementById("ajax");
    if (o.style.display=='none') o.style.display='block',o.width=o.height=100;
    else o.style.display='none';
      
  } catch (exc) {};
  try {
    o=document.getElementsByName("ifAjax")[0];
    if (parseInt(o.frameBorder)) {
      o.width=o.height=o.frameBorder=0;
     } else {
      o.width=o.height=100;
      o.frameBorder=1;
     }
  } catch (exc) {};
}
    
function sprintf() {
  if (!arguments || arguments.length < 1 || !RegExp) return;
  var str = arguments[0];
  str=str.replace(/\%s/g,'%&nbsp;s');
  str=str.replace(/\$/g,'%s');
  var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
  var a = b = [], numSubstitutions = 0, numMatches = 0;
  while (a = re.exec(str)) {
    var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
    var pPrecision = a[5], pType = a[6], rightPart = a[7];
    //alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision);
    numMatches++;
    if (pType == '%') subst = '%';
    else {
      numSubstitutions++;
      if (numSubstitutions >= arguments.length) {
        alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
      }
      var param = arguments[numSubstitutions];
      var pad = '';
      if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
      else if (pPad) pad = pPad;
      var justifyRight = true;
      if (pJustify && pJustify === "-") justifyRight = false;
      var minLength = -1;
      if (pMinLength) minLength = parseInt(pMinLength);
      var precision = -1;
      if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
      var subst = param;
      if (pType == 'b') subst = parseInt(param).toString(2);
      else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
      else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
      else if (pType == 'u') subst = Math.abs(param);
      else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
      else if (pType == 'o') subst = parseInt(param).toString(8);
      else if (pType == 's') subst = param;
      else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
      else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
    }
    str = leftpart + subst + rightPart;
  }
  return str;
} 

function getGidTxt(gid) {
  try {
    return eval('L_GID'+gid);
  } catch (ex) { return 'getGidTxt('+gid+') desconocido'; }
}

function getGidDescr(gid) {
  try {
    return eval('LX_GID'+gid);
  } catch (ex) { return 'getGidDescr('+gid+') desconocido'; }
}

function getGidTipo(gid) {
  var i=getIGid(gid);
  var t=(i>=0 ? gidsInfo[i][1]:'');
  if (t=='L') t='E';
	return t;
}

function mis2class(iMis,bPropia) {
  var t="";
  switch(iMis%100) {
    case 10: t="transport"; break;
    case 1: t="attack"; break;
    case 2: t="missile"; break;
    case 3: t="transport"; break;
    case 4: t="deploy"; break;
    case 5: t="hold"; break;
    case 6: t="espionage"; break;
    case 7: t="colony"; break;
    case 8: t="harvest"; break;
    case 9: t="destroy"; break;
    case 11: t="flight federation"; break;
    case 19: t="flight federation"; break;
  }
  if ((iMis%100)!=11 && (iMis%100)!=19) {
    if (bPropia) t="own"+t;
    if (iMis>=200) t="return "+t;
  }
  return(t);
}

function misTxt(iMis) { 
  var t=""; 
  switch(iMis%100) {
    case 1: t=L_MISION1; break;
    case 10: t=L_MISION10; break;
    case 11: t=L_MISION11; break;
    case 19: t=L_MISION19; break;
    case 2: t=L_MISION2; break;
    case 3: t=L_MISION3; break;
    case 4: t=L_MISION4; break;
    case 5: t=L_MISION5; break;
    case 6: t=L_MISION6; break;
    case 7: t=L_MISION7; break;
    case 8: t=L_MISION8; break;
    case 9: t=L_MISION9; break;
    default: t="??"; break; 
  } 
  if (iMis>=200) { t+=L_LETRAVUE; } 
  else if (iMis>=100) { t+=L_LETRAIDA; } 
  return t; 
}

function nombreRecurso(i) { 
  return i==0 ? L_R1:i==1 ? L_R2:i==2 ? L_R3: ''+i+"?";
}
  
  