function validar(formulario)
{
  var checkbox_obligatorio, tipo_campo
  valor_checkbox = ""
  
  lObjFormulario= document.getElementById(formulario)
 
  
  for (i = 0; i < lObjFormulario.elements.length; i++) {
     
	 //Significado de los carácteres: 
	 //		El caracter X es 'ciego' se pone en las posiciones nulas.
	 //		En 1er carácter.  - o: Campo obligatorio
	 
	 //		En 2º carácter. - n: Campo numérico.	
	 //		En 2º carácter. - e: Campo email.	
	 //		En 2º carácter. - b: Campo checkbox.		 
	 
	 //		En 3º carácter. - c: Campo que se enviará por correo.
	 
	 //		En (4º) o (4º y 5º) carácter. - posicion (ejem: 1,2,15,etc...). Número que identifica la posición del campo dentro de la tabla donde va a ir almacenado.
	 //		EJEM: 'onx1x_apellido1' Es un campo obligatorio, numerico, No envia por correo, se guardará en campo 1 en la tabla de BD

	 if (lObjFormulario.elements[i].name.substr(0,1)=="o"){
	    
		tipo_campo = lObjFormulario.elements[i].name.substr(1,1);
		
	 	switch(tipo_campo){
			case "e": //email
		   		if(lObjFormulario.elements[i].value.indexOf("@")==-1){
						alert("La dirección de correo no es valida");
						lObjFormulario.elements[i].focus();
						return false;
	  			}						
				break;

			case "n":
		   		if(isNaN( parseInt(lObjFormulario.elements[i].value) ) == 1){		   
						alert("El valor del campo deberá de ser numérico");
						lObjFormulario.elements[i].focus();
						return false;
				}		
				break;

			case "b":
			    checkbox_obligatorio = "1"		
		   		if(lObjFormulario.elements[i].checked != ""){	  
				  valor_checkbox = valor_checkbox + lObjFormulario.elements[i].value
				}
				break;
			default:
				if(lObjFormulario.elements[i].value == ""){
						alert("Falta valor en el campo obligatorio"); 						
						lObjFormulario.elements[i].focus();
						return false;
				}
			
		}
	  	 	 
	 }
	
  }//bucle for
  		 //Si la variable checkbox_obligatorio es igual a 1, es que es obligatorio. Si
		 // no hay valor seleccionado, avisamos que por lo menos necesitamos uno seleccionado.
         if ( (checkbox_obligatorio == "1") && (valor_checkbox == "") ){
		 	alert("Es obligatorio seleccionar una de las opciones expuestas.")
			return false;
		 }		 
   lObjFormulario.submit();
}

// Función para la fecha //
function fecha(){
	var this_month = new Array(12);
	this_month[0]  = "Enero";
	this_month[1]  = "Febrero";
	this_month[2]  = "Marzo";
	this_month[3]  = "Abril";
	this_month[4]  = "Mayo";
	this_month[5]  = "Junio";
	this_month[6]  = "Julio";
	this_month[7]  = "Agosto";
	this_month[8]  = "Septiembre";
	this_month[9]  = "Octubre";
	this_month[10] = "Noviembre";
	this_month[11] = "Diciembre";
	
	var this_day_e = new Array(7);
	this_day_e[0]  = "Domingo";
	this_day_e[1]  = "Lunes";
	this_day_e[2]  = "Martes";
	this_day_e[3]  = "Mi&eacute;rcoles";
	this_day_e[4]  = "Jueves";
	this_day_e[5]  = "Viernes";
	this_day_e[6]  = "S&aacute;bado";
	
	var today = new Date();
	var day   = today.getDate();
	var month = today.getMonth();
	var year  = today.getYear();
	var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
	   
	document.write (this_day_e[dia] + ", " + day + " de " + this_month[month] + " de " + year);
}

function fechaIngles(){

	var this_day_e = new Array(7);
	this_day_e[0]="Sunday";
	this_day_e[1]="Monday";
	this_day_e[2]="Tuesday";
	this_day_e[3]="Wednesday";
	this_day_e[4]="Thursday";
	this_day_e[5]="Friday";
	this_day_e[6]="Saturday";
	
	var this_month = new Array(12);
	this_month[0]="January";
	this_month[1]="February";
	this_month[2]="March";
	this_month[3]="April";
	this_month[4]="May";
	this_month[5]="June";
	this_month[6]="July";
	this_month[7]="August";
	this_month[8]="September";
	this_month[9]="October";
	this_month[10]="November";
	this_month[11]="December";
	
	var today = new Date();
	var day   = today.getDate();
	var month = today.getMonth();
	var year  = today.getYear();
	var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
	   
	document.write(this_day_e[dia] + ". " + this_month[month] + " " + day + ", " + year);
}

// Función para abrir popups //
function wOpen(ruta,target,w,h,scrolls){	
	var ancho = w;
	var alto = h;
	var top = (screen.height/2) - (alto/2+40);

	var left = (screen.width/2) - (ancho/2);
	
	if(w!=""){
		window.open(ruta,target,"width=" + w + ",height=" + h + ",left=" + left + ",top=" + top + ",scrollbars=" + scrolls);
	}
	else{
		window.open(ruta,target)
	}
}

// Abrir-Cerrar capas //
function mostrar(capa,enlace){
	if(document.getElementById(capa).style.display == "none")
	{
		document.getElementById(capa).style.display = "block";
		document.getElementById(enlace).style.color = "#66A228";
	}
	else
	{
		document.getElementById(capa).style.display = "none";
		document.getElementById(enlace).style.color = "#4997D9";
	}
}


function cargaDoc(idd)
	{	
		window.location = "documento_en.asp?id=" + idd

	}


/*function cargaDoc(ruta,target,w,h,scrolls)
	{	
		var ancho = "700";
		var alto = "400";
		var top = (screen.height/2) - (alto/2+40);
	
		var left = (screen.width/2) - (ancho/2);
		
		if(w!="")
		{
			window.open("/html/"+ruta,target,"width= 700 height=400" + ",left= 0" + ",top= 0" + ",scrollbars= yes" + ",resizable=1");		
			//document.getElementById('centro').innerHTML = "<iframe style=''height=2000'' frameborder=''0'' width=" + w + " src=/html/" + ruta + "></iframe>";			
		}
		else
		{
			window.open(ruta,target)
		}
	}*/


function cargar_pdf(ruta,target,w,h,scrolls)
	{	
		var ancho = "700";
		var alto = "400";
		var top = (screen.height/2) - (alto/2+40);
	
		var left = (screen.width/2) - (ancho/2);
		
		if(w!="")
		{
			window.open("../html/"+ruta+".pdf",target,"width= 700 height=400" + ",left= 0" + ",top= 0" + ",scrollbars= yes" + ",resizable=1");		
			//document.getElementById('centro').innerHTML = "<iframe style=''height=2000'' frameborder=''0'' width=" + w + " src=/html/" + ruta + "></iframe>";			
		}
		else
		{
			window.open(ruta,target)
		}
	}






