$(document).ready(function(){
$( "#dialog" ).hide();
$( "#img-diploma").hide();
$( "#diploma" ).click(function() { 

$( "#img-diploma" ).dialog(
									 {
										
										resizable: true,
										height:500,
										modal: true,
										minWidth: 600,
										title: "Diploma"									}
		 
								);

});
$( "#llamagratis_extendido" ).hide();
$( "#llamagratis" ).mouseenter(function(event) { 
event.preventDefault();
		$( "#llamagratis" ).hide();
	$( "#llamagratis_extendido" ).show();
			
			
		});

$( "#llamagratis_extendido" ).mouseleave(function() { 
		$( "#llamagratis_extendido" ).hide();
	$( "#llamagratis" ).show();
		});
$( "#telefono_callme" ).click(function() { 
		if ($("#telefono_callme").get(0).value=="Nº Teléfono")
			{		$("#telefono_callme").attr('value', '');
			}
		
		});
$( "#Enviar_callme" ).click(function() { 
			valor=$("#telefono_callme").val();
			numeroCaracteres = valor.length;
			//alert(valor.charAt(0));
			//alert (numeroCaracteres);
			if ((valor.charAt(0)!='6') && (valor.charAt(0)!='7') && (valor.charAt(0)!='8') && (valor.charAt(0)!='9') ) 
			{		//$("#telefono_callme").attr('value', '');
			alert ('Es necesario un número de Teléfono válido');
			return false;
			}
			
			
			if (numeroCaracteres<9) 
			{		//$("#telefono_callme").attr('value', '');
			alert ('Es necesario un número de Teléfono de 9 dígitos');
			return false;
			}
			
			
		if ($("#telefono_callme").get(0).value=="Nº Teléfono") 
			{		//$("#telefono_callme").attr('value', '');
			alert ('Es necesario un número de Teléfono');
			return false;
			}
		if ($("#telefono_callme").get(0).value=="")
			{		//$("#telefono_callme").attr('value', '');
			alert ('Es necesario un número de Teléfono');
			return false;
			}
			
			if(isNaN($("#telefono_callme").val())) {  
        alert("El teléfono solo debe contener números");  
        return false;  }

			var codcurso= $('#codcurso').val();
			var nombrecurso= $('#nombrecurso').val();
			var hora= $('#hora').val();
			var telefono= $('#telefono_callme').val();
			var submedio= $('#submedio').val();
			var tipo= $('#tipo').val();
			var parametros="Nombre=&Apellido1=&Telefono1="+telefono+"&hora="+hora+"&submedio="+submedio+"&codcurso="+codcurso+"&tipo="+tipo+"&Cod_empresa=0&nombrecurso="+nombrecurso;
			//var parametros="Nombre=&Apellido1=&Telefono1="+telefono+"&hora="+hora+"&submedio="+submedio+"&codcurso="+codcurso+"&Cod_empresa=0&nombrecurso=";
			var load_pag='http://'+document.domain+'/2/clicktocall-enviado.php?';
			//alert (load_pag);
		//var load_pag="http://www.cursosccc.com/index.asp";
				   $.ajax({
            type: 'POST',
            url: load_pag,
            data: parametros,
            success: function(data) {
                $('#dialog').html(data);
 
            }
			 })
			 
				$("#telefono_callme").attr('value', 'Nº Teléfono');
				$( "#dialog" ).show();
						
							$( "#dialog" ).dialog(
									 {
										
										resizable: true,
										height:300,
										modal: true,
										minWidth: 600,
										title: "Te llamamos ahora mismo"									}
		 
								);
		
		});
			})
