if(parent.frames.length > 0 ) { parent.location.href=self.location; }

function SinErrores() { return true; }
window.onerror=SinErrores;

function logout(url) {
html = document.getElementsByTagName('html');
html[0].style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)';
if(confirm('¿Estás seguro de que deseas cerrar sesión?')) {
location = url;
} else {
html[0].style.filter = '';
}
}

function mail(user,server,nombre) {
document.write('<a href="mailto:'+user+'@'+server+'"><b>'+nombre+'</b></a>');
}

function favoritos() {
var titulo = document.title;
var url = 'http://www.mundojuegos.info/';
if (document.all) {
window.external.AddFavorite(url,titulo);
} else if (window.sidebar||document.getElementById) {
window.sidebar.addPanel(titulo,url,'');
}
}

function imagenew() {
if (document.all||document.getElementById) {
	img = document.getElementById('image').src;
	imgsrc = img.substring(0,img.lastIndexOf('.')+4);
	document.getElementById('image').src = imgsrc+'?'+Math.round(Math.random()*10000000000);
	document.getElementById('codigo').value = '';
}
}

function marquee(string) {
var marquee = '<marquee direction="up" scrollamount="3" id="links" onmouseover="detener(\'links\')" onmouseout="inicio(\'links\')"></marquee>';
document.write(marquee);
string = string.replace(/&lt;/g,'<');
string = string.replace(/&gt;/g,'>');
document.getElementById('links').innerHTML = string;
}

function detener(id) {
var id = document.getElementById(id);
id.scrollAmount = 0;
}
function inicio(id) {
var id = document.getElementById(id);
id.direction = 'up';
id.scrollAmount = 3;
}
function atras(id) {
var id = document.getElementById(id);
id.direction = 'down';
id.scrollAmount = 8;
}
function adelante(id) {
var id = document.getElementById(id);
id.direction = 'up';
id.scrollAmount = 8;
}

function execopy(text) {
var div = document.getElementById(text);
var tmpval = eval(div);
tmpval.focus();
tmpval.select();
if(document.all) {
rango = tmpval.createTextRange();
rango.execCommand("Copy");
} else { alert('Presiona "Control + C" para copiar el código al portapapeles'); }
}

function changetxt(no) {
    for (var i=1; i<=2; i++) {
        if(i!=no) {
            document.getElementById('text'+i).style.display = 'none';
        } else {
            document.getElementById('text'+i).style.display = 'block';
        }
    }
}

function externalinks() {
if (!document.getElementsByTagName) return false;
var anchors = document.getElementsByTagName('a');
var nuevo = 'Se abrira en una ventana nueva';
for (var i=0;i<anchors.length;i++) {
var anchor = anchors[i];
if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == 'external' || anchor.getAttribute('rel') == 'external nofollow')) {
anchor.target = '_blank';
anchor.title = (anchor.title != '') ? anchor.title+' ('+nuevo+')' : nuevo;
anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
}
}
}
window.onload = externalinks;

function flash(nombre) {
if(!window.open(nombre, '_blank', 'width=780, height=480, directories=0, location=1, menubar=0, resizable=0, status=1, scrollbars=1, toolbar=0')) { alert('Tienes un bloqueador de ventanas emergentes y, para poder disfrutar de los juegos y animaciones, debes desactivarlo.\nMundoJuegos.INFO es seguro, no abriremos ventanas con publicidad por lo cual podrás navegar con tranquilidad.'); }
}

function agregar(titulo,tipo,c) {
switch(tipo) {
case 1: var f = 'juegos Favoritos?'; break;
case 2: var f = 'animaciones Favoritas?'; break;
default: var f = 'juegos Favoritos';
}
if(confirm('¿Deseas agregar "'+titulo+'" a tus '+f)) { location = c; }
}

function borrar(titulo,tipo,c) {
switch(tipo) {
case 1: var f = 'juegos Favoritos?'; break;
case 2: var f = 'animaciones Favoritas?'; break;
default: var f = 'juegos Favoritos';
}
if(confirm('¿Deseas borrar "'+titulo+'" de tus '+f)) { location = c; }
}

function ajaxobject() {
var xmlhttp = false;
try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(E) {
      xmlhttp = false;
    }
}
if(!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

function ajax(url,div,type,values) {
var div = document.getElementById(div);
var type = (type == 'POST')?'POST':'GET';
div.innerHTML = 'Loading...';
var xmlhttp = ajaxobject();
xmlhttp.open(type,url,true);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4) {
	if(xmlhttp.status==200) {
	div.innerHTML = xmlhttp.responseText;
	} else if(xmlhttp.status==404) {
	div.innerHTML = 'La direccion no existe.';
	} else {
	div.innerHTML = 'Error: '+xmlhttp.status;
	}
}
}
if(type == 'POST') {
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send(values);
} else {
xmlhttp.send(null);
}
}

function trim(s) {
return s.replace(/(^\s*)|(\s*$)/g,'');
}

function recomendar(fla) {
var tunombre = document.getElementById('tname').value;
var tucorreo = document.getElementById('tmail').value;
var sunombre = document.getElementById('sname').value;
var sucorreo = document.getElementById('smail').value;
var codigo = document.getElementById('codigo').value;
var alerta = '';
var pattern = /^[a-z0-9\._-]+@[a-z0-9_-]+\.([a-z0-9_-]+\.)*?[a-z]+$/i;
if(!trim(tunombre)) { alerta += '- ¿Cual es tu nombre?\n'; }
if(tucorreo.match(pattern) == null) { alerta += '- Tu e-mail es incorrecto.\n'; }
if(!trim(sunombre)) { alerta += '- ¿Como se llama tu amig@?\n'; }
if(sucorreo.match(pattern) == null) { alerta += '- El e-mail de tu amig@ es incorrecto.\n'; }
if(!trim(codigo)) { alerta += '- ¿Cual es el código de seguridad?\n'; } else if(codigo.length != 5) { alerta += '- El código de seguridad debe contener 5 caracteres.\n'; }
if(alerta != '') { alert('ERROR:\n'+alerta);return false; } else { ajax('recomendar/'+fla+'.html','rec','POST','tunombre='+encodeURIComponent(tunombre)+'&tucorreo='+encodeURIComponent(tucorreo)+'&sunombre='+encodeURIComponent(sunombre)+'&sucorreo='+encodeURIComponent(sucorreo)+'&codigo='+encodeURIComponent(codigo)+'&recomendar=Recomendar','POST'); }
}

function usuarios_online() {
var usuarios = document.getElementById('usuarios');
var xmlhttp = ajaxobject();
xmlhttp.open('GET','online.html',true);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4) {
	if(xmlhttp.status==200) { usuarios.innerHTML = xmlhttp.responseText; }
}
}
xmlhttp.send(null);
window.setTimeout(function() { usuarios_online(); }, 60000);
}
window.setTimeout(function() { usuarios_online(); }, 60000);

function comp() {
var compid = document.getElementById('comptoir');
var xmlhttp = ajaxobject();
xmlhttp.open('GET','users.php',true);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4) {
	if(xmlhttp.status==200) { compid.innerHTML = xmlhttp.responseText; }
}
}
xmlhttp.send(null);
window.setTimeout(function() { comp(); }, 30000);
}
window.setTimeout(function() { comp(); }, 30000);

var texto = "MundoJuegos.Info";
var control = 1;
setTimeout("statusbar()",100);
function statusbar() {
if(control == 1) {
window.status = texto;
control = 0;
} else {
window.status = texto;
control = 1;
}
setTimeout("statusbar()",100);
}

function clickNS(e) {
if(document.layers || (document.getElementById && !document.all)) {
if(navigator.appName == 'Netscape' && (e.which==2||e.which==3)) { return false; }
}
return false;
}
if(document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS;
} else {
document.onmouseup=clickNS;
document.oncontextmenu=clickNS;
}