//Validación Campos formulario Alta Cursos
function ValidaAltaCursos(){
	
	if (!document.getElementById('CategoriaD').value)
	{
		alert("Seleccione la categoría donde quiera posicionar el curso.");
		return false;
  }
	
	if (document.getElementById('IDI').value == "1")
	{
		if (!document.getElementById('COD_TIPO_IDOMAS').value)
		{
			alert("Seleccione la tipología del curso.");
			document.getElementById('COD_TIPO_IDOMAS').focus();
			return false;
		}
		
		if (!document.getElementById('COD_COLECTIVO_IDOMAS').value)
		{
			alert("Seleccione el colectivo del curso.");
			document.getElementById('COD_COLECTIVO_IDOMAS').focus();
			return false;
		}
		
		if (!document.getElementById('COD_PAIS').value)
		{
			alert("Seleccione el país del curso.");
			document.getElementById('COD_PAIS').focus();
			return false;
		}
	}
	
	if (document.getElementById('CURSO').value == "")
	{
		alert("Introduzca nombre de curso.");
		document.getElementById('CURSO').focus();
		return false;
  }
	
	if (document.getElementById('DURACION').value != "")
	{
		vDuracion = parseInt(document.getElementById('DURACION').value) 
		if (isNaN(vDuracion)) 
		{ 
			alert("Introduzca solo dígitos decimales en Duración.");
			document.getElementById('DURACION').focus();
			return false;
		}
	}
	
	if (document.getElementById('EUROS').value != "")
	{
		v1Euros = parseInt(document.getElementById('EUROS').value) 
		if (isNaN(v1Euros)) 
		{ 
			alert("Introduzca solo dígitos decimales en Importe.");
			document.getElementById('EUROS').focus();
			return false;
		}
	else
		{ 
			vEuros=document.getElementById('EUROS').value;
			vEurosFin=vEuros.replace(",",".");
			document.getElementById('EUROS').value=vEurosFin;
		} 
	}
		
	if (document.getElementById('TELEFONO').value != "")
	{
		vTelefono = parseInt(document.getElementById('TELEFONO').value) 
		if (isNaN(vTelefono)) 
		{ 
			alert("Introduzca solo dígitos decimales en Teléfono.");
			document.getElementById('TELEFONO').focus();
			return false;
		}
	}
	
	if (Arroba(document.getElementById('MAIL')) == false)
	{ 	return false  	}
	
	var vCurso = document.getElementById('CURSO');
	
	var exp1 = /<[^>]*>/gi;

	vCurso.value = vCurso.value.replace(exp1,"");
	if (DPVinculo(vCurso.value) == true)
		{alert("No se permite la introdución de hipervínculos en el nombre del curso");
		 vCurso.focus();
		 return false;}
	if (DPEmail(vCurso.value) == true)
		{alert("No se permite la introdución de direcciones de correo en el título del curso");
	   vCurso.focus();
		 return false;}		 
	if (DPDominioSimple(vCurso.value) == true)
		{alert("No se permite la introdución de nombres de dominio en el título del curso");
	   vCurso.focus();
		 return false;}
	if (DPDominioSinNet(vCurso.value) == true)
		{alert("No se permite la introdución de nombres de dominio en el título del curso");
		  vCurso.focus();
		 return false;}		 
	if (DPTelefono(vCurso.value) == true)
		{alert("No se permite la introdución de teléfonos en el título del curso");
	   vCurso.focus();
		 return false;}		 
	
	var oEditorPROGRAMA = FCKeditorAPI.GetInstance('PROGRAMA');
	var textoPROGRAMA = oEditorPROGRAMA.GetXHTML( true );
	vProgramaConEspacios = textoPROGRAMA.replace(/&nbsp;/gi, " ");
	vProgramaSinEspacios = textoPROGRAMA.replace(/&nbsp;/gi, " ");
	vProgramaSinEspacios = vProgramaSinEspacios.replace(/ /gi, "");
	if (textoPROGRAMA.length > 101095){
	  alert("El contenido del PROGRAMA es demasiado extenso.");
	  return false;
  	}
	if (DPTelefono(vProgramaSinEspacios) == true)
		{alert("No se permite la introdución de teléfonos en los campos Programa formativo y Requisitos");
		 oEditorPROGRAMA.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	if (DPVinculo(vProgramaSinEspacios) == true)
		{alert("No se permite la introdución de hipervínculos en los campos Programa formativo y Requisitos");
		 oEditorPROGRAMA.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	if (DPEmail(vProgramaSinEspacios) == true)
		{alert("No se permite la introdución de direcciones de correo en los campos Programa formativo y Requisitos");
		 oEditorPROGRAMA.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	if (DPDominioSimple(vProgramaSinEspacios) == true)
		{alert("No se permite la introdución de nombres de dominio en los campos Programa formativo y Requisitos");
		 oEditorPROGRAMA.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
 	if (DPDominioSinNet(vProgramaSinEspacios) == true)
		{alert("No se permite la introdución de nombres de dominio en los campos Programa formativo y Requisitos.");
		 oEditorPROGRAMA.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}


	var oEditorREQUISITOS = FCKeditorAPI.GetInstance('REQUISITOS') ;
	var textoREQUISITOS = oEditorREQUISITOS.GetXHTML( true );
	vRequisitosConEspacios = textoREQUISITOS.replace(/&nbsp;/gi, " ");
	vRequisitosSinEspacios = textoREQUISITOS.replace(/&nbsp;/gi, " ");
	vRequisitosSinEspacios = vRequisitosSinEspacios.replace(/ /gi, "");
	if (textoREQUISITOS.length > 101095){
		alert("El contenido de los REQUISITOS es demasiado extenso.");
	  return false;
		} 
	if (DPTelefono(vRequisitosSinEspacios) == true)
		{alert("No se permite la introdución de teléfonos en los campos Programa formativo y Requisitos");
		 oEditorREQUISITOS.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	if (DPVinculo(vRequisitosSinEspacios) == true)
		{alert("No se permite la introdución de hipervínculos en los campos Programa formativo y Requisitos");
		 oEditorREQUISITOS.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	if (DPEmail(vRequisitosSinEspacios) == true)
		{alert("No se permite la introdución de direcciones de correo en los campos Programa formativo y Requisitos");
		 oEditorREQUISITOS.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	if (DPDominioSimple(vRequisitosSinEspacios) == true)
		{alert("No se permite la introdución de nombres de dominio en los campos Programa formativo y Requisitos");
		 oEditorREQUISITOS.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}
	if (DPDominioSinNet(vRequisitosSinEspacios) == true)
		{alert("No se permite la introdución de nombres de dominio en los campos Programa formativo y Requisitos");
		 oEditorREQUISITOS.Commands.GetCommand( 'SelectAll' ).Execute();
		 return false;}

	var exp1 = new RegExp("'", "gi");
	var rem1 = textoPROGRAMA.replace(exp1,"''");
	//oEditorPROGRAMA.SetHTML( rem1 );
	var rem2 = textoREQUISITOS.replace(exp1,"''");
	//oEditorREQUISITOS.SetHTML( rem2 );

	var vHorario = document.getElementById('HORARIO');
	if (DPTelefono(vHorario.value) == true)
		{alert("No se permite la introdución de teléfonos en el campo Horario");
		 document.getElementById('HORARIO').focus();
		 return false;}
	if (DPVinculo(vHorario.value) == true)
		{alert("No se permite la introdución de hipervínculos en el campo Horario");
		 document.getElementById('HORARIO').focus();
		 return false;}
	if (DPEmail(vHorario.value) == true)
		{alert("No se permite la introdución de direcciones de correo en el campo Horario");
		 document.getElementById('HORARIO').focus();
		 return false;}
	if (DPDominio(vHorario.value) == true)
		{alert("No se permite la introdución de nombres de dominio en el campo Horario");
		 document.getElementById('HORARIO').focus();
		 return false;}

	var vPlazo = document.getElementById('PLAZO_INSCRIPCION');
	if (DPTelefono(vPlazo.value) == true)
		{alert("No se permite la introdución de teléfonos en el campo Plazo de Inscripción");
		 document.getElementById('PLAZO_INSCRIPCION').focus();
		 return false;}
	if (DPVinculo(vPlazo.value) == true)
		{alert("No se permite la introdución de hipervínculos en el campo Plazo de Inscripción");
		 document.getElementById('PLAZO_INSCRIPCION').focus();
		 return false;}
 	if (DPEmail(vPlazo.value) == true)
		{alert("No se permite la introdución de direcciones de correo en el campo Plazo de Inscripción");
		 document.getElementById('PLAZO_INSCRIPCION').focus();
		 return false;}
	if (DPDominio(vPlazo.value) == true)
		{alert("No se permite la introdución de nombres de dominio en el campo Plazo de Inscripción");
		 document.getElementById('PLAZO_INSCRIPCION').focus();
		 return false;}

	var vDirec = document.getElementById('DIRECCION');
	if (DPTelefono(vDirec.value) == true)
		{alert("No se permite la introdución de teléfonos en el campo Dirección");
		 document.getElementById('DIRECCION').focus();
		 return false;}
	if (DPVinculo(vDirec.value) == true)
		{alert("No se permite la introdución de hipervínculos en el campo Dirección");
		 document.getElementById('DIRECCION').focus();
		 return false;}
	if (DPEmail(vDirec.value) == true)
		{alert("No se permite la introdución de direcciones de correo en el campo Dirección");
		 document.getElementById('DIRECCION').focus();
		 return false;}
	if (DPDominio(vDirec.value) == true)
		{alert("No se permite la introdución de nombres de dominio en el campo Dirección");
		 document.getElementById('DIRECCION').focus();
		 return false;}

	var vLugar = document.getElementById('LUGAR');
	if (DPTelefono(vLugar.value) == true)
		{alert("No se permite la introdución de teléfonos en el campo Lugar");
		 document.getElementById('LUGAR').focus();
		 return false;}
	if (DPVinculo(vLugar.value) == true)
		{alert("No se permite la introdución de hipervínculos en el campo Lugar");
		 document.getElementById('LUGAR').focus();
		 return false;}
	if (DPEmail(vLugar.value) == true)
		{alert("No se permite la introdución de direcciones de correo en el campo Lugar");
		 document.getElementById('LUGAR').focus();
		 return false;}
	if (DPDominio(vLugar.value) == true)
		{alert("No se permite la introdución de nombres de dominio en el campo Lugar");
		 document.getElementById('LUGAR').focus();
		 return false;}
}

function ValidaDatosCentro_Old(){
	if (!document.getElementById('CLAVE').value){
		alert("Introduzca una Clave de Acceso no mayor de ocho caracteres.");
    document.getElementById('CLAVE').focus();
	 	return false;}
	  
	var le = document.getElementById('CLAVE').value;
	if (le.length > 8){
		alert("Introduzca una Clave de Acceso no mayor de ocho caracteres.");
  	document.getElementById('CLAVE').focus();
	 	return false;}
}

function ValidaDatosCentro()
{
	if(document.getElementById('COD_NIF').value != "")
	{
		dni = ValidaDNI(document.getElementById('COD_NIF').value);
		cif = ValidaCIF(document.getElementById('COD_NIF').value);
		if(dni)
		{
			//ok
		}
		else
		{	
			if(cif)
			{
				//ok
			}
			else
			{
				alert('El DNI/CIF es incorrecto.');
				document.getElementById('COD_NIF').focus();
				return false;
			}
		}
	}
	
//	if (document.getElementById('COD_NIF').value != "")
//	{
//		if (ValidaCIF(document.getElementById('COD_NIF')) == false)
//		{ 	
//			document.getElementById('COD_NIF').focus();
//			return false
//		}
//	}
	
	if (!document.getElementById('CONTACTO').value){
	 alert("Introduzca el nombre de la persona de contacto");
   document.getElementById('CONTACTO').focus();
	 return false;
  }
	
	if (!document.getElementById('CARGO').value){
	 alert("Introduzca cargo de la persona de contacto");
   document.getElementById('CARGO').focus();
	 return false;
  }
	
	if (!document.getElementById('TIPO_VIA').value){
	 alert("Seleccione tipo de vía");
   document.getElementById('TIPO_VIA').focus();
	 return false;
  }  
	
	if (!document.getElementById('NOM_VIA').value){
	 alert("Introduzca nombre de vía");
   document.getElementById('NOM_VIA').focus();
	 return false;
  }
	
	if (!document.getElementById('NUM_VIA').value){
	 alert("Introduzca número de vía");
   document.getElementById('NUM_VIA').focus();
	 return false;
  }
		
	if (!document.getElementById('PROVINCIA').value){
	 alert("Introduzca provincia");
   document.getElementById('PROVINCIA').focus();
	 return false;
  }
	
	if (!document.getElementById('CODPOSTAL').value){
	 alert("Introduzca código postal");
   document.getElementById('CODPOSTAL').focus();
	 return false;
  }
	else 
	{
	  codp = parseInt(document.getElementById('CODPOSTAL').value) 
   	if (isNaN(codp)) 
		{ 
   	  alert("Introduzca solo valores numéricos en número de vía.");
			document.getElementById('CODPOSTAL').focus();
			return false;
  	}
	}
	
	if (!document.getElementById('LOCALIDAD').value){
	 alert("Introduzca municipio");
   document.getElementById('LOCALIDAD').focus();
	 return false;
  }
	
	
	if (!document.getElementById('TELEFONO').value){
	 alert("Introduzca teléfono");
   document.getElementById('TELEFONO').focus();
	 return false;
  }
	else 
	{
	  vTelefono = parseInt(document.getElementById('TELEFONO').value) 
    if (isNaN(vTelefono)) 
		{ 
   	  alert("Introduzca solo valores numéricos en teléfono.");
			document.getElementById('TELEFONO').focus();
			return false;
  	}
	}
	
	if (Arroba(document.getElementById('MAIL')) == false)
	{ 
		document.getElementById('MAIL').focus();
		return false
	}
		
	if (document.getElementById('URL').value != ""){
		cadena=document.getElementById('URL').value
		if (cadena.substring(0,4)=="http") 
		{
			alert("No es necesario incluir la cadena http://");
			document.getElementById('URL').focus();
			return false;
		}
  }	
	
	if (!document.getElementById('USUARIO').value){
	 alert("Introduzca nombre de usuario");
   document.getElementById('USUARIO').focus();
	 return false;
 	}
	
	if (!document.getElementById('CLAVE').value){
	 alert("Introduzca una Clave de Acceso no mayor de ocho caracteres.");
   document.getElementById('CLAVE').focus();
	 return false;
 	}
	
  var le = document.getElementById('CLAVE').value;
  if (le.length > 8) {
    alert("Introduzca una Clave de Acceso no mayor de ocho caracteres.");
    document.getElementById('CLAVE').focus();
	 	return false;
  }
}

function RevisaContents() {
	var oEditor = "";
	var oEditor = FCKeditorAPI.GetInstance(contenido) ;
	var texto = "";
	var texto = oEditor.GetXHTML( true );
	
	var oEditorPROGRAMA = FCKeditorAPI.GetInstance('PROGRAMA') ;
	var textoPROGRAMA=oEditorPROGRAMA.GetXHTML( true );

	var oEditorREQUISITOS = FCKeditorAPI.GetInstance('REQUISITOS') ;
	var textoREQUISITOS=oEditorREQUISITOS.GetXHTML( true );

	
	//Elimina etiqueta HTML hipervínculo
	
	var exp7 = new RegExp("<a h([^>]*)>", "gi");
	var rem7 = textoPROGRAMA.replace(exp7," ");
	if (rem7.length != textoPROGRAMA.length)
		{ oEditorPROGRAMA.SetHTML( rem7 ) }
		
	var rem8 = textoREQUISITOS.replace(exp7," ");
	if (rem8.length != textoREQUISITOS.length)
		{ oEditorREQUISITOS.SetHTML( rem7 ) }

}

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;	}
}

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," ");
	
	var exp3 = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi;
	var rem3 = texto.replace(exp3," ");

	if ((rem1.length != texto.length)|(rem2.length != texto.length)|(rem3.length != texto.length))
		{	return true;	}
	else
		{	return false;	}
}

function DPEmail(texto) {
	//Patron de Email
	
	//xxxxx@zzzz.yyy
	//var exp1 = /([a-z]*)@([a-z]*)[\.]([a-z]{2,3})/gi;
	var exp1 = /([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/gi;
	var rem1 = texto.replace(exp1," ");
	
	if (rem1.length != texto.length)
		{	return true;	}
	else
		{	return false;	}
}

function DPDominio(texto) {
	//Patron de Dominio
	//.com .es .org .net
	var exp1 = /([a-zA-Z0-9]\.(com|es|org|net|cat)( |$|[^a-zA-Z0-9]))/gi;
	var rem1 = texto.replace(exp1," ");
	var exp2 = /(www\.)(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi;
	var rem2 = texto.replace(exp2," ");
	if ((rem1.length != texto.length)|(rem2.length != texto.length))
		{	return true;	}
	else
		{	return false;	}
}

function DPDominioSinNet(texto) {
	//Patron de Dominio
	//.com .es .org
	var exp1 = /([a-zA-Z0-9]\.(com|es|org|cat)( |$|[^a-zA-Z0-9]))/gi;
	var rem1 = texto.replace(exp1," ");
	var exp2 = /(www\.)(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi;
	var rem2 = texto.replace(exp2," ");
	if ((rem1.length != texto.length)|(rem2.length != texto.length))
		{	return true;	}
	else
		{	return false;	}
}

function DPDominioSimple(texto) {
	var exp2 = /(www\.)(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi;
	var rem2 = texto.replace(exp2," ");
	if (rem2.length != texto.length)
		{	return true;	}
	else
		{	return false;	}
}

// JavaScript Document
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Gestionar todos los mensajes de FSCommand de una película Flash
function popdemo(command, args) {
	var BannerDemoServiciosObj = isInternetExplorer ? document.all.BannerDemoServicios : document.BannerDemoServicios;
	window.open('/demo/Index.asp','Demo','width=640,height=480,scrollbars=0,menubar=0');
//-->
}

function AbrirInfoSeguridad(){
	ventana=window.open("/Include/IncludeInfoSeguridad.htm","","width=600,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
	ventana.focus()
	ventana.moveTo(Math.round((screen.availWidth-550)/2),Math.round((screen.availHeight-550)/2))
	return ventana
	
}

// Funcion de validación del Email
 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;      
		}
}

// Función de confirmación de eliminación de registro

function getPermission(cTipo) {
	if (cTipo=="E") {
		return window.confirm('¿Seguro que desea Eliminar este registro?')
	} else { 
		return window.confirm('¿Seguro que Actualizar este registro?')
	}
}

function salta(destino,seleccion,restore){
  eval(destino+".location='"+seleccion.options[seleccion.selectedIndex].value+"'");
  if (restore) seleccion.selectedIndex=0;
}

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 popcentrado(theURL,winName,features) 
{ //v2.0
	vVentana=window.open(theURL,winName,features)
	vVentana.focus()
	vVentana.moveTo(Math.round((screen.availWidth-550)/2),Math.round((screen.availHeight-550)/2))
	return vVentana
}

function isDescrip(valor,total) 
{   //alert (valor.value.length);
	if (valor.value.length > total) {
		alert ("Debe introducir una Descripción más corta para " + valor.name+" (Max. "+total+" caracteres).");
		valor.focus ();
		return false;
	} else return true; 
}

function Controlarcheck(f){
if (f.agree.checked == false) {
	alert('Debe aceptar antes de continuar.');
	return false;
	}
else
	return true;
	}

function entrar_celda(src,color_entrada) 
{
	src.bgColor=color_entrada;
	src.style.cursor="hand";
	src.fgColor="FFFFFF";
}

function salir_celda(src,color_restaurar) 
{
	src.bgColor=color_restaurar;
	src.style.cursor="default";
}

function PincharCelda(src,Enlace) 
{
	src.bgColor="FCED98";
	self.location.href=Enlace;
}

function abrirRegCentro(){
	ventana=window.open("zPcAltaCentros.asp","","width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
	ventana.focus()
	ventana.moveTo(Math.round((screen.availWidth-550)/2),Math.round((screen.availHeight-550)/2))
	return ventana
}

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);
}
	
function ValidaAltaCentros(){
	if (!fmrAltaCentro.CONTACTO.value){
		alert("Introduzca el nombre de la Persona de Contacto.");
		fmrAltaCentro.CONTACTO.focus();
		return false;
		}
	  
	if (!fmrAltaCentro.CARGO.value){
		alert("Introduzca el Cargo que ocupa la persona de contacto.");
		fmrAltaCentro.CARGO.focus();
		return false;
		}

	if (!fmrAltaCentro.CENTRO.value){
		alert("Introduzca el Nombre de Centro.");
		fmrAltaCentro.CENTRO.focus();
		return false;
		}

	if (fmrAltaCentro.PROVINCIA.value == "Seleccion"){
		alert("Seleccione la provincia.");
		fmrAltaCentro.PROVINCIA.focus();
		return false;
		}
	  
	if (!es_cp(fmrAltaCentro.CODPOSTAL.value)){
		if(fmrAltaCentro.CODPOSTAL.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);
		fmrAltaCentro.CODPOSTAL.focus();
		return false;
    }
	
	if (fmrAltaCentro.URL.value != ""){
		cadena=fmrAltaCentro.URL.value
		if (cadena.substring(0,4)=="http") {
			alert("No es necesario incluir la cadena http://");
			fmrAltaCentro.URL.focus();
			return false;
			}
		}

	if(fmrAltaCentro.MAIL.value == ""){
		alert("Introduzca el email de Recepción de Cupones.");
		fmrAltaCentro.MAIL.focus();
		return false;
		}
	
	if(fmrAltaCentro.MAIL2.value == ""){
		alert("Repita el email para confirmarlo.");
		fmrAltaCentro.MAIL2.focus();
		return false;
		}
	
	if(fmrAltaCentro.MAIL2.value != fmrAltaCentro.MAIL.value){
		alert("Los emails introducidos no coinciden.");
		fmrAltaCentro.MAIL2.focus();
		return false;
		}
   
	if (!fmrAltaCentro.USUARIO.value){
		alert("Introduzca el Nombre de Usuario para el acceso.");
		fmrAltaCentro.USUARIO.focus();
		return false;
		}
		
	if (!fmrAltaCentro.CLAVE.value){
		alert("Introduzca el Clave de Usuario para el acceso.");
		fmrAltaCentro.CLAVE.focus();
		return false;
		}

	if (!fmrAltaCentro.CLAVE2.value){
		alert("Repita la Clave para confirmarlo.");
		fmrAltaCentro.CLAVE2.focus();
		return false;
		}
	  
	if(fmrAltaCentro.CLAVE2.value != fmrAltaCentro.CLAVE.value){
		alert("Las Claves introducidas no coinciden.");
		fmrAltaCentro.CLAVE2.focus();
		return false;
		}

   document.fmrAltaCentro.submit();

}

function ValidaReenvio(){
	if (document.frmReenvioCupon.mail.value == ""){
	 alert("Indique la dirección de correo electrónico donde desea realizar el reenvio.");
	 document.frmReenvioCupon.mail.focus();
	 return false;
  	}		
}

function CambiaProvincia(id_prov){
	 //Cargamos la ventana de poblaciones con las poblaciones correspondientes a ese pais,según los valores del array id_prov.js
		document.fmrAltaCentro.LOCALIDAD.value="";

		if (id_prov=="Seleccion" || id_prov=="0"){
							 
			   document.fmrAltaCentro.LOCALIDAD.value = "";
			   //document.fmrAltaCentro.LOCALIDAD.disabled=false;
			   document.fmrAltaCentro.LOCALIDAD.focus();
			   
			   return;

		}
		//document.fmrAltaCentro.LOCALIDAD.disabled=true;
		var imp="zPcSeleccionMinicipios.asp?CD_Provincia="+id_prov;
                        
		myWin= open(imp,'_blank','menubar=no,locationbar=no,statusbar=no,scrollbars=yes,resizable=yes,height=400,width=300,screenX=0,screenY=0,top=160,left=550');

}


function Elige(code, name){

	if (code=='OTRO'){
		   
		   opener.document.fmrAltaCentro.LOCALIDAD.value = "";
		   //opener.document.fmrAltaCentro.LOCALIDAD.disabled=false;
		  
		   window.close();
		   opener.document.fmrAltaCentro.LOCALIDAD.focus();
		   return;
			}
			
	opener.document.fmrAltaCentro.LOCALIDAD.value  = name;
	opener.document.fmrAltaCentro.MUNICIPIO.value  = code;
	
	window.close();
        }


function CopiarCp(Valor,Destino)
{	
	eval(Destino).focus();
	if (Valor<10) {
		Valor='0'+Valor;
	}
	eval(Destino).value=Valor;
}

function calcularCIF(CIF) 
{
	var resul = false;
	var temp = CIF.value.toUpperCase(); // pasar a mayúsculas
	
	if (!/^[A-Za-z0-9]{9}$/.test(temp)) // Son 9 dígitos? 
	{
		alert ("Longitud incorrecta, un CIF consta de 9 dígitos")
		//document.fmrAltaCentro.COD_NIF.focus()
		return false 
	}
	else if (!/^[ABCDEFGHJKLMNPQS]/.test(temp)) // Es una letra de las admitidas ?
	{
		alert("El primer dígito es incorrecto, debe ser una letra de las siguientes: A,B,C,D,E,F,G,H,K,L,M,N,P,Q,S ")
		document.fmrAltaCentro.COD_NIF.focus()
		return false 
	}
	else 
	{
		var v1 = new Array(0,2,4,6,8,1,3,5,7,9); 
		var temp = 0;
		for( i = 2; i <= 6; i += 2 ) 
		{
			temp = temp + v1[ parseInt(CIF.value.substr(i-1,1)) ];
			temp = temp + parseInt(CIF.value.substr(i,1));
		};
		temp = temp + v1[ parseInt(CIF.value.substr(7,1)) ];
		temp = (10 - ( temp % 10));
		if( temp == 0 || temp == 1 || temp == 2 || temp == 3 || temp == 4 || temp == 5 || temp == 6 || temp == 7 || temp == 8 || temp == 9 )
		  return true;
		else
		  alert( "El CIF es incorrecto, consta de 9 dígitos" )
		  document.fmrAltaCentro.COD_NIF.focus()
		  return false 
	}
}

function ValidaCIF_anterior(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; 
} 


// Validación de CIF de la nueva normativa de la Orden EHA/451/2008.
function ValidaCIF(cif) {
	var par = 0;
	var non = 0;
	var letras = "ABCDEFGHJKLMNPRQSUVW";
	var caracterControlLetra = "KPQS";
	var caracterControlNum = "ABEH";
	var i;
	var parcial;
	var control;
	var controlLetra = "JABCDEFGHIJ";
	var letraIni = cif.charAt(0);
 
	if (cif.length != 9) {
		 //alert("El Cif debe tener 9 dígitos");
		 return false;
	}
	else {
		if (letras.indexOf(letraIni.toUpperCase()) == -1) {
			//alert("La letra del CIF introducido no es correcta");
			return false;
		}
		for (i=2;i<8;i+=2) {
			par = par + parseInt(cif.charAt(i));
		}
		for (i=1;i<9;i+=2) {
			var nn = 2 * parseInt(cif.charAt(i));
			if (nn > 9) nn = 1 + (nn-10);
			non = non + nn;
		}
		parcial = par + non;
		control = (10 - ( parcial % 10));
		if (caracterControlLetra.indexOf(letraIni.toUpperCase()) != -1) {
			// El caracter de control deberá ser una letra
			if (controlLetra.charAt(control) != cif.charAt(8).toUpperCase()) {
				//alert("El CIF no es válido.");
				return false;
			}
		}
		if (caracterControlNum.indexOf(letraIni.toUpperCase()) != -1) {
			// El caracter de control deberá ser un número
			if (control == 10) control = 0;
			if (control != cif.charAt(8)) {
				//alert("El CIF no es válido..");
				return false;
			}
		}
		if ((caracterControlLetra.indexOf(letraIni.toUpperCase()) == -1) && (caracterControlNum.indexOf(letraIni.toUpperCase()) == -1)) {
			// En este caso el carácter de control puede ser una letra o un número
			if (control == 10) {
				control = 0;
			}
			if ((controlLetra.charAt(control) != cif.charAt(8).toUpperCase()) && (control != cif.charAt(8))) {
				//alert("El CIF no es válido...");
				return false;
			}
		}
	}
	return true;
}


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;
}

/* Estas funciones se encargan de mostrar y ocultar capas.*/

function MostrarCapa(capa){
  if(document.layers) {
	document.layers[capa].style.visibility='visible' // Si utilizamos NS 
  }
  else if(document.all) { 
  	document.all(capa).style.visibility='visible' // Si utilizamos IE
  }
  else { 
	capaX = document.getElementById(capa);
	capaX.style.visibility="visible";
  }
}

function MostrarCapaFechas(capa){
 if(document.layers) {
	document.layers[capa].style.visibility='visible' // Si utilizamos NS
	}   
 else if(document.all) { 
	document.all(capa).style.visibility='visible'  // Si utilizamos IE
	}
 else {
	capaX = document.getElementById(capa);
	capaX.style.visibility="visible";
	}
}

function OcultarCapa(capa){
  if(document.layers)document.layers[capa].style.visibility='hide'     // Si utilizamos NS
  if(document.all)document.all(capa).style.visibility='hidden'   // Si utilizamos IE
}

function OcultarCapaFechas(capa){
  if(document.layers) {
	  document.layers[capa].style.visibility='hide'     // Si utilizamos NS
  }
  else if(document.all) {
	  document.all(capa).style.visibility='hidden'   // Si utilizamos IE
  }
  else {
	capaX = document.getElementById(capa);
	capaX.style.visibility="hidden";
  }
  document.frmAltaCursos.F_INICIO.value  = '';
  document.frmAltaCursos.F_FIN.value  = '';
}


function ValidaArchivo(){
	if (frmEnvioArchivo.archivo.value == ""){
		alert("Seleccione el archivo que desea enviar.");
	 	frmEnvioArchivo.archivo.focus();
	 	return false;
	}
	document.frmEnvioArchivo.submit();
}

<!-- Begin
function GenPassAleaorio(Longitud){
  chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  pass = "";
  for(x=0;x<Longitud;x++){
    i = Math.floor(Math.random() * 62);
    pass += chars.charAt(i);
  }
  return pass;
}

function formSubmit(Controlfrm){
	Controlfrm.value = GenPassAleaorio(8);
	alert('La clave de Acceso ha cambiado correctamente');
	return false;
}

function HabilitaCopiaDatos(CrtlHabilitaCopia){
	
}

function CopiaDatosUsuario(EstadoOpc,Usuario,Clave,CtrlDestinoUsr,CtrlDestinoClave){
	if (EstadoOpc){
		CtrlDestinoUsr.value = Usuario;
		CtrlDestinoClave.value = Clave;
		return false;
	} 
	else{
		CtrlDestinoUsr.value = '';
		CtrlDestinoClave.value = '';
		return false;
	}
}

function MostrarCapa(capa){
  if(document.layers)document.layers[capa].visibility='show'     // Si utilizamos NS
  if(document.all)document.all(capa).style.visibility='visible'  // Si utilizamos IE
}

function OcultarCapa(capa){
  if(document.layers)document.layers[capa].visibility='hide'     // Si utilizamos NS
  if(document.all)document.all(capa).style.visibility='hidden'   // Si utilizamos IE
}

//  End -->


function ValidaEnvioMail(vTipoCentro){
	/*if (frmContacto.dsComentarios.value == ""){
		alert("Indique una breve descripcion del motivo del contacto con su Comercial.");
	 	frmContacto.dsComentarios.focus();
	 	return false;
  	}*/
	if (!document.getElementById('dsComentarios').value){
	 alert("Indique una breve descripcion del motivo del contacto con su Comercial.");
 	 document.getElementById('dsComentarios').focus();
	 return false;
  	}
	
	if (vTipoCentro == 1 || vTipoCentro == 2){
		vSer=false
		for(var i = 0; i < frmContacto.Servicios.length; i++){
			if (frmContacto.Servicios[i].checked == true){
				vSer=true
			}
		}
		if (vSer==false){
			alert("Indique el/los Servicios a los que hace referencia su petición.");
			return false;
		}
	}
   //document.frmContacto.submit();
   			
	var oEditorPROGRAMA = FCKeditorAPI.GetInstance('txtComentarios') ;
	var textoPROGRAMA=oEditorPROGRAMA.GetXHTML( true );

	if (textoPROGRAMA.length > 101095){
	  alert("El motivo del contacto es demasiado extenso.");
	  return false;
  	} 
	if (textoPROGRAMA.length == 0){
	  alert("Indique el motivo del contacto.");
	  return false;
  	} 
	
	var exp1 = new RegExp("'", "gi");
	var rem1 = textoPROGRAMA.replace(exp1,"''");		
	oEditorPROGRAMA.SetHTML( rem1 ) ;
}

function ValidaContestarCupon(){
	//var oEditorPROGRAMA = FCKeditorAPI.GetInstance('txtComentarios') ;
	//var textoPROGRAMA=oEditorPROGRAMA.GetXHTML( true );
	var textoPROGRAMA=document.getElementById('txtComentarios').value;

	if (textoPROGRAMA.length > 101095){
	  alert("El contenido del mensaje es demasiado extenso.");
	  return false;
  	} 
	if (textoPROGRAMA.length == 0){
	  alert("Introduzca mensaje de contestación.");
	  return false;
  	} 
	
	var exp1 = new RegExp("'", "gi");
	var rem1 = textoPROGRAMA.replace(exp1,"''");		
	//oEditorPROGRAMA.SetHTML( rem1 ) ;
}

function entrar_celda(src,color_entrada){
	src.bgColor=color_entrada;
	src.style.cursor="hand";
	src.fgColor="FFFFFF";
}

function salir_celda(src,color_restaurar){
	src.bgColor=color_restaurar;
	src.style.cursor="default";
}

function PincharCelda(src,Enlace){
	src.bgColor="FCED98";
	self.location.href=Enlace;
}

/* formexp.js compiled from X 4.0 with XC 0.27b. Distributed by GNU LGPL. For copyrights, license, documentation and more visit Cross-Browser.com */
var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xNN4,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
	var i=xUA.indexOf('opera');
	if(i!=-1){
		var v=parseInt(xUA.charAt(i+6));
		xOp7Up=v>=7;
		xOp6Dn=v<7;
	}
}
else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){
	xIE4Up=parseFloat(navigator.appVersion)>=4;
	xIE4=xUA.indexOf('msie 4')!=-1;
	xIE5=xUA.indexOf('msie 5')!=-1;
}
else if(document.layers){
	xNN4=true;
}
xMac=xUA.indexOf('mac')!=-1;

function xDef(){
	for(var i=0; i<arguments.length; ++i){
		if(typeof(arguments[i])=='undefined') 
			return false;
		}
	return true;
}

function xDisplay(e,s){
	if(!(e=xGetElementById(e))) return null;
	if(e.style && xDef(e.style.display)) {
		if (xStr(s)) e.style.display = s;
			return e.style.display;
		}
		return null;
	}

function xGetElementById(e){
	if(typeof(e)!='string') return e;
	if(document.getElementById) e=document.getElementById(e);
	else if(document.all) e=document.all[e];else e=null;return e;}

function xStr(s){
	for(var i=0; i<arguments.length; ++i){
		if(typeof(arguments[i])!='string') return false;
	}
	return true;
}

function ValidarTotalCursos(sTipoCliente,vTotalCursos,vMaxCursos){
	if(vTotalCursos >= vMaxCursos){
		if(sTipoCliente == 0){
			alert('El total de su oferta ha alcanzado ' + vMaxCursos + ' cursos gratuitos\r\rPodrá añadir si elimina cursos previamente.');}
		else{
			alert('No es posible añadir cursos\r\rEl total de su oferta ha alcanzado ' + vMaxCursos + ' cursos\r\rPodrá añadir si elimina cursos previamente.');}
		return false;
	}
	else{
		return true;
	}
}

function ValidaRechazarCupon(){
	var otros = frmCtlConsultas.ckRechazo[3].checked;
	if ((otros) && (frmCtlConsultas.Otros.value == "")){
		alert("Indique los motivos del rechazo.");
	 	frmCtlConsultas.Otros.focus();
		return false;
	}		
}

function CompruebaIdioma(lista){
	var	arrcate = lista.split(',');
	var categoria = document.getElementById('CategoriaD').value;
	var idioma = false;
	for(var i=0; i<arrcate.length; ++i){
		if(arrcate[i]==categoria){
			idioma = true;
		}
	}
	if(idioma){
		document.getElementById("TRTIPOLOGIA").style.visibility = 'visible';
		document.getElementById("TRCOLECTIVO").style.visibility = 'visible';
		document.getElementById("TRPAIS").style.visibility = 'visible';
		document.getElementById("IDI").value = '1';
	}
	else{
		document.getElementById("TRTIPOLOGIA").style.visibility = 'hidden';
		document.getElementById("TRCOLECTIVO").style.visibility = 'hidden';
		document.getElementById("TRPAIS").style.visibility = 'hidden';
		document.getElementById("IDI").value = '0';
	}
}

