//Version 2.0
//Autor: Univ. Rolando Quispe Mamani
//ultima modificacion: 09/08/2006
//descripcion: Funciones de validacion para formularios con JavaScript

//-------------------Estas son las funciones basicas de BAJO NIVEL que validan cadenas y numeros

//retorna true si cad tiene una longitud en el rango [LongitudMin,LongitudMax], con 
//LongitudMin=0,1,2,... y LongitudMax=0,1,2,...'N'
//Para especificar una longitud maxima cualquiera use LongitudMax='n' o LongitudMax='N'

//28-Feb-2009
//Se agrego una funcion de validacion de nombre de correo que utiliza expresiones regulares


function CadTieneUnaLongitud(cad,LongitudMin,LongitudMax)
{
  if(cad.length<LongitudMin)return false;   
  if((LongitudMax!='n')&&(LongitudMax!='N')){
	     if(cad.length>LongitudMax)return false;   
  }
  return true;
}

//retorna true si Todos los elementos de cad pertenecen al conjunto de caracteres de dominio
//retorna true si cad esta vacia
function CadPerteneceAlDominio(cad,Dominio)
{var i,c; 
  if(Dominio.length>0) {
    for (i=0; i<cad.length; i++){   
        c=cad.charAt(i);
        if (Dominio.indexOf(c) == -1)return false;
    }
  }
  return true;
}

//retorna true si Todos elementos de cad NO pertenecen al conjunto de caracteres de dominio
function CadNoPerteneceAlDominio(cad,Dominio)
{var i,c; 
  if(Dominio.length>0) {
    for (i=0; i<cad.length; i++){   
        c=cad.charAt(i);
        if (Dominio.indexOf(c) != -1)return false;
    }
  }
  return true;
}

//retorna true si num esta en el rango [ValorMin,ValorMax]
//donde ValorMin='-N'...,-3,-2,-1,0,1,2,...'N'     y     ValorMax='-N'...,-3,-2,-1,0,1,2,...'N'
//Para especificar un valor minimo cualquiera use ValorMin='-n' o ValorMin='-N'
//Para especificar un valor maximo cualquiera use ValorMax='n' o ValorMax='N'
function NumEstaEnElRango(num,ValorMin,ValorMax)
{var i,c; 
  if((ValorMin!='-n')&&(ValorMin!='-N')){
    if(num<ValorMin)return false;   
  }
  if((ValorMax!='n')&&(ValorMax!='N')){
     if(num>ValorMax)return false;   
 }
  return true;
}

//retorna un cadena la cual se construye con los caracteres de cad que esten en el
//conjunto de caracteres de Dominio
function ConstruirCadenaDom(cad,Dominio)
{var i,c; 
 var res="";
    for (i=0; i<cad.length; i++){   
        c=cad.charAt(i);
        if (Dominio.indexOf(c) != -1)res += c;
  }
  return res;
}
//retorna un cadena la cual se construye con los caracteres de cad que No esten en el
//conjunto de caracteres de Dominio
function ConstruirCadenaNoDom(cad,Dominio)
{var i,c; 
 var res="";
    for (i=0; i<cad.length; i++){   
        c=cad.charAt(i);
        if (Dominio.indexOf(c) == -1)res += c;
  }
  return res;
}

// Retorna true si la cadena esta totalmente vacia
//function EstaVacia(s)
//{   if((s == null) || (s.length == 0))return true;
//    return false;
//}
//------------------------------------------------------------------------------------------


//-------------------Estas son las funciones basicas de ALTO NIVEL que validan cadenas y numeros

//Cuando se valida un formulario algunos campos son requeridos y otros no.
//Para los requeridos use la combinacion EstaVacia() y la(s) funcion(es) de validacion correspondiente(s).
//Para los no requeridos no use la funcion EstaVacia();

// Retorna true si cad NO esta vacio
function NoEstaVacio(cad)
{if(cad.length<=0)return false;
  return true;
}

// Retorna true si cad esta vacio
function EstaVacio(cad)
{if(cad.length<=0)return true;
  return false;
}

//---Nota : En caso de que el parametro cad en las siguientes funciones este vacio. Cada
//---funcion trata esto de acuerdo a las reglas de Conjuntos.
//---1.- En el vacio no existen elementos
//---2.- El vacio es subconjunto de cualquier conjunto
//---3.- EL vacio cumple con todas las propiedades

//Retorna true si cad No tiene espacios tabulaciones o saltos de linea
function NoExistenEspaciosTNR(cad)
{if(cad.length<=0)return true;//Retorna true si cad esta vacia
 return CadNoPerteneceAlDominio(" \t\n\r",cad);
}

//Retorna true si cad tiene espacios, tabulaciones o saltos de linea
function ExistenEspaciosTNR(cad)
{if(cad.length<=0)return false;//Retorna false si cad esta vacia
 return !CadNoPerteneceAlDominio(" \t\n\r",cad);
}

//Retorna true si cad No tiene espacios
function NoExistenEspacios(cad)
{if(cad.length<=0)return true;//Retorna true si cad esta vacia
 return CadNoPerteneceAlDominio(" ",cad);
}

//Retorna true si cad tiene espacios
function ExistenEspacios(cad)
{if(cad.length<=0)return false;//Retorna false si cad esta vacia
 return !CadNoPerteneceAlDominio(" ",cad);
}

//-----------CONSTANTES GLOBALES---------------
var g_Numeros = "0123456789";
var g_LetrasMinusculas = "aábcdeéfghiíjklmnñoópqrstuúvwxyz";
var g_LetrasMayusculas = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ";
//-----------------------------------------------------

//Retorna true si cad esta formada por letras
function SonLetras(cad)
{if(cad.length<=0)return true;//Retorna true si cad esta vacia
 return CadPerteneceAlDominio(cad,g_LetrasMinusculas+g_LetrasMayusculas);
}

//retorna true si cad esta formada por numeros
function SonNumeros(cad)
{if(cad.length<=0)return true; 
 return CadPerteneceAlDominio(cad,g_Numeros);
}

//Retorna true si cad esta formada por letras y numeros
function SonLetrasYNumeros(cad)
{if(cad.length<=0)return true;//Retorna true si cad esta vacia
 return CadPerteneceAlDominio(cad,g_Numeros+g_LetrasMinusculas+g_LetrasMayusculas);
}

function SonLetrasYEspacios(cad)
{if(cad.length<=0)return true;//Retorna true si cad esta vacia
 return CadPerteneceAlDominio(cad," "+g_LetrasMinusculas+g_LetrasMayusculas);
}
function SonNumerosYEspacios(cad)
{if(cad.length<=0)return true;//Retorna true si cad esta vacia
 return CadPerteneceAlDominio(cad," "+g_Numeros);
}
function SonLetrasYNumerosYEspacios(cad)
{if(cad.length<=0)return true;//Retorna true si cad esta vacia
 return CadPerteneceAlDominio(cad," "+g_Numeros+g_LetrasMinusculas+g_LetrasMayusculas);
}

//retorna true es un numero entero positivo valido 0,1,2,3,...,
function EsEnteroPositivo(cad)
{var i;
  if(cad.length<=0)return true;
  if(SonNumeros(cad)==false)return false;
  //if(cad!="0"){
	//  datos=cad.split("0");
	  //if(datos[0].length==0)return false;
  //}
  return true;
}

//retorna true es un numero entero negativo valido, -1,-2,-3,...
function EsEnteroNegativo(cad)
{
 if(cad.length<=0)return true;
 if(cad.charAt(0)!='-'||cad.length==1)return false;
 datos=cad.substring(1,cad.length);
 if(EsEnteroPositivo(datos)==false)return false;
 return true;
}

//retorna true es un numero float positivo valido , se incluye el 0. 
// Ejs:  2.4	0.52 	5	254	5515.0	0
function EsFloatPositivo(cad)
{var i;
  if(cad.length<=0)return true;
  if(CadPerteneceAlDominio(cad,"."+g_Numeros)==false)return false;
  datos=cad.split(".");
  if(datos.length>2||cad==".")return false;
  if(datos[0].length==0)return false;
  if(datos.length==2){
       if(datos[1].length==0)return false;
  }
  return true;
}

//retorna true es un numero float negativo valido
function EsFloatNegativo(cad)
{
 if(cad.length<=0)return true;
 if(cad.charAt(0)!='-'||cad.length==1)return false;
 datos=cad.substring(1,cad.length);
 if(EsFloatPositivo(datos)==false)return false;
 return true;
}

//retorna true si cad es un nombre simple Ej:Rolando
function EsNombreSimple(cad)
{return SonLetras(cad);
}

//retorna true si cad es un nombre compuesto
//Ej:Luis Fernando	 	retorna true
//Ej:Luis			retorna true
//Ej:L uis Fernando		retorna false
function EsNombreCompuesto(cad)
{var i;
  if(cad.length<=0)return true;//retorna true si es vacio
  if(cad==" ")return false;
  if(CadPerteneceAlDominio(cad," "+g_LetrasMinusculas+g_LetrasMayusculas)==false)return false;
 datos=cad.split(" ");
 if(datos.length>2)return false;
 if(datos[0].length==0)return false;
 if(datos.length==2){
      if(datos[1].length==0)return false;
 }
 return true;
}

//retorna true si cad es una direccion de correo valida:  a@b.xxx
function EsEmail(cad)
{if(cad.length<=0)return true;
  
  if(CadPerteneceAlDominio(cad,"_-@.0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")==false)return false;

  datos=cad.split("@");
  if(datos.length!=2)return false;
  if(datos[0].length==0||datos[1].length==0)return false;

  d2=datos[1];
  datos=d2.split(".");
  if(datos.length!=2)return false;
  if(datos[0].length==0||datos[1].length==0)return false;
  
  return true;
}

//retorna true si cad es un numero de telefono fijo valido
function EsNumeroTelefonoFijo(cad)
{if(cad.length<=0)return true;
  if(CadPerteneceAlDominio(cad,g_Numeros)==false)return false;
  if(cad.length!=7)return false;  
  return true;
}

//retorna true si cad es un numero de telefono movil valido
function EsNumeroTelefonoMovil(cad)
{if(cad.length<=0)return true;
  if(CadPerteneceAlDominio(cad,g_Numeros)==false)return false;
  if(cad.length!=8)return false;  
  return true;
}

//retorna true si cad es un numero de año valido, de 4 digitos
function EsYear(cad)
{if(cad.length<=0)return true;
 if(EsEnteroPositivo(cad)==false)return false;
 if(cad.length == 4)return true;
 return false;
}

//retorna true si cad es un numero de mes valido 1,2,...12
function EsMes(cad)
{if(cad.length<=0)return true;
 if(EsEnteroPositivo(cad)==false)return false;
 if(cad.length >2)return false;
 if(NumEstaEnElRango(parseFloat(cad),1,12)==false)return false;
 return true;
}

//retorna true si cad es un numero de dia valido 1,2,....31
function EsDia(cad)
{if(cad.length<=0)return true;
 if(EsEnteroPositivo(cad)==false)return false;
 if(cad.length >2)return false;
 if(NumEstaEnElRango(parseFloat(cad),1,31)==false)return false;
 return true;
}

//retorna la cantidad de dias para febrero de acuerdo al year
function DiasEnFebrero (year)
{//Febrero tiene 29 días por cualquier año que sea divisible entre cuatro.  
 //Salvo los años centuriales que tampoco son divisible entre 400.
  return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

//retorna true si year, mes, dia  es una fecha correcta
function EsFecha (year, mes, dia)
{//alert("sera fecha"+year+"m:"+parseFloat(mes)+"d:"+parseFloat(dia));
   var diasEnMes = new Array(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    if(EsYear(year)==false)return false;
    if(EsMes(mes)==false)return false;
    if(EsDia(dia)==false)return false;	
    var intYear = parseFloat(year);
    var intMes = parseFloat(mes);
    var intDia = parseFloat(dia);
    // verifica dias invalidos , excepto para febrero
    if (intDia > diasEnMes[intMes]) return false; 
    // verifica dias para febrero
    if ((intMes == 2) && (intDia > DiasEnFebrero(intYear))) return false;
    return true;
}
//-------------------------------------------------------------------------------------------------


//------------------------------Otras Funciones de interaccion-------------------------------------

//Muestra un mensaje de error y redirecciona el foco de la aplicacion al objeto referenciado por objForm
// objForm es una referencia a algun elemento dentro un formulario.
// Ej:  objForm=miform1.nombre
function MsgError(MsgError,objForm)
{alert(MsgError);
  if(objForm!=null)objForm.focus();
}

//Colocar texto en la barra de estado 
function TextoEnLaBarraDeEstado(texto)
{ window.status=texto;
}

//retorna true si alguna opcion dentro de las opciones del objRadio fue seleccionada.
//objRadio es una referencia a un objeto tipo radio dentro de un Form
function SeleccionoAlgunRadioButton (objRadio)
{   for (var i = 0; i < objRadio.length; i++){
	if (objRadio[i].checked==true)return true;
    }
    return false;
}

//retorna true si alguna opcion dentro de las opciones del objCheck fue seleccionada.
//objCheck es una referencia a un objeto tipo checkbox dentro de un Form
function SeleccionoAlgunCheckboxButton(objCheck)
{   for (var i = 0; i < objCheck.length; i++){
	if (objCheck[i].checked==true)return true;
    }
    return false;
}

//imprime un input de entrada de fecha
 function inputFecha(nomfecha,valfecha,nomyear,nommes,nomdia){ 
		  	var fechax=valfecha;
			var dia="";
			var mes="";
			var year="";
			var cadmes="";
			var accion="";
			 fechahor=fechax.split(" ");
			 datos=fechahor[0].split("-");
			 if(datos.length==3){
			 	year=datos[0];
//			 	mes=parseInt(datos[1]);
			 	mes=datos[1];
				switch(mes){
						case '01':cadmes="Enero";break;
						case '02':cadmes="Febrero";break;
						case '03':cadmes="Marzo";break;
						case '04':cadmes="Abril";break;
						case '05':cadmes="Mayo";break;
						case '06':cadmes="Junio";break;
						case '07':cadmes="Julio";break;
						case '08':cadmes="Agosto";break;
						case '09':cadmes="Septiembre";break;
						case '10':cadmes="Octubre";break;
						case '11':cadmes="Noviembre";break;
						case '12':cadmes="Diciembre";break;
				}
			 	dia=datos[2];
			 }			 
		document.writeln("<input type='hidden' name='"+nomfecha+"' class='textos' value='"+valfecha+"' size='30'>");		
		//document.writeln("<input name='"+nomfecha+"' class='textos' value='"+valfecha+"' size='30'>");		

		if(nomdia!=""){
			accion=" onchange=\""+nomfecha+".value="+nomyear+".value+'-'+"+nommes+".value+'-'+"+nomdia+".value;"+"\"";
		}else{
			accion=" onchange=\""+nomfecha+".value="+nomyear+".value+'-'+"+nommes+".value+'-'+"+"01;"+"\"";			
		}
		if(nomdia!=""){
	    	document.writeln("D&iacute;a:");
	        document.writeln("<select name='"+nomdia+"' size='1' class='textos' "+accion+">");
		       document.writeln("<option value='"+dia+"' selected>"+dia+"</option>");			  
			  	for(i=1;i<=31;i++){
			          if(i<10)document.writeln("<option value='"+"0"+i+"'>"+"0"+i+"</option>");
			          else document.writeln("<option value='"+i+"'>"+i+"</option>");
				}
    	    document.writeln("</select>");
		}
		document.writeln("Mes:");
        document.writeln("<select name='"+nommes+"' size='1' class='textos' "+accion+">");
	        document.writeln("<option value='"+mes+"' selected>"+cadmes+"</option>");			  
	        document.writeln("<option value='01'>Enero</option>");
	        document.writeln("<option value='02'>Febrero</option>");
	        document.writeln("<option value='03'>Marzo</option>");
	        document.writeln("<option value='04'>Abril</option>");
	        document.writeln("<option value='05'>Mayo</option>");
	        document.writeln("<option value='06'>Junio</option>");
	        document.writeln("<option value='07'>Julio</option>");
	        document.writeln("<option value='08'>Agosto</option>");
	        document.writeln("<option value='09'>Septiembre</option>");
	        document.writeln("<option value='10'>Octubre</option>");
	        document.writeln("<option value='11'>Noviembre</option>");
	   	    document.writeln("<option value='12'>Diciembre</option>");
	    document.writeln("</select>");
		document.writeln("A&ntilde;o:");
        document.writeln("<select name='"+nomyear+"' size='1' class='textos' "+accion+">");
		        document.writeln("<option value='"+year+"' selected>"+year+"</option>");			  
			  	for(i=1940;i<=2009;i++){
			          document.writeln("<option value='"+i+"'>"+i+"</option>");
				}
		document.writeln("</select>");
}
//----En las siguientes funciones se asume que:
//valfecha  esta en formato YYYY-MM-DD, o YYYY-MM-DD HH:MM:SS para las funciones que muestran Fecha
//valfecha  esta en formato YYYY-MM-DD HH:MM:SS para las funciones que muestran Hora
//----------------------

/*function mostrarFecha(valfecha){ 
		  	var fechax=valfecha;
			var dia="";
			var mes="";
			var year="";
			var cadmes="";
			 fechahor=fechax.split(" ");
			 datos=fechahor[0].split("-");
			 if(datos.length==3){
			 	year=datos[0];
			 	mes=datos[1];
				switch(mes){
						case '01':cadmes="Enero";break;
						case '02':cadmes="Febrero";break;
						case '03':cadmes="Marzo";break;
						case '04':cadmes="Abril";break;
						case '05':cadmes="Mayo";break;
						case '06':cadmes="Junio";break;
						case '07':cadmes="Julio";break;
						case '08':cadmes="Agosto";break;
						case '09':cadmes="Septiembre";break;
						case '10':cadmes="Octubre";break;
						case '11':cadmes="Noviembre";break;
						case '12':cadmes="Diciembre";break;
				}
			 	dia=datos[2];
			 }			 
		document.writeln(dia+"-"+cadmes+"-"+year);		
}
*/
function getYearFecha(valfecha){ 
	 var year="";
	 fechahor=valfecha.split(" ");
	 datos=fechahor[0].split("-");
	 if(datos.length==3){
	 	year=datos[0];
	 }			 
	return year;
}
function getMesFecha(valfecha){ 
	 var mes="";
	 fechahor=valfecha.split(" ");
	 datos=fechahor[0].split("-");
	 if(datos.length==3){
	 	mes=datos[1];
	 }			 
	return mes;
}
function getMesCadFecha(valfecha){ 
	 var mes="";
	 var cadmes="";
	 fechahor=valfecha.split(" ");
	 datos=fechahor[0].split("-");
	 if(datos.length==3){
	 	mes=datos[1];
				switch(mes){
						case '01':cadmes="Enero";break;
						case '02':cadmes="Febrero";break;
						case '03':cadmes="Marzo";break;
						case '04':cadmes="Abril";break;
						case '05':cadmes="Mayo";break;
						case '06':cadmes="Junio";break;
						case '07':cadmes="Julio";break;
						case '08':cadmes="Agosto";break;
						case '09':cadmes="Septiembre";break;
						case '10':cadmes="Octubre";break;
						case '11':cadmes="Noviembre";break;
						case '12':cadmes="Diciembre";break;
				}		
	 }			 
	return cadmes;
}
function getDiaFecha(valfecha){ 
	 var dia="";
	 fechahor=valfecha.split(" ");
	 datos=fechahor[0].split("-");
	 if(datos.length==3){
	 	dia=datos[2];
	 }			 
	return dia;
}
//-----Obtiene la hora de una cadena de fecha completa
//valfecha  esta en formato YYYY-MM-DD HH:MM:SS,
function getHoraFecha(valfecha){ 
	 var res="";
	 fechahor=valfecha.split(" ");
	 datos=fechahor[1].split(":");
	 if(datos.length==3){
	 	res=datos[0];
	 }			 
	return res;
}
function getMinutoFecha(valfecha){ 
	 var res="";
	 fechahor=valfecha.split(" ");
	 datos=fechahor[1].split(":");
	 if(datos.length==3){
	 	res=datos[1];
	 }			 
	return res;
}
function getSegundoFecha(valfecha){ 
	 var res="";
	 fechahor=valfecha.split(" ");
	 datos=fechahor[1].split(":");
	 if(datos.length==3){
	 	res=datos[2];
	 }			 
	return res;
}
//Las funciones mostrarCadFecha() y mostrarFecha() solo considera la fecha
//retorna la fecha que indica valfecha, en formato DD de CADMM de YYYY
function getCadFecha(valfecha){ 
		return (getDiaFecha(valfecha)+" de "+getMesCadFecha(valfecha)+" de "+getYearFecha(valfecha));			
}
//retorna la fecha que indica valfecha, en formato DD-MM-YYYY
function getFecha(valfecha){ 
		return (getDiaFecha(valfecha)+"-"+getMesFecha(valfecha)+"-"+getYearFecha(valfecha));			
}
//retorna la hora que indica valfecha, en formato HH-MM-SS
function getTiempo(valfecha){ 
		return (getHoraFecha(valfecha)+":"+getMinutoFecha(valfecha)+":"+getSegundoFecha(valfecha));			
}

 function inputPais(nompais,valpais){ 
        document.writeln("<select name='"+nompais+"' size='1' class='textos'>");
		        document.writeln("<option value='"+valpais+"' selected>"+valpais+"</option>");			  		
document.writeln("<OPTION value='Albania'>Albania</OPTION>");
document.writeln("<OPTION value='Angola'>Angola</OPTION>");
document.writeln("<OPTION value='Arabia Saudita'>Arabia Saudita</OPTION>");
document.writeln("<OPTION value='Argelia'>Argelia</OPTION>");
document.writeln("<OPTION value='Argentina'>Argentina</OPTION>");
document.writeln("<OPTION value='Australia'>Australia</OPTION>");
document.writeln("<OPTION value='Austria'>Austria</OPTION>");
document.writeln("<OPTION value='Bolivia'>Bolivia</OPTION>");
document.writeln("<OPTION value='Bosnia'>Bosnia</OPTION>");
document.writeln("<OPTION value='Brasil'>Brasil</OPTION>");
document.writeln("<OPTION value='Bulgaria'>Bulgaria</OPTION>");
document.writeln("<OPTION value='Belgica'>Belgica</OPTION>");
document.writeln("<OPTION value='Camerun'>Camerun</OPTION>");
document.writeln("<OPTION value='Canada'>Canada</OPTION>");
document.writeln("<OPTION value='Checoslovaquia'>Checoslovaquia</OPTION>");
document.writeln("<OPTION value='Chile'>Chile</OPTION>");
document.writeln("<OPTION value='China'>China</OPTION>");
document.writeln("<OPTION value='Colombia'>Colombia</OPTION>");
document.writeln("<OPTION value='Corea del Norte'>Corea del Norte</OPTION>");
document.writeln("<OPTION value='Corea del Sur'>Corea del Sur</OPTION>");
document.writeln("<OPTION value='Costa Rica'>Costa Rica</OPTION>");
document.writeln("<OPTION value='Croacia'>Croacia</OPTION>");
document.writeln("<OPTION value='Cuba'>Cuba</OPTION>");
document.writeln("<OPTION value='Dinamarca'>Dinamarca</OPTION>");
document.writeln("<OPTION value='Ecuador'>Ecuador</OPTION>");
document.writeln("<OPTION value='Egipto'>Egipto</OPTION>");
document.writeln("<OPTION value='El Salvador'>El Salvador</OPTION>");
document.writeln("<OPTION value='Emiratos Arabes Unidos'>Emiratos Arabes Unidos</OPTION>");
document.writeln("<OPTION value='Escocia'>Escocia</OPTION>");
document.writeln("<OPTION value='Eslovenia'>Eslovenia</OPTION>");
document.writeln("<OPTION value='Espa&ntilde;a'>Espa&ntilde;a</OPTION>");
document.writeln("<OPTION value='Estados Unidos'>Estados Unidos</OPTION>");
document.writeln("<OPTION value='Etiopia'>Etiopia</OPTION>");
document.writeln("<OPTION value='Finlandia'>Finlandia</OPTION>");
document.writeln("<OPTION value='Francia'>Francia</OPTION>");
document.writeln("<OPTION value='Gales'>Gales</OPTION>");
document.writeln("<OPTION value='Ghana'>Ghana</OPTION>");
document.writeln("<OPTION value='Gran Breta&ntilde;a'>Gran Breta&ntilde;a</OPTION>");
document.writeln("<OPTION value='Grecia'>Grecia</OPTION>");
document.writeln("<OPTION value='Guatemala'>Guatemala</OPTION>");
document.writeln("<OPTION value='Haiti'>Haiti</OPTION>");
document.writeln("<OPTION value='Holanda'>Holanda</OPTION>");
document.writeln("<OPTION value='Honduras'>Honduras</OPTION>");
document.writeln("<OPTION value='Hong Kong'>Hong Kong</OPTION>");
document.writeln("<OPTION value='Hungria'>Hungria</OPTION>");
document.writeln("<OPTION value='India'>India</OPTION>");
document.writeln("<OPTION value='Inglaterra'>Inglaterra</OPTION>");
document.writeln("<OPTION value='Irak'>Irak</OPTION>");
document.writeln("<OPTION value='Irlanda'>Irlanda</OPTION>");
document.writeln("<OPTION value='Iran'>Iran</OPTION>");
document.writeln("<OPTION value='Israel'>Israel</OPTION>");
document.writeln("<OPTION value='Italia'>Italia</OPTION>");
document.writeln("<OPTION value='Jamaica'>Jamaica</OPTION>");
document.writeln("<OPTION value='Japon'>Japon</OPTION>");
document.writeln("<OPTION value='Kuwait'>Kuwait</OPTION>");
document.writeln("<OPTION value='Malasia'>Malasia</OPTION>");
document.writeln("<OPTION value='Mali'>Mali</OPTION>");
document.writeln("<OPTION value='Mauritania'>Mauritania</OPTION>");
document.writeln("<OPTION value='Mozambique'>Mozambique</OPTION>");
document.writeln("<OPTION value='M&eacute;xico'>M&eacute;xico</OPTION>");
document.writeln("<OPTION value='Nicaragua'>Nicaragua</OPTION>");
document.writeln("<OPTION value='Nigeria'>Nigeria</OPTION>");
document.writeln("<OPTION value='Noruega'>Noruega</OPTION>");
document.writeln("<OPTION value='Nueva Zelanda'>Nueva Zelanda</OPTION>");
document.writeln("<OPTION value='Palestina'>Palestina</OPTION>");
document.writeln("<OPTION value='Panama'>Panama</OPTION>");
document.writeln("<OPTION value='Paraguay'>Paraguay</OPTION>");
document.writeln("<OPTION value='Per&uacute;'>Per&uacute;</OPTION>");
document.writeln("<OPTION value='Polonia'>Polonia</OPTION>");
document.writeln("<OPTION value='Portugal'>Portugal</OPTION>");
document.writeln("<OPTION value='Puerto Rico'>Puerto Rico</OPTION>");
document.writeln("<OPTION value='Reino Unido'>Reino Unido</OPTION>");
document.writeln("<OPTION value='Republica Checa'>Republica Checa</OPTION>");
document.writeln("<OPTION value='Rep&uacute;blica Dominicana'>Rep&uacute;blica Dominicana</OPTION>");
document.writeln("<OPTION value='Rep&uacute;blica Federal de Alemania'>Rep&uacute;blica Federal de Alemania</OPTION>");
document.writeln("<OPTION value='Rep&uacute;blica de Sudafrica'>Rep&uacute;blica de Sudafrica</OPTION>");
document.writeln("<OPTION value='Rep&uacute;blica democratica del Cong'>Rep&uacute;blica democratica del Cong</OPTION>");
document.writeln("<OPTION value='Rumania'>Rumania</OPTION>");
document.writeln("<OPTION value='Rusia'>Rusia</OPTION>");
document.writeln("<OPTION value='Senegal'>Senegal</OPTION>");
document.writeln("<OPTION value='Singapur'>Singapur</OPTION>");
document.writeln("<OPTION value='Sud&aacute;frica'>Sud&aacute;frica</OPTION>");
document.writeln("<OPTION value='Suecia'>Suecia</OPTION>");
document.writeln("<OPTION value='Suiza'>Suiza</OPTION>");
document.writeln("<OPTION value='Surinam'>Surinam</OPTION>");
document.writeln("<OPTION value='Tadjikist&aacute;n'>Tadjikist&aacute;n</OPTION>");
document.writeln("<OPTION value='Taiw&aacute;n'>Taiw&aacute;n</OPTION>");
document.writeln("<OPTION value='Turqu&iacute;a'>Turqu&iacute;a</OPTION>");
document.writeln("<OPTION value='T&uacute;nez'>T&uacute;nez</OPTION>");
document.writeln("<OPTION value='Ucrania'>Ucrania</OPTION>");
document.writeln("<OPTION value='Uni&oacute;n Sovi&eacute;tica'>Uni&oacute;n Sovi&eacute;tica</OPTION>");
document.writeln("<OPTION value='Uruguay'>Uruguay</OPTION>");
document.writeln("<OPTION value='Venezuela'>Venezuela</OPTION>");
document.writeln("<OPTION value='Yugoslavia'>Yugoslavia</OPTION>");
document.writeln("<OPTION value='Zaire'>Zaire</OPTION>");				
        document.writeln("</select>"); 
}
function inputOcupacion(nomocupacion,valocupacion){ 
        document.writeln("<select name='"+nomocupacion+"' size='1' class='textos'>");
		        document.writeln("<option value='"+valocupacion+"' selected>"+valocupacion+"</option>");			  		
document.writeln("<OPTION value='Consejero/a Delegado'>Consejero/a Delegado</OPTION>");
document.writeln("<OPTION value='Presidente/a'>Presidente/a</OPTION>");
document.writeln("<OPTION value='Vice Presidente/a'>Vice Presidente/a</OPTION>");
document.writeln("<OPTION value='Propietario/a'>Propietario/a</OPTION>");
document.writeln("<OPTION value='Socio/a'>Socio/a</OPTION>");
document.writeln("<OPTION value='Socio/a y Apoderado'>Socio/a y Apoderado</OPTION>");
document.writeln("<OPTION value='Subdirector/a'>Subdirector/a</OPTION>");
document.writeln("<OPTION value='Adjunto/a de Director'>Adjunto/a de Director</OPTION>");
document.writeln("<OPTION value='Adjunto/a de Presidente'>Adjunto/a de Presidente</OPTION>");
document.writeln("<OPTION value='Asistente de Director/a'>Asistente de Director/a</OPTION>");
document.writeln("<OPTION value='Administrador/a'>Administrador/a</OPTION>");
document.writeln("<OPTION value='Coordinador/a'>Coordinador/a</OPTION>");
document.writeln("<OPTION value='Coordinador/a de Campos'>Coordinador/a de Campos</OPTION>");
document.writeln("<OPTION value='Coordinador/a de Comunicacion'>Coordinador/a de Comunicacion</OPTION>");
document.writeln("<OPTION value='Coordinador/a de Telemarketing'>Coordinador/a de Telemarketing</OPTION>");
document.writeln("<OPTION value='Coordinador/a de Redacci&oacute;n'>Coordinador/a de Redacci&oacute;n</OPTION>");
document.writeln("<OPTION value='Director/a General'>Director/a General</OPTION>");
document.writeln("<OPTION value='Director/a de Area'>Director/a de Area</OPTION>");
document.writeln("<OPTION value='Director/a de Arte'>Director/a de Arte</OPTION>");
document.writeln("<OPTION value='Director/a Atenci&oacute;n al Cliente'>Director/a Atenci&oacute;n al Cliente</OPTION>");
document.writeln("<OPTION value='Director/a Creativo'>Director/a Creativo</OPTION>");
document.writeln("<OPTION value='Director/a Comercial'>Director/a Comercial</OPTION>");
document.writeln("<OPTION value='Director/a de Comunicaci&oacute;n'>Director/a de Comunicaci&oacute;n</OPTION>");
document.writeln("<OPTION value='Director/a de Departamento'>Director/a de Departamento</OPTION>");
document.writeln("<OPTION value='Director/a Desarrollo'>Director/a Desarrollo</OPTION>");
document.writeln("<OPTION value='Director/a Dise&ntilde;o Web'>Director/a Dise&ntilde;o Web</OPTION>");
document.writeln("<OPTION value='Director/a de E.Marketing'>Director/a de E.Marketing</OPTION>");
document.writeln("<OPTION value='Director/a de Expansi&oacute;n'>Director/a de Expansi&oacute;n</OPTION>");
document.writeln("<OPTION value='Director/a de Marketing'>Director/a de Marketing</OPTION>");
document.writeln("<OPTION value='Director/a de Marketing Directo'>Director/a de Marketing Directo</OPTION>");
document.writeln("<OPTION value='Director/a de Marketing OnLine'>Director/a de Marketing OnLine</OPTION>");
document.writeln("<OPTION value='Director/a de Marketing y Publicidad'>Director/a de Marketing y Publicidad</OPTION>");
document.writeln("<OPTION value='Director/a de Marketing y Ventas'>Director/a de Marketing y Ventas</OPTION>");
document.writeln("<OPTION value='Director/a de Medios'>Director/a de Medios</OPTION>");
document.writeln("<OPTION value='Director/a de Mercado'>Director/a de Mercado</OPTION>");
document.writeln("<OPTION value='Director/a de Personal'>Director/a de Personal</OPTION>");
document.writeln("<OPTION value='Director/a de Producci&oacute;n'>Director/a de Producci&oacute;n</OPTION>");
document.writeln("<OPTION value='Director/a de Programacion'>Director/a de Programacion</OPTION>");
document.writeln("<OPTION value='Director/a de Proyectos'>Director/a de Proyectos</OPTION>");
document.writeln("<OPTION value='Director/a de Publicidad'>Director/a de Publicidad</OPTION>");
document.writeln("<OPTION value='Director/a de Recursos Humanos'>Director/a de Recursos Humanos</OPTION>");
document.writeln("<OPTION value='Director/a de Servicios'>Director/a de Servicios</OPTION>");
document.writeln("<OPTION value='Director/a de Servicios al Cliente'>Director/a de Servicios al Cliente</OPTION>");
document.writeln("<OPTION value='Director/a Servicios de Marketing'>Director/a Servicios de Marketing</OPTION>");
document.writeln("<OPTION value='Director/a Tecnico'>Director/a Tecnico</OPTION>");
document.writeln("<OPTION value='Director/a de Telecomunicaciones'>Director/a de Telecomunicaciones</OPTION>");
document.writeln("<OPTION value='Director/a Venta a Distancia'>Director/a Venta a Distancia</OPTION>");
document.writeln("<OPTION value='Ejecutivo/a de cuentas'>Ejecutivo/a de cuentas</OPTION>");
document.writeln("<OPTION value='Estudiante'>Estudiante</OPTION>");
document.writeln("<OPTION value='Gerente'>Gerente</OPTION>");
document.writeln("<OPTION value='Gerente Administrador/a'>Gerente Administrador/a</OPTION>");
document.writeln("<OPTION value='Gerente Comercial'>Gerente Comercial</OPTION>");
document.writeln("<OPTION value='Gerente de Producto'>Gerente de Producto</OPTION>");
document.writeln("<OPTION value='Gerente de Ventas y Marketing'>Gerente de Ventas y Marketing</OPTION>");
document.writeln("<OPTION value='Analista de Marketing'>Analista de Marketing</OPTION>");
document.writeln("<OPTION value='Asistente de Medios'>Asistente de Medios</OPTION>");
document.writeln("<OPTION value='Asistente de Marketing'>Asistente de Marketing</OPTION>");
document.writeln("<OPTION value='Asistente de Negocios'>Asistente de Negocios</OPTION>");
document.writeln("<OPTION value='Ayudante de Departamento de Marketing'>Ayudante de Departamento de Marketing</OPTION>");
document.writeln("<OPTION value='Comercial'>Comercial</OPTION>");
document.writeln("<OPTION value='Consultor/a'>Consultor/a</OPTION>");
document.writeln("<OPTION value='Consultor/a-Formador'>Consultor/a-Formador</OPTION>");
document.writeln("<OPTION value='Consultor/a Gerente'>Consultor/a Gerente</OPTION>");
document.writeln("<OPTION value='Consultor/a de Marketing'>Consultor/a de Marketing</OPTION>");
document.writeln("<OPTION value='Contable'>Contable</OPTION>");
document.writeln("<OPTION value='Gestor/a de Cuentas'>Gestor/a de Cuentas</OPTION>");
document.writeln("<OPTION value='Delegado/a Comercial'>Delegado/a Comercial</OPTION>");
document.writeln("<OPTION value='Economista'>Economista</OPTION>");
document.writeln("<OPTION value='Informatico'>Informatico</OPTION>");
document.writeln("<OPTION value='Jefe de Estudios'>Jefe de Estudios</OPTION>");
document.writeln("<OPTION value='Planificador/a Extrat&eacute;gico'>Planificador/a Extrat&eacute;gico</OPTION>");
document.writeln("<OPTION value='Planificador/a de Negocios'>Planificador/a de Negocios</OPTION>");
document.writeln("<OPTION value='Productor/a Ejecutivo'>Productor/a Ejecutivo</OPTION>");
document.writeln("<OPTION value='Profesor/a'>Profesor/a</OPTION>");
document.writeln("<OPTION value='Programador/a'>Programador/a</OPTION>");
document.writeln("<OPTION value='Redactor/a jefe'>Redactor/a jefe</OPTION>");
document.writeln("<OPTION value='Relaciones P&uacute;blicas'>Relaciones P&uacute;blicas</OPTION>");
document.writeln("<OPTION value='Responsable de Base de Datos'>Responsable de Base de Datos</OPTION>");
document.writeln("<OPTION value='Responsable de Calidad'>Responsable de Calidad</OPTION>");
document.writeln("<OPTION value='Responsable Comercial'>Responsable Comercial</OPTION>");
document.writeln("<OPTION value='Responsable de Compras'>Responsable de Compras</OPTION>");
document.writeln("<OPTION value='Responsable de Comunicaci&oacute;n'>Responsable de Comunicaci&oacute;n</OPTION>");
document.writeln("<OPTION value='Responsable de Cuentas'>Responsable de Cuentas</OPTION>");
document.writeln("<OPTION value='Responsable de Departamento'>Responsable de Departamento</OPTION>");
document.writeln("<OPTION value='Responsable de Distribuciones'>Responsable de Distribuciones</OPTION>");
document.writeln("<OPTION value='Responsable de Documentacion'>Responsable de Documentacion</OPTION>");
document.writeln("<OPTION value='Responsable de Inversion y Desarrollo'>Responsable de Inversion y Desarrollo</OPTION>");
document.writeln("<OPTION value='Responsable de Investigacion y Analisis'>Responsable de Investigacion y Analisis</OPTION>");
document.writeln("<OPTION value='Responsable de Linea'>Responsable de Linea</OPTION>");
document.writeln("<OPTION value='Responsable de Log&iacute;stica'>Responsable de Log&iacute;stica</OPTION>");
document.writeln("<OPTION value='Responsable de Marketing Directo'>Responsable de Marketing Directo</OPTION>");
document.writeln("<OPTION value='Responsable de Marketing y Publicidad'>Responsable de Marketing y Publicidad</OPTION>");
document.writeln("<OPTION value='Responsable de Marketing y Ventas'>Responsable de Marketing y Ventas</OPTION>");
document.writeln("<OPTION value='Responsable de Operaciones'>Responsable de Operaciones</OPTION>");
document.writeln("<OPTION value='Responsable de Organizaci&oacute;n'>Responsable de Organizaci&oacute;n</OPTION>");
document.writeln("<OPTION value='Responsable de Publicidad'>Responsable de Publicidad</OPTION>");
document.writeln("<OPTION value='Responsable de Prensa'>Responsable de Prensa</OPTION>");
document.writeln("<OPTION value='Responsable de Producci&oacute;n'>Responsable de Producci&oacute;n</OPTION>");
document.writeln("<OPTION value='Responsable de Recursos Humanos'>Responsable de Recursos Humanos</OPTION>");
document.writeln("<OPTION value='Responsable de Relaciones P&uacute;blicas'>Responsable de Relaciones P&uacute;blicas</OPTION>");
document.writeln("<OPTION value='Responsable de Ventas'>Responsable de Ventas</OPTION>");
document.writeln("<OPTION value='Responsable Venta a Distancia'>Responsable Venta a Distancia</OPTION>");
document.writeln("<OPTION value='Secretaria/o'>Secretaria/o</OPTION>");
document.writeln("<OPTION value='Supervisor/a'>Supervisor/a</OPTION>");
document.writeln("<OPTION value='Supervisor/a de Cuentas'>Supervisor/a de Cuentas</OPTION>");
document.writeln("<OPTION value='Supervisor/a de Venta'>Supervisor/a de Venta</OPTION>");
document.writeln("<OPTION value='T&eacute;cnico/a'>T&eacute;cnico/a</OPTION>");
document.writeln("<OPTION value='T&eacute;cnico/a de Comunicaci&oacute;n'>T&eacute;cnico/a de Comunicaci&oacute;n</OPTION>");
document.writeln("<OPTION value='T&eacute;cnico/a Informatico'>T&eacute;cnico/a Informatico</OPTION>");
document.writeln("<OPTION value='T&eacute;cnico/a de Marketing'>T&eacute;cnico/a de Marketing</OPTION>");
document.writeln("<OPTION value='T&eacute;cnico de Marketing Directo'>T&eacute;cnico de Marketing Directo</OPTION>");
document.writeln("<OPTION value='Web Master'>Web Master</OPTION>");
		document.writeln("</select>"); 
}
function inputProfesion(nomprofesion,valprofesion){ 
        document.writeln("<select name='"+nomprofesion+"' size='1' class='textos'>");
		        document.writeln("<option value='"+valprofesion+"' selected>"+valprofesion+"</option>");			  		
document.writeln("<OPTION value='Abogado'>Abogado</OPTION>");
document.writeln("<OPTION value='Actor'>Actor</OPTION>");
document.writeln("<OPTION value='Administraci&oacute;n de Empresas'>Administraci&oacute;n de Empresas</OPTION>");
document.writeln("<OPTION value='Agrimensor'>Agrimensor</OPTION>");
document.writeln("<OPTION value='Ama de Casa'>Ama de Casa</OPTION>");
document.writeln("<OPTION value='Arquitecto'>Arquitecto</OPTION>");
document.writeln("<OPTION value='Artista pl&aacute;stico'>Artista pl&aacute;stico</OPTION>");
document.writeln("<OPTION value='Bi&oacute;logo'>Bi&oacute;logo</OPTION>");
document.writeln("<OPTION value='Bioqu&iacute;mico'>Bioqu&iacute;mico</OPTION>");
document.writeln("<OPTION value='Comerciante'>Comerciante</OPTION>");
document.writeln("<OPTION value='Contador P&uacute;blico'>Contador P&uacute;blico</OPTION>");
document.writeln("<OPTION value='Deportista'>Deportista</OPTION>");
document.writeln("<OPTION value='Desocupado'>Desocupado</OPTION>");
document.writeln("<OPTION value='Dise&ntilde;ador gr&aacute;fico/web'>Dise&ntilde;ador gr&aacute;fico/web</OPTION>");
document.writeln("<OPTION value='Economista'>Economista</OPTION>");
document.writeln("<OPTION value='Empleado'>Empleado</OPTION>");
document.writeln("<OPTION value='Escribano'>Escribano</OPTION>");
document.writeln("<OPTION value='Estudiante'>Estudiante</OPTION>");
document.writeln("<OPTION value='Fot&oacute;grafo'>Fot&oacute;grafo</OPTION>");
document.writeln("<OPTION value='Ingeniero'>Ingeniero</OPTION>");
document.writeln("<OPTION value='Jubilado'>Jubilado</OPTION>");
document.writeln("<OPTION value='M&eacute;dico'>M&eacute;dico</OPTION>");
document.writeln("<OPTION value='M&uacute;sico'>M&uacute;sico</OPTION>");
document.writeln("<OPTION value='Odont&oacute;logo'>Odont&oacute;logo</OPTION>");
document.writeln("<OPTION value='Otra'>Otra</OPTION>");
document.writeln("<OPTION value='Periodista'>Periodista</OPTION>");
document.writeln("<OPTION value='Profesional de la Educaci&oacute;n'>Profesional de la Educaci&oacute;n</OPTION>");
document.writeln("<OPTION value='Profesional de la Salud'>Profesional de la Salud</OPTION>");
document.writeln("<OPTION value='Programador'>Programador</OPTION>");
document.writeln("<OPTION value='Psic&oacute;logo'>Psic&oacute;logo</OPTION>");
document.writeln("<OPTION value='Psicopedagogo'>Psicopedagogo</OPTION>");
document.writeln("<OPTION value='Publicista'>Publicista</OPTION>");
document.writeln("<OPTION value='Qu&iacute;mico'>Qu&iacute;mico</OPTION>");
document.writeln("<OPTION value='Soci&oacute;logo'>Soci&oacute;logo</OPTION>");
document.writeln("<OPTION value='Traductor'>Traductor</OPTION>");
document.writeln("<OPTION value='Veterinario'>Veterinario</OPTION>");
	document.writeln("</select>"); 
}
//funciones para vectores
//este par de funciones permite manejar un vector para que contenga unicamente elementos diferentes
//Si xelem no esta en el arrayb xmat, entonces se agrega al array xmat.
//xelem, elemento a adicionar
//xmat, array
//xne, numero de elementos del array xmat
//retornan el numero de elementos despues de hacer la operacion
function vcAgregarElemento(xelem,xmat,xne){
	var i;
	var sw=0;
	//busca si ya existe el elemento
	for(i=0;i<xne;i++){if(xmat[i]==xelem)sw=1;}
	if(sw==0){
		//agregar elemento
		xmat[xne]=xelem;
		xne++;
	}
	return xne;
}
//borrar elemneto del array
function vcQuitarElemento(xelem,xmat,xne){
	var i,j;
	for(i=0;i<xne;i++){
		if(xmat[i]==xelem){
			for(j=i;j<xne-1;j++)xmat[j]=xmat[j+1];
			xne=xne-1;
			break;
		}	
	}
	return xne;
}

function EsEmailEreg(email) 
{
var s = email;
var filter=/^[A-Za-z][A-Za-z0-9_.-]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 )return false;
if (filter.test(s))return true;
return false;
}

