	/****************************************************/
	// GENERAL										  	//
	/****************************************************/

	var isIE = (navigator.appName.indexOf("Microsoft Internet Explorer") != -1) ? true : false;

	if (isIE){
		onerror = hdlError;
		function hdlError(msg, url, l){
			var txt="";
			txt="There was an error on this page.\n\n";
			txt+="Error: " + msg + "\n";
			txt+="URL: " + url + "\n";
			txt+="Line: " + l + "\n\n";
			//alert(txt);
			return true;
		}
	}


	function getTop(){			return parent;	}
	function getContext(){		return getTop().context;	}
	function getResources(){	return getTop().resources;	}
	function getTitleBar(){		return getTop().titleBar;	}
	function getToolBar(){		return getTop().toolBar;	}
	function getMngWindow(){	return getTop().mngWindow;	}
	function getMenu(){			return getTop().menu;		}

	function getUserConfig(){	return getTop().userConfig;	}
	function setUserConfig(userConfiguration){
		return getTop().userConfig = userConfiguration;
	}
	
	function getMessage(idMsg){
		return getTop().msg[idMsg];
	}

	function getEvent(event){
		return (event ? event : window.event);
	}

	function getKeyCode(event){
		return (event.keyCode ? event.keyCode : event.which);
	}

	function deleteElementById(id){
		var element = document.getElementById(id);
		if (element != null) element.parentNode.removeChild(element);
	}

	function deleteElement(element){
		if (element != null) element.parentNode.removeChild(element);
	}

	function insertAfter(newNode, refNode){
		refNode.parentNode.insertBefore(newNode, refNode.nextSibling);
	}

	function showProcessing(){
		if (getTop().nPetProcess == 0) getTop().document.getElementById("processing").style.display = "";
		getTop().nPetProcess ++;
	}

	function hideProcessing(force){
		if (force == null) force = false;
		getTop().nPetProcess--;
		if (getTop().nPetProcess == 0 || force) {
			getTop().setDefaultProcessing();
			getTop().document.getElementById("processing").style.display = "none";
		}
		if (force) getTop().nPetProcess = 0;
		if (getTop().nPetProcess < 0) getTop().nPetProcess = 0;
	}

	function chgResourceProcessing(src, width, height) {
		getTop().chgProcessing(src, width, height);
	}

	function showCalendar(input){
		/*var params = new Params();
		params.put("field", input);
		mngWindow.showWindow("COM_CALENDAR", params);*/
		if(getTop().initCalendar != null)
			getTop().initCalendar(input);
		else
			initCalendar(input);
	}

	function showClock(input){
		var params = new Params();
		params.put("field", input);
		mngWindow.showWindow("CLOCK", params);
	}

	function showElement(id, show){
		if (document.getElementById(id) != null) document.getElementById(id).style.display = (show? "" : "none");
	}

	function isEmpty(string){
		if (string == null) return true;
		return ((string == undefined) || (string == "") || (string.replace == null) || (string.replace(/ /g, "") == ""));
	}

	//**************************//
	//		 CONSOLE.LOG	 	//
	//**************************//
	function Console(){}
	Console.prototype.log = function(s){return null;}

	try {
		console.log();
	} catch(e){
		console = new Console();
	}

	//**************************//
	//		 CLASE PARAM	 	//
	//**************************//
	function Param(name, value){
		this.name = name;
		this.value = value;
	}
	Param.prototype.getName = function(){return this.name;}
	Param.prototype.setName = function(name){this.name = name;}
	Param.prototype.getValue = function(){return this.value;}
	Param.prototype.setValue = function(value){this.value = value;}

	//**************************//
	//		 CLASE PARAMS   	//
	//**************************//
	function Params(){
		this.aParams = new Array();
	}
	Params.prototype.put = function(name, value){this.aParams.push(new Param(name, value));}
	Params.prototype.putByName = function(name, value){
		var success = false;
		for(var i = 0; i < this.aParams.length; i++){
			if (this.aParams[i].getName() == name){
				this.aParams[i].setValue(value);
				success = true;
			}
		}
		if(!success) this.aParams.push(new Param(name, value));
	}
	Params.prototype.putValues = function(name, aValues){
		for(var i = 0; i < aValues.length; i++){
			this.aParams.push(new Param(name, aValues[i]));
		}
	}
	Params.prototype.remByName = function(name){
		for(var i = 0; i < this.aParams.length; i++){
			if(this.aParams[i].getName() == name) this.aParams.splice(i,1);
		}
	}
	Params.prototype.append = function(params){this.aParams = this.aParams.concat(params.getParams());}
	Params.prototype.getParams = function(){return this.aParams;}
	Params.prototype.getParamValue = function(name){
		for(var i = 0; i < this.aParams.length; i++){
			var param = this.aParams[i];
			if(param.getName() == name) return param.getValue();
		}
		return null;
	}
	Params.prototype.getParamValues = function(name){
		var result = new Array();
		for(var i = 0; i < this.aParams.length; i++){
			var param = this.aParams[i];
			if(param.getName() == name) result.push(param.getValue());
		}
		return result;
	}
	Params.prototype.clean = function(){this.aParams() = new Array();}
	Params.prototype.toString = function(){
		var result = "?";
		for(var x = 0; x < this.aParams.length; x++){
			if(x > 0) result += "&";
			result += this.aParams[x].getName() + "=" + window.encodeURIComponent(this.aParams[x].getValue());
		}
		return result;
	}
	Params.prototype.cloneNode = function() {
		var params = new Params();
		for (var i in this.aParams) params.put(this.aParams[i].getName(), this.aParams[i].getValue());
		return params;
	}
	Params.prototype.isEmpty = function(name) {
		return (this.getParamValue(name) == null || this.getParamValue(name) == "");
	}


	/****************************************************/
	//		VERIFICACION Y FORMATO						//
	/****************************************************/

	function formatPrice(priceUsr, price, currency, target){
		target.innerHTML = "&nbsp;";
		target.align = "right";
		target.style.whiteSpace = "nowrap";

		var span;
		if (priceUsr != null && priceUsr != "") {
			span = document.createElement("span");
			span.style.color = "#D67300";
			span.innerHTML = "(" + priceUsr + " " + getCurrencySymbol(getUserConfig().getCurrency()) + ") ";
			target.appendChild(span);
		}
		span = document.createElement("span");
		span.innerHTML = price + " " + getCurrencySymbol(currency);
		target.appendChild(span);
	}

	function getFormattedString(values, separator, group){
		var result = "";
		for(var i = 0; i < values.length; i++){
			if(i > 0) result += separator + " ";
			result += values[i];
		}
		if(result.length > 0){
			if(group == "POINT") result += ".";
			else if(group == "BRAKETS") result = "(" + result + ")";
		}
		return result;
	}

	function replaceParam(textSource, numParam, textParam){
		return (textSource.replace("{" + numParam + "}", textParam));
	}
	
	/* CLASE FORMAT NUMBER */
	/* Clase para el formato de numeros */
	function FormatNumber(numberDecimals){

		this.DOT = ".";
		this.COMMA = ",";

		this.sepM;
		this.sepD;
		this.numberDecimals = 0;
		this.minValue;
		this.maxValue;
		this.formatted = true;
		this.onformatRound = false;

		if (!isNaN(numberDecimals)) this.numberDecimals = numberDecimals;

		if (getUserConfig().getNumberFormat() == "DC"){
			this.sepM = this.DOT;
			this.sepD = this.COMMA;
		} else {
			this.sepM = this.COMMA;
			this.sepD = this.DOT;
		}
	}
	FormatNumber.prototype.setOnformatRound = function(onformatRound){this.onformatRound = onformatRound;}
	FormatNumber.prototype.setFormatted = function(formatted){this.formatted = formatted;}
	FormatNumber.prototype.setNumberDecimals = function(numberDecimals){this.numberDecimals = numberDecimals;}
	FormatNumber.prototype.setMinValue = function(minValue){this.minValue = minValue;}
	FormatNumber.prototype.setMaxValue = function(maxValue){this.maxValue = maxValue;}
	FormatNumber.prototype.applyRanges = function(value){
		if(this.minValue != null && value < this.minValue) return this.minValue;
		else if(this.maxValue != null && value > this.maxValue) return this.maxValue;
		else return value;
	}
	FormatNumber.prototype.getFormattedNumber = function(value, hasComma, hasZero, isFormatting){
		if (this.onformatRound) value = this.round(value);
		var result = null;
		if(hasComma == null) hasComma = false;
		if(hasZero == null) hasZero = false;
		var valueStr = new String(value);
		var aBase = valueStr.split(this.DOT);
		var pInt = aBase[0];
		var pDec = aBase[1];
		var fPInt = "";
		var count = 1;
		if(this.formatted){
			for(var i = pInt.length - 1; i >= 0; i--){
				fPInt = pInt.charAt(i) + fPInt;
				if(count == 3 && i > 0){
					if (!((pInt.charAt(0) == '-') && (i == 1))) {
						fPInt = this.sepM + fPInt;
						count = 0;
					}
				}
				count++;
			}
		} else {
			fPInt = pInt;
		}
		var fPDec = "";
		if(pDec != null && this.numberDecimals != null && this.numberDecimals != 0){
			fPDec = this.sepD;
			if(this.numberDecimals < pDec.length) fPDec += pDec.substring(0, this.numberDecimals);
			else fPDec += pDec;
			if(hasZero && this.formatted) fPDec = "0";
		}else if(hasComma && this.numberDecimals > 0  && this.formatted){
			fPDec = this.sepD;
		}
		if(hasZero && this.formatted) fPDec = this.sepD + "0";
		result = fPInt + fPDec;
		if(isFormatting == null) result = this.fillZero(result);
		return (result);
	}
	FormatNumber.prototype.fillZero = function(value){
		if(value == "") return value;
		var index = value.indexOf(this.sepD);
		if(index != -1){
			index++;
			if(this.numberDecimals == 0){value += this.sepD; index++;}
			for(var i = 0; i < this.numberDecimals; i++){
				if(index + i > value.length - 1) value += "0";
			}
		}else if(index == -1 && this.numberDecimals > 0){
			value += this.sepD;
			for(var i = 0; i < this.numberDecimals; i++) value += "0";
		}
		return value;
	}
	FormatNumber.prototype.round = function(value){
		if(this.numberDecimals > 0){
			var aux = Math.pow(10, this.numberDecimals);
			return (Math.round(value * aux) / aux);
		} else {
			return value;
		}
	}
	FormatNumber.prototype.parse = function(value){
		var aBase = value.split(this.sepM);
		var result = aBase.join("");
		if(this.sepD == this.COMMA) result = result.replace(/,/g, this.DOT);
		return this.round(parseFloat(result, 10));
	}
	FormatNumber.prototype.format = function(value){
		if(value == null || value.length == 0 || value.charAt(0) == this.sepD) return "";
		var hasComma = false;
		if(this.sepD == this.DOT) hasComma = (value.indexOf(".") != -1);
		else hasComma = (value.indexOf(",") != -1);

		var index = value.indexOf(this.sepD);
		var hasZero = false;
		if(index != -1){
			var decimals = "";
			decimals = value.substr(index + 1);
			var len = decimals.length - this.numberDecimals;
			if(len > 0) value = value.substring(0, value.length - len);
			hasZero = (value.charAt(value.length - 1) == "0" && len < 0);
		}
		var floatValue = this.parse(value);
		floatValue = this.applyRanges(floatValue);
		formatValue = this.getFormattedNumber(floatValue, hasComma, hasZero, true);
		if(formatValue == "NaN" || formatValue == "undefined") return "";
		else return formatValue;
	}
	FormatNumber.prototype.check = function(value){
		if(value == null || value.length == 0) return true;
		if(value.charAt(value.length - 1) == this.sepD) return false;
		try{this.parse(value);}catch(ex){return false;}
		return true;
	}
	FormatNumber.prototype.cloneNode = function(){
		var fnumber = new FormatNumber();
		fnumber.sepM = this.sepM;
		fnumber.sepD = this.sepD;
		fnumber.numberDecimals = this.numberDecimals;
		fnumber.minValue = this.minValue;
		fnumber.maxValue = this.maxValue;
		fnumber.formatted = this.formatted;
		return fnumber;
	}

	function getCurrencySymbol(currency){
		if (currency == "EUR") return "&euro;";
		else if (currency == "USD") return "$";
		else if (currency == "GBP") return "&pound;";
		else return currency;
	}

	//	Funcion que valida dos contrasenyas
	function checkPassword(val1, val2){

		var cad1 = val1;
		var cad2 = val2
		var len1 = cad1.length;
		var len2 = cad2.length;

		if (val1 != val2){
			alert(getMessage("msg09")); return false;
		} else if ((len1 < 6) || (len2 < 6)){
			alert(getMessage("msg10")); return false;
		}
		
		return true;
	}

	function metersToFeet(field1, field2){
		field2.setValueFromFloat(field1.getValueAsFloat() * 3.281);
	}

	function feetToMeters(field1, field2){
		field2.setValueFromFloat(field1.getValueAsFloat() / 3.281);
	}

	function meters2ToFeet2(field1, field2){
		field2.setValueFromFloat(field1.getValueAsFloat() * 10.764);
	}

	function feet2ToMeters2(field1, field2){
		field2.setValueFromFloat(field1.getValueAsFloat() / 10.764);
	}

	function parseDecimal(integer){
		return (parseFloat(integer.replace(/,/g,'.') * 100) / 100);
	}

	// TODO Hacer clase que FormatDate
	function strToDate(strDate){
		var formatDate = getUserConfig().getFormatDate();
		if(strDate != null && strDate != ""){
			var aDate = strDate.split("/");
			var myDay;
			var myMonth;
			if(formatDate == "ESP"){
				myDay = parseInt(aDate[0], 10);
				myMonth = parseInt(aDate[1], 10) - 1;
			} else if(formatDate == "ENG"){
				myDay = parseInt(aDate[1], 10);
				myMonth = parseInt(aDate[0], 10) - 1;
			}
			var myYear = aDate[2];

			var myDate = new Date(myYear, myMonth, myDay);
			myDate.setHours(0);
			myDate.setMinutes(0);
			myDate.setSeconds(0);
			myDate.setMilliseconds(0);

			return myDate;
		}
		return null;
	}

	function dateToStr(date){
		var formatDate = getUserConfig().getFormatDate();

		var day = date.getDate(); if(day < 10) day = "0" + day;
		var month = date.getMonth(); month++; if(month < 10) month = "0" + month;
		var year = date.getFullYear();

		var value = "";
		if(formatDate == "ESP") value = day + "/" + month + "/" + year;
		else if(formatDate == "ENG") value = month + "/" + day + "/" + year;

		return value;
	}

	function compareDates(fInicio, fFin, op){
		if (op == null) op = "<=";

		var tInicio = fInicio.getTime();
		var tFin = fFin.getTime();

		return (eval("tInicio "+ op +" tFin"));
	}

	function numDays(fInicio, fFin){
		try {
			var tInicio = ((fInicio.getTime == null)? strToDate(fInicio).parse() : fInicio.getTime());
			var tFin = ((fFin.getTime == null)? strToDate(fFin).parse() : fFin.getTime());

			var numN = Math.round((tFin - tInicio) / (1000 * 60 * 60 * 24)) + 1;
			if (parseFloat(numN, 10) >= 0) return new String(numN);
		} catch (ex){ }
		
		return new String(0);
	}

	function numNights(fInicio, fFin){
		
		try {
			var fecInicio;
			var fecFin;

			if (fInicio instanceof Date) 			fecInicio = fInicio;
			else if (fInicio.getDate == null) 	fecInicio = strToDate(fInicio);
			else fecInicio = fInicio.getDate();

			if (fFin instanceof Date) 			fecFin = fFin;
			else if (fFin.getDate == null) 		fecFin = strToDate(fFin);
			else fecFin = fFin.getDate();
			
			var numN = Math.round((fecFin.getTime() - fecInicio.getTime()) / (1000 * 60 * 60 * 24));
			
			if (parseFloat(numN, 10) < 0) return new String(0);
			return new String(numN);
		} catch (ex) {
			return new String(0);
		}
	}

	function addDays(date, numDays) {
		var formatDate = getUserConfig().getFormatDate();
		var myDay, myMonth, myYear;

		if (date.getDate == null) date = strToDate(date);

		date.setHours(9);
		date.setTime(date.getTime() + (numDays * 24*60*60*1000));
		myDay = date.getDate();
		if (myDay <= 9) myDay = '0' + myDay;
		myMonth = date.getMonth()+1;
		if (myMonth < 9) myMonth ='0' + myMonth;
		if (formatDate == "ESP") {
			date = myDay + '/' + myMonth + '/' + date.getFullYear();
		} else if (formatDate == "ENG")	{
			date = myMonth + '/' + myDay + '/' + date.getFullYear();
		}
		
		return (strToDate(date));
	}

	function getWeekDay(date){
		if (date.getDay() == 0) return getTop().msg["msg16"];
		else if (date.getDay() == 1) return getTop().msg["msg17"];
		else if (date.getDay() == 2) return getTop().msg["msg18"];
		else if (date.getDay() == 3) return getTop().msg["msg19"];
		else if (date.getDay() == 4) return getTop().msg["msg20"];
		else if (date.getDay() == 5) return getTop().msg["msg21"];
		else if (date.getDay() == 6) return getTop().msg["msg22"];
	}

	function monthLenghtCurrentYear(mes) {
		var date = new Date();
		return monthLenght(mes, date.getFullYear());
	}

	function monthLenght(mes, anyo) {
		var days = new Array (0,31,28,31,30,31,30,31,31,30,31,30,31);
		if (mes == 2 && ((anyo % 4 == 0) && ((anyo % 100 != 0) || (anyo % 400 == 0)))) return 29;
		else return days[mes];
	}

	function checkDate(input, format){
		hoy = new Date();
		var d = hoy.getDate();
		var m = hoy.getMonth() + 1;
		var y = hoy.getFullYear();
		var auxYear = "" + y;
		if(parseInt(d,10)<10) d = "0"+d;
		if(parseInt(m,10)<10) m = "0"+m;

		var valor = input.value;
		if(valor == "h" || valor == "H"){ input.value = d+"/"+m+"/"+y; return false;}
		var charsDate = "1234567890/";
		for(var i = 0; i < valor.length; i++) if(charsDate.indexOf("" + valor.charAt(i)) == -1) return fechaNoValida(input);

		if(valor.indexOf("/") == -1){
			if(valor.length == 3 || valor.length == 5 || valor.length == 7 || valor.length > 8) d = 0;
			else if(valor == "") return false;
			else if(valor.length < 3){
				d = valor;
				if(d.length == 1) d = "0" + d;
				if(format != "ESP") m = hoy.getDate();
			} else if(valor.length >= 4){
				m = valor.substring(2, 4);
				d = valor.substring(0, 2);
				if(valor.length == 6) y = "20" +  valor.substring(4);
				else if(valor.length == 8) y = valor.substring(4);
			}
		} else {
			d = valor.substring(0, valor.indexOf("/"));
			valor = valor.replace(valor.substring(0, valor.indexOf("/") + 1), "");
			m = valor.substring(0, valor.indexOf("/"));
			y = valor.replace(valor.substring(0, valor.indexOf("/") + 1), "");
			if (y.indexOf("/") != -1) d = 0;
			if(d.length <= 1) d = "0"+d;
			if(m.length <= 1) m = "0"+m;
			if(y.length <= 1) y = auxYear.substring(0, 3) + y;
			else if(y.length == 2) y = auxYear.substring(0, 2) + y;
			else if(y.length == 3) y = auxYear.substring(0, 1) + y;
		}

		if(format != "ESP" && !testDate(m, d, y, input)) return false;
		else if(format == "ESP" && !testDate(d, m, y, input)) return false;

		input.value = d+"/"+m+"/"+ ((parseInt(y, 10) < 2000)? 2000 : y);
	}

	function testDate(day, month, year, input){
		if(parseInt(day,10) != 0 && parseInt(day,10) <= monthLenght(parseInt(month,10), year) && parseInt(month,10) <= 12 && parseInt(month,10) >= 1) return true;
		else return fechaNoValida(input);
	}

	function fechaNoValida(input){
		alert(getTop().msg["msg23"]);
		input.value = "";
		return false;
	}

	function hideProcessingIfNecessary(){
		if(getTop().nPetProcess == 0){
			getTop().document.getElementById("processing").style.display = "none";
		}
	}

	function fieldsAffectedValue(fieldA, fieldB){
		fieldsAffected(fieldA, fieldB);
		fieldA.getObj().onchange = function(){
			fieldsAffected(fieldA, fieldB);
		};
	}

	function fieldsAffected(fieldA, fieldB){
		if (fieldA.getValue() == ""){
			fieldB.setValue("");
			fieldB.setReadOnly(true);
		} else if(!fieldA.isReadOnly()) {
			fieldB.setReadOnly(false);
		}
	}

	function quitAccents(s){
		á="a";
		é="e";
		í="i";
		ó="o";
		ú="u";
		accents=/[áéíóú]/g;
		return s.replace(accents,function($1){return eval($1)});
	}

	function sleep(milliseconds) {
		var start = new Date().getTime();
		for (var i = 0; i < start; i++) {
			if ((new Date().getTime() - start) > milliseconds){
				break;
			}
		}
	}

	function checkTime(input) {
		var valor = input.value;
		var aux = "";

		if(valor == "") return true;
		var charsDate = "1234567890:";
		for(var i = 0; i < valor.length; i++) if(charsDate.indexOf("" + valor.charAt(i)) == -1) return horaNoValida(input);

		if(valor.indexOf(":") == -1){
			if(valor.length == 1) aux = "0" + valor + ":00";
			else if(valor.length == 2 && parseInt(valor,10) < 24) aux = valor + ":00";
			else if(valor.length == 4 && parseInt(valor.substr(0, 2),10) < 24 && parseInt(valor.substr(2, 4),10) < 60) aux = valor.substr(0, 2) + ":" + valor.substr(2, 4);
		} else {
			var horas = valor.substr(0, valor.indexOf(":"));
			var minutos = valor.replace(valor.substr(0, valor.indexOf(":") + 1), "");
			if (minutos.indexOf(":") != -1) return horaNoValida(input);
			if(horas == "") aux = "00:";
			else if(parseInt(horas,10) < 24) (horas.length == 1)? aux += "0" + horas + ":":aux += horas + ":";
			if(minutos == "") aux += "00";
			else if(parseInt(minutos,10) < 60) (minutos.length == 1)? aux += "0" + minutos:aux += minutos;
		}

		if(aux.length != 5) return horaNoValida(input);
		else input.value = aux;

		return true;
	}

	function horaNoValida(input){
		alert(getTop().msg["msg24"]);
		input.value = "00:00";
		return false;
	}

	//	Funcion para comprobar que el NIF introducido es correcto
	function checkNIF(input, showAlert){

		var s = ((input.length != null)? input : input.value);

		var filter = new RegExp("^([0-9]{8})[a-z]$", "i");
		if ((s.length > 0) && (filter.test(s))){
			var code = "TRWAGMYFPDXBNJZSQVHLCKE";
			var number = s.substring(0, 8);
			var letter = s.substring(8);

			var index = parseInt(number) % 23;
			if (code.charAt(index) == letter.toUpperCase()) return true;
		}

		if (showAlert){
			alert(getMessage("msg01"));
			if (input.select != null) input.select();
		}
		return false;
	}

	//	Funcion para comprobar que el CIF introducido es correcto
	function checkCIF(input, showAlert){

		alert(input);

		var s = ((input.length != null)? input : input.value);

		var filter = new RegExp("^([0-9]{8})[a-z]$", "i");
		if ((s.length > 0) && (filter.test(s))){
			var code = "TRWAGMYFPDXBNJZSQVHLCKE";
			var number = s.substring(0, 8);
			var letter = s.substring(8);

			var index = parseInt(number) % 23;
			if (code.charAt(index) == letter.toUpperCase()) return true;
		}

		if (showAlert){
			alert(getMessage("msg01"));
			if (input.select != null) input.select();
		}

		return false;
	}

	//	Funcion para comprobar que el email introducido es correcto
	function checkEmail(input, showAlert){
		var s = ((input.length != null)? input : input.value);

		var filter = new RegExp("^[a-zA-Z0-9._-]+([+][a-zA-Z0-9._-]+){0,1}[@][a-zA-Z0-9._-]+[.][a-zA-Z]{2,6}$", "i");
		if ((s != null) && (s.length > 0) && (!filter.test(s))){
			if (showAlert){
				alert(getMessage("msg25"));
				if (input.select != null) input.select();
			}

			return false;
		}

		return true;
	}

	//	Funcion de chequeo del numero de tarjeta de credito
	function checkCard(input, showAlert){
		var s = ((input.length != null)? input : input.value);

		var filter = new RegExp("([0-9]{16})");
		if ((s != null) && (s.length > 0) && (filter.test(s))){

			var cifra = null;
			var cifra_cad = null;
			var suma = 0;

			for (var i = 0; i < s.length; i += 2){
				cifra = parseInt(s.charAt(i)) * 2;
				if (cifra > 9){
					cifra_cad = cifra.toString();
					cifra = parseInt(cifra_cad.charAt(0)) + parseInt(cifra_cad.charAt(1));
				}
				suma += cifra;
			}

			for (var i = 1; i < s.length; i += 2){
				suma += parseInt(s.charAt(i));
			}

			// Controla si el número cumple el algoritmo
			if ((suma % 10) == 0) return true;
		}

		if (showAlert){
			alert(getMessage("msg26"));
			if (input.select != null) input.select();
		}

		return false;
	}

	//	Funcion de chequeo de cuenta bancaria IBAN
	function checkAccount(input, showAlert){
		var s = ((input.length != null)? input : input.value);
		var ok = true;

		if (s != null){
			var size = s.length;
			var iban = s.substring(0, 4);

			var rexp = new RegExp("\\W+|[_]", "i");
			ok = ok && !rexp.test(s);
			ok = ok && (size < 35);

			var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

			// Validamos el numero IBAN
			if (isNaN(iban)){
				var account = (s.substring(4) + iban).toUpperCase();
				for (i=0; i < code.length; i++){ account = account.replace(code.charAt(i), String(i+10)); }

				if (!isNaN(account)){
					var m = "";
					for(i=0; i < account.length; i++){ m = (parseInt(m + account.charAt(i)) % 97); }

					ok = ok && (parseInt(m) == 1);
				} else {
					ok = false;
				}
			}

			// Si es IBAN español validamos la cuenta y si no tiene el codigo IBAN lo generamos
			if (ok && iban.indexOf("ES") == 0 || (!isNaN(iban) && size == 20)){
				var cuenta = s.substring(size - 10, size);
				var control = s.substring(size - 12, size - 10);
				var sucursal = 	s.substring(size - 16, size - 12);
				var entidad = s.substring(size - 20, size - 16);

				if (!isNaN(cuenta) && !isNaN(control) && !isNaN(sucursal) && !isNaN(entidad)){

					// Codigo de control de la cuenta ************************************
					var check1 = new Array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
					var control1 = 0;
					for (i=0; i<=9; i++) control1 += parseInt(cuenta.charAt(i)) * check1[i];
					control1 = 11 - (control1 % 11);
					if (control1 == 11) control1 = 0; else if (control1 == 10) control1 = 1;

					// Codigo de control de la entidad-sucursal **************************
					var check2 = new Array(4, 8, 5, 10, 9, 7, 3, 6);
					var control2 = 0;
					for (i=0; i<=7; i++) control2 += parseInt(entidad.concat(sucursal).charAt(i)) * check2[i];
					control2 = 11 - (control2 % 11);
					if (control2 == 11) control2 = 0; else if (control2 == 10) control2 = 1;

					ok = ok && (control == String(control2).concat(String(control1)));

					// Generamos el codigo IBAN en caso necesario*************************
					if (!isNaN(iban) && input.length == null){
						var account = s + "ES00";
						for (i=0; i < code.length; i++){ account = account.replace(code.charAt(i), String(i+10)); }

						if (!isNaN(account)){
							var m = "";
							for(i=0; i < account.length; i++){ m = (parseInt(m + account.charAt(i)) % 97); }

							m = 98 - parseInt(m);
							input.value = ("ES"+ ((parseInt(m) < 10)? "0"+m : m) + s);
						}
					}
				}

			} else if ((!isNaN(iban) && size != 20)){
				ok = false;
			}
		}

		if (!ok && showAlert){
			alert(getMessage("msg27"));
			if (input.focus != null) input.focus();
		}

		return ok;
	}
	