// JavaScript Document//validar contacto
 $(document).ready(function (){
							 
	$('#contactocl').click(function(){$('#apDiv1').css("display","block");});		
	$('#crzfor').click(function(){$('#apDiv1').css("display","none");});
	
	//$('.mapa').mouseover(function(){$('#mapg').css("display","block");});
	//$('#mapg').mouseout(function(){$('#mapg').css("display","none");});	
	//$('#cerm').click(function(){$('#mapg').css("display","none");});
	
	//$('#foto').mouseover(function(){$('#apDiv2').css("display","block");});	
	$('#apDiv2').mouseout(function(){$('#apDiv2').css("display","none");});	
	$('#apDiv2').click(function(){$('#apDiv2').css("display","none");})
 
 
$('#name').keydown(function(){$('#name').css("background-color", "white");});
$('#subject').keydown(function(){$('#subject').css("background-color", "white");});
$('#email').keydown(function(){$('#email').css("background-color", "white");});
$('#message').keydown(function(){$('#message').css("background-color", "white");});

$("#action").keydown(function(event){ if(event.which == 13){valforcon()};});

$('#action').click(function(){valforcon()});
							
function valforcon(){							
if ($('#name').val()=='')
               { alert("Inserte un nombre");$('#name').focus();$('#name').css("background-color", "red");
				return false;}

var valoema=$('#email').val();
var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
if ($('#email').val()=='') {alert('Inserte una direccion email');$('#email').focus();$('#email').css("background-color", "red");return false}
if (filter.test(valoema))   {}
else {alert('La direccion de email ' + valoema + ' no es correcta.');$('#email').focus();$('#email').css("background-color", "red");return false;}       

if ($('#subject').val()=='')
               { alert("Inserte un Asusnto");$('#subject').focus();$('#subject').css("background-color", "red");
				return false;}
if ($('#message').val()=='')
               { alert("Inserte un Mensaje");$('#message').focus();$('#message').css("background-color", "red");
				return false;}
				
				

$('#contact').submit(); if ($('#contact').submit()){alert('Su mensaje ha sido enviado con éxito');};
}

//libenokia
$("#pcsuiteTable .kk:even").css("background-color", "#CCCCCC");


//VALIDAR FORMULARIO TOMA DE DATOS:
function validartomadatos(){

if ($('#nombre').val()=='')
               { alert("Inserte un Nombre");$('#nombre').focus();
				return false;}
				
if ($('#apellidos').val()=='')
               { alert("Inserte su Apellido");$('#apellidos').focus();
				return false;}
				
if ($('#cp').val()=='')
               { alert("Inserte su CP");$('#cp').focus();
				return false;}
				

var sexo = $("input[@name='sexo']:checked").val();
//if (sexo=='null'){alert('Seleccionar sexo');return false;}
				
if ($('#edad').val()=='')
               { alert("Inserte su edad");$('#edad').focus();
				return false;}				
				
if ($('#telefono').val()=='')
               { alert("Inserte su Teléfono");$('#telefono').focus();
				return false;}	
				

/*
var valoema=$('#e-mail').val();
var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
if ($('#e-mail').val()=='') {alert('Inserte una direccion email');$('#e-mail').focus();return false}
if (filter.test(valoema))   {}
else {alert('La direccion de email ' + valoema + ' no es correcta.');$('#e-mail').focus();return false;}     
*/
if ($('#WII').attr('checked')== true){var WII="WII"} else {var WII=""};
if ($('#PSP').attr('checked')== true){var PSP="PSP"} else {var PSP=""};
if ($('#XBOX').attr('checked')== true){var XBOX="XBOX"} else {var XBOX=""};
if ($('#NDS').attr('checked')== true){var NDS="NDS"} else {var NDS=""};
if ($('#PS2').attr('checked')== true){var PS2="PS2"} else {var PS2=""};
if ($('#PS3').attr('checked')== true){var PS3="PS3"} else {var PS3=""};

$.ajax({
				url: 'tomadatos.php',
				type: "POST",
				data:  "nombre="+ $("#nombre").val()+ "&apellidos="+ $("#apellidos").val()+ "&cp="+ $("#cp").val()+ "&sexo="+ sexo+ "&edad="+ $("#edad").val()+ "&telefono="+ $("#telefono").val()+ "&e-mail="+ $("#e-mail").val()+ "&WII="+ WII+ "&PSP="+PSP+ "&XBOX="+XBOX+ "&NDS="+NDS+ "&PS2="+PS2+ "&PS3="+PS3+ "&ima="+ $("#telefono").val() ,
				success: function(datos){
				alert('Datos enviados correctamente');
				$('#vercupon').empty();
				$('#vercupon').append(datos);
				$('#nombre').val('');
				$('#apellidos').val('');
				$('#cp').val('');
				$('#sexo').attr('checked',  '');
				$('#edad').val('');
				$('#telefono').val('');
				$('#e-mail').val('');
				$('#WII').attr('checked',  '');
				$('#PSP').attr('checked',  '');
				$('#XBOX').attr('checked',  '');
				$('#PS2').attr('checked',  '');
				$('#PS3').attr('checked',  '');
				$('#NDS').attr('checked',  '');
				
				;}
}); }
$('#boton_tomadatos').click(function(){validartomadatos();});




}); 
