Customer.INVALID_PHONE       = "Parece que el numero de teléfono introducido es incorrecto.\nAsegúrese de introducir tan solo números, sin espacios y sin delimitadores.\n\nEjemplo: 91123123123.";
Customer.INVALID_CELLULAR    = "Parece que el numero de móvil introducido es incorrecto.\nAsegúrese de introducir tan solo números, sin espacios y sin delimitadores.\n\nEjemplo: 616626636.";
Customer.INVALID_IDDOC 		 = "El Numero del Documento Identidad no es correcto, por favor, comprueba los datos,\n\nSi se trata de un NIF debes incluir la letra final.\nEjemplo: 11222333X.\n\nSi se trata de un CIF debes incluir la letra inicial de denominación.\nPor Ejemplo: B12345678.\n\nSi se trata de una TARJETA DE RESIDENCIA la letra inicial ha de ser una X\nPor Ejemplo: X12345678.";

function Customer(){
}

function validateCIF( sValue ) { 
    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; 

    sValue = sValue.toUpperCase(); 
    var regular =/^[ABCDEFGHKLMNPQS]\d\d\d\d\d\d\d[0-9,A-J]$/g; 
     if (!regular.exec(sValue)) return false; 
     ultima = sValue.substr(8,1); 
     for (var cont = 1 ; cont < 7 ; cont ++){ 
         xxx = (2 * parseInt(sValue.substr(cont++,1))).toString() + 0; 
         impares += parseInt(xxx.substr(0,1)) + parseInt(xxx.substr(1,1)); 
         pares += parseInt(sValue.substr(cont,1)); 
     } 
     xxx = (2 * parseInt(sValue.substr(cont,1))).toString(); 
     impares += parseInt(xxx.substr(0,1)) + parseInt(0 + xxx.substr(1,1)); 
     suma = (pares + impares).toString(); 
     unumero = parseInt(suma.substr(suma.length - 1, 1)); 
     unumero = (10 - unumero).toString(); 
     return ( (ultima == unumero) || (ultima == uletra[unumero]) );
};

function validateNIF( sValue ) { 
	//NIF validation
	var regexp = /^(\d+)-?(.)$/;
	var matches = sValue.match( regexp );
	if ( matches != null && matches.length == 3 ) {
      ( getNIFLetter( matches[1] ) == matches[2].toUpperCase() ) ? result = true: result = false;
	} else {
      result = false;
	}
	return result;
};

function getNIFLetter( number ) {
	var d = ( number / 23 );
	d = Math.floor( d );
	var e = d * 23;
	var r = number - e;
	if ( r ==  0 ) return "T";
	if ( r ==  1 ) return "R";
	if ( r ==  2 ) return "W";
	if ( r ==  3 ) return "A";
	if ( r ==  4 ) return "G";
	if ( r ==  5 ) return "M";
	if ( r ==  6 ) return "Y";
	if ( r ==  7 ) return "F";
	if ( r ==  8 ) return "P";
	if ( r ==  9 ) return "D";
	if ( r == 10 ) return "X";
	if ( r == 11 ) return "B";
	if ( r == 12 ) return "N";
	if ( r == 13 ) return "J";
	if ( r == 14 ) return "Z";
	if ( r == 15 ) return "S";
	if ( r == 16 ) return "Q";
	if ( r == 17 ) return "V";
	if ( r == 18 ) return "H";
	if ( r == 19 ) return "L";
	if ( r == 20 ) return "C";
	if ( r == 21 ) return "K";
	if ( r == 22 ) return "E";
};

function isValidPhone( sPhone ) {
	result = true;
	if ( sPhone != null && sPhone.trim().length != 0 ) {
		( sPhone.search( /^\d+$/ ) != -1 ) ? result = true: result = false;
	}
	return result;
};

function isValidCellular( sCellular ) {
	result = true;
	if ( sCellular != null && sCellular.trim().length != 0 ) {
		( sCellular.search( /^\d+$/ ) != -1 ) ? result = true: result = false;
	}
	return result;
};



