function nuevoAjax()
{ 
	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 eliminaEspacios(cadena)
{
	var x=0, y=cadena.length-1;
	while(cadena.charAt(x)==" ") x++;	
	while(cadena.charAt(y)==" ") y--;	
	return cadena.substr(x, y-x+1);
}



function ReportarAbuso(evento) 
{
	//REPORTAR ABUSO
	if(evento=="abuso")
	{	
		//Sesion
		var r_sesion   = document.getElementById("v_sesion").value;
		var r_idmodelo = document.getElementById("v_idmodelo").value;

		
		//VALIDACIONES
		if(r_sesion=="") 
		{
			alert("Sólo para Usuarios de la Comunidad");
			errores++;
			return false;
		}
		
		if(r_sesion!="") 
		{
			if(confirm("¿Seguro de que deseas reportar este Usuario como abuso?"))
			{
				//ELIMINAR ESPACIOS 
				var errores = 0;	
				r_idmodelo = eliminaEspacios(r_idmodelo);
				
				//VALIDACIONES
				if(r_idmodelo=="") 
				{
					div_alerta.innerHTML = "<img src='imagenes/icon_error.gif' border='0'>&nbsp;No existe Usuario a reportar";
					errores++;
					return false;
				}
				
				//ENVIO
				if(errores == 0)
				{				
					var ajax=nuevoAjax();
					ajax.open("POST", "mipagina_rptabuso_mtr.php5", true);
					ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					ajax.send("v_evento="+evento+"&v_idmodelo="+r_idmodelo);			
					ajax.onreadystatechange=function()
					{
						if (ajax.readyState==4)
						{
							//div_alerta.innerHTML = ajax.responseText;		
							alert("Se ha reportado satisfactoriamente")
						}
					}
				}
			}
		}
	}
}
