// JavaScript Document
<!--
function myXMLHttpRequest ()
{
	var xmlhttplocal;
	try {
		xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
	catch (e) {
		try {
			xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")
		}
		catch (E) {
			xmlhttplocal = false;
		}
  	}
	if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
		try {
			var xmlhttplocal = new XMLHttpRequest ();
		}
		catch (e) {
	  		var xmlhttplocal = false;
			alert ('couldn\'t create xmlhttp object');
		}
	}
	return (xmlhttplocal);
}

var mnmxmlhttp = Array ();
var mnmString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;
var xmlhttp = new myXMLHttpRequest ();
var update_voters = false;
var loginVisible = false;

function crearComunidad (url)
{
	if (document.getElementById('wacom').innerHTML == "anonimo") {

		if (!loginVisible) {
//		document.getElementById('reg-crearComunidad').innerHTML = "<div style='border: 1px solid #000000; text-align:center; height: 190px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;'><p>Para crear una comunidad, tienes que estar <strong>autentificado</strong>.</p><p>Si aún no lo estás y quieres registrarte, haz click <strong><a href='?go=ab7c7d504b7f581ea631d88d89b5750436db8b90b5501fd36c43eec78702a44a190daa3c42691b1e'>aquí.</a></strong></p><form name='form_seccion_4228' style='margin: 0px;height: 110px;' action='' method='post'><label for='' class='' style='font-size: x-small; color: #000; font-weight: bold;'>Usuario</label><br /><input id='' tabindex='1' maxlength='' name='username' value='' type='text'><br /><label for='' class='' style='font-size: x-small; color: #000; font-weight: bold;'>Clave</label><br /><input id='' tabindex='1' maxlength='' name='password' value='' type='password'><br /><input id='' tabindex='1' maxlength='' name='zona' value='134' type='hidden'><input id='' style='font-family: Arial,Helvetica,sans-serif; font-size: x-small; color: BLACK;' name='entrar' value='Entrar' tabindex='1' type='submit'></form></div>";
		document.getElementById('reg-crearComunidad').innerHTML = "<div style='border: 1px solid #000000; text-align:center; background-color: #CCCCCC; height: 90px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;'><p>Para crear una comunidad tienes que estar <strong>registrado</strong>.</p><p><strong><a href='/registroUsuarios/_TJj9qzBb_-gfrBvET700Tdpc7-aOMMQ8'>REGISTRATE, CLICK AQUI</a></strong></p></div>";
		loginVisible = true;
		} else {
		document.getElementById('reg-crearComunidad').innerHTML = "";
		loginVisible = false;
		}
		/*parent.location.href='?go=ab7c7d504b7f581ea631d88d89b5750436db8b90b5501fd36c43eec78702a44a190daa3c42691b1e';*/	
	} 
}


//function menealo (id, url, voto, karma)
function menealo (id, url, voto, karma, link)
{
//	if (voto == "0" && document.getElementById('wacom').innerHTML == "anonimo") {
//alert (link);

//	if (document.getElementById('wacom').innerHTML == "anonimo") {
	if (document.getElementById('wacom').innerHTML == "anonimo" && link=="x") {

		if (!loginVisible) {
//		document.getElementById('reg-' + id).innerHTML = "<div style='border: 1px solid #000000; text-align:center; height: 190px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;'><p>Para poder participar tienes que estar <strong>autentificado</strong>.</p><p>Si aún no lo estás y quieres registrarte, haz click <strong><a href='?go=ab7c7d504b7f581ea631d88d89b5750436db8b90b5501fd36c43eec78702a44a190daa3c42691b1e'>aquí.</a></strong></p><form name='form_seccion_4228' style='margin: 0px;height: 110px;' action='' method='post'><label for='' class='' style='font-size: x-small; color: #000; font-weight: bold;'>Usuario</label><br /><input id='' tabindex='1' maxlength='' name='username' value='' type='text'><br /><label for='' class='' style='font-size: x-small; color: #000; font-weight: bold;'>Clave</label><br /><input id='' tabindex='1' maxlength='' name='password' value='' type='password'><br /><input id='' tabindex='1' maxlength='' name='zona' value='134' type='hidden'><input id='' style='font-family: Arial,Helvetica,sans-serif; font-size: x-small; color: BLACK;' name='entrar' value='Entrar' tabindex='1' type='submit'></form></div>";
		document.getElementById('reg-' + id).innerHTML = "<div style='border: 1px solid #000000; text-align:center; background-color: #CCCCCC; height: 90px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;'><p>Para votar tienes que estar <strong>registrado</strong>.</p><p><strong><a href='/registroUsuarios/_TJj9qzBb_-gfrBvET700Tdpc7-aOMMQ8'>REGISTRATE, CLICK AQUI</a></strong></p></div>"; 		
		loginVisible = true;
		} else {
		document.getElementById('reg-' + id).innerHTML = "";
		loginVisible = false;
		}
		/*parent.location.href='?go=ab7c7d504b7f581ea631d88d89b5750436db8b90b5501fd36c43eec78702a44a190daa3c42691b1e';*/	
	} else {
	if (xmlhttp) {
		//url = base_url + "backend/menealo.php";
		//content = "id=" + id + "&user=" + user;
		mnmxmlhttp[id] = new myXMLHttpRequest ();
		if (mnmxmlhttp[id]) {
			//url = url + "?" + content;
			mnmxmlhttp[id].open ("GET", url, true);
			mnmxmlhttp[id].send (null);
			valor = document.getElementById('num-' + id).innerHTML;
			
	
			if (voto > 0){
			valor.replace("+", "");
			valor = document.getElementById('num-' + id).innerHTML - (-karma);
			} else if (voto < 0) {
			valor = document.getElementById('num-' + id).innerHTML - (-karma);
			} else {
			valor = document.getElementById('num-' + id).innerHTML - (-karma);
			}
			if (valor > 0){
				document.getElementById('num-' + id).innerHTML = "<font color='#35B218'>+" + valor + "</font>";				
			} else if (valor == 0) {
				document.getElementById('num-' + id).innerHTML = "";	
			} else {
				document.getElementById('num-' + id).innerHTML = "<font color='#FC2C00'>" + valor + "</font>";
			}
			
			
			//document.getElementById('num-' + id).innerHTML = document.getElementById('num-' + id).innerHTML - 1;
			document.getElementById('link1-' + id).innerHTML = "<img src='/headers/zonas/2825/masGris.gif' border='0' alt='Ya has votado' name='Ya has votado'>";
			document.getElementById('link2-' + id).innerHTML = "<img src='/headers/zonas/2825/menosGris.gif' border='0' alt='Ya has votado' name='Ya has votado'>";
			document.getElementById('link3-' + id).innerHTML = "<img src='/headers/zonas/2825/xGris.gif' border='0' alt='Ya has votado' name='Ya has votado'>";
document.getElementById('reg-' + id).innerHTML = "";
			warnmatch = new RegExp ("^WARN:");
			errormatch = new RegExp ("^ERROR:");

			mnmxmlhttp[id].onreadystatechange = function () {
				if (mnmxmlhttp[id].readyState == 4) {
					mnmString[id] = mnmxmlhttp[id].responseText;
					if (mnmString[id].match (errormatch)) {
						mnmString[id] = mnmString[id].substring (6, mnmString[id].length);
						alert (mnmString[id]);
						//changemnmvalues (id, true);
					} else {
						// Just a warning, do nothing
						if (mnmString[id].match (warnmatch)) {
							alert(mnmString[id]);
						} else {
							//changemnmvalues (id, false);
							//updateVoters(id);
						}
					}
				}
			}
		} else {
			alert('Couldn\'t create XmlHttpRequest');
		}
	}
	}
}

//Reportar Mensaje
function enviarFormulario(url,id,ip){
var contenido;
var valor;
valor='contenido-' + id;
contenido=document.getElementById(valor).value;
contenido= contenido.replace(/#/g,"[blobic:almohadilla]");
contenido= contenido.replace(/&/g,"[blobic:amp]");
contenido= contenido.replace(/'/g,"[blobic:comilla_simple]");
contenido= contenido.replace(/"/g,'[blobic:comilla_doble]');
contenido= contenido.replace(/\r/g,'[blobic:return]');
contenido= contenido.replace(/Á/g,'á');
contenido= contenido.replace(/É/g,'é');
contenido= contenido.replace(/Í/g,'í');
contenido= contenido.replace(/Ó/g,'ó');
contenido= contenido.replace(/Ú/g,'ú');

	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			contenido= contenido.replace(/\n/g,'[blobic:return]');
			http_request.overrideMimeType('text/xml');
		}
		} else if (window.ActiveXObject) { // IE
			contenido= contenido.replace(/\n/g,'');
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
		contenido= contenido.replace(/\n/g,'');		

	}

	if (!http_request) {
	alert('Error iniciando sesion');
	return false;
	}
	http_request.onreadystatechange = function () {
		if (http_request.readyState == 4) 
		{
			if (http_request.status == 200) 
			{
				document.getElementById('flotante-' +id).innerHTML = '<div class="motivoMensaje" style="text-align:center; height: 50px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;"><p>El Mensaje ha sido enviado al administrador. <br>Será atendido lo antes posible. Gracias.</p></div>';
				//document.getElementById('flotante-' +id).style.display='block';
				//document.getElementById('flotante-' + id).innerHTML = "";
				//loginVisible = false;
			} 
			else 
			{
				alert(http_request.status + ' ' + 'Hubo problemas con la peticiÃ³n.');
			}
		}
	};

	//alert(contenido);
	// Codifica en utf8
	//contenido= unescape(encodeURIComponent(contenido));
	//contenido= unescape(contenido);
	contenido=encodeURIComponent(contenido);
	//alert(contenido);
	var urlNueva;
	urlNueva=url+'&ip='+ip+'&contenido='+contenido;

	//http_request.open('GET', urlNueva, true);
	http_request.open('POST', urlNueva, true);
	//http_request.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
	http_request.send(null);
}

function mostrardiv(id, url, ip) {
if (!loginVisible) {
//document.getElementById('flotante-' + id).innerHTML = "<div class='motivoMensaje' style='border: 1px solid #000000; text-align:center; height: 180px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;'><p>Informa al administrador de contenido inapropiado</strong>.</p><strong></strong></p><form name='form_reportar' style='margin: 0px;height: 110px;' action='"+url+"' method='post'><label for='' class='' style='font-size: x-small; color: #000; font-weight: bold;'>Motivo</label><br/><textarea name='contenido' rows='5' cols='30'></textarea><br><input id='' style='font-family: Arial,Helvetica,sans-serif; font-size: x-small; color: BLACK;' name='enviar' value='Enviar' tabindex='1' type='submit'></form></div>";
//document.getElementById('flotante-' + id).innerHTML = '<div class="motivoMensaje" style="border: 1px solid #000000; text-align:center; height: 180px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;"><p>Informa al administrador de contenido inapropiado.</p><form name="form_reportar" id="form_reportar" style="margin: 0px;height: 110px;"><label for="" class="" style="font-size: x-small; color: #000; font-weight: bold;">Motivo</label><br><textarea name="contenido" rows="5" cols="30"></textarea><br><input id="" style="font-family: Arial,Helvetica,sans-serif; font-size: x-small; color: BLACK;" name="enviar" value="Enviar" tabindex="1" type="submit" onclick=javascript:enviarFormulario("/reportarMensaje","form_reportar",'+id+');></form></div>';
//document.getElementById('flotante-' + id).innerHTML = '<div class="motivoMensaje" style="border: 1px solid #000000; text-align:center; height: 180px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;"><p>Informa al administrador de contenido inapropiado.</p><label for="" class="" style="font-size: x-small; color: #000; font-weight: bold;">Motivo</label><br><textarea name="contenido-'+id+'" id="contenido-'+id+'" rows="5" cols="30"></textarea><br><input id="enviar" style="font-family: Arial,Helvetica,sans-serif; font-size: x-small; color: BLACK;" name="enviar" value="Enviar" tabindex="1" type="submit" onclick=javascript:enviarFormulario("'+url+'",'+id+');></div>';
document.getElementById('flotante-' + id).innerHTML = '<div class="motivoMensaje" style="border: 1px solid #000000; text-align:center; height: 180px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;"><p>Informa al administrador de contenido inapropiado.</p><p>Motivo</p><textarea name="contenido-'+id+'" id="contenido-'+id+'" rows="5" cols="30"></textarea><br><input id="enviar" style="font-family: Arial,Helvetica,sans-serif; font-size: x-small; color: BLACK;" name="enviar" value="Enviar" tabindex="1" type="submit" onclick=javascript:enviarFormulario("'+url+'",'+id+',"'+ip+'");></div>';
loginVisible = true;
}
else {
document.getElementById('flotante-' + id).innerHTML = "";
loginVisible = false;
}
}

function actualizarTagSelector(idTag,idUsuario,activo) {
//alert(document.getElementById('tags_' + idTag).innerHTML);
contenido=document.getElementById('tags_' + idTag).innerHTML;
var navegador = navigator.appName;
if (navegador == "Microsoft Internet Explorer")
{
	var posI=contenido.indexOf("BACKGROUND-COLOR: #a9d0ed;");
	if(posI != -1)
		contenido= contenido.replace("BACKGROUND-COLOR: #a9d0ed;","");
	else
		contenido= contenido.replace("px","px;BACKGROUND-COLOR: #a9d0ed;");
	}
else{
	var pos=contenido.indexOf("background-color: rgb(169, 208, 237);");
	if(pos != -1)
		contenido= contenido.replace("background-color: rgb(169, 208, 237);","");
	else
		contenido= contenido.replace("px;","px;background-color: rgb(169, 208, 237);");
}
document.getElementById('tags_' + idTag).innerHTML=contenido;

	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			contenido= contenido.replace(/\n/g,'[blobic:return]');
			http_request.overrideMimeType('text/xml');
		}	
		} else if (window.ActiveXObject) { // IE
			contenido= contenido.replace(/\n/g,'');
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
			}
		contenido= contenido.replace(/\n/g,'');	
	}
	
	if (!http_request) {
		alert('Error iniciando sesion');
		return false;
	}
	http_request.onreadystatechange = function () {
		if (http_request.readyState == 4) 
		{
		if (http_request.status == 200) 
		{
			//document.getElementById('flotante-' +id).innerHTML = '<div class="motivoMensaje" style="text-align:center; height: 50px; padding-top: 20px;width: 100%;font-family: Verdana,Arial,Helvetica,sans-serif;font-size: x-small; color: #000; font-weight: bold;"><p>El Mensaje ha sido enviado al administrador. <br>Será atendido lo antes posible. Gracias.</p></div>';			
		} 
		else 
		{
			alert(http_request.status + ' ' + 'Hubo problemas con la peticiÃ³n.');
		}
		}
	};
	//alert(contenido);
	var urlNueva;
	urlNueva='/tagSelector/?idUsuario='+idUsuario+'&idTag='+idTag;	
	http_request.open('POST', urlNueva, true);
	http_request.send(null);

}
//-->


