// JavaScript Document


	var x;
	x=$(document);
	x.ready(inicializar);
	function inicializar (){
		
		x=$("#selecCanciones");
		x.click(cargoCancion);
		
		x=$("#comentar");
	    x.click(comentar);
		x=$("#pepito");
		x.click(prueba);
		
		document.getElementById('direccion').disabled  = true;
		document.getElementById('telefono').disabled  = true;
		document.getElementById('ciudad').disabled = true;
		document.getElementById('pais').disabled = true;
		document.getElementById('graduacion').disabled = true;
						
		x=$("#siG");
		x.click(miembroSi);
		x=$("#noG");
		x.click(miembroNo);
		x=$("#nombre");
		x.blur(validoNombre);
		
		//x=$("#comentar");
	   // x.click(comentar);
	   
	  
		 
	}
	

function cargoCancion(){ 

			var x =$(this);
			var cod =x.attr("value");
			
			
			$.ajax({async:true,
					type:"GET",
					dataType:"html",
					contentType:"application/x-www-form-urlencoded",
					url:"cancion.php",
					data:"cancion="+cod,
					success:cargoCancionOK,
					});
}
		
function cargoCancionOK(resultado){
			var x=$("#letra");
			x.html(resultado);
			
}
		
	

function prueba(){
	alert("hola");
}


function comentar(){
	alert("hola");
	var x=$("#nombreForista");
	var n = x.attr("value");
	var y=$("#textoCometario");
	var t = y.attr("value");
	var z=$("#idTema");
	var i =z.attr("value");
	
	
fecha = new Date();
mes = fecha.getMonth();
dia = fecha.getDate().toString();
anio = fecha.getYear().toString();
mes +=1;
mes.toString();
anio=anio.substring(1, 3); 
anio="20"+anio;

//alert(dia+"/"+mes+"/"+anio);
var f=(dia+"/"+mes+"/"+anio);
	//alert(i);
	//alert(t);
	cargarComentario(n,t,i,f);
	
}




function reseteo(){
	
		document.getElementById('direccion').disabled  = true;
		document.getElementById('telefono').disabled  = true;
		document.getElementById('ciudad').disabled = true;
		document.getElementById('pais').disabled = true;
		document.getElementById('graduacion').disabled = true;
}


function miembroNo(){
	x=$(this);
	if(x.attr("value")== "no"){
		document.getElementById('direccion').disabled  = true;
		document.getElementById('telefono').disabled  = true;
		document.getElementById('ciudad').disabled = true;
		document.getElementById('pais').disabled = true;
		document.getElementById('graduacion').disabled = true;
	}
}

function miembroSi(){
	x=$(this);
	if(x.attr("value")== "si"){
		document.getElementById('direccion').disabled  = false;
		document.getElementById('telefono').disabled  = false;
		document.getElementById('ciudad').disabled = false;
		document.getElementById('pais').disabled = false;
		document.getElementById('graduacion').disabled = false;
	}
}

function validoNombre(){
	var r = false;
	var x=$("#nombre");
	if(x.attr("value")!=""){
		r=true;
		
	}else{
		alert("El campo Nombre no puede estar vacio!");
	}
	return r;
}
function validoApellido(){
	var r = false;
	var x=$("#apellido");
	if(parseInt( x.attr("value"))){
		alert("El campo Apellido no puede tener carecteres Numericos!");
	}else{
		r=true;
	}
	return r;
}
function validoEdad(){
	var r = false;
	var x=$("#edad");
	if(!isNaN(x.attr("value"))){
		r=true;
		
	}else{
		alert("El campo Edad debe tener solo caracteres Numericos!");
	}
	return r;
}
function validoMail(){
	var r = false;
	var x=$("#mail");
	if(x.attr("value")==""){
		
		alert("El campo E-Mail NO puede estar vacio!");
	}else{
		r=true;
	}
	return r;
}
function validoMailRep(){
	var r = false;
	var x=$("#mail");
	var y=$("#repmail");
	if(y.attr("value")==""){
		
		alert("El campo 'repita E-Mail' NO puede estar vacio!");
	}else{
		if(y.attr("value")==x.attr("value")){
			r=true;
		}else{
			alert("Los E-Mail's NO coinsiden!");
		}
		
	}
	return r;
}
function validoClave(){
	var r = false;
	var x=$("#pass");
	if(x.attr("value")==""){
		
		alert("El campo Clave NO puede estar vacio!");
	}else{
		r=true;
	}
	return r;
}
function validoConfirmacion(){
	var r = false;
	var x=$("#pass");
	var y=$("#confirmacion");
	if(y.attr("value")==""){
		
		alert("El campo Confirmación NO puede estar vacio!");
	}else{
		if(y.attr("value")==x.attr("value")){
			r=true;
		}else{
			alert("Las Claves NO coinsiden!");
		}
		
	}
	return r;
}
function validoTel(){
	var r = false;
	var x=$("#telefono");
	if(x.attr("value")==""){
		alert("El campo Teléfono NO puede estar vacio!");
	}else{
		r=true;
	}
	return r;
}
function validoGraduacion(){
	var r = false;
	var x=$("#graduacion");
	if(x.attr("value")==""){
		alert("El campo Graduación NO puede estar vacio!");
	}else{
		r=true;
	}
	return r;
}

function validoNomU(){ 
			var x=$("#nomU");
			var nomU = x.attr("value");
			
			if(x.attr("value")==""){
				alert("El campo Nombre de Usuario NO puede estar vacio!");
			}else{
				
				validoUsuario(nomU);
				r=true;
				
			}
					
			
	}
function validoUsuario(nombre){ 
			alert(nombre);
			
			$.ajax({async:true,
					type:"GET",
					dataType:"html",
					contentType:"application/x-www-form-urlencoded",
					url:"validoUsuario.php",
					data:"nomU="+nombre,
					success:validoUsuarioOK,
					error:errorDatos,
					});
	}
		
		function validoUsuarioOK(resultado){
			var x;
			//x.change("window.location='fotos.php'");
			x.alert("pepe");
			x=$("#usuarioValido");
			x.html(resultado);
			
		}
				

	
function validar(){
	
	alert("validando!");
}

/*function registrar(nombre){ 
			//alert("validando!");
			
			$.ajax({async:true,
					type:"GET",
					dataType:"html",
					contentType:"application/x-www-form-urlencoded",
					url:"guardarRegistro.php",
					data:"nomU="+nombre,
					success:datoOK,
					error:errorDatos,
					});
	}
		
		function datoOK(resultado){
			var x;
			//x.change("window.location='fotos.php'");
			x.alert("pepe");
			x=$("#mensaje");
			x.html(resultado);
			
		}
		
		function errorDatos{
			
			alert("error!");
		}
		*/

/*function f(foto,y){
	x=this;
	x.alert(foto);
	x.alert(y);
	//x.change("window.location='fotos.php'");
}


function cargoFoto1(){
	
	x="images/pic/5.jpg";
	alert(x);
	x.change("window.location='fotos.php'");
}

/*function cargoFoto(foto,volver){ 
			
			
			$.ajax({async:true,
					type:"GET",
					dataType:"html",
					contentType:"application/x-www-form-urlencoded",
					url:"fotos.php",
					data:"urlFoto="+"images/pic/"+foto+".jpg"+"&nomFoto="+foto+"&volver="+volver,
					success:datoOK,
					});
	}
		
		function datoOK(resultado){
			var x;
			//x.change("window.location='fotos.php'");
			x.alert(foto);x.alert(volver);
			x=$("#divFoto");
			x.html(resultado);
			
		}

/*function selctFoto(f){
	alert("hoka");	
	<html>
	<link rel="stylesheet" href="images/BrightSide.css" type="text/css" />

	 
<div align="center"><img src="images/pic/mestres1.jpg" alt="home" width="500" height="500" border="0" align="bottom" class="center" />
<div align="center">
 <a href="historia.html" ><input type="submit"  value="Volver" class="button2" ></a>
<br><br>
</div>
	
</		html>	/*var x=document.getElementById('media').value;
	var f= foto;
	 alert("hola");
	//<div id="main">
   x.html('<a href="index.html"><img src="images/'f'.jpg" width="230" height="130" alt="home" title="logo" border="0" class="logo" /></a><');
  alert("hola");*/
//}
