// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Validación
function vText(v, lg){
	if(v.value != ""){ return 1; }else{ 
	switch(lg){
	case "en":
		alert("Required field.");
		break;
	case "fr":
		alert("Campo obligatorio fr.");
		break;
	default:
		alert("Campo "+v.name+"\nCampo obligatorio.");
		break;
	}
	v.style.border="1px solid #F66";
	v.focus();
	return 0; }
}

function vCaracteresMin(v,n, lg){
	if(v.value.length >= n){ return 1; }else{ 
	switch(lg){
	case "en":
		alert("Número de caracteres insuficiente.\nEl campo debe contener al menos "+n+" caracteres.");
		break;
	case "fr":
		alert("Número de caracteres insuficiente.\nEl campo debe contener al menos "+n+" caracteres.");
		break;
	default:
		alert("Campo "+v.name+"\nNúmero de caracteres insuficiente.\nEl campo debe contener al menos "+n+" caracteres.");
		break;
	}
	
	v.style.border="1px solid #F66";
	v.focus();
	return 0; }
}

function vEmail(v, lg){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(v.value)){ return 1; } else { 
	switch(lg){
	case "en":
		alert("El e-mail no es correcto");
		break;
	case "fr":
		alert("El e-mail no es correcto");
		break;
	default:
		alert("El e-mail no es correcto");
		break;
	}
	v.style.border="1px solid #F66";
	v.focus();
	return 0; }
}

function vEquidad(v1,v2, lg){
	if (v1.value==v2.value){ return 1; } else { 
	switch(lg){
	case "en":
		alert("El valor de los dos campos no coincide");
		break;
	case "fr":
		alert("El valor de los dos campos no coincide");
		break;
	default:
		alert("El valor de los dos campos no coincide");
		break;
	}
	v2.style.border="1px solid #F66";
	v2.focus();
	return 0; }
}

/*function quitarTodosEspacios(cadena) {
	for(i=0; i<cadena.length; i++) {
		if(cadena.charAt(i)==" ") {
			cadena=cadena.substring(i+1, cadena.length);
		}
	}

	for(i=cadena.length-1; i>=0; i--)	{
		if(cadena.charAt(i)==" ") {
			cadena=cadena.substring(0,i);
		}
		
	}
	
	return cadena;
}*/
function vNum(v, lg) {
	// Return immediately if an invalid value was passed in
	if (v.value+"" == "undefined" || v.value+"" == "null" || v.value+"" == "") {
		switch(lg){
		case "en":
			alert("Required field.");
			break;
		case "fr":
			alert("Campo obligatorio fr.");
			break;
		default:
			alert("Campo obligatorio.");
			break;
		}
		v.style.border="1px solid #F66";
		v.focus();
		return 0;
	}
	var isValid = 1;
	
	// convert to a string for performing string comparisons.
	v.value += ""; 
	// Loop through length of string and test for any alpha numeric 
	// characters
	for (i = 0; i < v.value.length; i++) {
		// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
		if (!((v.value.charAt(i) >= "0") && (v.value.charAt(i) <= "9")))
		{
			isValid = 0;
			switch(lg){
			case "en":
				alert("Debe introducir un valor numérico para este campo");
				break;
			case "fr":
				alert("Debe introducir un valor numérico para este campo");
				break;
			default:
				alert("Debe introducir un valor numeérico para este campo");
				break;
			}
			v.style.border="1px solid #F66";
			v.focus();
			break;
		} 
	} // END for 
	return isValid;
} // end vNum

function vChekbox(v, lg) {
	if(v.checked){ return 1; }else{ 
		switch(lg){
		case "en":
			alert("You may apcept the legal conditions.");
			break;
		case "fr":
			alert("Debe aceptar las condiciones legales fr.");
			break;
		default:
			alert("Debe aceptar las condiciones legales.");
			break;
		}
	}
}

function vAlfaNum(v, lg) {
	// Return immediately if an invalid value was passed in
	if (v.value+"" == "undefined" || v.value+"" == "null" || v.value+"" == "") {
		switch(lg){
		case "en":
			alert("Required field.");
			break;
		case "fr":
			alert("Campo obligatorio fr.");
			break;
		default:
			alert("Campo obligatorio.");
			break;
		}
		v.style.border="1px solid #F66";
		v.focus();
		return 0;
	}
	var isValid = 1;
	
	// convert to a string for performing string comparisons.
	v.value += ""; 
	// Loop through length of string and test for any alpha numeric 
	// characters
	for (i = 0; i < v.value.length; i++) {
		// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
		if (!(((v.value.charAt(i) >= "0") && (v.value.charAt(i) <= "9")) || 
		((v.value.charAt(i) >= "a") && (v.value.charAt(i) <= "z")) ||
		((v.value.charAt(i) >= "A") && (v.value.charAt(i) <= "Z"))))
		{
			isValid = 0;
			switch(lg){
			case "en":
				alert("El campo solo puede contener caracteres alfanumericos anglosajones\ny no debe contener espacios.");
				break;
			case "fr":
				alert("El campo solo puede contener caracteres alfanumericos anglosajones\ny no debe contener espacios.");
				break;
			default:
				alert("El campo solo puede contener caracteres alfanumericos anglosajones\ny no debe contener espacios.");
				break;
			}
			v.style.border="1px solid #F66";
			v.focus();
			break;
		} 
	} // END for 
	return isValid;
} // end vAlfaNum

//Fecha actual
function dibujarFecha(){
	var fecha=new Date();
	var diames=fecha.getDate();
	var mes=fecha.getMonth()+1 ;
	var ano=fecha.getFullYear();
	
	var textomes = new Array (12);
			textomes[1]="enero";
			textomes[2]="febrero";
			textomes[3]="marzo";
			textomes[4]="abril";
			textomes[5]="mayo";
			textomes[6]="junio";
			textomes[7]="julio";
			textomes[8]="agosto";
			textomes[9]="septiembre";
			textomes[10]="octubre";
			textomes[11]="noviembre";
			textomes[12]="diciembre";
			
	
	document.write(diames + " de " +  textomes[mes] + " de " + ano);
}

		
		