function validarAcceso(formu){
	if(formu.user.value!="" && formu.pass.value!=""){
		return true;
	}else{
		alert("Todos los campos son obligatorios");
		return false;
	}
}

function verTipo(tipo){
	tipo=tipo.value;
	var capa=parent.document.getElementById("datosProfesionales");
	switch(tipo){
		case "": alert("ATENCION: Debe elegir una opcion");
			parent.document.getElementById("formaPago").style.visibility="hidden";		
			capa.innerHTML="";
			break;
			
		case "estudiante":
			capa.innerHTML='<span class="rojo" style="font-size:14px">Datos Profesionales</span><table style="border:solid 1px #cccccc; padding:5px; line-height:22px" width="100%"><tr><td class="gris" width="33%">Escuela/Facultad:</td><td><input type="text" name="escuela" size="35" /> <span class="rojo">*</span></td></tr><tr><td class="gris">Titulaci&oacute;n que cursa:</td><td><input type="text" name="titulacion" size="40" /> <span class="rojo">*</span></td></tr><tr><td class="gris">Curso en el que se ecuentra:</td><td><input type="text" name="cursoActual" /> <span class="rojo">*</span></td></tr><tr><td class="gris">Doctorado:</td><td><input type="radio" name="doctorado" checked="checked" value="no" onclick="verDoctorado(finscripcion)" />no <input type="radio" name="doctorado" value="si" onclick="verDoctorado(finscripcion)" />si</td></tr><tr><td class="gris">Departamento:</td><td><input type="text" name="departamento" disabled="disabled" size="40" /></td></tr><tr><td class="gris">Pertenece a alguna Asociaci&oacute;n:</td><td><input type="radio" name="discapacitado" checked="checked" value="no" onclick="discapacidad(finscripcion)" />no <input type="radio" name="discapacitado" value="si" onclick="discapacidad(finscripcion)" />si</td></tr><tr><td class="gris">Indique a cual:</td><td><input type="text" name="tipoDiscapacidad" disabled="disabled" size="40" /></td></tr><tr style="visibility:hidden"><td class="gris">Convalidaci&oacute;n Cr&eacute;ditos:</td><td><input type="checkbox" name="convalidacion" value="si" /><span class="gris">Si, solicito certificado de convalidaci&oacute;n de cr&eacute;ditos</span></td></tr></table>';
			parent.document.getElementById("formaPago").style.visibility="visible";
		break;
			
		case "profesional": 
			capa.innerHTML='<span class="rojo" style="font-size:14px">Datos Profesionales</span><table style="border:solid 1px #cccccc; padding:5px; line-height:22px" width="100%"><tr><td class="gris" width="33%">Puesto/Cargo que desarrolla:</td><td><input type="text" name="cargo" size="35" /> <span class="rojo">*</span></td></tr><tr><td class="gris">Entidad:</td><td><input type="text" name="entidad" size="40" /><span class="rojo">*</span></td></tr><tr><td class="gris">Ciudad Trabajo:</td><td><input type="text" name="ciudadTrabajo" /></td></tr><tr><td class="gris">Pertenece a alguna Asociaci&oacute;n:</td><td><input type="radio" name="discapacitado" checked="checked" value="no" onclick="discapacidad(finscripcion)" />no <input type="radio" name="discapacitado" value="si" onclick="discapacidad(finscripcion)" />si</td></tr><tr><td class="gris">Indique a cual:</td><td><input type="text" name="tipoDiscapacidad" disabled="disabled" size="40" /></td></tr></table>';			
			parent.document.getElementById("formaPago").style.visibility="visible";
		break;
	}
}

function discapacidad(formu){
	valor=formu.discapacitado;
	if(valor[1].checked){
		formu.tipoDiscapacidad.disabled=false;
		return false;
	}
	if(valor[0].checked){
		formu.tipoDiscapacidad.disabled=true;
		formu.tipoDiscapacidad.value="";
		return false;
	}
}

function verDoctorado(formu){
	valor=formu.doctorado;
	if(valor[1].checked){
		formu.departamento.disabled=false;
		return false;
	}
	if(valor[0].checked){
		formu.departamento.disabled=true;
		formu.departamento.value="";
		return false;
	}
}

function validarInscripcion(formu){
	if((formu.nombre.value=="")||(formu.apellidos.value=="")||(formu.dni.value=="")||(formu.domicilio.value=="")||(formu.email.value=="")){
		alert("ATENCION: Hay DATOS PERSONALES obligatorios sin completar");
		return false;
	}
	if(formu.email.value.search(/^[A-Za-z][A-Za-z0-9._-]*@[A-Za-z0-9_-]+\.[A-Za-z0-9_.]+[A-za-z]$/))
	{
        alert("ATENCION: Formato de E-Mail no valido.");
        return false;
    }	
	if((formu.pais.value=="-1")||(formu.provincia.value=="-1")||(formu.localidad.value=="-1")){
		alert("ATENCION: PAIS, PROVINCIA y LOCALIDAD, son campos obligatorios");
		return false;
	}
	if(formu.tipo.value=="-1"){
		alert("ATENCION: Debe elegir un TIPO DE INSCRIPCION");
		return false;
	}
	switch(formu.tipo.value){
		case 'estudiante':
			if((formu.escuela.value=="")||(formu.titulacion.value=="")||(formu.cursoActual=="")){
				alert("ATENCION: Hay DATOS PROFESIONALES obligatorios sin completar");
				return false;
			}
			break;
		case 'profesional':
			if((formu.cargo.value=="")||(formu.entidad.value=="")){
				alert("ATENCION: Hay DATOS PROFESIONALES obligatorios sin completar");
				return false;
			}		
			break;
	}
	window.scroll(0,0);
}

function validaNacimiento(valor){
	fecha=valor.value;
	if(fecha!=""){
		if(fecha.length < 4){
			alert("ERROR: Formato erroneo.  ej: 1977"); 
			valor.value="";
			return false;
		}
		if((fecha>2000)||(fecha<1940)){
			alert("ERROR: Fecha fuera de rango");
			valor.value="";
			return false;
		}
		return true;
	}
}

function validaDni(valor) {
	/*
	dni=valor.value;
	if(dni!=""){
		numero = dni.substr(0,dni.length-1);
		let =dni.substr(dni.length-1,1);
		let=let.toUpperCase();
		
		numero = numero % 23;
		letra='TRWAGMYFPDXBNJZSQVHLCKET';
		letra=letra.substring(numero,numero+1);
		if (letra!=let){
			alert('ERROR: NIF erroneo. ej: 11222333A');
			valor.value="";
			return false;
		}else{
			numero=dni.substr(dni.lenght-1,8);
			valor.value=numero+""+let;
			var capa=parent.document.getElementById("dnivalido");
			capa.innerHTML="<img style='vertical-align:middle' src='images/loading21.gif'>";
			doAjax2(capa,'scripts/servicios.scr.php?funcion=dni','valor='+valor.value+'','dniDuplicado','post',0);		
		}
	}
	*/
}

function dniDuplicado(html){
	var capa=parent.document.getElementById("dnivalido");
	if(html=="0"){
		capa.innerHTML=arreglaTexto("<span style='font-size:12px'>ERROR: DNI ya registrado</span>");
		var formu=parent.document.getElementById("finscripcion");
		formu.dni.value="";
		
	}
	if(html=="1"){
		capa.innerHTML="*";
	}
}

function wopen(url, name, w, h)
{
	w += 32;
	h += 96;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;
	var win = window.open(url,
	name,
	'width=' + w + ', height=' + h + ', ' +
	'left=' + wleft + ', top=' + wtop + ', ' +
	'location=no, menubar=no, ' +
	'status=no, toolbar=no, scrollbars=no, resizable=no');
	// Just in case width and height are ignored
	win.resizeTo(w, h);
	// Just in case left and top are ignored
	win.moveTo(wleft, wtop);
	win.focus();
}
function wopen2(url, name, w, h)
{
	w += 32;
	h += 96;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;
	var win = window.open(url,
	name,
	'width=' + w + ', height=' + h + ', ' +
	'left=' + wleft + ', top=' + wtop + ', ' +
	'location=no, menubar=no, ' +
	'status=no, toolbar=no, scrollbars=yes, resizable=no');
	// Just in case width and height are ignored
	win.resizeTo(w, h);
	// Just in case left and top are ignored
	win.moveTo(wleft, wtop);
	win.focus();
}

function saludar(){
	alert("hola");
}

function dameProvincias(idpais){
	document.getElementById("cploading1").innerHTML="<img width='15' src='images/loading.gif'>";
	doAjax3('inscripciones/scripts/dameProvincias.scr.php','idpais='+idpais.value+'','dameProvincias_','post',0);
}
function dameProvincias_(html){
	var inner = html; 
	cargaINNER(document.getElementById("provincias"),inner);	
	document.getElementById("cploading1").innerHTML="";	
}

function dameMunicipios(idprovincia){	
	document.getElementById("cploading2").innerHTML="<img width='15' src='images/loading.gif'>";
	doAjax3('inscripciones/scripts/dameProvincias.scr.php','idprovincia='+idprovincia.value+'','dameMunicipios_','post',0);
}
function dameMunicipios_(html){
	document.getElementById("cploading2").innerHTML="";	
	var inner = html; 
	cargaINNER(document.getElementById("localidades"),inner);	
}

function cargaINNER(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Versão: 2.1 - 04/09/2007
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.toLowerCase().replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
      
    
    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];
  
        if(spantemp.tagName){     
            opt = document.createElement("OPTION")
    
   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }       
    
   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   opt.className = spantemp.className;
  } 
 }    
 document.body.removeChild(selTemp)
 selTemp = null
}