function borrarFoto(intIdFoto, tipo, id) {
	div = document.getElementById("divBorrarFotos");
	div.innerHTML = '<img src="images/ajax.gif"> borrando foto...';
	simple_ajax("ajaxBorrarFoto.php", "POST","foto=" + intIdFoto + "&tipo=" + tipo + "&id=" + id);
	
}

function enviarSolicitudAmigo(intIdAmigo, intIdUsuario){
	var frm = document.Form;
		var strError = '';
		var objCheck = new check("Form");
		
		//objCheck.checkString("txtMensajeA", "mensaje personal", 1, 255, true);
		
		strError = objCheck.toString();
		if(strError == "") {
			
			var strValues = "ida="+intIdAmigo+"&idu="+intIdUsuario+"&txtMensaje="+document.getElementById("txtMensajeA").value;
			document.getElementById("txtMensajeA").value="Enviado";
			document.getElementById("divSerAmigo").innerHTML = "<img src='images/ajax.gif'>"
			simple_ajax("ajaxEnviarSolicitudAmigoUsuario.php", "POST", strValues);
		} else {
			alert(strError);
		}
	
	
}

function enviarInapropiado(intIdUsuario, intId, intTipo){
	var frm = document.Form;
	var strError = '';
	var objCheck = new check("Form");
	//objCheck.checkString("txtMensajeInapropiado", "mensaje", 1, 500, false);
	
	strError = objCheck.toString();
	if(strError == "") {
		var strValues = "usuario="+intIdUsuario+"&idu="+intId+"&tipo="+intTipo+"&mensaje="+document.getElementById("divInapropiado").value;
			document.getElementById("divInapropiado").value="Enviado";
			document.getElementById("divInapropiado").innerHTML = "<img src='images/ajax.gif'>"
			simple_ajax("ajaxInapropiado.php", "POST", strValues);

	//	div = document.getElementById("divInapropiado");
		//var strMensaje = frm.txtMensajeInapropiado.value;
		//div.innerHTML = '<img src="images/ajax.gif"> Enviando mensaje...';

		//ajaxHTML("POST", "ajaxInapropiado.php", div, "usuario=" + intIdUsuario + "&id=" + intId + "&tipo=" + intTipo + "&mensaje=" + strMensaje);
	} else {
		alert(strError);
	}
}
function borrarFotos(){
		if(document.getElementById("divBorrarFotos").style.display == "none") {
			document.getElementById("divBorrarFotos").style.display ="block";
		} else {
			document.getElementById("divBorrarFotos").style.display ="none";
		}
}
function verInapropiado() {
	document.getElementById("divInapropiado").style.display ="block";
}

function ocultarInapropiado(){
	document.getElementById("divInapropiado").style.display ="none";
}

function cambiarSolapa() {
			if(document.getElementById("Fotos").src.indexOf("fotos_.png") > 0) {
				MM_swapImage('Fotos','','images/player/videos_.png',1)
				document.getElementById("divPlayerVideo").style.display = "block";
				document.getElementById("divPlayerFotos").style.display = "none";
			} else {
				MM_swapImage('Fotos','','images/player/fotos_.png',1)
				document.getElementById("divPlayerVideo").style.display = "none";
				document.getElementById("divPlayerFotos").style.display = "block";
			}	
		}

function mostrarVideo() {
	if(document.getElementById("divVideo").style.display == "none") {
		document.getElementById("divVideo").style.display ="block";
	} else {
    	document.getElementById("divVideo").style.display ="none";
	}	
}

function mostrarFoto() {
	if(document.getElementById("divImagen").style.display == "none") {
		document.getElementById("divImagen").style.display ="block";
	} else {
    	document.getElementById("divImagen").style.display ="none";
	}	
}

function subirImagen() {
	var frm = document.Form;
	
	if(frm.filImagen.value != "") {
		arrExt = frm.filImagen.value.split(".");
		if(arrExt[arrExt.length-1].toLowerCase() != "jpg" && arrExt[arrExt.length-1].toLowerCase() != "jpeg") {	
			alert('Por favor, seleccione un archivo JPG');
			return;
		}
		frm.hidEnviarFoto.value="1";	
		document.getElementById("lbl1").innerHTML = '<img src="images/uploading.gif">subiendo archivo, un momento por favor...';
		frm.submit();
		
	} else {
		alert('Por favor, seleccione un archivo JPG');
	}
	
}

function subirImagenNew() {
	var frm = document.anadfoto;
	
	if(frm.filImagen.value != "") {
		arrExt = frm.filImagen.value.split(".");
		if(arrExt[arrExt.length-1].toLowerCase() != "jpg" && arrExt[arrExt.length-1].toLowerCase() != "jpeg") {	
			alert('Por favor, seleccione un archivo JPG');
			return;
		}
		frm.hidEnviarFoto.value="1";	
		frm.submit();
		
	} else {
		alert('Por favor, seleccione un archivo JPG');
	}
	
}



function subirVideo() {
	var frm = document.Form;
	var strError = '';
	var objCheck = new check("Form");
	objCheck.checkString("txtTitulovideo", "título del video", 1, 60, false);

	strError = objCheck.toString();
	if(strError == "") {
		//chequear si la imagen es JPG o JPEG
		if(frm.filImagenVideo.value != "") {
			arrExt = frm.filImagenVideo.value.split(".");
			if(arrExt[arrExt.length-1].toLowerCase() != "jpg" && arrExt[arrExt.length-1].toLowerCase() != "jpeg") {	
				alert('Por favor, seleccione un archivo JPG');
				return;
			}
		}
		
		
		//chequear si el archivo esta lleno, y es flv.
		if(frm.filVideo.value == "") {
			alert('Por favor, seleccione un archivo FLV');
			return;
		}
		arrExt = frm.filVideo.value.split(".");
		if(arrExt[arrExt.length-1].toLowerCase() != "flv") {
			alert('El archivo debe ser de formato FLV');
			return;
		} else {
			frm.hidEnviarVideo.value="1";	
			document.getElementById("lbl3").innerHTML = '<img src="images/uploading.gif">subiendo archivo, un momento por favor...';
			frm.submit();
		}
		
	} else {
		alert(strError);
		
	}

}

function verVideo(intIdVideo, intId, tipo, borrar) {
	div = document.getElementById("divPlayerVideo");
	div.height="250";
	div.innerHTML = '<img src="images/ajax.gif">';
	
	ajaxHTML("GET", "ajaxVerVideo.php?borrar="+borrar+"&tipo="+tipo+"&id="+intId+"&video=" + intIdVideo, div);
}

function borrarVideo(intIdVideo, intId, tipo, borrar) {
	div = document.getElementById("divPlayerVideo");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxBorrarVideo.php?borrar="+borrar+"&id=" + intId +  "&tipo="+tipo+"&video=" + intIdVideo, div);
}

function subirVideo_() {
	var frm = document.Form;
	var strError = '';
	var objCheck = new check("Form");
	objCheck.checkString("txtTituloVideo", "título del video", 1, 100, false);	
	if(frm.txtCodigoVideo.value == "") {
			alert('Inserte el código embebido del video por favor.');
			return;	
		}	
		
		if(frm.txtCodigoVideo.value.toUpperCase().indexOf("SCRIPT") > 0) {
			alert('El campo código embebido es inválido');
			return;	
		}	
		if(frm.txtCodigoVideo.value.toUpperCase().indexOf("EMBED") == 0) {
			alert('El campo código embebido es inválido');
			return;	
		}	

	strError = objCheck.toString();
	if(strError == "") {
		
		frm.hidEnviarVideo.value="1";	
		document.getElementById("lbl3").innerHTML = '<img src="images/uploading.gif">un momento por favor...';
		frm.submit();
		
	} else {
		alert(strError);
		
	}

}

function mostrarMp3() {
	if(document.getElementById("divMp3").style.display == "none") {
		document.getElementById("divMp3").style.display ="block";
	} else {
    	document.getElementById("divMp3").style.display ="none";
	}	
}

function subirMp3() {


var frm = document.Form;
var strError = '';
var objCheck = new check("Form");
objCheck.checkString("txtTitulomp3", "título del mp3", 1, 60, false);

strError = objCheck.toString();
if(strError == "") {
	//chequear si el archivo esta lleno, y es mp3.
	if(frm.filMp3.value == "") {
		alert('Por favor, seleccione un archivo MP3');
		return;
	}
	arrExt = frm.filMp3.value.split(".");
	if(arrExt[arrExt.length-1].toLowerCase() != "mp3") {
		alert('El archivo debe ser de formato MP3');
		return;
	} else {
		frm.hidEnviarMp3.value="1";	
		document.getElementById("lbl2").innerHTML = '<img src="images/uploading.gif">subiendo archivo, un momento por favor...';
		frm.submit();
	}
	
} else {
	alert(strError);
	
}


}


function BuscarTag(strTag, intOpc) {
	switch(intOpc) {
		case 2: 
				document.forms[0].action = "listado_grupos.php";
				document.forms[0].hidBuscadorTag.value = strTag;
				document.forms[0].submit();				
				break;
		case 1: 
				document.forms[1].action = "listado_usuarios.php";
				document.forms[1].hidBuscadorTag.value = strTag;
				document.forms[1].submit();				
				break;		
		case 0: 
				document.forms[1].action = "listado_general.php";
				document.forms[1].hidBuscadorTag.value = strTag;
				document.forms[1].submit();				
				break;
		case 3: 
				document.forms[1].action = "listado_eventos.php";
				document.forms[1].hidBuscadorTag.value = strTag;
				document.forms[1].submit();				
				break;				
	} 
}

function BuscadorGeneral() {
		var frm = document.FormBuscador;
		var strError = '';
		var objCheck = new check("FormBuscador");
		LimpiarCampo(frm.txtBuscadorG, 'Introduce aqui tu búsqueda');
		objCheck.checkString("txtBuscadorG", "buscador general", 3, 1000, false);
		
		strError = objCheck.toString();
		if(strError == "") {
			frm.submit();
		} else {
			alert(strError);
			
		}
}

function BuscadorGrupos() {
	var frm = document.Form;
		var strError = '';
		var objCheck = new check("Form");
		
		objCheck.checkString("txtBuscadorGrupo", "tags", 3, 1000, false);
		
		strError = objCheck.toString();
		if(strError == "") {
			frm.action="listado_grupos.php";
			frm.submit();
		} else {
			alert(strError);
		}
}
function BuscadorGruposNew() {
	var frm = document.buscasgrupos;
		var strError = '';
		var objCheck = new check("buscasgrupos");
		
		//objCheck.checkString("palabras", "tags", 3, 1000, false);
		objCheck.checkString("txtBuscadorGrupo", "tags", 3, 1000, false);
		strError = objCheck.toString();
		if(strError == "") {
			frm.action="listado_grupos.php";
			frm.submit();
		} else {
			alert(strError);
		}
}

function BuscadorUsuarios() {
	var frm = document.Form;
		var strError = '';
		var objCheck = new check("Form");
		objCheck.checkString("txtBuscadorUsuario", "tags", 3, 1000, false);
		
		
		strError = objCheck.toString();
		if(strError == "") {
			frm.action="listado_usuarios.php";
			frm.submit();
		} else {
			alert(strError);
		}
}

function BuscadorUsuariosNew1() {
	var frm = document.buscar;
		var strError = '';
		var objCheck = new check("buscar");
		
		//objCheck.checkString("palabras", "tags", 3, 1000, false);
		objCheck.checkString("txtBuscadorUsuario1", "tags", 3, 1000, false);
		strError = objCheck.toString();
		if(strError == "") {
			frm.action="listado_usuarios.php";
			frm.submit();
		} else {
			alert(strError);
		}
}
function BuscadorUsuariosNew2() {
	var frm = document.buscasamigos;
		var strError = '';
		var objCheck = new check("buscasamigos");
		
		//objCheck.checkString("palabras", "tags", 3, 1000, false);
		objCheck.checkString("txtBuscadorUsuario2", "tags", 3, 1000, false);
		strError = objCheck.toString();
		if(strError == "") {
			frm.action="listado_usuarios.php";
			frm.submit();
		} else {
			alert(strError);
		}
}
function BuscadorUsuariosNew3() {
	var frm = document.buscas-amigos;
		var strError = '';
		var objCheck = new check("buscas-amigos");
		
		//objCheck.checkString("palabras", "tags", 3, 1000, false);
		objCheck.checkString("txtBuscadorUsuario3", "tags", 3, 1000, false);
		strError = objCheck.toString();
		if(strError == "") {
			frm.action="listado_usuarios.php";
			frm.submit();
		} else {
			alert(strError);
		}
}


function verImagen(intOpc) {
	if(intOpc == 1) {
		document.getElementById("divImagen1").style.display = "none";
		document.getElementById("divImagen2").style.display = "block";
	} else {
		document.getElementById("divImagen2").style.display = "none";
		document.getElementById("divImagen1").style.display = "block";
	}	
}

function verPass(intOpc) {
	if(intOpc == 1) {
		document.getElementById("divPass1").style.display = "none";
		document.getElementById("divPass2").style.display = "block";
	} else {
		document.getElementById("divPass2").style.display = "none";
		document.getElementById("divPass1").style.display = "block";
	}	
}

function actualizarImagen(){
	div = document.getElementById("divImg");
	div.innerHTML = '<img src="images/ajax.gif">';
	ajaxHTML("GET", "ajaxCaptcha.php", div);
}

function LimpiarCampo(objText, strValue){
	if(objText.value == strValue) {
		objText.value = "";
	}
}

function emptyObjCmb(obj){
		for (i=0; i < obj.length; i++) {
	 		obj.options[i] = null;
	 	}
	 	obj.options.length = 0;
}

function comentar() {
	if(document.getElementById("divComentario").style.display == "block"){
		document.getElementById("divComentario").style.display = "none";
	} else {
		document.getElementById("divComentario").style.display = "block";
		document.getElementById("txtComentario").focus();
	};
	
}

function publicarComentario(intIdDestino) {
		var frm = document.FormComentario;
		var strError = '';
		var objCheck = new check("FormComentario");
		
		/* Limpio los campos */
		LimpiarCampo(frm.txtComentario, 'Escribe aquí tu comentario...');
		
		objCheck.checkString("txtComentario", "comentario", 5, 10000, false);
			
		strError = objCheck.toString();
		
		if (strError == "") {
			document.getElementById("divComentario").style.display = "none";
			document.getElementById("divComentarios").innerHTML = "<img src='images/ajax.gif'>";
			document.getElementById("txtComentario").value = strReplace(document.getElementById("txtComentario").value, "&", "[amp]");
			InsertarComentario(intIdDestino);
			document.getElementById("txtComentario").value = "Escribe aquí tu comentario...";
		} else {
			alert(strError);
		}
}

function login(frm){
	frm.action="login.php";
	frm.submit();
}

function verPagina(strPagina) {
	document.Form.action = strPagina;
	document.Form.submit();
}
function verPaginacion(strPagina) {
	document.location = strPagina;
}