function borrar_clasif(nro){
		var dataString = 'idclasif='+ nro;
		if(confirm('¿Seguro que desea eliminar su clasificado?')){
			// Enviar datos
			jQuery.ajax({
				type: "POST",
				url: "wall/borrar_clasif_home.php",
				data: dataString,
				cache: false,
				success: function(html){
					jQuery("#clas_"+nro).hide("slow");
				}
			});
		}
	 	return false;
}

function cierra_navegador(){
	dataString = "id="+getCookie("useridwall");
	$.ajax({
		type: "POST",
		url: "wall/baja_estado_chat.php",
		data: dataString,
		cache: false,
		success: function(html){
		}
	});
}

function recargar_usuarios_conectados(){
	$.ajax({
		type: "POST",
		url: "wall/recargar_usuarios.php",
		cache: false,
		success: function(html){
			$("#chat_users").html(html);
		}
	});
	setTimeout('recargar_usuarios_conectados();','30000');
}

function hayMalasPalabras(str){
	var flag = false;
	str = str.toLowerCase();
	var groserias = ["' or '1'='1'", 'insert', '[/url]', '[/link]','select', '<iframe', '<div', '<a', '<script>', 'script', 'document','<object', 'embed', 'vergas', 'verga', 'count', 'url', 'union','puto','puta','culo','trolo','trola','mierda','cagon','conchuda','pija','maricon','maraca','concha','pelotudo','conchudo','sorete', 'boludo','voludo','zorete',
	,'hijo de puta', 'la puta madre que te pario','pajero','pajera' ,'huebon', 'huevon', 'chupame esta', 'chupala', 'hdp', 'orto', 'horto', 'lpm', 'chupen', 'cojerte', 'cojanse', 'cogerte',
	'forro', 'forra', 'guacho', 'cojer', 'mal cojida', 'garompa', 'garchar', 'pelotudece', 'cogida', 'cogido', 'cago', 'mal cogida', 'culoroto', 'gil', 'hijodeputa', 'mamala', 'culo roto', 'gay', 'marica', 'ojete', 'navo', 'nabo', 'culean', 'culiar', 'culeo'];
	for(i=0; i<groserias.length && !flag; i++){
		if(str.indexOf(groserias[i])!=-1){
			//alert("IZQ---"+str.charAt(str.indexOf(groserias[i])-1)+"---"+str.charAt(str.indexOf(groserias[i])-1)+"DER----"+str.charAt(str.indexOf(groserias[i])+groserias[i].length)+"---"+str.charAt(str.indexOf(groserias[i])+groserias[i].length))
			if( (str.charAt(str.indexOf(groserias[i])-1)=="" || str.charAt(str.indexOf(groserias[i])-1)==" ") && (str.charAt(str.indexOf(groserias[i])+groserias[i].length)=="" || str.charAt(str.indexOf(groserias[i])+groserias[i].length)==" "))
				flag = true;
		}
	}
	return flag;
}

/*FUNCION PARA EL LIBRO DE VISITAS DE LOS SUPLEMENTOS Y cLASIFICADOS PARA QUE NO PUEDAN ESCRIBIR MALAS PALABRAS*/
function filtrarPalabrasLibroVisitas(){
	var msj = document.comentarios.mensaje.value;
	if(!hayMalasPalabras(msj)){
		//alguna accion
	}
	else{
		alert("El mensaje no se publicara porque el mensaje contiene malas palabras");
		return false;
	}
}

function filtrarPalabrasClasif(){
	var nombre = document.clasif.nombre.value;
	var titulo = document.clasif.titulo.value;
	if(nombre != titulo){
		return false;
	}
	else{
		alert("El mensaje no se publicara porque el mensaje contiene palabras no apropiadas");
		return false;
	}
}
/*FIN*/

function cambiar_estado(user_id){
	dataString = "id="+getCookie("useridwall");
	$.ajax({
		type: "POST",
		url: "wall/toogle_estado_chat.php",
		data: dataString,
		cache: false,
		success: function(html){
		}
	});
}

function bloquear_usuario(user_bloqueado){
	dataString = "user_bloqueado="+user_bloqueado;
	$.ajax({
		type: "POST",
		url: "admin_chat.php",
		data: dataString,
		cache: false,
		success: function(html){
		}
	});
}

function showNot(type){
	$("#numN").html("0");
	var posicion;
	if(type=="M"){
		if($("#viewMensajes").is(":visible"))
			$("#viewMensajes").hide();
		else{
			$("#viewNotificaciones").hide();
			$("#viewMensajes").show("slow");
			posicion = $("#M").position();
			$("#viewMensajes").css("top", posicion.top);
			$("#viewMensajes").css("left", posicion.left+20);
		}
	}
	else{
		if($("#viewNotificaciones").is(":visible"))
			$("#viewNotificaciones").hide();
		else{
			$("#viewMensajes").hide();
			$("#viewNotificaciones").show("slow");
			posicion = $("#N").position();
			$("#viewNotificaciones").css("top", posicion.top);
			$("#viewNotificaciones").css("left", posicion.left+20);
		}
	}
}
function showInvitacion(){
	if($("#viewInvitarAmigos").is(":visible"))
			$("#viewInvitarAmigos").hide();
		else{
			posicion = $("#amigos").position();
			$("#viewInvitarAmigos").css("left", posicion.left);
			$("#viewInvitarAmigos").show("slow");
			
			//$("#viewInvitarAmigos").css("top", posicion.top);
			//$("#viewInvitarAmigos").css("left", posicion.left);
		}
}

function abrirVentana (pagina) {
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=490, height=800, top=130, left=590";
	window.open(pagina,"",opciones);
}

function irAlPerfil(){
	$("#viewNotificaciones").hide("slow");
	/*var iframe = parent.frames["ifWall1"];
	iframe.window.location.href="http://www.barilochense.com/wall/mi_perfil_presentacion.php";*/
}

function viewNot(idnoticia, tipo, megusta){
	/*var dataString = "idnoticia="+idnoticia+"&idusers="+idusers;*/
	$("#viewNotificaciones").hide("slow");
	$("#item"+idnoticia).remove();
	n=$("#numN").html();
	if(n>0)
		$("#numN").html(n-1);
	var iframe = parent.frames["ifWall1"];
	iframe.window.location.href="http://www.barilochense.com/wall/ver_notificacion.php?idnoticia="+idnoticia+"&tipo="+tipo+"&megusta="+megusta;
}

function viewMens(idmens, idde, idusers){
	/*var dataString = "idmens="+idmens+"&idde="+idde+"&idusers="+idusers;*/
	$("#viewMensajes").hide("slow");
	$("#mens"+idmens).hide();
	n=$("#numM").html();
	if(n>0)	
		$("#numM").html(n-1);
	var iframe = parent.frames["ifWall1"];
	iframe.window.location.href="http://www.barilochense.com/wall/ver_mensaje.php?idmens="+idmens+"&idde="+idde+"&idusers="+idusers;
}

function viewAllMens(){
	$("#viewMensajes").hide("slow");
	n=$("#numM").html();
	if(n>0)	
		$("#numM").html("0");
	$("#viewMensajes div.item").each(function(){
		$(this).hide();
	});
	var iframe = parent.frames["ifWall1"];
	iframe.window.location.href="http://www.barilochense.com/wall/viewAllMens.php?idusers="+getCookie("useridwall");
	
}
function viewAllNot(){
	$("#viewNotificaciones").hide("slow");
	n=$("#numN").html();
	if(n>0)	
		$("#numN").html("0");
	$("#viewNotificaciones div.item").each(function(){
		$(this).hide();
	});
	var iframe = parent.frames["ifWall1"];
	iframe.window.location.href="http://www.barilochense.com/wall/viewAllNot.php?idusers="+getCookie("useridwall");

}

function mi_perfil(idperfil){
	var iframe = parent.frames["ifWall1"];
	if ($("#ifWall1").length>0)
		iframe.window.location.href="http://www.barilochense.com/wall/wrap_perfil.php?idperfil="+idperfil;
	else
		window.location="http://www.barilochense.com?muros="+getCookie("useridwall");
	$("#uno").removeClass("pestanaseleccionada");
	$("#dos").addClass("pestanaseleccionada");
	$("#tres").removeClass("pestanaseleccionada");
	document.getElementById("ifWall1").style.height=100+"px";
}
function mi_perfil_presentacion(idperfil){
	var iframe = parent.frames["ifWall1"];
	iframe.window.location.href="http://www.barilochense.com/wall/mi_perfil_presentacion.php?idperfil="+idperfil;
	$("#uno").removeClass("pestanaseleccionada");
	$("#dos").removeClass("pestanaseleccionada");
	$("#tres").addClass("pestanaseleccionada");
	document.getElementById("ifWall1").style.height=100+"px";
}
function enviarSolicitud_amigos(nombreMio){
		var mailAmigo = $("#invitarAmigo").val();
		var nombreAmigo = $("#nombreAmigo").val();
		var interes = $("#interes").val();
		
		//$("#respSolic").html(nombreAmigo);
		// lo que se pasa en string son las variables que se le pasaran al archivo .php
		var dataString = "nombreAmigo="+nombreAmigo+"&mailAmigo="+mailAmigo+"&nombreYo="+nombreMio+"&interes="+interes;
		//if(validarEmail_amigos(mailAmigo) && validarCadena_amigos(nombreAmigo) && nombreAmigo!="Nombre de mi amigo" && !hayMalasPalabras_amigos(nombreAmigo)){
			$("#respSolic").html("Procesando...");
			$.ajax({
				type: "POST",
				url: "wall/enviar_amigo_solicitud.php",
				data: dataString,
				cache: false,
				success: function(html){
					//alert(html);
					$("#respSolic").html(html);
					$("#invitarAmigo").val("");
					$("#nombreAmigo").val("");
					$("#interes").val("");
					$("#interes").hide();
					$("#enviarAmigo2").hide();
					$("#enviarAmigo").show();
					$("#respSolic").html(html);
				}
			});
		//}
		/*else{
			alert("Debe ingresar un email valido y el nombre de su amigo - Barilochense.com");
		}*/
		return false;
		
}
function validarCadena_amigos(q) {	
	var r = false;
	for (i=0; i<q.length; i++){
		if (q.charAt(i) != " ")
			r = true;
	}
	if(r){
		if(tiene_numeros(q)==1)
			r=false
	}
	return r;
}
function validarEmail_amigos(e) {
	var r = false;
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(e))
		r = true;
	return r;
}
function hayMalasPalabras_amigos(str){
	var flag = false;
	str = str.toLowerCase();
	var groserias = ["' or '1'='1'", 'insert','select', '<iframe', '<div', '<a', '<script>', 'script', 'document','<object', 'embed', 'vergas', 'verga', 'count', 'url', 'union','puto','puta','culo','trolo','trola','mierda','cagon','conchuda','pija','maricon','maraca','concha','pelotudo','conchudo','sorete', 'boludo','voludo','zorete',
	,'hijo de puta', 'la puta madre que te pario','pajero','pajera' ,'huebon', 'huevon', 'chupame esta', 'chupala', 'hdp', 'orto', 'horto', 'lpm', 'chupen', 'cojerte', 'cojanse', 'cogerte',
	'forro', 'forra', 'guacho', 'cojer', 'mal cojida', 'cogida', 'cogido', 'cago', 'mal cogida', 'culoroto', 'gil', 'hijodeputa', 'mamala', 'culo roto', 'gay', 'marica', 'ojete', 'navo', 'nabo', 'culean', 'culiar', 'culeo'];
	for(i=0; i<groserias.length && !flag; i++){
		if(str.indexOf(groserias[i])!=-1){
			//alert("IZQ---"+str.charAt(str.indexOf(groserias[i])-1)+"---"+str.charAt(str.indexOf(groserias[i])-1)+"DER----"+str.charAt(str.indexOf(groserias[i])+groserias[i].length)+"---"+str.charAt(str.indexOf(groserias[i])+groserias[i].length))
			if( (str.charAt(str.indexOf(groserias[i])-1)=="" || str.charAt(str.indexOf(groserias[i])-1)==" ") && (str.charAt(str.indexOf(groserias[i])+groserias[i].length)=="" || str.charAt(str.indexOf(groserias[i])+groserias[i].length)==" "))
				flag = true;
		}
	}
	return flag;
}
function interes(){
	$("#interes").show();
	$("#linteres").hide();
	$("#enviarAmigo").hide();
	$("#enviarAmigo2").show();
}
function muro_favorito_si(muro,user){
	$.ajax({
		type: "POST",
		url: "wall/setMuroFavorito.php",
		data: {muro: muro,user: user},
		cache: false,
		success: function(html){
			if (html=="1")
				$("#muro_favorito").html("Listo!");
			else
				$("#muro_favorito").html("Error");
		}
	});		
}
function cerrar_notificaciones(){
	$("#viewNotificaciones").hide();
}
function cerrar_mensajes(){
	$("#viewMensajes").hide();
}
