contador=1;
function cambiarimg(){
	document.images['imagenizquierda'].src='../img/izquierda' + contador + '.jpg';
	contador++;
	if(contador==5){
		contador=0;
	}
}

function validaUsuR() {
  opciones = 'scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width=770,height=530,top=0,left=0'
  window.open ('','InfolexNet',opciones)
  document.forms('form1').submit
 }
 
 
 /********************************************************************
   Validate 3.13                                           2002-10-10

   Collection of validate functions.

   // Markus Gemstad
   gemstad@hotmail.com
   http://www.gemstad.com (references, samples etc)

********************************************************************/
/** Errormessages ***************************************************/

var sErrIsEmpty                 = " is required.\n";
var sErrFormat                  = "Err!";
var sErrNotChoosen              = " is not choosen.\n";

var sErrValidateZipcode         = " must contain a zipcode in the formats \"123 45\" or \"12345\".\n";
var sErrValidateEmail           = " is not a valid e-mail address.\n";
/*******************************************************************/

function validateZipcode(sZipcode, sName, bAllowEmpty) {
   // Valid format    Length
   // ======================
   // 12345           5
   // 123 45          6

   var sErrorMsg = "";
   var objRegExp;

   sZipcode = trim(sZipcode);

   if(!bAllowEmpty && sZipcode.length == 0) // If empty
   {
      sErrorMsg = "- " + sName + sErrIsEmpty;
   }
   else if(sZipcode.length > 0) // else check zipcode
   {
      if(sZipcode.length == 5) // 12345
      {
         objRegExp = new RegExp("[0-9]{5}");
         if(sZipcode.search(objRegExp) == -1) // If invalid
            sErrorMsg = "- " + sName + sErrValidateZipcode;
      }
      else if(sZipcode.length == 6) // 123 45
      {
         objRegExp = new RegExp("[0-9]{3} [0-9]{2}");
         if(sZipcode.search(objRegExp) == -1) // If invalid
            sErrorMsg = "- " + sName + sErrValidateZipcode;
      }
      else // If another length
         sErrorMsg = "- " + sName + sErrValidateZipcode;
   }
   return sErrorMsg;
}
function validateEmail(sEmail, sName, bAllowEmpty) {
   /* Written by Paolo Wales (paolo@taize.fr) starting on a basis by Samrat Sen.

   Notes:
   
   'exclude' checks 5 conditions:
   
   a) characters that should not be in the address
   b) characters that should not be at the start
   c) & d) characters that shouldn't be together
   e) there's not more than one '@'
   
   'check' checks there's at least one '@', later followed by at least one '.'
   'checkend' checks the address ends with a period followed by 2 or 3 alpha characters.
   N.B. Javascript 1.2 only works with version 4 browsers and higher. */
   
   var exclude   =/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
   var check     =/@[\w\-]+\./;
   var checkend  =/\.[a-zA-Z]{2,3}$/;   
   var sErrorMsg = "";
   sEmail = trim(sEmail);
 
   if(!bAllowEmpty && sEmail == "")
   {
      sErrorMsg = "- " + sName + sErrIsEmpty;
   }
   else if(sEmail != "")
   {
      if(((sEmail.search(exclude) != -1) || 
          (sEmail.search(check)) == -1) || 
          (sEmail.search(checkend) == -1))
      {
         sErrorMsg = "- " + sName + sErrValidateEmail;
      }
   }
   return sErrorMsg;
}
function ltrim(sValue) {
   while(1) {
      if(sValue.substring(0, 1) != " ")
         break;
      sValue = sValue.substring(1, sValue.length);
   }
   return sValue;
}
function rtrim(sValue) {
   while(1) {
      if(sValue.substring(sValue.length - 1, sValue.length) != " ")
         break;
      sValue = sValue.substring(0, sValue.length - 1);
   }
   return sValue;
}
function trim(sValue) {
   var sTemp = ltrim(sValue);
   return rtrim(sTemp);
}


function ComprobarValor(campo,nombre){
	if(document.getElementById(campo).value==''){
		alert('El campo '+nombre+' no puede estar vacío')
		document.getElementById(campo).focus();
		document.getElementById(campo).select();
		return false
	}else{
		return true
	}
}

valDato = function(obj,cad,tipo) 
{
	if (obj.value!='') 
	{
		if (validateEmail(obj.value, obj.name, true)=='') 
		{
			return obj.value
		} else {
			alert('Escribir un valor válido para '+cad)
			obj.focus()
		    	return false
		}
	} else {
		return obj.value
	}
}

function validarCIF(texto){
        
    var pares = 0;
    var impares = 0;
    var suma;
    var ultima;
    var unumero;
    var uletra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I");
    var xxx;
        
    texto = texto.toUpperCase();
        
    var regular = new RegExp(/^[ABCDEFGHKLMNPQS]\d\d\d\d\d\d\d[0-9,A-J]$/g);
     if (!regular.exec(texto)){
    
      return false;
      }
             
     ultima = texto.substr(8,1);

     for (var cont = 1 ; cont < 7 ; cont ++){
         xxx = (2 * parseInt(texto.substr(cont++,1))).toString() + "0";
         impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
         pares += parseInt(texto.substr(cont,1));
     }
     xxx = (2 * parseInt(texto.substr(cont,1))).toString() + "0";
     impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1));
         
     suma = (pares + impares).toString();
     unumero = parseInt(suma.substr(suma.length - 1, 1));
     unumero = (10 - unumero).toString();
     if(unumero == 10) unumero = 0;
         
     if ((ultima == unumero) || (ultima == uletra[unumero])){
         return true;
         
     }else{
		return false;
	}
} 



function esBisiesto(year) { 
    return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? true : false;
}