$(function(){
	$("#SendBoton").click(function(event) {
		event.preventDefault();
//		alert('hola');
		error = 0;
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		var str = $('#email').val()
			if($('#userName').val()!='')		{nombre = $('#userName').val(); $('#nombreError').html('');	} else { error=1; $('#nombreError').html('Por favor ingresa tu nombre');}
			if( filter.test(str) )				{mail = $('#email').val();		$('#mailError').html('');	} else { error=1;$('#mailError').html('Por favor ingresa tu mail');}
			if($('#cp').val()!='')				{codigop = $('#cp').val();			$('#cpError').html('');		} else { error=1;$('#cpError').html('Por favor ingresa tu codigo postal');}
			if($('#edad').val()!='')			{edades = $('#edad').val();		$('#edadError').html('');	} else { error=1;$('#edadError').html('Por favor ingresa tu edad');}
	
			if(!referer){referer='null'}
			if(!or){or=99}
			if(!userIp){userIp=0}

	
		if(error == 0 ){
			$("#SendBoton").css("display","none");
			$.ajax({
				type: 'POST',
				url: 'musica/handler/handler',
				data: "micrositio=1&nombre="+nombre+"&mail="+mail+"&edad="+edades+"&cp="+codigop+"&userIp="+userIp+"&referer="+referer+"&or="+or,
				success: function(answer){eval(answer);}
			});
		}else{
		}	
	});
});
