<!--
//Rutina para la impresión de la fecha actual
function PrintFechaCab () {
	var mydate=new Date()
	var year=mydate.getFullYear()
	if (year<2000)
		year="19"+year
	var day=mydate.getDay()
	var month=mydate.getMonth()
	var daym=mydate.getDate()
	if (daym<10)
		daym="0"+daym
	var dayarray=new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado")
	var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre")
	document.write(dayarray[day]+", "+daym+" de "+montharray[month]+" de "+year)
}
// Rutinas de Controls sobre el GUI de usuario para el buscador

function CargarCategoria() {
	location.href=document.frmCategorias.categoria.value;
}

function CargarCategoriaProvincia() {
	location.href=document.frmCategoriasProvincias.Provincia.value;
}

function CargarCategoriaModalidad() {
	location.href=document.frmCategoriasModalidades.Modalidad.value;
}

function CargaSearch() {
	valor = document.frmBusqueda.cursos.value;
	if (valor =="Ejemplo: master executive MBA" || valor =="Introduzca Palabra" || valor =="") {
		document.frmBusqueda.cursos.value="Introduzca Palabra";
	} 
	else {
		document.frmBusqueda.submit();
	}
}

function CargaSearchAdv() {
	valor = document.frmBusquedaAdv.cursos.value;
	if (valor =="Ejemplo: master executive MBA" || valor =="Introduzca Palabra" || valor =="") {
		document.frmBusquedaAdv.cursos.value="Introduzca Palabra";
	} 
	else {
		document.frmBusquedaAdv.submit();
	}
}

function VaciarSearch() {
	document.frmBusqueda.cursos.value="";
}


function VaciarSearchAdv() {
	document.frmBusquedaAdv.cursos.value="";
}

// Rutinas de precarga de imagenes.
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
//Funcion para la comprobacion de Email correcto
function Arroba(sString){	
	var str = sString.value
	// Return false if e-mail field does not contain a '@' and '.' .   
	if (str.indexOf ('@',0) == -1 || str.indexOf ('.',0) == -1){
		alert('Introduzca correctamente el E-mail')
		sString.focus()
		return false 
	}
	else{
		return true;      
	}
}

//Funcion para la comprobacion de Email correcto
function Arroba_Legal(sString,sLegal){	
	var str = sString.value
	// Return false if e-mail field does not contain a '@' and '.' .   
	if (str.indexOf ('@',0) == -1 || str.indexOf ('.',0) == -1){
		alert('Introduzca correctamente el E-mail')
		sString.focus()
		return false 
	}
	else{
		if (sLegal.checked) {
			return true;      
		}
		else {
			alert('Debe aceptar las bases legales.')
			sLegal.focus()
			return false 			
		}

	}
}


//Funcion para la apertura de PopUps
function AbrirVentanaCentro(Centro){
	window.open('/ConsultaCentroDatos.asp?Centro=' + Centro,'','toolbar=no,location=no,resizable=no,directories=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,width=568,height=300');
}

function AbrirVentanaEnvioAmigo(Ruta,Param) {
  vUrl="/Include/EnviarAmigo.asp?" + Ruta
  if (Param == ""){vUrl="/Include/EnviarAmigo.asp?Ruta=" + Ruta}
  else{vUrl="/Include/EnviarAmigo.asp?Ruta=" + Ruta + "&Param=" + Param}
  //window.open(vUrl,'','toolbar=no,location=no,resizable=no,directories=no,status=no,menubar=no,copyhistory=no,scrollbars=no,width=400,height=410,top=130,left=250');
  window.open(vUrl,'','toolbar=no,location=no,resizable=no,directories=no,status=no,menubar=no,copyhistory=no,scrollbars=no,width=415,height=510,top=130,left=250');
}

function AbrirVentanaMicro(url_centro){
	window.open(url_centro,'','toolbar=no,location=no,resizable=no,directories=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,width=820,height=600');
}

function AbrirVentanaLegal(){
	window.open('/Legal/IndexBody.asp','','toolbar=no,location=no,resizable=no,directories=no,status=no,menubar=no,copyhistory=no,scrollbars=yes,width=568,height=380');
}

//Funcion para el Saltador de Provincias
function CargarProvincia(){
	document.frmSaltadorProvincias.submit();
}

//Funciones comunes para la validacion de los campos de formulario
function es_num(v){
   var t=/^[0-9]\d*$/;
   return t.test(v);
}

function cadena_letras(v){
   var t=/^[A-Za-z_ áéíóúÁÉÍÓÚñÑçÇ-]*$/i;
   return t.test(v);
}

function es_cadena_letras_frm(v){
   var t=/^[A-Za-z_\sáéíóúÁÉÍÓÚñÑçÇ-]*$/i;
   return t.test(v);
}

function es_telefono(v){
	var t=/^(6|8|9)\d{8}$/
  return t.test(v);
}

function es_cp(v){
   var t=/^[0-9]\d*$/
   return t.test(v);
}

//Función de comprobación de teléfonos extranjeros 
function es_telefonoE(v){
  var t=/^\d{10,15}$/;
  return t.test(v);
}


function es_email(v){
   var t=/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/i;
   return t.test(v);
}


/*********************************************************
	Función que valida la restricción de código postal de Madrid según incidencia 13724 para el centro 14411 CAUD Centro Universitario a Distancia
*********************************************************/
function es_cp_madrid(v){		
   var t=/^28[0-9]{3}$/;
   return t.test(v);
}

/*********************************************************
	Función que valida la restricción de código postal de Vizcaya según incidencia 18787 para el centro 14683 ARGI
*********************************************************/
function es_cp_vizcaya(v){
   var t=/^48[0-9]{3}$/;
   return t.test(v);
}

/*********************************************************
	Función que valida la restricción de código postal de La Coruña según incidencia 18927 para el centro 16638 KATEDRA PROFESIONAL
*********************************************************/
function es_cp_coruna(v){
   var t=/^15[0-9]{3}$/;
   return t.test(v);
}

// Funciones para mostrar y ocultar text en formulario publicidad
function MostrarCapa(capa){
	document.frmPublicidad.fmMediosOtros.style.visibility="visible";
	document.frmPublicidad.fmMediosOtros.focus();
}

function OcultarCapa(capa){
	document.frmPublicidad.fmMediosOtros.style.visibility="hidden";
	document.frmPublicidad.fmMediosOtros.value  = '';
}
 
//Funcion para controlar la insercion de un maxiomo de caracteres
function isDescrip(valor,total) {
	if (valor.value.length > total) {
		alert ("Debe introducir una CONSULTA más corta.(Max. "+total+" caracteres).");
		valor.focus ();
		return false;
	}
	else return true; 
}

// Funciones campaña PromoWORLDMBA
// para recuperar posición del ratón
function Vertop(y){
	/*detectar navegador y capturar la posicion del click*/
	var IE = document.all?true:false
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	var tempX = 0
	var tempY = 0/*llamada a la funcion con un handler*/
	document.onclick = getMouseXY;
	function getMouseXY(e) { //hace todo el trabajo
  if (IE) {
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } 
	else {
    tempX = e.pageX
    tempY = e.pageY
  }
  return (tempY - 450);
	}
}

function MostrarCapaCam(capa){
  if(document.layers)document.layers[capa].visibility='show'     // Si utilizamos NS
  if(document.all)document.all(capa).style.visibility='visible'  // Si utilizamos IE
	  document.all(capa).style.top = document.body.scrollTop + 20
}

function OcultarCapaCam(capa){
  if(document.layers)document.layers[capa].visibility='hide'     // Si utilizamos NS
  if(document.all)document.all(capa).style.visibility='hidden'   // Si utilizamos IE
}

// Función para comprobar si existe contenido del editor de texto
function RevisaContents(fmConsulta) {
	var oEditor = FCKeditorAPI.GetInstance(fmConsulta) ;
	var texto = "";
	var texto = oEditor.GetXHTML( true );
	if  ((texto) == ""){
			return false;
	}
}

// Función para comprobar el tamaño contenido del editor de texto
function RevisaContentsLong(fmConsulta, long) {
	var oEditor = FCKeditorAPI.GetInstance(fmConsulta) ;
	var texto = "";
	var texto = oEditor.GetXHTML( true );
	var len = texto.length;	
	if (len > long){
		return false;
	}	
}

// Función que devuelve la longitud de la consulta
function LongitudContents(fmConsulta) {
	var oEditor = FCKeditorAPI.GetInstance(fmConsulta) ;
	var texto = "";
	var texto = oEditor.GetXHTML( true );
	var len = texto.length;	
	return len;
}

// Función para comprobar los contenidos del editor de texto
function GetContents(fmConsulta) {
	// Get the editor instance that we want to interact with.
	var oEditor = "";
	var oEditor = FCKeditorAPI.GetInstance(fmConsulta) ;
	// Get the editor contents in XHTML.
	var texto = "";
	var texto = oEditor.GetXHTML( true );
	
	if  (DPTelefono(texto) == true)
		{alert("No se permite la introdución de teléfonos en el contenido del Anuncio");
		 oEditor.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	
	if  (DPVinculo(texto) == true)
		{alert("No se permite la introdución de hipervínculos en el contenido del Anuncio");
		 oEditor.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	
	if  (DPEmail(texto) == true)
		{alert("No se permite la introdución de direcciones de correo en el contenido del Anuncio");
		 oEditor.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	
	oEditor.SetHTML( texto ) ;
	return true;  
}

// Función para comprobar si hay un nº de telefono en el editor de texto
function DPTelefono(texto) {
	//Patrones de Teléfonos
	
	//xxxxxxxxx /o/xxxxxxxxx/
	var exp1 = /([0-9]{9}\D)|([0-9]{9})/gi;
	var rem1 = texto.replace(exp1,"");
	
	//xxx xxx xxx /o/xxx xxx xxx/
	var exp2 = /([0-9]{3}\D)([0-9]{3}\D)([0-9]{3}\D)|([0-9]{3}\D)([0-9]{3}\D)([0-9]{3})/gi;
	var rem2 = texto.replace(exp2,"");
	
	//xx xxx xx xx /o/xx xxx xx xx/
	var exp3 = /(\d{2}\D\d{3}\D\d{2}\D\d{2}\D)|(\d{2}\D\d{3}\D\d{2}\D\d{2})/gi;
	var rem3 = texto.replace(exp3,"");
	
	//xx xxxxxxx /o/xx xxxxxxx/
	var exp4 = /(\d{2}\D\d{7}\D)|(\d{2}\D\d{7})/gi;
	var rem4 = texto.replace(exp4,"");
	
	if ((rem1.length != texto.length)|(rem2.length != texto.length)|(rem3.length != texto.length)|(rem4.length != texto.length))
		{	return true;	}
	else
		{	return false;	}
}

// Función para comprobar si hay un Hipervínculo en el editor de texto
function DPVinculo(texto) {
	//Patrones de Hipervínculos
	
	var exp1 = new RegExp("http://([a-z]*)", "gi");
	var rem1 = texto.replace(exp1," ");
	
	var exp2 = /(www[\.])/gi;
	var rem2 = texto.replace(exp2," ");
	
	if ((rem1.length != texto.length)|(rem2.length != texto.length))
		{	return true;	}
	else
		{	return false;	}
}

// Función para comprobar si hay un Email en el editor de texto
function DPEmail(texto) {
	//Patron de Email

	//xxxxx@zzzz.yyy
	var exp1 = /([a-z]*)@([a-z]*)[\.]([a-z]{2,3})/gi;
	var rem1 = texto.replace(exp1," ");
	
	if (rem1.length != texto.length)
		{	return true;	}
	else
		{	return false;	}
}

// Función para controlar que el contenido del editor sean espacios en blanco
function GetLength(fmConsulta)
{
	var oEditor = FCKeditorAPI.GetInstance(fmConsulta) ;
	var oDOM = oEditor.EditorDocument ;
	var iLength=0 ;

	if ( document.all ){		// If Internet Explorer.
		iLength = oDOM.body.innerText.length ;
		valor = oDOM.body.innerText; 
	}else{					// If Firefox.
		iLength = oDOM.body.textContent.length ;
		valor = oDOM.body.textContent; 
	}
	if ((vacio(valor) == false)){
	 
	  return false;
	}else{
	  return true;
	}
}

function vacio(q){	
	for(i = 0; i < q.length; i++){ 
		if ((escape(q.charAt(i))!="%A0") ){ 		
			if((escape(q.charAt(i))!="%20") ){
				return true ;
			}
		} 
	} 
	return false ;
}
// Fin Función para controlar que el contenido del editor sean espacios en blanco

function ImprimirReportaje(Reportaje) {
	  win = window.open('ImprimirReportaje.asp?Reportaje='+ Reportaje, 'Imprimir', 'width=700, height=600,top=0,left=100, directories=0,resizable=0,location=0,status=0,scrollbars=1,toolbar=0,menubar=0,titlebar=0');
	  win.print();
}

function ImprimirBreve(Breve) {
	  win = window.open('/Breves/ImprimirBreve.asp?Breve='+ Breve, 'Imprimir', 'width=700, height=600,top=0,left=100, directories=0,resizable=0,location=0,status=0,scrollbars=1,toolbar=0,menubar=0,titlebar=0');
	  win.print();
}

function ImprimirNoticia(Noticia) {
	  win = window.open('/Noticias/ImprimirNoticia.asp?Noticia='+ Noticia, 'Imprimir', 'width=700, height=600,top=0,left=100, directories=0,resizable=0,location=0,status=0,scrollbars=1,toolbar=0,menubar=0,titlebar=0');
	  win.print();
}

function ImprimirCurso(Curso) {
	  win = window.open('/Include/ImprimirCurso.asp?Curso='+ Curso, 'Imprimir', 'width=700, height=600,top=0,left=100, directories=0,resizable=0,location=0,status=0,scrollbars=1,toolbar=0,menubar=0,titlebar=0');
	  win.print();
}

//Funcion de AJAX para la carga de contenidos dinamicos en select
function cargarContenido(vModulo){ 
	var d1,contenedor; 
	contenedor = document.getElementById('contenedor'); 
	if (vModulo == 'Anuncio'){
		d1 = document.frmAltaAnuncios.fmProvincia.options[document.frmAltaAnuncios.fmProvincia.selectedIndex].value; 
		}
	if (vModulo == 'Formularios'){
		d1 = document.frmFormularios.fmProvincia.options[document.frmFormularios.fmProvincia.selectedIndex].value; 
		if (d1 == "") {d1=99}
		}
	ajax=nuevoAjax(); 
	ajax.open("GET", "/Include/CargaSelect.asp?vMod="+ vModulo + "&vOpcSel="+d1,true);  
	ajax.onreadystatechange=function() { 
		if (ajax.readyState==4) { 
			 contenedor.innerHTML = ajax.responseText 
			} 
		} 
	ajax.send(null) 
} 

function nuevoAjax(){ 
  var xmlhttp=false; 
  try { 
   // Creación del objeto ajax para navegadores diferentes a Explorer 
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
  } catch (e) { 
   // o bien 
   try { 
     // Creación del objet ajax para Explorer 
     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { 
     xmlhttp = false; 
   } 
  } 

  if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
   xmlhttp = new XMLHttpRequest(); 
  } 
  return xmlhttp; 
}


//Funciones de validacion de consulta de Anuncios
function ValidaConsultaAnuncios(){
	if(frmInfoAnuncio.fmNombre.value == ""){
		alert("Introduce tu Nombre.");
		frmInfoAnuncio.fmNombre.focus();
		return false;
	}
	// Llamadas a las funciones propias del editor
	if ((RevisaContents("fmConsulta") == false)){
	  alert("Introduce el Texto de la Consulta.");
	  return false;
	}
	if ((RevisaContentsLong("fmConsulta", 500) == false)){
	 alert("El contenido de la consulta es demasiado extenso.");
	  return false;
	}	
	// Fin de llamadas a las funciones propias del editor
	if(frmInfoAnuncio.fmProvincia.value == ""){
		alert("Selecciona tu Provincia.");
		frmInfoAnuncio.fmProvincia.focus();
		return false;
	}
	if(frmInfoAnuncio.fmEmail.value == ""){
		alert("Introduce tu Email.");
		frmInfoAnuncio.fmEmail.focus();
		return false;
	}
	if(frmInfoAnuncio.fmEmail2.value == ""){
		alert("Repite tu Email para confirmarlo.");
		frmInfoAnuncio.fmEmail2.focus();
		return false;
	}
	if(frmInfoAnuncio.fmEmail2.value != frmInfoAnuncio.fmEmail.value){
		alert("Los emails introducidos no coinciden.");
		frmInfoAnuncio.fmEmail2.focus();
		return false;
	}
}

// Función Validacion de Anuncios
function ValidaAltaAnuncios(){
	
	var frmAltaAnuncios = document.getElementById('frmAltaAnuncios'); 
	
	if(frmAltaAnuncios.fmCategoria.value == ""){
		alert("Introduce la Categoria.");
		frmAltaAnuncios.fmCategoria.focus();
		return false;
	}

	if(frmAltaAnuncios.fmDuracion.value == ""){
		alert("Introduce la Duración del Anuncio.");
		frmAltaAnuncios.fmDuracion.focus();
		return false;
	}

	if(frmAltaAnuncios.fmProvincia.value == ""){
		alert("Selecciona tu Provincia.");
		frmAltaAnuncios.fmProvincia.focus();
		return false;
	}

	if(frmAltaAnuncios.fmMunicipio.value == ""){
		alert("Introduce tu Municipio.");
		frmAltaAnuncios.fmMunicipio.focus();
		return false;
	}

	if(frmAltaAnuncios.fmEmpresa.value == ""){
		alert("Introduce nombre de la Empresa o tu Nombre.");
		frmAltaAnuncios.fmEmpresa.focus();
		return false;
	}
	
	if (!es_cp(frmAltaAnuncios.fmCP.value)){
		if(frmAltaAnuncios.fmCP.value.length==5){
			msgErr="El Código Postal introducido no es válido.";
		}
		else{
			msgErr="El Código Postal debe de ser un número de cinco cifras";
		}
		alert(msgErr);
		frmAltaAnuncios.fmCP.focus();
		return false;
	}
	
	if(frmAltaAnuncios.fmTitulo.value == ""){
		alert("Introduce el Título del Anuncio.");
		frmAltaAnuncios.fmTitulo.focus();
		return false;
	}

	if(frmAltaAnuncios.fmNombre.value == ""){
		alert("Introduce tu Nombre.");
		frmAltaAnuncios.fmNombre.focus();
		return false;
	}

	if(frmAltaAnuncios.fmEmail.value == ""){
		alert("Introduce tu Email.");
		frmAltaAnuncios.fmEmail.focus();
		return false;
	}

	if ((RevisaContents("fmTexto") == false)){
	  alert("Introduce el Texto del Anuncio.");
	  return false;
	}
	if ((RevisaContentsLong("fmTexto", 300) == false)){
	 alert("El contenido del anuncio es demasiado extenso.");
	  return false;
	}

	if ((GetContents("fmTexto") == false)){
	  alert("Introduce un Texto correcto.");
	  return false;
	}

	if(document.frmAltaAnuncios.TextBoxUserCode.value == ""){
		alert("Escriba los caracteres que vea en la imagen.");
		document.frmAltaAnuncios.TextBoxUserCode.focus();
		return false;
  }
}


//Función Validación Campos de Alta ClubFOrmación.
// dos funciones para cada post


//Función Validación Campos de Alta ClubFOrmación.
// Validación campos requeridos en el 1º post
function ValidaAltaClubPost1(){

	if(document.getElementById('fmNombre').value == ""){
  	  	alert("Introduce tu nombre.");
     	document.getElementById('fmNombre').focus();
     	return false;
   }else if(cadena_letras(document.getElementById('fmNombre').value)==false){
   	alert("En el nombre no se pueden introducir caracteres numéricos.");
      document.getElementById('fmNombre').focus();
      return false;
   }   
  
	if(document.getElementById('fmEmail').value == ""){
		alert("Introduce tu Email.");
		document.getElementById('fmEmail').focus();
		return false;
	}
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}

	if(document.getElementById('fmEmail2').value == ""){
		alert("Repite tu Email para confirmarlo.");
		document.getElementById('fmEmail2').focus();
		return false;
	}
	else if (!es_email(document.getElementById('fmEmail2').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail2').focus();
		return false;
	}

	if(document.getElementById('fmEmail').value != document.getElementById('fmEmail2').value){
		alert("Los emails introducidos no coinciden.");
		document.getElementById('fmEmail').focus();
		return false;
	}		

	if(document.getElementById('fmProvincia').value == ""){
		alert("Selecciona tu Provincia.");
		document.getElementById('fmProvincia').focus();
		return false;
	}

	if(document.getElementById('fmCategorias').value == ""){
		alert("Selecciona las Categorías que más te interesan.");
		document.getElementById('fmCategorias').focus();
		return false;
	}

}

// Validación campos requeridos en el 2º post
function ValidaAltaClubPost2(){

	if(document.getElementById('fmConocido').value == ""){
		alert("Selecciona una opción.");
		document.getElementById('fmConocido').focus();
		return false;
	}

	if(document.getElementById('TextBoxUserCode').value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
      document.getElementById('TextBoxUserCode').focus();
      return false;
  }

}


//Función Validación Alta Publicidad.
function ValidaAltaPublicidad(){
   var msg;
	
	var frmPublicidad = document.getElementById('frmPublicidad'); 
	
   if(frmPublicidad.fmNombre.value == ""){
      alert("Indique su Nombre.");
      frmPublicidad.fmNombre.focus();
      return false;
   }
   else{
      if(cadena_letras(frmPublicidad.fmNombre.value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
         frmPublicidad.fmNombre.focus();
         return false;
      }
   }   

   if(frmPublicidad.fmApellido1.value == ""){
      alert("Indique sus Apellidos.");
      frmPublicidad.fmApellido1.focus();
      return false;
   }
   else{
      if(cadena_letras(frmPublicidad.fmApellido1.value)==false){
         alert("En los apellidos no se pueden introducir caracteres numéricos.");
         frmPublicidad.fmApellido1.focus();
         return false;
      }
   }   
   
	if(frmPublicidad.fmEmpresa.value == ""){
      alert("Introduzca el Nombre de la Empresa.");
      frmPublicidad.fmEmpresa.focus();
      return false;
   } 
   
	if(frmPublicidad.fmEmail.value == ""){
      alert("Introduzca un Email de contacto.");
      frmPublicidad.fmEmail.focus();
      return false;
   }
	else if (!es_email(frmPublicidad.fmEmail.value)){
		alert("El e-mail introducido no es válido.");
		frmPublicidad.fmEmail.focus();
		return false;
	}

	if  (frmPublicidad.fmProvincia.value== 0){
	  if (!es_telefonoE(frmPublicidad.fmTelefono.value)){
			 alert("El número de teléfono extranjero NO es válido.");
			 frmPublicidad.fmTelefono.focus();
			 return false;
		  }
	}
	else{
		if(frmPublicidad.fmTelefono.value == ""){
      alert("Introduzca un teléfono de contacto.");
      frmPublicidad.fmTelefono.focus();
      return false;
   	}
//			if (!es_telefono(document.frmPublicidad.fmTelefono.value)){
//			 alert("El teléfono no es un número de teléfono válido.\nIntroduce solamente números (sin espacios).");
//			 document.frmPublicidad.fmTelefono.focus();
//			 return false;
//		  }
	}  	  

	if(frmPublicidad.fmHorario.value == ""){
      alert("Introduzca un horario para ponernos en contacto con usted.");
      frmPublicidad.fmHorario.focus();
      return false;
   }
	if(frmPublicidad.fmProvincia.value == ""){
      alert("Indique la Provincia donde esta situada la empresa.");
      frmPublicidad.fmProvincia.focus();
      return false;
   }
	if(frmPublicidad.fmPais.value == ""){
      alert("Indique el País donde esta situada la empresa.");
      frmPublicidad.fmPais.focus();
      return false;
   }

	
   if(frmPublicidad.fmSector.value == ""){
      alert("Introduzca un Sector.");
      frmPublicidad.fmSector.focus();
      return false;
   }
   
   if(frmPublicidad.fmMedio.value == ""){
      alert("Introduzca un Medio.");
      frmPublicidad.fmMedio.focus();
      return false;
   }
    
 /* if (document.frmPublicidad.fmMediosOtros.style.visibility==false){
  	 if(document.frmPublicidad.fmMediosOtros.value == ""){
        alert ("Especificar medio");
  		return false;
		}
	}
	if (document.frmPublicidad.fmMediosOtros.style.visibility=="visible") {
		if(document.frmPublicidad.fmMediosOtros.value == ""){
        	alert ("Especificar medio");
  			return false;
		}
  }*/
     /* if(document.frmPublicidad.fmObservaciones.value == ""){
      alert("Indique el motivo del contacto.");
      document.frmPublicidad.fmObservaciones.focus();
      return false;
   }*/
   
   // Llamadas a las funciones propias del editor
	if ((RevisaContents("fmObservaciones") == false)){
	  alert("Introduce el motivo del contacto.");
	  return false;
	}
	if ((RevisaContentsLong("fmObservaciones", 500) == false)){
	 alert("El motivo del contacto es demasiado extenso.");
	  return false;
	}	
	// Fin de llamadas a las funciones propias del editor
	
	if(frmPublicidad.TextBoxUserCode.value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
      frmPublicidad.TextBoxUserCode.focus();
      return false;
  }
      
}

//Función Validación Formulario de Contacto de Usuario
function ValidaContacta(){
   var msg;
  
   if(document.getElementById('fmNombre').value == ""){
      alert("Introduce tu nombre.");
      document.getElementById('fmNombre').focus();
      return false;
   }
   else{
      if(cadena_letras(document.getElementById('fmNombre').value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
         document.getElementById('fmNombre').focus();
         return false;
      }
   }   
  
   if(document.getElementById('fmApellidos').value == ""){
      alert("Introduce tus apellidos.");
      document.getElementById('fmApellidos').focus();
      return false;
   }
   else{
      if(cadena_letras(document.getElementById('fmApellidos').value)==false){
         alert("En los apellidos no se pueden introducir caracteres numéricos.");
         document.getElementById('fmApellidos').focus();
         return false;
      }
   }   
   
	if(document.getElementById('fmEmail').value == ""){
      alert("Introduce tu email.");
      document.getElementById('fmEmail').focus();
      return false;
   }
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}

	// Llamadas a las funciones propias del editor
	if ((RevisaContents("fmObservaciones") == false)){
	  alert("Introduce el motivo del contacto.");
	  return false;
	}
	if ((RevisaContentsLong("fmObservaciones", 300) == false)){
	 alert("Introduce una CONSULTA más corta.(Max. 300 caracteres).");
	 return false;
	}
	if ((GetContents("fmObservaciones") == false)){
		return false;
	}
	// Fin de llamadas a las funciones propias del editor
   
	if(document.getElementById('TextBoxUserCode').value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
		document.getElementById('TextBoxUserCode').focus();
      return false;
  	}

}


//Función Validación Formulario de Contacto de Usuario
function ValidaConsultaTablon(){
   var msg;
  
   if(document.getElementById('fmNombre').value == ""){
      alert("Introduce tu Nombre.");
      document.getElementById('fmNombre').focus();
      return false;
   }
   else{
      if(cadena_letras(document.getElementById('fmNombre').value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
         document.getElementById('fmNombre').focus();
         return false;
      }
   }   
    
	if(document.getElementById('fmProvincia').value == ""){
		alert("Selecciona tu Provincia.");
		document.getElementById('fmProvincia').focus();
		return false;
	}
   
	if(document.getElementById('fmEmail').value == ""){
      alert("Introduce tu Email.");
      document.getElementById('fmEmail').focus();
      return false;
   }
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El Email introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}
	
		if(document.getElementById('fmEmail2').value == ""){
      alert("Introduce tu Email.");
      document.getElementById('fmEmail2').focus();
      return false;
   }
	else if (!es_email(document.getElementById('fmEmail2').value)){
		alert("El Email introducido no es válido.");
		document.getElementById('fmEmail2').focus();
		return false;
	}
	
	if(document.getElementById('fmEmail2').value != document.getElementById('fmEmail').value){
		alert("Los mails introducidos no son iguales");
		document.getElementById('fmEmail2').focus();
		return false;
	}

	// Llamadas a las funciones propias del editor
	if ((RevisaContents("fmConsulta") == false)){
	  alert("Introduce el motivo del contacto.");
	  return false;
	}
	if ((RevisaContentsLong("fmConsulta", 500) == false)){
	 alert("Introduce una CONSULTA más corta.(Max. 500 caracteres).");
	 return false;
	}
	if ((GetContents("fmConsulta") == false)){
		return false;
	}
	// Fin de llamadas a las funciones propias del editor
   
	if(document.getElementById('TextBoxUserCode').value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
		document.getElementById('TextBoxUserCode').focus();
      return false;
  	}

}


//Función Validación Formulario de Residencias
function ValidaResidencia(){
   var msg;
  
   if(document.getElementById('fmNombre').value == ""){
      alert("Introduce tu nombre.");
      document.getElementById('fmNombre').focus();
      return false;
   }
   else{
      if(cadena_letras(document.getElementById('fmNombre').value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
         document.getElementById('fmNombre').focus();
         return false;
      }
   }   
  
	if(document.getElementById('fmEmail').value == ""){
      alert("Introduce tu email.");
      document.getElementById('fmEmail').focus();
      return false;
   }
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}

	// Fin de llamadas a las funciones propias del editor
	if(document.getElementById('fmProvincia').value == ""){
		alert("Selecciona tu Provincia.");
		document.getElementById('fmProvincia').focus();
		return false;
	}
   
	if(document.getElementById('TextBoxUserCode').value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
		document.getElementById('TextBoxUserCode').focus();
      return false;
  	}

}


//Función Validación Formulario de Recuperacion del Telefono
function ValidaTelefono(){
   var msg;
  
   if(document.getElementById('fmNombre').value == ""){
      alert("Introduce tu nombre.");
      document.getElementById('fmNombre').focus();
      return false;
   }
   else{
      if(cadena_letras(document.getElementById('fmNombre').value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
         document.getElementById('fmNombre').focus();
         return false;
      }
   }   
  
	if(document.getElementById('fmEmail').value == ""){
      alert("Introduce tu email.");
      document.getElementById('fmEmail').focus();
      return false;
   }
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}
}




//Función Validación Formulario de Patrocinio
function validarURL(sString){
		var str = sString.value
		//var expr= /^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*/ 
		var expr= /((^w{3})[.][\w]*.)([\.][\w])/
		
		if (str.search(expr) )
		 {
			alert("Introduce una URL correcta");
			 frmPatrocinio.fmUrl.focus();
		 return false;
		}
}
	
	  
function ValidaPatrocinio(){
   var msg;
  
	if(document.getElementById('fmNombre').value == ""){
      alert("Introduce tu nombre.");
      document.getElementById('fmNombre').focus();
      return false;
   }
   else{
      if(cadena_letras(document.getElementById('fmNombre').value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
        	document.getElementById('fmNombre').focus();
         return false;
      }
   }   
  
   if(document.getElementById('fmApellidos').value == ""){
      alert("Introduce tus apellidos.");
      document.getElementById('fmApellidos').focus();
      return false;
   }
   else{
      if(cadena_letras(document.getElementById('fmApellidos').value)==false){
         alert("En los apellidos no se pueden introducir caracteres numéricos.");
          document.getElementById('fmApellidos').focus();
         return false;
      }
   }   
   
   if(document.getElementById('fmEmpresa').value == ""){
      alert("Introduce el nombre de tu empresa.");
      document.getElementById('fmEmpresa').focus();
      return false;
   }   
 	
	if(document.getElementById('fmEmail').value == ""){
      alert("Introduce tu email.");
      document.getElementById('fmEmail').focus();
      return false;
   }
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}

	if(document.getElementById('fmUrl').value == ""){
      alert("Introduce tu web.");
      document.getElementById('fmUrl').focus();
      return false;
   }
	
	// Llamadas a las funciones propias del editor
	if ((RevisaContents("fmObservaciones") == false)){
	  alert("Introduce el motivo del contacto.");
	  return false;
	}
	if ((RevisaContentsLong("fmObservaciones", 300) == false)){
	 alert("Introduce una CONSULTA más corta.(Max. 300 caracteres).");
	 return false;
	}
	if ((GetContents("fmObservaciones") == false)){
		return false;
	}
	// Fin de llamadas a las funciones propias del editor
   
	if(document.getElementById('TextBoxUserCode').value == ""){
   	alert("Escriba los caracteres que vea en la imagen.");
   	document.getElementById('TextBoxUserCode').focus();
   	return false;
  	}

}


// Función validar trabaja con nosotros
function ValidaTrabaja(){
   var msg;
  
   if(frmTrabaja.fmNombre.value == ""){
      alert("Introduce tu nombre.");
      frmTrabaja.fmNombre.focus();
      return false;
   }
   else{
      if(cadena_letras(frmTrabaja.fmNombre.value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
         frmTrabaja.fmNombre.focus();
         return false;
      }
   }   
  
   if(frmTrabaja.fmApellidos.value == ""){
      alert("Introduce tus apellidos.");
      frmTrabaja.fmApellidos.focus();
      return false;
   }
   else{
      if(cadena_letras(frmTrabaja.fmApellidos.value)==false){
         alert("En los apellidos no se pueden introducir caracteres numéricos.");
         frmTrabaja.fmApellidos.focus();
         return false;
      }
   }   
   
	 if(frmTrabaja.fmEmail.value == ""){
      alert("Introduce tu email.");
      frmTrabaja.fmEmail.focus();
      return false;
   }
   
    if(frmTrabaja.fmArchivo.value == ""){
      alert("Seleccione un archivo con su Curriculum.");
      frmTrabaja.fmArchivo.focus();
      return false;
   }

}
// Función validar trabaja con nosotros
function ValidaOferta(){
  // var msg;
  
   if(frmOferta.fmNombre.value == ""){
      alert("Introduce tu nombre.");
      frmOferta.fmNombre.focus();
      return false;
   }
   else{
      if(cadena_letras(frmOferta.fmNombre.value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
         frmOferta.fmNombre.focus();
         return false;
      }
   }   
  
   if(frmOferta.fmApellidos.value == ""){
      alert("Introduce tus apellidos.");
      frmOferta.fmApellidos.focus();
      return false;
   }
   
   else{
      if(cadena_letras(frmOferta.fmApellidos.value)==false){
         alert("En los apellidos no se pueden introducir caracteres numéricos.");
         frmOferta.fmApellidos.focus();
         return false;
      }
   }   
   
	 if(frmOferta.fmEmail.value == ""){
      alert("Introduce tu email.");
      frmOferta.fmEmail.focus();
      return false;
   }
   
    if(frmOferta.fmArchivo.value == ""){
      alert("Seleccione un archivo con su Curriculum.");
      frmOferta.fmArchivo.focus();
      return false;
   }

}

//Funciones de validacion de formulario
function ValidaEnvioAmigo(){
	
	if(document.getElementById('fmNombre').value == ""){
		alert("Introduce tu Nombre.");
		document.getElementById('fmNombre').focus();
		return false;
	}else if(cadena_letras(document.getElementById('fmNombre').value)==false){
   	alert("En el nombre no se pueden introducir caracteres numéricos.");
      document.getElementById('fmNombre').focus();
      return false;
   }   
	
	if(document.getElementById('fmEmail').value == ""){
		alert("Introduce tu Email.");
		document.getElementById('fmEmail').focus();
		return false;
	}	
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}

	if(document.getElementById('fmEmail2').value == ""){
		alert("Introduce el Email de tu amigo.");
		document.getElementById('fmEmail2').focus();
		return false;
	}
	
	//Validaciones del Mensaje
	var texto = document.getElementById('fmMensaje').value;
	
	if  (DPTelefono(texto) == true)
		{alert("No se permite la introdución de teléfonos en el contenido del Mensaje");
		 document.getElementById('fmMensaje').focus();
		 return false;}
	
	if  (DPVinculo2(texto) == true)
		{alert("No se permite la introdución de hipervínculos en el contenido del Mensaje");
		 document.getElementById('fmMensaje').focus();
		 return false;}
	
	if  (DPEmail(texto) == true)
		{alert("No se permite la introdución de direcciones de correo en el contenido del Mensaje");
		 document.getElementById('fmMensaje').focus();
		 return false;}

	if(document.getElementById('TextBoxUserCode').value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
      document.getElementById('TextBoxUserCode').focus();
      return false;
  	}
}

function DPVinculo2(texto) {
	//Patrones 2 de Hipervínculos
	
	var exp1 = new RegExp("www.([a-z]*).([a-z]{3})", "gi");
	var rem1 = texto.replace(exp1," ");
	
	var exp2 = new RegExp("www.([a-z]*).([a-z]{2})", "gi");
	var rem2 = texto.replace(exp2," ");
	
	var exp3 = new RegExp("http://", "gi");
	var rem3 = texto.replace(exp3," ");

	
	if ((rem1.length != texto.length)|(rem2.length != texto.length)|(rem3.length != texto.length))
		{	return true;	}
	else
		{	return false;	}
}

// Función validar Formulario Consultorio
function ValidaConsultorio(){
 
   if(document.getElementById('fmCategoria').value == ""){
     	alert("Introduce la Categoría donde estara incluida la consulta.");
     	document.getElementById('fmCategoria').focus();
     	return false;
   }
   
   if(document.getElementById('fmTitulo').value == ""){
     	alert("Introduce el Título de la Consulta.");
     	document.getElementById('fmTitulo').focus();
   	return false;
   }

	if ((RevisaContents("fmConsulta") == false)){
	  	alert("Introduce el Texto de la Consulta.");
		return false;
	}
	
	if ((RevisaContentsLong("fmConsulta", 1000) == false)){
	  	var sobran = LongitudContents("fmConsulta") - 1000;
	  	alert("Máximo 1000 caracteres en la Consulta. Sobran: " + sobran);
		return false;
	}
 
	if(document.getElementById('fmNombre').value == ""){
  	  	alert("Introduce tu nombre.");
     	document.getElementById('fmNombre').focus();
     	return false;
   }else if(cadena_letras(document.getElementById('fmNombre').value)==false){
   	alert("En el nombre no se pueden introducir caracteres numéricos.");
      document.getElementById('fmNombre').focus();
      return false;
   }   
  
	if(document.getElementById('fmApellidos').value == ""){
     	alert("Introduce tus apellidos.");
     	document.getElementById('fmApellidos').focus();
     	return false;
	}else if(cadena_letras(document.getElementById('fmApellidos').value)==false){
   	alert("En los apellidos no se pueden introducir caracteres numéricos.");
      document.getElementById('fmApellidos').focus();
      return false;
   }   
 
	if(document.getElementById('fmEmail').value == ""){
   	alert("Introduce tu email.");
     	document.getElementById('fmEmail').focus();
     	return false;
   }
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}
	
   if(document.getElementById('fmProvincia').value == ""){
     	alert("Introduce tu provincia.");
     	document.getElementById('fmProvincia').focus();
     	return false;
   }
	
	if(document.getElementById('TextBoxUserCode').value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
      document.getElementById('TextBoxUserCode').focus();
      return false;
  	}

	if (document.getElementById('fmBoletin').checked){
  		if(document.getElementById('fmEmail').value == ""){
	   	alert("Para recibir el Newsletter debes introducir tu email.");
		 	document.getElementById('fmEmail').focus();
		 	return false;
	  	}
	}	

}

	
//Función validar Formulario Altas Centros
function CompruebaTelefono(v){
  var t=/^(6|8|9)\d{8}$/
  t.test(v);
	alert(v)
  if( t.test(v) == false){
		alert("Escriba un número de teléfono correcto");
		v== 0;
		return false;
  }
  else{
  	return true;  
  }
}

function CompruebaClave(sString){	
	if(document.frmAltaCentros.fmClave.value!=document.frmAltaCentros.fmClave2.value){
		alert("La contraseña no se ha reescrito correctamente");
	}
	else{
		return true;      
	}
}

function CompruebaUrl(sString){
	if (frmAltaCentros.fmUrl.value != ""){
		cadena=frmAltaCentros.fmUrl.value
		if (cadena.substring(0,4)=="http"){
			alert("No es necesario incluir la cadena http://");
			frmAltaCentros.fmUrl.focus();
			return false;
		}
  }
}

function ValidaAltaCentros(){

	if(document.getElementById('fmNombre').value == ""){
  	  	alert("Introduce tu nombre.");
     	document.getElementById('fmNombre').focus();
     	return false;
   }else if(cadena_letras(document.getElementById('fmNombre').value)==false){
   	alert("En el nombre no se pueden introducir caracteres numéricos.");
      document.getElementById('fmNombre').focus();
      return false;
   }   
  
	if(document.getElementById('fmApellidos').value == ""){
     	alert("Introduce tus apellidos.");
     	document.getElementById('fmApellidos').focus();
     	return false;
	}else if(cadena_letras(document.getElementById('fmApellidos').value)==false){
   	alert("En los apellidos no se pueden introducir caracteres numéricos.");
      document.getElementById('fmApellidos').focus();
      return false;
   }   
	 
 	if(document.getElementById('fmCargo').value == ""){
		alert("Introduce tu Cargo.");
		document.getElementById('fmCargo').focus();
		return false;
	}

	if(document.getElementById('fmCentro').value == ""){
		alert("Introduce el Nombre del Centro.");
		document.getElementById('fmCentro').focus();
		return false;
	}
	else{
		vTextoCentroSinEspacios = document.getElementById('fmCentro').value.replace(/ /gi, "");
		//alert(vTextoCentroSinEspacios);
	 	var t =/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i;
   	if(t.test(vTextoCentroSinEspacios)==true){
			alert("El Nombre de Centro no puede contener hiperenlaces.");
			document.getElementById('fmCentro').focus();
			return false;
	 	}
		var t = /(www\.)(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i;
		if(t.test(vTextoCentroSinEspacios)==true){
			alert("El Nombre de Centro no puede ser una página web.");
			document.getElementById('fmCentro').focus();
			return false;
	 	}
		var t = /(\.(com|es)( |$|[^a-zA-Z0-9]))/i;
   	if(t.test(vTextoCentroSinEspacios)==true){
			alert("El Nombre de Centro no puede ser un dominio web.");
			document.getElementById('fmCentro').focus();
			return false;
	 	}
	}

	if(document.getElementById('fmTipoFormacion').value == ""){
		alert("Selecciona el Tipo de Formación.");
		document.getElementById('fmTipoFormacion').focus();
		return false;
	}	 
	 
   /*var t=/[a-zA-Z]/;
   if(t.test(document.frmAltaCentros.fmCentro.value)==false){
       alert("Introduce el Nombre del Centro.");
       document.frmAltaCentros.fmCentro.focus();
       return false;
   }*/

	if(document.getElementById('fmNif').value == ""){
		alert("Introduce tu DNI o CIF.");
		document.getElementById('fmNif').focus();
		return false;
	}
	else{
		dni = ValidaDNI(document.getElementById('fmNif').value);
		cif = ValidaCIF(document.getElementById('fmNif').value);
		if(dni)
		{
			//ok
		}
		else
		{	
			if(cif)
			{
				//ok
			}
			else
			{
				alert('El DNI/CIF es incorrecto.');
				document.getElementById('fmNif').focus();
				return false;
			}
		}
	}
	
	if(document.getElementById('fmProvincia').value == ""){
		alert("Selecciona tu provincia.");
		document.getElementById('fmProvincia').focus();
		return false;
	}
	
	if(document.getElementById('fmLocalidad').value == ""){
		alert("Introduce tu Localidad.");
		document.getElementById('fmLocalidad').focus();
		return false;
	}
   
	if(document.getElementById('fmTipoVia').value == ""){
		alert("Selecciona un Tipo de Vía.");
		document.getElementById('fmTipoVia').focus();
		return false;
	}
	
	if(document.getElementById('fmNombreVia').value == ""){
		alert("Introduce el Nombre de Vía.");
		document.getElementById('fmNombreVia').focus();
		return false;
	}
	
	if(document.getElementById('fmNumeroVia').value == ""){
		alert("Introduce el Número de Vía.");
		document.getElementById('fmNumeroVia').focus();
		return false;
	}
	
	if(document.getElementById('fmCp').value == ""){
		alert("Introduce tu Código Postal.");
		document.getElementById('fmCp').focus();
		return false;
	}
	
	if(document.getElementById('fmTelefono').value == ""){
		alert("Introduce tu Teléfono.");
		document.getElementById('fmTelefono').focus();
		return false;
	}
	else{
		var exp1=/([a-z]*)/gi;
		var rem1 = document.getElementById('fmTelefono').value.replace(exp1,"");
		if (rem1.length != document.getElementById('fmTelefono').value.length){
			alert("Escriba un número de teléfono correcto");
			document.getElementById('fmTelefono').focus();
			return false;
		}
	}
	
	if(document.getElementById('fmEmail').value == ""){
	  alert("Introduce tu Email.");
	  document.getElementById('fmEmail').focus();
	  return false;
	}
	else if (!es_email(document.getElementById('fmEmail').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail').focus();
		return false;
	}
	
	if(document.getElementById('fmEmail2').value == ""){
	  alert("Reescribe tu Email.");
	  document.getElementById('fmEmail2').focus();
	  return false;
	}
	else if (!es_email(document.getElementById('fmEmail2').value)){
		alert("El e-mail introducido no es válido.");
		document.getElementById('fmEmail2').focus();
		return false;
	}
	
	if(document.getElementById('fmEmail').value != document.getElementById('fmEmail2').value){
		alert("Los Emails introducidos no coinciden.");
		document.getElementById('fmEmail').focus();
		return false;
	}	
	
	if(document.getElementById('fmUsuario').value == ""){
	  alert("Introduce tu Usuario.");
	  document.getElementById('fmUsuario').focus();
	  return false;
	}
	else{
		var t=/[^a-zA-Z0-9_@]/
   	if(t.test(document.getElementById('fmUsuario').value)==true){
			alert("El usuario sólo puede contener letras, números, _ y @.");
			document.getElementById('fmUsuario').focus();
			return false;
	 	}
	}
	
	if(document.getElementById('fmClave').value == ""){
	  alert("Introduce tu Contraseña.");
	  document.getElementById('fmClave').focus();
	  return false;
	}
	else{
		var t=/[^a-zA-Z0-9_@]/
   	if(t.test(document.getElementById('fmClave').value)==true){
			alert("La contraseña sólo puede contener letras, números, _ y @.");
			document.getElementById('fmClave').focus();
			return false;
	 	}
	}	
	
	if(document.getElementById('fmClave2').value == ""){
	  alert("Reescribe tu Contraseña.");
	  document.getElementById('fmClave2').focus();
	  return false;
	}
	else{
		var t=/[^a-zA-Z0-9_@]/
   	if(t.test(document.getElementById('fmClave2').value)==true){
			alert("La contraseña sólo puede contener letras, números, _ y @.");
			document.getElementById('fmClave2').focus();
			return false;
	 	}
	}	
	
	if(document.getElementById('fmClave').value != document.getElementById('fmClave2').value){
		alert("Las Contraseñas introducidas no coinciden.");

		document.getElementById('fmClave').focus();
		return false;
	}

	if(document.getElementById('TextBoxUserCode').value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
      document.getElementById('TextBoxUserCode').focus();
      return false;
  }

}


function ValidaDNI(dni) 
{
	DNIvalido = true;
//	var toremove = "-";
//	var re = new RegExp(toremove, 'gi');
//	vfmDni = dni.replace(re, "");
	var exp1 = /-/gi;
	dni = dni.replace(exp1,"");
	var exp1 = / /gi;
	dni = dni.replace(exp1,"");

//	alert(dni);

	if (!/^\d{1,8}[A-Za-z]{1}$/.test(dni)){
		//alert('El D.N.I. es incorrecto. El formato para el D.N.I debería ser de 8 dígitos seguidos de una letra en mayúscula, sin espacios.');
		//dni.focus();
		DNIvalido = false;
	} 
	else{
		var letras = 'TRWAGMYFPDXBNJZSQVHLCKE';
		var numero = parseInt(dni.substr(0,dni.length-1))%23;
		if (letras.substring(numero,numero+1) != dni.substring(dni.length-1).toUpperCase()){
			//alert('El D.N.I. es incorrecto. La última letra no es correcta.');
			//dni.focus();
			DNIvalido = false;
		}
	}
	return DNIvalido;
}

function ValidaCIF(cif){
	var pares = 0; 
	var impares = 0; 
	var suma; 
	var ultima; 
	var unumero; 
	var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I"); 
	var xxx; 
	 
	cif = cif.toUpperCase();
	var exp1 = /-/gi;
	cif = cif.replace(exp1,"");
	var exp1 = / /gi;
	cif = cif.replace(exp1,"");

//	alert(cif);

	var regular = new RegExp(/^[ABCDEFGHKLMNPQS]\d\d\d\d\d\d\d[0-9,A-J]$/g); 
	if (!regular.exec(cif)) return false; 
			
	ultima = cif.substr(8,1); 
	
	for (var cont = 1 ; cont < 7 ; cont ++){ 
		 xxx = (2 * parseInt(cif.substr(cont++,1))).toString() + "0"; 
		 impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
		 pares += parseInt(cif.substr(cont,1)); 
	} 
	xxx = (2 * parseInt(cif.substr(cont,1))).toString() + "0"; 
	impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
	
	suma = (pares + impares).toString(); 
	unumero = parseInt(suma.substr(suma.length - 1, 1)); 
	unumero = (10 - unumero).toString(); 
	if(unumero == 10) unumero = 0; 
	
	if ((ultima == unumero) || (ultima == uletra[unumero])) 
		 return true; 
	else 
		 return false; 
} 

//Función validar Formulario Acceso Centros
function ValidaAccesoCentros(){
	var Usuario, Clave;
	Usuario = frmAcceso.fmUsuario.value;
	Clave = frmAcceso.fmClave.value;
	if (Usuario.length == 0 || Clave.length == 0){
		alert("Debe rellenar los campos Nombre y Clave antes de poder continuar");
		frmAcceso.fmUsuario.value="";
		frmAcceso.fmClave.value="";
		return false;
	}
	else{
  	frmAcceso.submit();
	}
}

// Función Valida registro boletin
function ValidaRegistroBoletin(){
	if(frmBoletinRegistro.fmNombre.value == ""){
		alert("Introduce tu Nombre.");
		frmBoletinRegistro.fmNombre.focus();
		return false;
	}
	
	if(frmBoletinRegistro.fmEmail.value == ""){
	  alert("Introduce tu Email.");
	  frmBoletinRegistro.fmEmail.focus();
	  return false;
	}
}

// Función validar Contacto Prensa
function ValidaContactoPrensa(){
	var msg;
	
	if(document.frmContacto.fmEmpresa.value == ""){
		alert("Introduce el nombre de la Empresa.");
		document.frmContacto.fmEmpresa.focus();
		return false;
	}

	if(document.frmContacto.fmNombre.value == ""){
      alert("Introduce tu nombre.");
      document.frmContacto.fmNombre.focus();
      return false;
   }
   else{
      if(cadena_letras(document.frmContacto.fmNombre.value)==false){
         alert("En el nombre no se pueden introducir caracteres numéricos.");
         document.frmContacto.fmNombre.focus();
         return false;
      }
   }   
  
   if(document.frmContacto.fmApellidos.value == ""){
      alert("Introduce tus apellidos.");
      document.frmContacto.fmApellidos.focus();
      return false;
   }
   
   else{
      if(cadena_letras(document.frmContacto.fmApellidos.value)==false){
         alert("En los apellidos no se pueden introducir caracteres numéricos.");
         document.frmContacto.fmApellidos.focus();
         return false;
      }
   }   
     /*if(document.frmContacto.fmComunicacion.value == ""){
      alert("Introduce el comunicado.");
      document.frmContacto.fmComunicacion.focus();
      return false;
   }*/
   
   // Llamadas a las funciones propias del editor
	if ((RevisaContents("fmComunicacion") == false)){
	  alert("Introduce el comunicado.");
	  return false;
	}
	// Fin de llamadas a las funciones propias del editor
   
  if(document.frmContacto.fmArchivo.value == ""){
      alert("Seleccione un archivo.");
      document.frmContacto.fmArchivo.focus();
      return false;
   }

}

//Funciones de validacion de Envio del boletin
function ValidaEnvioBoletin(){
	if(document.getElementById('fmNombre').value == ""){
		alert("Introduce tu Nombre.");
		document.getElementById('fmNombre').focus();
		return false;
	}
	if(document.getElementById('fmEmail').value == ""){
		alert("Introduce tu Email.");
		document.getElementById('fmEmail').focus();
		return false;
	}

}


//Funcion para aumentar o disminuir el tamaño de una fuente
//Parametros:
//	opcion - 1, aumenta
//         - 2, disminuye
//  maximo - tamaño máximo posible en %
//  minimo - tamaño minimo posible en %
//  incremento - % a incrementar o decrementar la fuente
//  elemento - elemento contenedor del texto a tratar.
function CambiaTamanoFuente(opcion, maximo, minimo, incremento, elemento)
{
	var obj = document.getElementById(elemento);

	if (obj.style.fontSize == ""){
		//obj.style.fontSize = "100%";
		actual = 100
	}
	else
	{
		actual = parseInt(obj.style.fontSize);
	}

	if (maximo > 200){
		maximo = 200;
	}
	if (minimo < 100){
		minimo = 100;
	}	
	if (maximo < minimo){
		maximo = actual;
	}
	if (incremento < 10 || incremento > 40){
		incremento = 10;
	}		

	switch(opcion)
	{
		case 1:
			resultante = actual + incremento;
			if (resultante > maximo){
				resultante = maximo;
			}
			obj.style.fontSize = parseInt(resultante) + "%";
			break;
		case 2:
			resultante = actual - incremento;
			if (resultante < minimo){
				resultante = minimo;
			}
			obj.style.fontSize = parseInt(resultante) + "%";		
			break;
	}
}



//Función Validación Formulario de Opinión
function ValidaOpinion(){
  
   if(document.getElementById('fmNombre').value == ""){
      alert("Introduce tu nombre.");
      document.getElementById('fmNombre').focus();
      return false;
   }
   else{
		if(cadena_letras(document.getElementById('fmNombre').value)==false){
         alert("En el nombre no se pueden introducir caracteres no alfabeticos.");
         document.getElementById('fmNombre').focus();
         return false;
      }
   }
          
	if(document.getElementById('fmEmail').value == ""){
      alert("Introduce tu email.");
      document.getElementById('fmEmail').focus();
      return false;
   }
	else {
		if (!es_email(document.getElementById('fmEmail').value)){
			alert("El e-mail introducido no es válido.");
			document.getElementById('fmEmail').focus();
			return false;
		}
	}

   // Llamadas a las funciones propias del editor
	if ((RevisaContents('fmOpinion') == false)){
	  	alert("Introduce tu opinion.");
		return false;
	}
	
	if ((GetLength('fmOpinion') == false)){
	  	alert("Introduce tu opinion.");
		return false;
	}

	if ((RevisaContentsLong('fmOpinion', 1500) == false)){
	  	var sobran = LongitudContents('fmOpinion') - 1500;
	  	alert("Máximo 1500 caracteres en la Opinion. Sobran: " + sobran);
		return false;
	}
	// Fin de llamadas a las funciones propias del editor
	
	if(document.getElementById('TextBoxUserCode').value == ""){
      alert("Escriba los caracteres que vea en la imagen.");
      document.getElementById('TextBoxUserCode').focus();
      return false;
  }
}


function VaciarCampoCaja(campo, texto){
	dato = document.getElementById(campo).value;
	if (dato == "" || dato == texto){
		document.getElementById(campo).value = "";
	} 
}

function EsEmailCaja(campo){
	var email = document.getElementById(campo).value;
	// Return false if e-mail field does not contain a '@' and '.' .   
	var mascara = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,i;
	testMascara = mascara.test(email);
	if (!testMascara) {  // Validamos el email
		alert('Escriba correctamente el e-mail');
		return false;
	}
}

function vaciar_campo(campo){
	valor = campo.value;
	if (valor == "" || valor == "tu email"){
		campo.value = "";
	} 
}

function valida_email(email){
	var mascara = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,i;
	testMascara = mascara.test(email);
	if (!testMascara) {  // Validamos el email
		alert('Escriba correctamente el e-mail');
		return false;
	}
}
	
