function openArtista(idUsuario, pagina){
	var resposta=sendFormGET("formulario&layout=none&idUsuario="+idUsuario+"&page="+pagina);
	document.getElementById('dinamicSuperior').innerHTML = resposta;
	
	var swfu = new SWFUpload(settings);
	var oFCKeditor = new FCKeditor( 'Biografia','465','200'); oFCKeditor.BasePath = BASEDIR + 'libs/fckeditor/'; oFCKeditor.ReplaceTextarea();
	
	if(document.getElementById('dinamicSuperior').style.display=='none'){
		new Effect.BlindDown('dinamicSuperior');
	}
}

function saveArtista(){
	var Nombre = document.getElementById('Nombre').value;
	var Username = document.getElementById('Username').value;
	var idUsuario = document.getElementById('idUsuario').value;
	var pass = document.getElementById('Password').value;
	var conf_pass = document.getElementById('Conf_Password').value;
	
	
	if (Username != "" && Nombre != ""){
		if (pass != conf_pass){ alert(art[1]); return;}
		var resNombre = sendFormGET(BASEDIR+"usuarios/comprobarUsername&username="+Username+"&idUsuario="+idUsuario+"&template=none");
		if (resNombre!="Ok"){alert(art[2]); return;}
		if (idUsuario!=""){
			if(confirm(art[3])){
				document.getElementById("datos").submit();
			}
		}else{
			if (pass != ""){
				document.getElementById("datos").submit();
			}else{
				alert(art[4]);
			}
		}
	}else{
		alert(art[5]);
	}
}

function deleteArtista(idUsuario, Pagina){
	if(idUsuario!=''){
		if(confirm(art[6])){
			var resposta = sendFormGET(BASEDIR+"admin/usuarios/eliminar&template=none&idUsuario="+idUsuario);
		}
		location.reload();
	}
}

function changeState(Item){
	/* Cojemos la ruta de la imagen */
	aPath = explode("/", document.getElementById("Estado"+Item).src);
	/* Cojemos el estadoActual */
	estadoActual = (aPath[aPath.length-1]);
	estadoActual = substr(estadoActual, 0, -4);
	estadoActual = substr(estadoActual, 5, 1);
	/*Llamamos a la accion por ajax*/
	var res=sendFormGET(BASEDIR + "admin/usuarios/cambiarEstado&layout=none&idUsuario="+Item+"&estado="+estadoActual+"&template=none");
	if (res!=""){
		/* Cambiar la imagen actual */
		aPath = explode("/", document.getElementById("Estado"+Item).src);
		path  = "";
		for (i=0; i<aPath.length-1; i++) path += aPath[i] + "/" ;
		
		/*Actualizar la imagen*/
		path += "state"+res+".png";
		document.getElementById("Estado"+Item).src = path;
	}
}

function addFavoritos(idArtista){
	if (idArtista == '') return;
	var resposta = sendFormGET(BASEDIR+"artistas/addFavoritos&template=none&idArtista="+idArtista);
	
	if (resposta == "0") alert(art[0]);
	else if (resposta == "1"){
		//Todo ok
		document.getElementById('addFavoritos').style.display = 'none';
		document.getElementById('delFavoritos').style.display = 'block';
	}
	else
		alert(resposta);
}

function delFavoritos(idArtista){
	if (idArtista == '') return;
	
	if (confirm(art[1])){
	var resposta = sendFormGET(BASEDIR+"artistas/delFavoritos&template=none&idArtista="+idArtista);
	
	if (resposta == "0") alert(art[2]);
	else if (resposta == "1"){
		//Todo ok
		document.getElementById('delFavoritos').style.display = 'none';
		document.getElementById('addFavoritos').style.display = 'block';		
	}
	else
		alert(resposta);
	}
}

function addFavoritosB(nombreArtista){
	if (nombreArtista == '') return;
	var resposta = sendFormGET(BASEDIR+"artistas/addFavoritosB&template=none&nombreArtista="+nombreArtista);
	
	if (resposta == "0") alert(art[0]);
	else if (resposta == "1"){
		//Todo ok
		document.getElementById('addFavoritosB').style.display = 'none';
		document.getElementById('delFavoritosB').style.display = 'block';
	}
	else
		alert(resposta);
}

function delFavoritosB(nombreArtista){
	if (nombreArtista == '') return;
	
	if (confirm(art[1])){
	var resposta = sendFormGET(BASEDIR+"artistas/delFavoritosB&template=none&nombreArtista="+nombreArtista);
	
	if (resposta == "0") alert(art[2]);
	else if (resposta == "1"){
		//Todo ok
		document.getElementById('delFavoritosB').style.display = 'none';
		document.getElementById('addFavoritosB').style.display = 'block';		
	}
	else
		alert(resposta);
	}
}
