var timer;
var minutos=0;
var comienzo=0;
var momentoentrada=0;
var meses=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
function initc() {
	var tiempo=new Date();
	if (momentoentrada==0) {
		momentoentrada=parseInt(tiempo.getTime()/1000);
		timer=window.setInterval("initc()",20000);
	}
	momentoactual=parseInt(tiempo.getTime()/1000);
	if((momentoactual-momentoentrada)<=1200) {
		chatdinamico('http://www.funkaticos.com/mensajes.php');
	}
	else {
		momentoentrada=tiempo.getTime()/1000;
		document.getElementById("chat").innerHTML="<a href='javascript:initc();' style='font-size: 18px; color:#000000;'><br>Clic aquí<br>para actualizar</a>";
	}
}
function cargar(php)
{
	url = php;
	pars = '';
	var myAjax = new Ajax.Request(
		url, 
		{ 
			method: 'post',
			parameters: pars,
			onComplete: mostrarTexto 
			}
		);
}
function cargarmensaje(linea)
{
	alert(linea);	
}
function mostrarTexto(originalRequest)
{
	$('chat').innerHTML=originalRequest.responseText;
}
function mostrarf(URL) 
{
	document.getElementById("texto").style.visibility="visible";
	if (URL!="")
		cargar('includes/cargarlinea.php?me='+URL);
}
function desaparecer()
{
	document.getElementById("texto").style.visibility='hidden';
}
function abriv(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=yes,location=0,statusbar=0,status=no,menubar=no,resizable=yes,width=410,height=500,left = 140,top = 25');");
}
function abriv350(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=no,location=0,statusbar=0,status=no,menubar=no,resizable=yes,width=405,height=400,left = 140,top = 25');");
}
function cuentac() {
//	alert(document.getElementById("mensaje").innerHTML); //=document.form1.mensaje.value.length;
if(document.form1.mensaje.value.length>200) {
	document.form1.mensaje.value = document.form1.mensaje.value.substring(0, 200);
	document.form1.caracteres.style.color="#FF0000";
	return false; 
}
else document.form1.caracteres.style.color="#666666";
document.form1.caracteres.value=document.form1.mensaje.value.length;
//alert(document.form1.mensaje.value);
} 
function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url="http://www.funkaticos.com/"; 
      var titulo="FUNKATICOS";
      window.external.AddFavorite(url,titulo);
   } else { 
      if(navigator.appName == "Netscape") 
         alert("Presione Crtl+D para agregar este sitio en sus Bookmarks"); 
   }
}

check = []; 

function checkBox(id) { 
    if(check[id] != true) { 
        document.getElementById('imgCheck' + id).src = "http://www.funkaticos.com/imagenes/comunes/verdadero.png";
        document.getElementById('inputCheck' + id).value = "true";
        check[id] = true;
    } 
    else { 
        document.getElementById('imgCheck' + id).src = "http://www.funkaticos.com/imagenes/comunes/falso.png"; 
        document.getElementById('inputCheck' + id).value = "false"; 
        check[id] = false; 
	} 
}

function waitPreloadPage() {
	if (document.getElementById){
		document.getElementById('prepage').style.visibility='hidden';
	}
	else{
		if (document.layers){ //NetScape 4
			document.prepage.visibility = 'hidden';
		}else { //IE4
			document.all.prepage.style.visibility = 'hidden';
		}
	}
}

function showPreloadPage() {
	if (document.getElementById){
		document.getElementById('prepage').style.visibility='';
	}
	else{
		if (document.layers){ //NetScape 4
			document.prepage.visibility = '';
		}
		else { //IE4
			document.all.prepage.style.visibility = '';
		}
	}
}
function cargaXML(url) {
	if(url==''){
		return;
	}
	//	!IE
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send(null);
	//	IE
	} else if (window.ActiveXObject) {
		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send();
		}
	}
}function chatdinamico(mensajes) {
	if(mensajes==''){
		return;
	}
	//	!IE
	if (window.XMLHttpRequest) {
		objetochat = new XMLHttpRequest();
		objetochat.onreadystatechange = respuestachat;
		objetochat.open("GET", mensajes, true);
		objetochat.send(null);
	//	IE
	} else if (window.ActiveXObject) {
		isIE = true;
		objetochat = new ActiveXObject("Microsoft.XMLHTTP");
		if (objetochat) {
			objetochat.onreadystatechange = respuestachat;
			objetochat.open("GET", mensajes, true);
			objetochat.send();
		}
	}
}
function processReqChange(){
	var detalles = document.getElementById("recc");
	if(req.readyState == 4){
		detalles.innerHTML = req.responseText;
	} 
	else {
		detalles.innerHTML = 'Cargando ...';
	}
}
function respuestachat(){
	var htmlchat = document.getElementById("chat");
	if(objetochat.readyState == 4){
		htmlchat.innerHTML = objetochat.responseText;
	} 
	else {
		htmlchat.innerHTML = 'Cargando ...';
	}
}
function masnoticias(esto) {
	vista=document.getElementById(esto).style.display;
	if (vista=='none')
		vista='block';
	else
		vista='none';

	document.getElementById(esto).style.display = vista;
}