function objetoAjax(){

	var xmlhttp=false;

	try {

		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

		} catch (e) {

		try {

			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

			} catch (E) {

			xmlhttp = false;

			}

		}

		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

			xmlhttp = new XMLHttpRequest();

		}

	return xmlhttp;

}



function ValidadTexto(control){

	if(document.getElementById(control).value=="" || /^\s+$/.test(document.getElementById(control).value)){

		document.getElementById(control).style.backgroundColor="#FEDF98";

		estado=0;

		document.getElementById(control).focus();

		return estado;

	}else{

		document.getElementById(control).style.backgroundColor="#FFF";

		estado=1;

	}

	return estado;

}



function ValidaClave(control,contro2){

	if(document.getElementById(control).value!=""){

		if(document.getElementById(contro2).value!=""){

			if(document.getElementById(control).value==document.getElementById(contro2).value){

				document.getElementById(contro2).style.backgroundColor="#FFF";

				estado=1;

				return estado;

			}else{

				document.getElementById(contro2).style.backgroundColor="#FEDF98";

				estado=0;

				document.getElementById(contro2).focus();

				document.getElementById(contro2).select();

				return estado;

			}



		}else{

			document.getElementById(control).style.backgroundColor="#FFF";

			document.getElementById(contro2).style.backgroundColor="#FEDF98";

			estado=0;

			document.getElementById(contro2).focus();

			return estado;

		}

	}else{

		document.getElementById(control).style.backgroundColor="#FEDF98";

		estado=0;

		document.getElementById(control).focus();

	}

	return estado;

}





function ValidaCorreo(control){

	if(document.getElementById(control).value==""){

		document.getElementById(control).style.backgroundColor="#FEDF98";

		estado=0;

		document.getElementById(control).focus();

		return estado;

	}else{

		 if(document.getElementById(control).value.indexOf("@")==-1 || document.getElementById(control).value.indexOf(".")==-1){

			document.getElementById(control).style.backgroundColor="#FEDF98";

			estado=0;

			document.getElementById(control).focus();

			document.getElementById(control).select();

			return estado;

		}else{

		document.getElementById(control).style.backgroundColor="#FFF";

		estado=1;

		}

	}

	return estado;

}



function ValidaNumeroTelefono(control){

	if(document.getElementById(control).value==""){

		document.getElementById(control).style.backgroundColor="#FEDF98";

		estado=0;

		document.getElementById(control).focus();

		return estado;

	}else{



		var valid = "()*-0123456789" 

		var ok = "yes"; 

		var temp; 

		for (var i=0; i<document.getElementById(control).value.length; i++) { 

			temp = "" + document.getElementById(control).value.substring(i, i+1); 

			if (valid.indexOf(temp) == -1) ok = "no"; 

		} 

		if (ok == "no") { 

			document.getElementById(control).style.backgroundColor="#FEDF98";

			estado=0;

			document.getElementById(control).focus();

			document.getElementById(control).select();		

			return estado;

		 }else{

			document.getElementById(control).style.backgroundColor="#FFF";

			estado=1

		}		

	}

	return estado;

}

function ValidaNumero(control){

	if(document.getElementById(control).value==""){

		document.getElementById(control).style.backgroundColor="#FEDF98";

		estado=0;

		document.getElementById(control).focus();

		return estado;

	}else{

		var valid = "0123456789" 

		var ok = "yes"; 

		var temp; 

		for (var i=0; i<document.getElementById(control).value.length; i++) { 

			temp = "" + document.getElementById(control).value.substring(i, i+1); 

			if (valid.indexOf(temp) == -1) ok = "no"; 

		} 

		if (ok == "no") { 

			document.getElementById(control).style.backgroundColor="#FEDF98";

			estado=0;

			document.getElementById(control).focus();

			document.getElementById(control).select();		

			return estado;

		 }else{

			document.getElementById(control).style.backgroundColor="#FFF";

			estado=1

		}		

	}

	return estado;

}


function ValidadSelecion(control){

	if(document.getElementById(control).value=="0"){

		document.getElementById(control).style.backgroundColor="#FEDF98";

		estado=0;

		document.getElementById(control).focus();

		return estado;

	}else{

		document.getElementById(control).style.backgroundColor="#FFF";

		estado=1;

	}

	return estado;

}

function Validad2Opcion(control){

	if(document.getElementsByName(control)[0].checked || document.getElementsByName(control)[1].checked){

		document.getElementsByName(control)[0].style.backgroundColor="#FFF";

		estado=1;

	}else{

		document.getElementsByName(control)[0].style.backgroundColor="#FEDF98";

		document.getElementsByName(control)[0].focus();

		estado=0;

	}

	return estado;

}





function Validad3Opcion(control){

	if(document.getElementsByName(control)[0].checked || document.getElementsByName(control)[1].checked || document.getElementsByName(control)[2].checked){

		document.getElementsByName(control)[0].style.backgroundColor="#FFF";

		estado=1;

	}else{

		document.getElementsByName(control)[0].style.backgroundColor="#FEDF98";

		document.getElementsByName(control)[0].focus();

		estado=0;

	}

	return estado;

}

function ValidaFile(control){

	if(document.getElementById(control).value != ""){

		document.getElementById(control).style.backgroundColor="#FFF";

		estado=1;

	}else{

		document.getElementById(control).style.backgroundColor="#FEDF98";

		document.getElementById(control).focus();

		estado=0;

	}

	return estado;

}

function carga_ing_centro(){

	if(document.getElementById("slt_centrop_e_otro").value=="01"){

		document.getElementById("imgr_txt_centro").style.display="block";	

		document.getElementById("imgr_txt_centro_2").style.display="block";	

		document.getElementById("nuevo_centro").value=2;	

	}else{

		document.getElementById("imgr_txt_centro").style.display="none";	

		document.getElementById("imgr_txt_centro_2").style.display="none";	

		document.getElementById("nuevo_centro").value=1;	

	}



}







function JsDirEmpresa(){

	if(document.RegistroCapece.OptDirEmpresa[0].checked){

		document.getElementById('DivDirEmpresa').style.display='block';

	}else{

		document.getElementById('DivDirEmpresa').style.display='none';

	}

}



function JsMuestraSectorEmpresa(Id){

	if(ListaSeccionEmpresa[Id]==undefined || ListaSeccionEmpresa[Id]=="0"){

		document.getElementById('DivSecorEmpresa_'+Id).style.display='block';

		ListaSeccionEmpresa[Id]="1";

	}else{

		document.getElementById('DivSecorEmpresa_'+Id).style.display='none';

		ListaSeccionEmpresa[Id]="0";

	}

}



function JsValidaCorreoExistente(Correo){

	var TxtCorreo= document.getElementById(Correo).value;

	var DivTituloEstadoCorreo=document.getElementById("TituloEstadoCorreo");

	ajax=objetoAjax();

	ajax.open("POST", "Includes/CorreoExite.php",true);	

	if(ValidaCorreo(Correo)==1){

		ajax.onreadystatechange=function(){

		if(ajax.readyState==1){

			DivTituloEstadoCorreo.innerHTML = "Cargando...";

		}else if(ajax.readyState==4){

				if(ajax.status==200){

					//mostramos los datos dentro de la div

					if(ajax.responseText==0){

						DivTituloEstadoCorreo.innerHTML = "Correo disponible";

						document.getElementById(Correo).style.backgroundColor="#FFF";
						document.getElementById("txmail_rep").value = document.getElementById(Correo).value;
						EstadoCorreoExiste=1;
						
						//JsEnviaDatosRegistro();
						sendFormulario();

					}else{

						DivTituloEstadoCorreo.innerHTML = "Su correo ya esta en uso";

						document.getElementById(Correo).style.backgroundColor="#FEDF98";
						document.getElementById("txmail_rep").value = "";
						document.getElementById(Correo).focus();

						document.getElementById(Correo).select();

						EstadoCorreoExiste=0;

					}	



				}else if(ajax.status==404){

						DivTituloEstadoCorreo.innerHTML = "La página no existe";

				}else{

						//mostramos el posible error

						DivTituloEstadoCorreo.innerHTML = "Error:".ajax.status; 

				}

			}

		}

	}	

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	ajax.send("Correo="+TxtCorreo);

}





/*------------*/





function JsValidaRazonExistenteAdministra(Razon){

	var TxtRazonSocial= document.getElementById(Razon).value;

	var DivTituloEstadoRazon=document.getElementById("TituloEstadoRazonSocial");

	ajax=objetoAjax();

	ajax.open("POST", "Includes/RazonExite.php",true);	

	if(ValidadTexto('TxtRazonSocial')==1){

		ajax.onreadystatechange=function(){

		if(ajax.readyState==1){

			DivTituloEstadoRazon.innerHTML = "Cargando...";

		}else if(ajax.readyState==4){

				if(ajax.status==200){

					//mostramos los datos dentro de la div

					if(ajax.responseText==0){

						DivTituloEstadoRazon.innerHTML = "Empresa disponible";

						document.getElementById(Razon).style.backgroundColor="#FFF";

						EstadoRazonExiste=1;

						JsInsertaEmpresaOportunidad();

					}else{

						DivTituloEstadoRazon.innerHTML = "Su empresa ya eta registrada";

						document.getElementById(Razon).style.backgroundColor="#E4E4E4";

						document.getElementById(Razon).focus();

						document.getElementById(Razon).select();

						EstadoRazonExiste=0;

					}	



				}else if(ajax.status==404){

						DivTituloEstadoRazon.innerHTML = "La página no existe";

				}else{

						//mostramos el posible error

						DivTituloEstadoRazon.innerHTML = "Error:".ajax.status; 

				}

			}

		}

	}	

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	ajax.send("RazonSocial="+TxtRazonSocial);

}







function JsValidaRucExistenteAdministra(Ruc){

	var TxtRuc= document.getElementById(Ruc).value;

	var DivTituloEstadoRazon=document.getElementById("TituloEstadoRuc");

	ajax=objetoAjax();

	ajax.open("POST", "Includes/RucExite.php",true);	

	if(ValidaNumero('TxtRuc')==1){

		ajax.onreadystatechange=function(){

		if(ajax.readyState==1){

			DivTituloEstadoRazon.innerHTML = "Cargando...";

		}else if(ajax.readyState==4){

				if(ajax.status==200){

					//mostramos los datos dentro de la div

					if(ajax.responseText==0){

						DivTituloEstadoRazon.innerHTML = "Ruc disponible";

						document.getElementById(Ruc).style.backgroundColor="#FFF";

						EstadoRucExiste=1;

						JsInsertaEmpresaOportunidad();

					}else{

						DivTituloEstadoRazon.innerHTML = "Su ruc ya eta registrada";

						document.getElementById(Ruc).style.backgroundColor="#E4E4E4";

						document.getElementById(Ruc).focus();

						document.getElementById(Ruc).select();

						EstadoRucExiste=0;

					}	



				}else if(ajax.status==404){

						DivTituloEstadoRazon.innerHTML = "La página no existe";

				}else{

						//mostramos el posible error

						DivTituloEstadoRazon.innerHTML = "Error:".ajax.status; 

				}

			}

		}

	}	

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	ajax.send("Ruc="+TxtRuc);

}

/* -------------- */



/*function JsValidaRazonExistente(Razon){

	var TxtRazonSocial= document.getElementById(Razon).value;

	var DivTituloEstadoRazon=document.getElementById("TituloEstadoRazonSocial");

	ajax=objetoAjax();

	ajax.open("POST", "Includes/RazonExite.php",true);	

	if(ValidadTexto('TxtRazonSocial')==1){

		ajax.onreadystatechange=function(){

		if(ajax.readyState==1){

			DivTituloEstadoRazon.innerHTML = "Cargando...";

		}else if(ajax.readyState==4){

				if(ajax.status==200){

					//mostramos los datos dentro de la div

					if(ajax.responseText==0){

						DivTituloEstadoRazon.innerHTML = "Empresa disponible";

						document.getElementById(Razon).style.backgroundColor="#FFF";

						EstadoRazonExiste=1;

						JsEnviaDatosRegistro();

					}else{

						DivTituloEstadoRazon.innerHTML = "Su empresa ya eta registrada";

						document.getElementById(Razon).style.backgroundColor="#E4E4E4";

						document.getElementById(Razon).focus();

						document.getElementById(Razon).select();

						EstadoRazonExiste=0;

					}	



				}else if(ajax.status==404){

						DivTituloEstadoRazon.innerHTML = "La página no existe";

				}else{

						//mostramos el posible error

						DivTituloEstadoRazon.innerHTML = "Error:".ajax.status; 

				}

			}

		}

	}	

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	ajax.send("RazonSocial="+TxtRazonSocial);

}*/



function JsValidaRucExistente(Ruc){

	var TxtRuc= document.getElementById(Ruc).value;

	var DivTituloEstadoRazon=document.getElementById("TituloEstadoRuc");

	ajax=objetoAjax();

	ajax.open("POST", "Includes/RucExite.php",true);	

	if(ValidaRuc(Ruc)==1){

		ajax.onreadystatechange=function(){

		if(ajax.readyState==1){

			DivTituloEstadoRazon.innerHTML = "Cargando...";

		}else if(ajax.readyState==4){

				if(ajax.status==200){

					//mostramos los datos dentro de la div

					if(ajax.responseText==0){

						DivTituloEstadoRazon.innerHTML = "Ruc disponible";

						document.getElementById(Ruc).style.backgroundColor="#FFF";

						EstadoRucExiste=1;

						sendFormulario();

					}else{

						DivTituloEstadoRazon.innerHTML = "Su ruc ya esta registrado";

						document.getElementById(Ruc).style.backgroundColor="#FEDF98";

						document.getElementById(Ruc).focus();

						document.getElementById(Ruc).select();

						EstadoRucExiste=0;

					}	



				}else if(ajax.status==404){

						DivTituloEstadoRazon.innerHTML = "La página no existe";

				}else{

						//mostramos el posible error

						DivTituloEstadoRazon.innerHTML = "Error:".ajax.status; 

				}

			}

		}

	}	

	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	ajax.send("Ruc="+TxtRuc);

}





/*---------------*/

function JsCambiaCorreo(){

	EstadoCorreoExiste=0;

}



function JsCambiaRazon(){

	EstadoRazonExiste=0;

}



function JsCambiaRuc(){

	EstadoRucExiste=0;

}



function JsReValidaCorreoExistente(){

	JsValidaCorreoExistente('TxtCorreo');

}



/*function JsEnviaDatosRegistro(){

	var EstadoInteres=0;

	var EstadoEspecialidad=0;

	if(Validad3Opcion('TipoAfiliacion')==1)

	if(ValidadTexto('TxtNombre')==1)

	if(ValidadTexto('TxtApellido')==1)

	if(ValidaCorreo('TxtCorreo')==1)

	if(ValidaClave('TxtClave1','TxtClave2')==1)

	if(ValidaNumeroTelefono('TxtTelefonoCasa')==1)

	if(ValidaNumeroTelefono('TxtMovilCasa')==1)

	if(ValidadTexto('TxtDireccionCasa')==1)

	if(ValidadTexto('TxtCiudadPer')==1)

	if(ValidadSelecion('SlctPaisPer')==1)

	if(ValidadSelecion('FechaNacimiento[2]')==1)

	if(ValidadSelecion('FechaNacimiento[1]')==1)

	if(ValidadSelecion('FechaNacimiento[0]')==1)

	if(Validad2Opcion('OptSexo')==1)

	if(ValidadSelecion('SlctEStadoCivil')==1)

	if(ValidadSelecion('SlctProfesion')==1)

	if(ValidadSelecion('SlctConocio')==1)

	

	if(document.getElementsByName('OptBoletin2')[0].checked){

		for(a=1;a<=document.getElementById('CantInteres').value;a++){

			if(document.getElementById('ChbInteres_'+a).checked){

				document.getElementById('ChbInteres_1').style.backgroundColor="#FFF";

				EstadoInteres=1;

				break;

			}

		}

		if(EstadoInteres==0){

			alert("Selecciona un Intereses");

			document.getElementById('ChbInteres_1').style.backgroundColor="#E4E4E4";

			document.getElementById('ChbInteres_1').focus();

			document.getElementById('ChbInteres_1').select();

			return;

		}

	}



	

	if(document.getElementsByName('OptDirEmpresa')[0].checked){

		

		if(ValidadTexto('TxtRazonSocial')==1)

		if(ValidaNumero('TxtRuc')==1)

		

		

		for(a=1;a<=document.getElementById('CantEspecialidad').value;a++){

			if(typeof(document.getElementById('ChbEspecialidad_'+a))!='undefined'){

				if(document.getElementById('ChbEspecialidad_'+a).checked){					

					document.getElementById('ChbEspecialidad_1').style.backgroundColor="#FFF";

					EstadoEspecialidad=1;

					break;

				}

			}

		}

		

		if(EstadoEspecialidad==0){

			alert("Selecciona un sector empresarial");

			document.getElementById('DivSecorEmpresa_1').style.display='block';

			document.getElementById('ChbEspecialidad_1').style.backgroundColor="#E4E4E4";

			document.getElementById('ChbEspecialidad_1').focus();

			document.getElementById('ChbEspecialidad_1').select();

			return;

		}

		

		if(ValidadSelecion('SlctTamanioEmpresa')==1)

		if(ValidadSelecion('SlctAniosEmpresa')==1)

		if(ValidaNumeroTelefono('TxtTelefonoEmpresa1')==1)

//		if(ValidaNumeroTelefono('TxtTelefonoEmpresa2')==1)

//		if(ValidaNumeroTelefono('TxtFaxEmpresa')==1)

		if(Validad2Opcion('OptMuestraCel')==1)

//		if(ValidadTexto('TxtPaginaWeb')==1)

		if(ValidadTexto('TxtDireccionEmpresa')==1)

		if(ValidadTexto('TxtCiudadEmpresa')==1)

		if(ValidadSelecion('SlctPaisEmpresa')==1)

		if(ValidadTexto('TxtContactoAdmin')==1)

		if(ValidadSelecion('SlctCargoEmpresa')==1)

		if(ValidadTexto('TxtDescripcion')==1)

		if(ValidadTexto('TxtMetaDesc')==1)

		if(ValidadTexto('TxtMetaKey')==1);	

	}

	









	

	if(estado==1){

		if(EstadoCorreoExiste==0){

			JsValidaCorreoExistente('TxtCorreo');

			if(estado==1){

				return;

			}

		}

		

		if(document.getElementsByName('OptDirEmpresa')[0].checked){

			if(EstadoRazonExiste==0){

				JsValidaRazonExistente('TxtRazonSocial');

				if(estado==1){

					return;

				}

			}

			

			if(EstadoRucExiste==0){

				JsValidaRucExistente('TxtRuc');

				if(estado==1){

					return;

				}

			}

		}

		document.getElementById('activa_envio').value=1;

		document.RegistroCapece.submit();

	}

}*/

























function JsActualizaEmpresaOportunidad(){

	var EstadoInteres=0;

	var EstadoEspecialidad=0;



	for(a=1;a<=document.getElementById('CantEspecialidad').value;a++){

		if(typeof(document.getElementById('ChbEspecialidad_'+a))!='undefined'){

			if(document.getElementById('ChbEspecialidad_'+a).checked){					

				document.getElementById('ChbEspecialidad_1').style.backgroundColor="#FFF";

				EstadoEspecialidad=1;

				break;

			}

		}

	}

	

	if(EstadoEspecialidad==0){

		alert("Selecciona un sector empresarial");

		document.getElementById('DivSecorEmpresa_1').style.display='block';

		document.getElementById('ChbEspecialidad_1').style.backgroundColor="#E4E4E4";

		document.getElementById('ChbEspecialidad_1').focus();

		document.getElementById('ChbEspecialidad_1').select();

		return;

	}

	

	if(ValidadSelecion('SlctTamanioEmpresa')==1)

	if(ValidadSelecion('SlctAniosEmpresa')==1)

	if(ValidaNumeroTelefono('TxtTelefonoEmpresa1')==1)

//		if(ValidaNumeroTelefono('TxtTelefonoEmpresa2')==1)

//		if(ValidaNumeroTelefono('TxtFaxEmpresa')==1)

	if(Validad2Opcion('OptMuestraCel')==1)

//		if(ValidadTexto('TxtPaginaWeb')==1)

	if(ValidadTexto('TxtDireccionEmpresa')==1)

	if(ValidadTexto('TxtCiudadEmpresa')==1)

	if(ValidadSelecion('SlctPaisEmpresa')==1)

	if(ValidadTexto('TxtContactoAdmin')==1)

	if(ValidadSelecion('SlctCargoEmpresa')==1)

	if(ValidadTexto('TxtDescripcion')==1)

	if(ValidadTexto('TxtMetaDesc')==1)

	if(ValidadTexto('TxtMetaKey')==1);	



	if(estado==1){

		document.getElementById('activa_envio').value=1;

		document.ActualizaEmpresa.submit();

	}

}





function JsInsertaEmpresaOportunidad(){

	var EstadoInteres=0;

	var EstadoEspecialidad=0;

	for(a=1;a<=document.getElementById('CantEspecialidad').value;a++){

		if(typeof(document.getElementById('ChbEspecialidad_'+a))!='undefined'){

			if(document.getElementById('ChbEspecialidad_'+a).checked){					

				document.getElementById('ChbEspecialidad_1').style.backgroundColor="#FFF";

				EstadoEspecialidad=1;

				break;

			}

		}

	}

	

	if(EstadoEspecialidad==0){

		alert("Selecciona un sector empresarial");

		document.getElementById('DivSecorEmpresa_1').style.display='block';

		document.getElementById('ChbEspecialidad_1').style.backgroundColor="#E4E4E4";

		document.getElementById('ChbEspecialidad_1').focus();

		document.getElementById('ChbEspecialidad_1').select();

		return;

	}

	

	if(ValidadSelecion('SlctTamanioEmpresa')==1)

	if(ValidadSelecion('SlctAniosEmpresa')==1)

	if(ValidaNumeroTelefono('TxtTelefonoEmpresa1')==1)

//		if(ValidaNumeroTelefono('TxtTelefonoEmpresa2')==1)

//		if(ValidaNumeroTelefono('TxtFaxEmpresa')==1)

	if(Validad2Opcion('OptMuestraCel')==1)

//		if(ValidadTexto('TxtPaginaWeb')==1)

	if(ValidadTexto('TxtDireccionEmpresa')==1)

	if(ValidadTexto('TxtCiudadEmpresa')==1)

	if(ValidadSelecion('SlctPaisEmpresa')==1)

	if(ValidadTexto('TxtContactoAdmin')==1)

	if(ValidadSelecion('SlctCargoEmpresa')==1)

	if(ValidadTexto('TxtDescripcion')==1)

	if(ValidadTexto('TxtMetaDesc')==1)

	if(ValidadTexto('TxtMetaKey')==1)

	if(ValidaFile('filelogo')==1);	



	if(estado==1){

		

		if(EstadoRazonExiste==0){

			JsValidaRazonExistenteAdministra('TxtRazonSocial');

			if(estado==1){

				return;

			}

		}

		

		if(EstadoRucExiste==0){

			JsValidaRucExistenteAdministra('TxtRuc');

			if(estado==1){

				return;

			}

		}

		

		document.getElementById('activa_envio').value=1;

		document.ActualizaEmpresa.submit();

	}

}









function JsEnviaDatosContacto(){

	if(ValidadTexto('TxtNombre')==1)

	if(ValidadTexto('TxtApellido')==1)

	if(ValidaCorreo('TxtCorreo')==1)

	if(ValidaNumeroTelefono('TxtTelefono')==1)

	if(ValidadTexto('TxtRepresenta')==1)

	if(ValidadSelecion('SlctPais')==1)

	if(ValidadSelecion('SlctSectorEmpresa')==1)

	if(ValidadSelecion('SlctMotivo')==1)

	if(ValidadSelecion('SlctConocio')==1)

	if(ValidadTexto('TxtMensaje')==1)

	

	if(estado==1){

		document.getElementById('activa_envio').value=1;

		document.RegistroCapece.submit();

	}

}



function EnviaEncuesta(id){

	var Contenido, PrecargaEncuesta;

	var EstadoEncuesta=0;

	Contenido = document.getElementById('Encuesta');

	PrecargaEncuesta = document.getElementById('PrecargaEncuesta');

	

	for(a=0;a<document.getElementById('CantidadRespuestas').value;a++){

		if(document.getElementsByName('OptEncuesta')[a].checked){

			document.getElementsByName('OptEncuesta')[a].style.backgroundColor="#FFF";

			EstadoEncuesta=1;

			break;

		}

	}

	if(EstadoEncuesta==0){

		alert("Selecciona un respuesta");

		document.getElementsByName('OptEncuesta')[0].style.backgroundColor="#E4E4E4";

		document.getElementsByName('OptEncuesta')[0].focus();

		document.getElementsByName('OptEncuesta')[0].select();

		return;

	}



		ajax=objetoAjax();

		ajax.open("POST", "Includes/InsertaEncuesta.php",true);		

        ajax.onreadystatechange=function(){

                if(ajax.readyState==1){

                        PrecargaEncuesta.innerHTML = "Cargando...";

	               }else if(ajax.readyState==4){

                        if(ajax.status==200){

							if(ajax.responseText==0){

								PrecargaEncuesta.innerHTML = "No se pudo regisrtar la encuesta";

							}else{

								Contenido.innerHTML = ajax.responseText;

							}	

                        }else if(ajax.status==404){

                                PrecargaEncuesta.innerHTML = "La página no existe";

                        }else{

                                //mostramos el posible error

                                PrecargaEncuesta.innerHTML = "Error:".ajax.status; 

                        }

                }

        }



		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

	  ajax.send("IdRes="+id);

}





//------------------



var EstadoContenidoInvierta=0;

var ContadorContenidoInvierta=1;

var CantidadContenidoInvierta=34;

function DescargaContenidoInviertaPeru(){

	for(a=1; a<=CantidadContenidoInvierta ; a++){

		document.getElementById('ContenidoInvierta_'+a).style.display='none';

	}	

}

function CargaContenidoInviertaPeru(id){

	DescargaContenidoInviertaPeru();

		document.getElementById('ContenidoInvierta_'+id).style.display='block';

	if(EstadoContenidoInvierta==id){

		if(ContadorContenidoInvierta==1){

			ContadorContenidoInvierta=0;

		}else{

			DescargaContenidoInviertaPeru();

			ContadorContenidoInvierta=1;

		}

	}else{

	ContadorContenidoInvierta=0;

	}

	EstadoContenidoInvierta=id;

}












function JsTestCursoUniversidad(){

var EstadoRespuestaEnvia=1;

var EstadoValidacion = document.getElementById('DivEstadoValidacion');

	for(var a=1;a<=document.getElementById('CantidadPreguntasCurso').value;a++){	

		for(var b=1;b<=document.getElementById('CantidadRespuestaCapitulo').value+1;b++){	

			if(document.getElementById("Respuesta_"+a+"_"+b)!=null){

				if(document.getElementById("Respuesta_"+a+"_"+b).checked){

					document.getElementById("Respuesta_"+a+"_1").style.backgroundColor="#FFF";

					EstadoRespuestaEnvia=1;

					break;

				}else{

					document.getElementById("Respuesta_"+a+"_1").style.backgroundColor="#E4E4E4";

					document.getElementById("Respuesta_"+a+"_1").focus();	

					EstadoRespuestaEnvia=0;

				}

			}else{

				break;

			}

		}

	}	

	if(EstadoRespuestaEnvia==1){

		EstadoValidacion.innerHTML = "Cargando...";						

		document.getElementById('activa_envio').value=1;

		document.TestUniversidad.submit();

	}else{

		EstadoValidacion.innerHTML = "Maque todas las opciones";	

	}



}





function JsTestCapituloUniversidad(){

var EstadoRespuestaEnvia=1;

var EstadoValidacion = document.getElementById('DivEstadoValidacion');

	for(var a=1;a<=document.getElementById('CantidadPreguntasCapitulo').value;a++){	

		for(var b=1;b<=document.getElementById('CantidadRespuestaCapitulo').value+1;b++){	

			if(document.getElementById("Respuesta_"+a+"_"+b)!=null){

				if(document.getElementById("Respuesta_"+a+"_"+b).checked){

					document.getElementById("Respuesta_"+a+"_1").style.backgroundColor="#FFF";

					EstadoRespuestaEnvia=1;

					break;

				}else{

					document.getElementById("Respuesta_"+a+"_1").style.backgroundColor="#E4E4E4";

					document.getElementById("Respuesta_"+a+"_1").focus();	

					EstadoRespuestaEnvia=0;

				}

			}else{

				break;

			}

		}

	}	

	if(EstadoRespuestaEnvia==1){

		EstadoValidacion.innerHTML = "Cargando...";						

		document.getElementById('activa_envio').value=1;

		document.TestUniversidad.submit();

	}else{

		EstadoValidacion.innerHTML = "Maque todas las opciones";	

	}



}





function JsSoloParaUsuaios(){

	alert("Solo para usuarios capece");	

}



function JsDebeAprobarCapitulo(){

	alert("Tiene que aprobar el capitulo anteior");	

}





function RecomiendaAmigo(){

	if(ValidadTexto('txnombres')==1)

	if(ValidadTexto('txnomamigo')==1)

	if(ValidaCorreo('txcorreoamigo')==1)

	if(ValidadTexto('txcomentarios')==1)

	if(estado ==1){

		document.EnviaEmail.submit();

	}

}



function JsInvitaAmiogos(){

	

	if(ValidadTexto('TxtNombre_1')==1)

	if(ValidadTexto('TxtApellidos_1')==1)

	if(ValidaCorreo('TxtCorreo_1')==1)



	if(ValidadTexto('TxtNombre_2')==1)

	if(ValidadTexto('TxtApellidos_2')==1)

	if(ValidaCorreo('TxtCorreo_2')==1)



	if(ValidadTexto('TxtNombre_3')==1)

	if(ValidadTexto('TxtApellidos_3')==1)

	if(ValidaCorreo('TxtCorreo_3')==1)



	if(ValidadTexto('TxtNombre_4')==1)

	if(ValidadTexto('TxtApellidos_4')==1)

	if(ValidaCorreo('TxtCorreo_4')==1)



	if(ValidadTexto('TxtNombre_5')==1)

	if(ValidadTexto('TxtApellidos_5')==1)

	if(ValidaCorreo('TxtCorreo_5')==1)





	if(estado==1){

		document.getElementById('activa_envio').value=1;

		document.RegistroCapece.submit();

	}

}





//-------------------------------------

//Consulta de curso





function JsMuestraAgregarRespuesta(id){



	if(TempIdRespuesta==0){

		document.getElementById("DivAgregaPregunta").style.display="none";

	}



	if(TempIdRespuesta != "" && TempIdRespuesta != 0){

			document.getElementById("DivAgregaRespuesta_"+TempIdRespuesta).style.display="none";	

	}



	TempIdRespuesta = id;

	document.getElementById("DivAgregaRespuesta_"+id).style.display="block";	

	document.getElementById("DivAgregaRespuesta_"+id).focus();

	document.getElementById('EstadoGraba').value=id;





}



function JsMuestraAgregarPregunta(){



	if(TempIdRespuesta!="" && TempIdRespuesta!=0){

		document.getElementById("DivAgregaRespuesta_"+TempIdRespuesta).style.display="none";	

	}

	

	TempIdRespuesta=0;

	document.getElementById("DivAgregaPregunta").style.display="block";	

	document.getElementById('EstadoGraba').value=0;

	document.getElementById("DivAgregaPregunta").focus();

	document.getElementById("DivAgregaPregunta").select();

}





	

function JsGrabaPreguntaConsulta(){	

	if(TempIdRespuesta==0){



		if(ValidadTexto('TxtPregunta')==1);

	

	}

	

	if(TempIdRespuesta!="" && TempIdRespuesta!=0){



		if(ValidadTexto('TxtRespuesta_'+TempIdRespuesta)==1);

	

	}

	

	

	if(estado==1){

		document.getElementById('activa_envio').value=1;

		document.FrmConsultaCurso.action="universidad-administrar-consultas-cursos-capece.php?accion=registra";

		document.FrmConsultaCurso.submit();

	}

}
<!--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-->
var xmlHttp;
function contactoCiudad(){
	var varid = document.getElementById("cbpais").value;
	var url = "Includes/contacto-ciudad.php?id="+varid;
	xmlHttp = objetoAjax();
	xmlHttp.open("GET", url);
	xmlHttp.onreadystatechange = imprimeCasilla;
	xmlHttp.send(null);	
}

function imprimeCasilla() {
	if(xmlHttp.readyState == 4){
		document.getElementById("divloader").style.display = "none";
		document.getElementById("divcuidad").innerHTML = xmlHttp.responseText;
		document.getElementById("divcuidad").style.display = "block";
	}else{
		document.getElementById("divloader").style.display = "block";
		document.getElementById("divcuidad").style.display = "none";
	}
}

function ValidaOpcionRegistro(control){
	var sector = document.getElementsByName(control).length
	estado=0;
	for(i=0; i<sector; i++){
	 	if (document.getElementsByName(control)[i].checked) {
      		 estado=1; 
			 document.getElementById("spansector").style.display ="none";
			 break;
     	}
	}	
	if(document.getElementsByName(control)[sector-1].checked){
		if(ValidadTexto('txsector_otro')!=1){
			estado=0;			
		}
	}
	if(estado == 0){		
		document.getElementsByName(control)[0].focus();
		document.getElementById("spansector").style.display ="block";
		document.location.href = "#obligatorio";
	}
	return estado;
}

function ValidaCheckedRegistro(control, varnum, span, ancla){
	estado=0;
	for(i=1; i<=varnum; i++){
		if(document.getElementById(control+'_'+i).checked){
 			estado=1; 
			document.getElementById(span).style.display ="none";
			break;
		}
	}
	if(estado == 0){
		document.getElementsByName(control+'_1')[0].focus();
		document.getElementById(span).style.display ="block";
		if(ancla != ""){		
		document.location.href = ancla;
		}
	}
	return estado;
}

function ValidaRuc(control){
	var varruc= document.getElementById(control).value;
	if(document.getElementById(control).value==""){
		document.getElementById(control).style.backgroundColor="#FEDF98";
		estado=0;
		document.getElementById(control).focus();
		return estado;
	}else{
		var valid = "0123456789" 
		var ok = "yes"; 
		var temp; 
		for (var i=0; i<document.getElementById(control).value.length; i++) { 
			temp = "" + document.getElementById(control).value.substring(i, i+1); 
			if (valid.indexOf(temp) == -1) ok = "no";
		} 

		if (ok == "no" ||  varruc.length < 11){ 	
			document.getElementById(control).style.backgroundColor="#FEDF98";
			estado=0;
			document.getElementById(control).focus();
			document.getElementById(control).select();
			return estado;
		 }else{
			document.getElementById(control).style.backgroundColor="#FFF";
			estado=1
		}
	}
	return estado;
}

function showPromocionEmail(){
	if(document.getElementById('rbpromociones').checked){
		document.getElementById('DivIntereses').style.display='block';
	}else{
		document.getElementById('DivIntereses').style.display='none';
	}
}

function JsIniciarSesion(){

	var Contenido, PrecargaIniciarSesion;
	var EstadoEncuesta=0;	

	Contenido = document.getElementById('IniciarSesion');
	PrecargaIniciarSesion = document.getElementById('PrecargaIniciarSesion');	

		ajax = objetoAjax();
		ajax.open("POST", "Includes/IniciarSesion.php",true);		

        ajax.onreadystatechange=function(){

                if(ajax.readyState==1){
                        PrecargaIniciarSesion.innerHTML = "Cargando...";
	               }else if(ajax.readyState==4){
                        if(ajax.status==200){
							switch(ajax.responseText){
								case "0":
								PrecargaIniciarSesion.innerHTML = "<span class='session_msj'>No se pudo iniciar sesión,<br>los datos son incorrectos</span>";
								break;
								case "1":
								PrecargaIniciarSesion.innerHTML = "<span class='session_msj'>No se pudo iniciar sesión,<br>su cuenta aun esta pendiente</span>";
								break;
								case "2":
								PrecargaIniciarSesion.innerHTML = "<span class='session_msj'>No se pudo iniciar sesión,<br>su cuenta esta desactivada</span>";
								break;
								case "3":
								PrecargaIniciarSesion.innerHTML = "<span class='session_msj'>No se pudo iniciar sesión,<br>su cuenta esta bloqueda intente despues</span>";
								break;
								case "4":
								PrecargaIniciarSesion.innerHTML = "<span class='session_msj'>No se pudo iniciar sesión,<br>su cuenta ha sido bloqueda intente despues</span>";
								break;
								case "5":
								PrecargaIniciarSesion.innerHTML = "<span class='session_msj'>No se pudo iniciar sesión,<br>Aun no activado su cuenta, verifique su correo</span>";
								break;
								default:
								Contenido.innerHTML = ajax.responseText;
								break;
							}	

                        }else if(ajax.status==404){
                                PrecargaIniciarSesion.innerHTML = "La página no existe";
                        }else{
                                //mostramos el posible error
                                PrecargaIniciarSesion.innerHTML = "Error:".ajax.status;
                        }
                }
        }

	if(ValidaCorreo('Txt_Email')==1)

	if(ValidadTexto('Txt_Clave')==1)	

	if(estado==1){
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send("Email="+document.getElementById('Txt_Email').value+"&Clave="+document.getElementById('Txt_Clave').value);
	}
}



function JsCerrarSession(){
	var Contenido, PrecargaIniciarSesion;
	var EstadoEncuesta=0;
	Contenido = document.getElementById('IniciarSesion');
	PrecargaIniciarSesion = document.getElementById('PrecargaIniciarSesion');	

		ajax=objetoAjax();
		ajax.open("POST", "Includes/CerrarSession.php",true);		

        ajax.onreadystatechange=function(){

                if(ajax.readyState==1){

                        PrecargaIniciarSesion.innerHTML = "Cargando...";

	               }else if(ajax.readyState==4){

                        if(ajax.status==200){

							if(ajax.responseText==0){

								PrecargaIniciarSesion.innerHTML = "No se pudo cerrar la sesión";			

							}else{

								Contenido.innerHTML = ajax.responseText;			

							}	

                        }else if(ajax.status==404){

                                PrecargaIniciarSesion.innerHTML = "La página no existe";

                        }else{
                                //mostramos el posible error

                                PrecargaIniciarSesion.innerHTML = "Error:".ajax.status; 
                        }
                }
        }

		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send("Estado=1");
}

function uploadCertificado(varid){
	var url = "Includes/certificado-confianza.php?id="+varid;
	xmlHttp = objetoAjax();
	xmlHttp.open("GET", url);
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4){
		document.getElementById("divcertificado").innerHTML = xmlHttp.responseText;		
		showCertificado(varid)
		}else{
		/*document.getElementById("divloader").style.display = "block";
		document.getElementById("divcuidad").style.display = "none";*/
		}		
	}
	xmlHttp.send(null);	
}

function hideCertification(){
	document.getElementById("divcertificado").style.display = "none";
}