function mOvr(src,clrOver) {
 if (!src.contains(event.fromElement)) {
	 src.style.cursor = 'hand';
	 src.style.background=clrOver
}
 }
 function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
	 src.style.cursor = 'default';
	 src.style.background=clrIn
	}
 }



function nwinprecio(curso)
{
pagina="formcursomodfast.asp?tipo=precio&curso=" +curso
msg=window.open(pagina ,"uhprecio","height=125,width=512,left=200,top=100");
}
function nwinfecha(curso)
{
pagina="formcursomodfast.asp?tipo=fecha&curso=" +curso
msg=window.open(pagina ,"uhfecha","height=175,width=512,left=200,top=100");
}

function buscar1_onclick(form,caja){
if(caja==""){
	alert("La búsqueda debe contener al menos 3 caracteres.");
}else{
	var buscar=caja
	
	for(i=0;i<10;i++)
		buscar=buscar.replace(" ","");
	

		if (buscar.length<=2){
			alert("La búsqueda debe contener al menos 3 caracteres.");
		}else{
			form.submit();
		}}
}


function buscar_onclick(form1) {
if(form1.tema.selectedIndex==0){
	alert("Debe seleccionar un tema");
}else{
	form1.submit();
}}


function buscar2_onclick(form,caja){
if(caja.selectedIndex==0){
	alert("Debe seleccionar un "+ caja.title +".");
}else{
	form.submit()
}}

function salir()
{
document.form1.submit()
window.close()
}

function validarpais(form1,camprovincia,camregion,obligatorio)
{
if ((form1.pais.value!="España") && (form1.pais.value!=""))
{
	camprovincia.selectedIndex=55;
	camprovincia.disabled=true;
	camregion.disabled=false;
	camregion.id=obligatorio;
	camprovincia.id=0;
	camregion.focus();
}
else 
if (form1.pais.value=="España")
{
	camregion.value="";
	camprovincia.selectedIndex=0;
	camprovincia.disabled=false;
	camregion.disabled=true;
	camregion.id=0;
	camprovincia.id=obligatorio;
	camprovincia.focus();
}
else
{
	camprovincia.selectedIndex=0;
	camregion.value="";
	camprovincia.disabled=true;
	camregion.disabled=true;
}

}

function checkbae(){
if (document.layers||document.all)
return validarusuario(form1)
else
return true
}

function borrar(name,id){
  if(confirm("¿Desea dar de baja el Curso "+name+"?")){
    document.formBorrar.id.value=id;
    document.formBorrar.submit();
  }
}
function alta(name,id){
  if(confirm("¿Desea dar de alta el Curso "+name+"?")){
    document.formAlta.id.value=id;
    document.formAlta.submit();
  }
}

function fechas(cajaTxt) {
var fechaOK = "ok"
var fecha;
fecha = cajaTxt.value
if(fecha!=""){
meses = new Array(31,28,31,30,31,30,31,31,30,31,30,31) 
parts = fecha.split("/")
if (parts.length!=3) 
	fechaOK = "error"
else 
	{ 
		if (isNaN(parts[0]) || isNaN(parts[1]) || isNaN(parts[2]) ||  parts[2].length != 4)
		fechaOK = "error" 
		if((fecha.indexOf('.')!=-1) || (fecha.indexOf(' ')!=-1))
		fechaOK = "error"
		if ((fechaOK=="ok") && (parts[2].length == 4 ))
			{ 
	 			if ( parseInt(parts[2],10)%4 == 0 )
	 			meses[1] = 29
	 		} 
		else 
			fechaOK = "error" 
		if ((fechaOK=="ok") && (parts[1].length <= 2 ) && (parseInt(parts[1],10) <=12)) 
			{ 
			mes = (parts[1]) - 1
			diasMax = eval("meses["+mes+"]")
			//diasMax = meses[mes]
			} 
		else 
			fechaOK = "error" 
		if (((fechaOK=="ok") && ((parts[0].length >= 3 ) || (parseInt(parts[0],10) >diasMax || (parseInt(parts[0],10) == 0)))))

			fechaOK = "error" 
			
	}
}
//else{fechaOK = "vacia"}
if(fechaOK=="error"){
alert("Error al introducir la fecha")
cajaTxt.focus()
}
}

function marcartemas(campo)
{
for(var i=0; i < campo.length ;i++)
	if (campo.elements[i].id=="tema") 
		campo.elements[i].checked=true;
}
function desmarcartemas(campo)
{
for(var i=0; i < campo.length ;i++)
	if (campo.elements[i].id=="tema") 
		campo.elements[i].checked=false;
}

function enviarnoencontro(campo){
var txarea=campo.mensaje.value
  if (txarea.length<1){
      alert("Debe indicar el Comentario a enviar");
	  campo.mensaje.focus();}
  else if (txarea.length>500){
      alert("El campo Comentarios no puede tener mas de 500 caracteres. Usted ha introducido "+txarea.length+" caracteres");
		campo.mensaje.focus();}
  else 
	{
   for(var i=0; i < campo.length ;i++)
	{
	if ( (campo.elements[i].value.replace(/ /g,"")=="") && (campo.elements[i].id=="1")   )
			{ 
			alert("El campo "+ campo.elements[i].name +" no puede estar vacío");
			campo.elements[i].focus();
			i=campo.length+2;
			}
	}

	if(i==campo.length)
		campo.submit() 

    
    }
    }  


function marcar(campo,valor)
{
for(var i=0; i < campo.length ;i++)
	if (campo.elements[i].id==valor) 
		campo.elements[i].checked=true;
}
function desmarcar(campo,valor)
{
for(var i=0; i < campo.length ;i++)
	if (campo.elements[i].id==valor) 
		campo.elements[i].checked=false;
}


function algun(campo,valor)
{var i
for(i=0; i < campo.length ;i++)
	if ((campo.elements[i].id==valor) && (campo.elements[i].checked==true))
		{
		i=campo.length + 5;
		}
		
if (i>campo.length)
	campo.submit();
else
	alert('Debes marcar alguna casilla');
}

function temario(curso,pagina)
{
pagina=pagina + curso
msg=window.open(pagina ,"msg","height=470,width=500,left=200,top=100");
}

function compruebatextarea(campo)
{
var txarea=campo.value
if (txarea.length<1)
{
      alert("Debe indicar el "+ campo.title +" a enviar");
	  campo.focus();
	  campo.id=2;
}
else if (txarea.length>500)
{
      alert("El campo  "+ campo.title +" no puede tener mas de 500 caracteres. Usted ha introducido "+txarea.length+" caracteres");
      campo.focus();
      campo.id=2;
}
else
{
campo.id=1;
}
}   
 
      
function validar(campo)
{
  for(var i=0; i < campo.length ;i++)
	{
	if (campo.elements[i].id==2)
	{		
		campo.elements[i].focus();
		i=campo.length+2;
	}
	else if ( (campo.elements[i].value.replace(/ /g,"")=="") && (campo.elements[i].id=="1") )
		{ 
			if (( campo.elements[i].title=="Provincia" && campo.pais.value=="España"  )|| ( campo.elements[i].title!="Provincia") )
			{
				alert("El campo "+ campo.elements[i].title +" no puede estar vacío");
				campo.elements[i].focus();
				i=campo.length+2;
			}
		}
	}

	if(i==campo.length)
		campo.submit()

}

function cambiamail (buzon)
{
var res = "";
for (var n = 0; n < buzon.length; n++)
res += String.fromCharCode(buzon.charCodeAt(n));
if (res.indexOf('@') < 0)
res = res + '@' + 'conferenzias.com';
location = "mail" + "to:" + res;
}


function validarusuario(campo)
{
if (campo.correo==null) 
	var str=campo.email.value.replace(/ /g,"")
else
{	
	campo.correo.value=campo.correo.value.replace(/ /g,"")
	var str=campo.correo.value
}
var filter=/^.+@.+\..{2,4}$/
if (filter.test(str))
	{
	for(var i=0; i < campo.length ;i++)
	{
	if ( (campo.elements[i].value.replace(/ /g,"")=="") && (campo.elements[i].id=="1")   )
			{ 
			alert("El campo "+ campo.elements[i].title +" no puede estar vacío");
			campo.elements[i].focus();
			i=campo.length+2;
			}
	}

	if(i==campo.length)
		campo.submit()
	
	}
else{
	alert("Por favor, introduzca una dirección de E-Mail existente")
	if (campo.correo==null) 
		campo.email.focus();	
	else
		campo.correo.focus();	
	}
}


function haz_tamano()
{
window.resizeTo(320,300);
}


function quitacomillas(DnEvents) 
{
k = (document.layers) ? DnEvents.which : window.event.keyCode; 
if ((k == 34)|| (k == 39)) 
return false; 
else 
return true; 
} 
document.onkeypress = quitacomillas; 


function compruebanum( valor_1,valor_2 ) {
var aceptar=1
for(var i=0; i < valor_1.length; i++)
	{
		var ch=valor_1.substring(i, i + 1)
		if ((ch < "0" || "9" < ch))
 
			{
			aceptar=0;
			}
	}
if(aceptar==0){
	alert("Debe introducir un valor entero y sin puntos.");
	valor_2.value="";
	valor_2.focus();
}
	return true;
}

function compruebanum1( valor_1,valor_2,valor_3 ) {
var aceptar1=1
for(var i=0; i < valor_1.length; i++)
	{
		var ch=valor_1.substring(i, i + 1)
		if (((ch < "0" || "9" < ch) && ch!=","))
 
			{
			aceptar1=0;
			}
	}
if(aceptar1==0){
	alert("Debe introducir el valor en Euros, sin puntos y separado por coma.");
	valor_2.value="";
	valor_2.focus();
}
	valor_1=valor_1.replace(",",".")
	valor_3.value=Math.round(valor_1*166.386);
	return true;
}

function ContarTexto( texto, salida, max ) {
   if (texto.value.length >	max) texto.value = texto.value.substr(0,max); salida.value = max - texto.value.length;
}

//Funcion para elegir el combo
function doSel(obj)
 {
 
     for (i = 0; i < obj.length; i++)
	    if (obj[i].selected == true)
           eval(obj[i].value);
}

function registrar_onclick()
{
if(document.form1.usuario.value=="" || document.form1.clave.value=="" || document.form1.email.value=="")
{
	alert("Debe rellenar todos los campos marcados con asterisco rojo.");
	document.form1.usuario.focus();	
}
else
{
    if (document.form1.pais.value=="")
    {
		alert("Debe rellenar el país de residencia");
		document.form1.pais.focus();
	}
	else 
	{
		if(document.form1.pais.value=="España" && (document.form1.provincia.value=="") )
		{
			alert("Debe rellenar la provincia");
			document.form1.provincia.focus();	
		}
		else{document.form1.submit();}
	}
}
}

function compruebanum_onchange( valor_1,valor_2 ) {
var aceptar=1
for(var i=0; i < valor_1.length; i++)
	{
		var ch=valor_1.substring(i, i + 1)
		if ((ch < "0" || "9" < ch))
 
			{
			aceptar=0;
			}
	}
if(aceptar==0){
	alert("En el Código Postal debe introducir un valor entero y sin puntos.");
	valor_2.value="";
	valor_2.focus();
}
	return true;
}

function abrir()
{
pagina='actdatosempmod.asp?ncorreo='+ formc.ncorreo.value + '&ncorreoc=' + formc.ncorreoc.value;
msg=window.open(pagina ,'msg','height=240,width=407,left=200,top=100');
}

function checkemail(campo)
{
	campo.value=campo.value.replace(/ /g,"")
	var str=campo.value
	var filter=/^.+@.+\..{2,4}$/
	if(str!="")
	if (!filter.test(str))
	{
		alert("Por favor, introduzca una dirección de E-Mail existente")
		campo.focus();	
	}
}

function entrar_onclick() {
if(document.form2.usuario.value=="" || document.form2.clave.value==""){
	alert("Debe introducir su Usuario y Password");
	document.form2.usuario.focus();
}else{
	document.form2.submit();
}}

function enviar_onclick() {
if(document.form1.nombreempresa.value=="" || document.form1.personacontacto.value=="" || document.form1.telefono.value==""){
	alert("Debe rellenar todos los campos marcados.");
	document.form1.nombreempresa.focus();	
}else{
	document.form1.submit();
}}

var parametros1 = "toolbar=1;menubar=1;status=1;resizable=1;maximize=1;center=1;minimize=0"
var cnt1=0;
var wnd1;

function abrir_ventana(pagina2,ancho,alto)
{
cnt1++;
wnd1=open(pagina2, "gl"+cnt1, "width="+ancho+",height="+alto+",left=50,top=150,screenX=50,screenY=150");
}

function validarPais()
{
if (form1.pais.value!="España")
{
	form1.provincia.selectedIndex=55;
	form1.provincia.disabled=true;
	form1.provincia.id="";
}
else
{
	form1.provincia.disabled=false;	
}
}


function enviardatosalta1_onclick(){

if(document.form1.curso.value=="" || document.form1.tipoev.selectedIndex==0 || document.form1.tipo.selectedIndex==0)
	{
		alert("Debe rellenar todos los campos obligatorios.");
	}
else
	{	
		document.form1.submit();
    }
}


function enviardatosalta2_onclick(){
		document.form1.submit();
}

