/* * Metadata - jQuery plugin for parsing metadata from elements * * Copyright (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Revision: $Id: jquery.metadata.js,v 1.1 2012/02/13 17:09:26 \camelia Exp $ * */ /** * Sets the type of metadata to use. Metadata is encoded in JSON, and each property * in the JSON will become a property of the element itself. * * There are three supported types of metadata storage: * * attr: Inside an attribute. The name parameter indicates *which* attribute. * * class: Inside the class attribute, wrapped in curly braces: { } * * elem: Inside a child element (e.g. a script tag). The * name parameter indicates *which* element. * * The metadata for an element is loaded the first time the element is accessed via jQuery. * * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements * matched by expr, then redefine the metadata type and run another $(expr) for other elements. * * @name $.metadata.setType * * @example
This is a p
* @before $.metadata.setType("class") * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label" * @desc Reads metadata from the class attribute * * @exampleThis is a p
* @before $.metadata.setType("attr", "data") * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label" * @desc Reads metadata from a "data" attribute * * @exampleThis is a p
* @before $.metadata.setType("elem", "script") * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label" * @desc Reads metadata from a nested script element * * @param String type The encoding type * @param String name The name of the attribute to be used to get metadata (optional) * @cat Plugins/Metadata * @descr Sets the type of encoding to be used when loading metadata for the first time * @type undefined * @see metadata() */ (function($) { $.extend({ metadata : { defaults : { type: 'class', name: 'metadata', cre: /({.*})/, single: 'metadata' }, setType: function( type, name ){ this.defaults.type = type; this.defaults.name = name; }, get: function( elem, opts ){ var settings = $.extend({},this.defaults,opts); // check for empty string in single property if ( !settings.single.length ) settings.single = 'metadata'; var data = $.data(elem, settings.single); // returned cached data if it already exists if ( data ) return data; data = "{}"; if ( settings.type == "class" ) { var m = settings.cre.exec( elem.className ); if ( m ) data = m[1]; } else if ( settings.type == "elem" ) { if( !elem.getElementsByTagName ) return undefined; var e = elem.getElementsByTagName(settings.name); if ( e.length ) data = $.trim(e[0].innerHTML); } else if ( elem.getAttribute != undefined ) { var attr = elem.getAttribute( settings.name ); if ( attr ) data = attr; } if ( data.indexOf( '{' ) <0 ) data = "{" + data + "}"; data = eval("(" + data + ")"); $.data( elem, settings.single, data ); return data; } } }); /** * Returns the metadata object for the first member of the jQuery object. * * @name metadata * @descr Returns element's metadata object * @param Object opts An object contianing settings to override the defaults * @type jQuery * @cat Plugins/Metadata */ $.fn.metadata = function( opts ){ return $.metadata.get( this[0], opts ); }; })(jQuery);/* * File: jquery.dataTables.js * Version: 1.7.5 * Description: Paginate, search and sort HTML tables * Author: Allan Jardine (www.sprymedia.co.uk) * Created: 28/3/2008 * Language: Javascript * License: GPL v2 or BSD 3 point style * Project: Mtaala * Contact: allan.jardine@sprymedia.co.uk * * Copyright 2008-2010 Allan Jardine, all rights reserved. * * This source file is free software, under either the GPL v2 license or a * BSD style license, as supplied with this software. * * This source file is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. * * For details please refer to: http://www.datatables.net */ /* * When considering jsLint, we need to allow eval() as it it is used for reading cookies and * building the dynamic multi-column sort functions. */ /*jslint evil: true, undef: true, browser: true */ /*globals $, jQuery,_fnExternApiFunc,_fnInitalise,_fnInitComplete,_fnLanguageProcess,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnGatherData,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnArrayCmp,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap*/ (function(jQuery, window, document) { /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Section - DataTables variables * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Variable: dataTableSettings * Purpose: Store the settings for each dataTables instance * Scope: jQuery.fn */ jQuery.fn.dataTableSettings = []; var _aoSettings = jQuery.fn.dataTableSettings; /* Short reference for fast internal lookup */ /* * Variable: dataTableExt * Purpose: Container for customisable parts of DataTables * Scope: jQuery.fn */ jQuery.fn.dataTableExt = {}; var _oExt = jQuery.fn.dataTableExt; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Section - DataTables extensible objects * * The _oExt object is used to provide an area where user dfined plugins can be * added to DataTables. The following properties of the object are used: * oApi - Plug-in API functions * aTypes - Auto-detection of types * oSort - Sorting functions used by DataTables (based on the type) * oPagination - Pagination functions for different input styles * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * Variable: sVersion * Purpose: Version string for plug-ins to check compatibility * Scope: jQuery.fn.dataTableExt * Notes: Allowed format is a.b.c.d.e where: * a:int, b:int, c:int, d:string(dev|beta), e:int. d and e are optional */ _oExt.sVersion = "1.7.5"; /* * Variable: sErrMode * Purpose: How should DataTables report an error. Can take the value 'alert' or 'throw' * Scope: jQuery.fn.dataTableExt */ _oExt.sErrMode = "alert"; /* * Variable: iApiIndex * Purpose: Index for what 'this' index API functions should use * Scope: jQuery.fn.dataTableExt */ _oExt.iApiIndex = 0; /* * Variable: oApi * Purpose: Container for plugin API functions * Scope: jQuery.fn.dataTableExt */ _oExt.oApi = { }; /* * Variable: aFiltering * Purpose: Container for plugin filtering functions * Scope: jQuery.fn.dataTableExt */ _oExt.afnFiltering = [ ]; /* * Variable: aoFeatures * Purpose: Container for plugin function functions * Scope: jQuery.fn.dataTableExt * Notes: Array of objects with the following parameters: * fnInit: Function for initialisation of Feature. Takes oSettings and returns node * cFeature: Character that will be matched in sDom - case sensitive * sFeature: Feature name - just for completeness :-) */ _oExt.aoFeatures = [ ]; /* * Variable: ofnSearch * Purpose: Container for custom filtering functions * Scope: jQuery.fn.dataTableExt * Notes: This is an object (the name should match the type) for custom filtering function, * which can be used for live DOM checking or formatted text filtering */ _oExt.ofnSearch = { }; /* * Variable: afnSortData * Purpose: Container for custom sorting data source functions * Scope: jQuery.fn.dataTableExt * Notes: Array (associative) of functions which is run prior to a column of this * 'SortDataType' being sorted upon. * Function input parameters: * object:oSettings- DataTables settings object * int:iColumn - Target column number * Return value: Array of data which exactly matched the full data set size for the column to * be sorted upon */ _oExt.afnSortData = [ ]; /* * Variable: oStdClasses * Purpose: Storage for the various classes that DataTables uses * Scope: jQuery.fn.dataTableExt */ _oExt.oStdClasses = { /* Two buttons buttons */ "sPagePrevEnabled": "paginate_enabled_previous", "sPagePrevDisabled": "paginate_disabled_previous", "sPageNextEnabled": "paginate_enabled_next", "sPageNextDisabled": "paginate_disabled_next", "sPageJUINext": "", "sPageJUIPrev": "", /* Full numbers paging buttons */ "sPageButton": "paginate_button", "sPageButtonActive": "paginate_active", "sPageButtonStaticDisabled": "paginate_button", "sPageFirst": "first", "sPagePrevious": "previous", "sPageNext": "next", "sPageLast": "last", /* Stripping classes */ "sStripOdd": "odd", "sStripEven": "even", /* Empty row */ "sRowEmpty": "dataTables_empty", /* Features */ "sWrapper": "dataTables_wrapper", "sFilter": "dataTables_filter", "sInfo": "dataTables_info", "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */ "sLength": "dataTables_length", "sProcessing": "dataTables_processing", /* Sorting */ "sSortAsc": "sorting_asc", "sSortDesc": "sorting_desc", "sSortable": "sorting", /* Sortable in both directions */ "sSortableAsc": "sorting_asc_disabled", "sSortableDesc": "sorting_desc_disabled", "sSortableNone": "sorting_disabled", "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */ "sSortJUIAsc": "", "sSortJUIDesc": "", "sSortJUI": "", "sSortJUIAscAllowed": "", "sSortJUIDescAllowed": "", "sSortJUIWrapper": "", /* Scrolling */ "sScrollWrapper": "dataTables_scroll", "sScrollHead": "dataTables_scrollHead", "sScrollHeadInner": "dataTables_scrollHeadInner", "sScrollBody": "dataTables_scrollBody", "sScrollFoot": "dataTables_scrollFoot", "sScrollFootInner": "dataTables_scrollFootInner", /* Misc */ "sFooterTH": "" }; /* * Variable: oJUIClasses * Purpose: Storage for the various classes that DataTables uses - jQuery UI suitable * Scope: jQuery.fn.dataTableExt */ _oExt.oJUIClasses = { /* Two buttons buttons */ "sPagePrevEnabled": "fg-button ui-button ui-state-default ui-corner-left", "sPagePrevDisabled": "fg-button ui-button ui-state-default ui-corner-left ui-state-disabled", "sPageNextEnabled": "fg-button ui-button ui-state-default ui-corner-right", "sPageNextDisabled": "fg-button ui-button ui-state-default ui-corner-right ui-state-disabled", "sPageJUINext": "ui-icon ui-icon-circle-arrow-e", "sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w", /* Full numbers paging buttons */ "sPageButton": "fg-button ui-button ui-state-default", "sPageButtonActive": "fg-button ui-button ui-state-default ui-state-disabled", "sPageButtonStaticDisabled": "fg-button ui-button ui-state-default ui-state-disabled", "sPageFirst": "first ui-corner-tl ui-corner-bl", "sPagePrevious": "previous", "sPageNext": "next", "sPageLast": "last ui-corner-tr ui-corner-br", /* Stripping classes */ "sStripOdd": "odd", "sStripEven": "even", /* Empty row */ "sRowEmpty": "dataTables_empty", /* Features */ "sWrapper": "dataTables_wrapper", "sFilter": "dataTables_filter", "sInfo": "dataTables_info", "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+ "ui-buttonset-multi paging_", /* Note that the type is postfixed */ "sLength": "dataTables_length", "sProcessing": "dataTables_processing", /* Sorting */ "sSortAsc": "ui-state-default", "sSortDesc": "ui-state-default", "sSortable": "ui-state-default", "sSortableAsc": "ui-state-default", "sSortableDesc": "ui-state-default", "sSortableNone": "ui-state-default", "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */ "sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n", "sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s", "sSortJUI": "css_right ui-icon ui-icon-carat-2-n-s", "sSortJUIAscAllowed": "css_right ui-icon ui-icon-carat-1-n", "sSortJUIDescAllowed": "css_right ui-icon ui-icon-carat-1-s", "sSortJUIWrapper": "DataTables_sort_wrapper", /* Scrolling */ "sScrollWrapper": "dataTables_scroll", "sScrollHead": "dataTables_scrollHead ui-state-default", "sScrollHeadInner": "dataTables_scrollHeadInner", "sScrollBody": "dataTables_scrollBody", "sScrollFoot": "dataTables_scrollFoot ui-state-default", "sScrollFootInner": "dataTables_scrollFootInner", /* Misc */ "sFooterTH": "ui-state-default" }; /* * Variable: oPagination * Purpose: Container for the various type of pagination that dataTables supports * Scope: jQuery.fn.dataTableExt */ _oExt.oPagination = { /* * Variable: two_button * Purpose: Standard two button (forward/back) pagination * Scope: jQuery.fn.dataTableExt.oPagination */ "two_button": { /* * Function: oPagination.two_button.fnInit * Purpose: Initalise dom elements required for pagination with forward/back buttons only * Returns: - * Inputs: object:oSettings - dataTables settings object * node:nPaging - the DIV which contains this pagination control * function:fnCallbackDraw - draw function which must be called on update */ "fnInit": function ( oSettings, nPaging, fnCallbackDraw ) { var nPrevious, nNext, nPreviousInner, nNextInner; /* Store the next and previous elements in the oSettings object as they can be very * usful for automation - particularly testing */ if ( !oSettings.bJUI ) { nPrevious = document.createElement( 'div' ); nNext = document.createElement( 'div' ); } else { nPrevious = document.createElement( 'a' ); nNext = document.createElement( 'a' ); nNextInner = document.createElement('span'); nNextInner.className = oSettings.oClasses.sPageJUINext; nNext.appendChild( nNextInner ); nPreviousInner = document.createElement('span'); nPreviousInner.className = oSettings.oClasses.sPageJUIPrev; nPrevious.appendChild( nPreviousInner ); } nPrevious.className = oSettings.oClasses.sPagePrevDisabled; nNext.className = oSettings.oClasses.sPageNextDisabled; nPrevious.title = oSettings.oLanguage.oPaginate.sPrevious; nNext.title = oSettings.oLanguage.oPaginate.sNext; nPaging.appendChild( nPrevious ); nPaging.appendChild( nNext ); jQuery(nPrevious).click( function() { if ( oSettings.oApi._fnPageChange( oSettings, "previous" ) ) { /* Only draw when the page has actually changed */ fnCallbackDraw( oSettings ); } } ); jQuery(nNext).click( function() { if ( oSettings.oApi._fnPageChange( oSettings, "next" ) ) { fnCallbackDraw( oSettings ); } } ); /* Take the brutal approach to cancelling text selection */ jQuery(nPrevious).bind( 'selectstart', function () { return false; } ); jQuery(nNext).bind( 'selectstart', function () { return false; } ); /* ID the first elements only */ if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined" ) { nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' ); nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' ); nNext.setAttribute( 'id', oSettings.sTableId+'_next' ); } }, /* * Function: oPagination.two_button.fnUpdate * Purpose: Update the two button pagination at the end of the draw * Returns: - * Inputs: object:oSettings - dataTables settings object * function:fnCallbackDraw - draw function to call on page change */ "fnUpdate": function ( oSettings, fnCallbackDraw ) { if ( !oSettings.aanFeatures.p ) { return; } /* Loop over each instance of the pager */ var an = oSettings.aanFeatures.p; for ( var i=0, iLen=an.length ; i
* jQuery.md5("admin");
*
* Result
*
* "21232f297a57a5a743894a0e4a801fc3"
*
*
* @param {jQuery} {md5:function(string))
* @return string
*/
(function(jQuery){
var rotateLeft = function(lValue, iShiftBits) {
return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
}
var addUnsigned = function(lX, lY) {
var lX4, lY4, lX8, lY8, lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
if (lX4 | lY4) {
if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ lX8 ^ lY8);
}
}
var F = function(x, y, z) {
return (x & y) | ((~ x) & z);
}
var G = function(x, y, z) {
return (x & z) | (y & (~ z));
}
var H = function(x, y, z) {
return (x ^ y ^ z);
}
var I = function(x, y, z) {
return (y ^ (x | (~ z)));
}
var FF = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var GG = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var HH = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var II = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var convertToWordArray = function(string) {
var lWordCount;
var lMessageLength = string.length;
var lNumberOfWordsTempOne = lMessageLength + 8;
var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64;
var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
var lWordArray = Array(lNumberOfWords - 1);
var lBytePosition = 0;
var lByteCount = 0;
while (lByteCount < lMessageLength) {
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
lByteCount++;
}
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
return lWordArray;
};
var wordToHex = function(lValue) {
var WordToHexValue = "", WordToHexValueTemp = "", lByte, lCount;
for (lCount = 0; lCount <= 3; lCount++) {
lByte = (lValue >>> (lCount * 8)) & 255;
WordToHexValueTemp = "0" + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
}
return WordToHexValue;
};
var uTF8Encode = function(string) {
string = string.replace(/\x0d\x0a/g, "\x0a");
var output = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
output += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
output += String.fromCharCode((c >> 6) | 192);
output += String.fromCharCode((c & 63) | 128);
} else {
output += String.fromCharCode((c >> 12) | 224);
output += String.fromCharCode(((c >> 6) & 63) | 128);
output += String.fromCharCode((c & 63) | 128);
}
}
return output;
};
jQuery.extend({
md5: function(string) {
var x = Array();
var k, AA, BB, CC, DD, a, b, c, d;
var S11=7, S12=12, S13=17, S14=22;
var S21=5, S22=9 , S23=14, S24=20;
var S31=4, S32=11, S33=16, S34=23;
var S41=6, S42=10, S43=15, S44=21;
string = uTF8Encode(string);
x = convertToWordArray(string);
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
for (k = 0; k < x.length; k += 16) {
AA = a; BB = b; CC = c; DD = d;
a = FF(a, b, c, d, x[k+0], S11, 0xD76AA478);
d = FF(d, a, b, c, x[k+1], S12, 0xE8C7B756);
c = FF(c, d, a, b, x[k+2], S13, 0x242070DB);
b = FF(b, c, d, a, x[k+3], S14, 0xC1BDCEEE);
a = FF(a, b, c, d, x[k+4], S11, 0xF57C0FAF);
d = FF(d, a, b, c, x[k+5], S12, 0x4787C62A);
c = FF(c, d, a, b, x[k+6], S13, 0xA8304613);
b = FF(b, c, d, a, x[k+7], S14, 0xFD469501);
a = FF(a, b, c, d, x[k+8], S11, 0x698098D8);
d = FF(d, a, b, c, x[k+9], S12, 0x8B44F7AF);
c = FF(c, d, a, b, x[k+10], S13, 0xFFFF5BB1);
b = FF(b, c, d, a, x[k+11], S14, 0x895CD7BE);
a = FF(a, b, c, d, x[k+12], S11, 0x6B901122);
d = FF(d, a, b, c, x[k+13], S12, 0xFD987193);
c = FF(c, d, a, b, x[k+14], S13, 0xA679438E);
b = FF(b, c, d, a, x[k+15], S14, 0x49B40821);
a = GG(a, b, c, d, x[k+1], S21, 0xF61E2562);
d = GG(d, a, b, c, x[k+6], S22, 0xC040B340);
c = GG(c, d, a, b, x[k+11], S23, 0x265E5A51);
b = GG(b, c, d, a, x[k+0], S24, 0xE9B6C7AA);
a = GG(a, b, c, d, x[k+5], S21, 0xD62F105D);
d = GG(d, a, b, c, x[k+10], S22, 0x2441453);
c = GG(c, d, a, b, x[k+15], S23, 0xD8A1E681);
b = GG(b, c, d, a, x[k+4], S24, 0xE7D3FBC8);
a = GG(a, b, c, d, x[k+9], S21, 0x21E1CDE6);
d = GG(d, a, b, c, x[k+14], S22, 0xC33707D6);
c = GG(c, d, a, b, x[k+3], S23, 0xF4D50D87);
b = GG(b, c, d, a, x[k+8], S24, 0x455A14ED);
a = GG(a, b, c, d, x[k+13], S21, 0xA9E3E905);
d = GG(d, a, b, c, x[k+2], S22, 0xFCEFA3F8);
c = GG(c, d, a, b, x[k+7], S23, 0x676F02D9);
b = GG(b, c, d, a, x[k+12], S24, 0x8D2A4C8A);
a = HH(a, b, c, d, x[k+5], S31, 0xFFFA3942);
d = HH(d, a, b, c, x[k+8], S32, 0x8771F681);
c = HH(c, d, a, b, x[k+11], S33, 0x6D9D6122);
b = HH(b, c, d, a, x[k+14], S34, 0xFDE5380C);
a = HH(a, b, c, d, x[k+1], S31, 0xA4BEEA44);
d = HH(d, a, b, c, x[k+4], S32, 0x4BDECFA9);
c = HH(c, d, a, b, x[k+7], S33, 0xF6BB4B60);
b = HH(b, c, d, a, x[k+10], S34, 0xBEBFBC70);
a = HH(a, b, c, d, x[k+13], S31, 0x289B7EC6);
d = HH(d, a, b, c, x[k+0], S32, 0xEAA127FA);
c = HH(c, d, a, b, x[k+3], S33, 0xD4EF3085);
b = HH(b, c, d, a, x[k+6], S34, 0x4881D05);
a = HH(a, b, c, d, x[k+9], S31, 0xD9D4D039);
d = HH(d, a, b, c, x[k+12], S32, 0xE6DB99E5);
c = HH(c, d, a, b, x[k+15], S33, 0x1FA27CF8);
b = HH(b, c, d, a, x[k+2], S34, 0xC4AC5665);
a = II(a, b, c, d, x[k+0], S41, 0xF4292244);
d = II(d, a, b, c, x[k+7], S42, 0x432AFF97);
c = II(c, d, a, b, x[k+14], S43, 0xAB9423A7);
b = II(b, c, d, a, x[k+5], S44, 0xFC93A039);
a = II(a, b, c, d, x[k+12], S41, 0x655B59C3);
d = II(d, a, b, c, x[k+3], S42, 0x8F0CCC92);
c = II(c, d, a, b, x[k+10], S43, 0xFFEFF47D);
b = II(b, c, d, a, x[k+1], S44, 0x85845DD1);
a = II(a, b, c, d, x[k+8], S41, 0x6FA87E4F);
d = II(d, a, b, c, x[k+15], S42, 0xFE2CE6E0);
c = II(c, d, a, b, x[k+6], S43, 0xA3014314);
b = II(b, c, d, a, x[k+13], S44, 0x4E0811A1);
a = II(a, b, c, d, x[k+4], S41, 0xF7537E82);
d = II(d, a, b, c, x[k+11], S42, 0xBD3AF235);
c = II(c, d, a, b, x[k+2], S43, 0x2AD7D2BB);
b = II(b, c, d, a, x[k+9], S44, 0xEB86D391);
a = addUnsigned(a, AA);
b = addUnsigned(b, BB);
c = addUnsigned(c, CC);
d = addUnsigned(d, DD);
}
var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
return tempValue.toLowerCase();
}
});
})(jQuery);
jQuery.noConflict();
var IdleAdminUserTimeout = 900;
var IdleAffiliateUserTimeout = 900;
var datepickeryearRange = '2005 : 2015';
var datepickeralltimeRange = '1900 : 2015';
var datepickerdobRange = '1900 : 1998';
/* Store all common Javascript functions associated with the jquery library here
these functions should be items that are common to many js files across the site - or extend the standard jquery library
*/
/*
Name : serializeJSON()
Purpose : Searialize form inputs as a json string
Call Example : jQuery('form').serializeJSON(); (alternative form serializing options are : jQuery('formid').serialize();, jQuery('formid').serializeArray();)
*/
oServerSideselectlists = "../includes/scripts/ajax/lists.asp";
jQuery(function() {
jQuery('.datepick').datepicker({
altFormat: 'yy/mm/dd',
dateFormat: 'yy/mm/dd' ,
yearRange: datepickeryearRange,
gotoCurrent: true,
showButtonPanel: true,
changeMonth : true,
changeYear: true
//showCurrentAtPos: 2,numberOfMonths: 3
});
jQuery('.JQstddates, input[dob="true"]').datepicker({
showButtonPanel: false,
beforeShow: function (input, inst) {
var offset = jQuery(input).offset();
var height = jQuery(input).height();
var windowpos = (offset.top -jQuery(document).scrollTop() );
inputoffsetBottom = jQuery(window).height() - windowpos;
if (inputoffsetBottom<300) {
jQuery('html,body').animate({scrollTop: jQuery(document).scrollTop() + (300-inputoffsetBottom)});
}
}
});
jQuery('.JQstddates').datepicker('change', {yearRange: datepickeralltimeRange});
jQuery('input[dob="true"]').datepicker('change', {minDate:'-99y', maxDate: '-18y', defaultDate: '-20y'});
jQuery('#startdate').bind(
'dpClosed',
function(e, selectedDates)
{
var d = selectedDates[0];
if (d) {
d = new Date(d);
jQuery('#enddate').dpSetStartDate(d.addDays(1).asString());
}
}
);
jQuery('#enddate').bind(
'dpClosed',
function(e, selectedDates)
{
var d = selectedDates[0];
if (d) {
d = new Date(d);
$('#startdate').dpSetEndDate(d.addDays(-1).asString());
}
}
);
})
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
function FNQueryStringArray(queryString) {
var result = {};
if (!queryString ? location.search.substring(1) : queryString);
var re = /([^&=]+)=([^&]*)/g
var m;
while (m = re.exec(queryString)) {
result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
return result;
}
///////////////////////////////////////
// DROPDOWNLIST LOADER --> SAMPLE : params = {merchantid:curmerchantid}
function FNloadselectlist (fieldname,listname,selectedvalue,additionalparams) {
if (!fieldname){fieldname='';}else {
if (!additionalparams){additionalparams="";}
var activeformid = '#' + jQuery('#' + fieldname).closest('form').attr('id');
var dataToBeSent = jQuery(activeformid).serialize() + '&list=' + listname;
dataToBeSent +=(additionalparams.length>0? "&" + additionalparams: "");
dataToBeSent +='&nocache=' + new Date().getTime();
var selects = jQuery('#' + fieldname);
selects.html('');
jQuery.ajaxQueue({
type: "GET",
url: oServerSideselectlists,
dataType: "json",
data: dataToBeSent,
success: function(msg){
selects.html('');
jQuery.each(msg, function(i, opt) {
if (selectedvalue==opt['optionValue'] ){
selects.append('');
}else{
selects.append('');
}
});
},
error: function(xhr, textStatus, errorThrown){
selects.html('');
selects.append('');
}
});
}
}
function fnoptionlist(selboxid,listarray, selectedoption) {
var select = jQuery(selboxid);
var options = select.attr('options');
jQuery('option', select).remove();// drop all the existing options
for (var i = 0; i < listarray.length; i++) {
options = jQuery('')
.val(listarray[i].optionValue)
.html(listarray[i].optionDisplay);
options.attr("title",listarray[i].optionDisplay);
if (listarray[i].optionValue==selectedoption && selectedoption.length>0 ) {
options.attr('selected','selected');
}
select.append(options);
}
}
// date formatting
function GetMonthIndex(shortMonthName)
{
var MonthName = new Array();
MonthName [0]='january';
MonthName [1]='february';
MonthName [2]='march';
MonthName [3]='april';
MonthName [4]='may';
MonthName [5]='june';
MonthName [6]='july';
MonthName [7]='august';
MonthName [8]='september';
MonthName [9]='october';
MonthName [10]='november';
MonthName [11]='december';
for (i=0;i<12;i++)
{
if (MonthName[i].substring(0,3).toUpperCase()==shortMonthName.toUpperCase())
{ return i;}
}
}
// Number formating
function FNformatCurrency(num) {
num = (isNaN(num) || num === '' || num === null ? 0.00 : num) ;
return parseFloat(num).toFixed(2);
}
///////////////////////////////////////
// OVERLAY functions - simple functions to apply overlay to an elemetn/form or whole page, use FNappendOverlay to add and FNremoveOvrelay to remove
overlayDiv = ' ';
function FNappendOverlay(formname) {
form = (formname=="body"?jQuery(formname) :jQuery("#" + formname));
var formWidth = (formname=="body" ? '100%' : form.width() + 'px');
var formHeight = (formname=="body" ? '100%' : form.height() + 'px');
var formPositionleft = (formname=="body" ? '0px' : form.position().left + 'px');
var formPositiontop = (formname=="body" ? '0px' : form.position().top + 'px');
jQuery('body').append(overlayDiv);
jQuery('#overlay').css({
'left' : formPositionleft ,
'top' : formPositiontop
});
jQuery('#overlay, .ui-widget-overlay').css({
'width' : formWidth ,
'height' : formHeight
});
jQuery('#overlay').fadeIn(300);
}
function FNremoveOverlay(formname) {
form = jQuery("#" + formname)
jQuery('#overlay').fadeOut(300, function() {
jQuery(this).remove();
});
}
function FNresizeOverlay(formname) {
form = jQuery("#" + formname) ;
var formWidth = form.width();
var formHeight = form.height() ;
var formPosition = form.position();
jQuery('#overlay').css({
'left' : formPosition.left + 'px',
'top' : formPosition.top + 'px'
});
jQuery('#overlay, .ui-widget-overlay').css({
'width' : formWidth + 'px',
'height' : formHeight + 'px'
});
}
/*
* jQuery.ajaxQueue - A queue for ajax requests
* Requires jQuery 1.4+
*/
(function($) {
// jQuery on an empty object, we are going to use this as our Queue
var ajaxQueue = $({});
$.ajaxQueue = function(ajaxOpts) {
// hold the original complete function
var oldComplete = ajaxOpts.complete;
// queue our ajax request
ajaxQueue.queue(function(next) {
// create a complete callback to fire the next event in the queue
ajaxOpts.complete = function() {
// fire the original complete if it was there
if (oldComplete) oldComplete.apply(this, arguments);
next(); // run the next query in the queue
};
// run the query
$.ajax(ajaxOpts);
});
};
})(jQuery);
/*
* jQuery.ajaxQueue - A queue for ajax requests
* Requires jQuery 1.5+
(function(jQuery) {
// jQuery on an empty object, we are going to use this as our Queue
var ajaxQueue = jQuery({});
jQuery.ajaxQueue = function( ajaxOpts ) {
var jqXHR,
dfd = jQuery.Deferred(),
promise = dfd.promise();
// queue our ajax request
ajaxQueue.queue( doRequest );
// add the abort method
promise.abort = function( statusText ) {
// proxy abort to the jqXHR if it is active
if ( jqXHR ) {
return jqXHR.abort( statusText );
}
// if there wasn't already a jqXHR we need to remove from queue
var queue = ajaxQueue.queue(),
index = jQuery.inArray( doRequest, queue );
if ( index > -1 ) {
queue.splice( index, 1 );
}
// and then reject the deferred
dfd.rejectWith( ajaxOpts.context || ajaxOpts,
[ promise, statusText, "" ] );
return promise;
};
// run the actual query
function doRequest( next ) {
jqXHR = jQuery.ajax( ajaxOpts )
.then( next, next )
.done( dfd.resolve )
.fail( dfd.reject );
}
return promise;
};
})(jQuery);
*/
var validatedLoginAgain = false;
(function(jQuery) {
if (typeof jQuery.timeout != "undefined") return;
jQuery.extend({
timeout : function (func,delay) {
// init
if (typeof jQuery.timeout.count == "undefined") jQuery.timeout.count = 0;
if (typeof jQuery.timeout.funcs == "undefined") jQuery.timeout.funcs = new Array();
// set timeout
if (typeof func =='string') return setTimeout(func, delay);
if (typeof func =='function') {
jQuery.timeout.count++;
jQuery.timeout.funcs[jQuery.timeout.count] = func;
return setTimeout("jQuery.timeout.funcs['"+jQuery.timeout.count+"']();", delay);
}
},
interval : function (func,delay) {
// init
if (typeof jQuery.interval.count == "undefined") jQuery.interval.count = 0;
if (typeof jQuery.interval.funcs == "undefined") jQuery.interval.funcs = new Array();
// set interval
if (typeof func =='string') return setInterval(func, delay);
if (typeof func =='function') {
jQuery.interval.count++;
jQuery.interval.funcs[jQuery.interval.count] = func;
return setInterval("jQuery.interval.funcs['"+jQuery.interval.count+"']();", delay);
}
},
idle : function (func,delay) {
// init
if (typeof jQuery.idle.lasttimeout == "undefined") jQuery.idle.lasttimeout = null;
if (typeof jQuery.idle.lastfunc == "undefined") jQuery.idle.lastfunc = null;
// set idle timeout
if (jQuery.idle.timeout) { clearTimeout(jQuery.idle.timeout); jQuery.idle.timeout = null; jQuery.idle.lastfunc = null; }
if (typeof(func)=='string') {
jQuery.idle.timeout = setTimeout(func, delay);
return jQuery.idle.timeout;
}
if (typeof(func)=='function') {
jQuery.idle.lastfunc = func;
jQuery.idle.timeout = setTimeout("jQuery.idle.lastfunc();", delay);
return jQuery.idle.timeout;
}
},
clear : function (countdown) {
clearInterval(countdown);
clearTimeout(countdown);
}
});
})(jQuery);
(function(jQuery){
jQuery.fn.idleTimeout = function(idletype,options) {
validatedLoginAgain = false;
// DIALOG TIMEOYUT SETTINGS
var defaults = { "default" : {
template: "default",
inactivity: 1200, //20 Minutes IN SECONDS 60 SEC X 20 MIN = 1200
logout_url: '/logout.asp',
modalbody : adminuserauthbody
},
"adminuserauth" :{
template: "adminuserauth",
inactivity: IdleAdminUserTimeout,
logout_url: '/admin/logout.asp',
modalbody : adminuserauthbody
}
}
var type = (!idletype ? "default" : idletype);
var opts = jQuery.extend(defaults[type], options);
var modal = (opts.modalbody>0 ? opts.modalbody : idletimeoutdefaultbody );
opts.inactivity =opts.inactivity *1000;
//jQuery.idle(function() { alert('idelexpire'); }, 30000);
var start_liveTimeout = function() {
jQuery.idle(function() {
// default modal dialog
var $dialog = jQuery('')
var dialogOpts = {};
if (opts.template=="adminuserauth") {
dialogOpts = dialogOptsadminuserauth;
}
if (opts.template=='default') {
dialogOpts = {
buttons: {"Stay Logged In": function(){
jQuery(this).dialog('close');
// stay_logged_in();
start_liveTimeout();
}},
modal: true,
title: 'Auto Logout'
};
}
$dialog.dialog(dialogOpts);
$dialog.append(opts.modalbody);
$dialog.dialog("open");
}, opts.inactivity)
}
var logout = function()
{
}
//###############################
//Build & Return the instance of the item as a plugin
// This is basically your construct.
//###############################
return this.each(function() {
obj =jQuery(this);
start_liveTimeout();
});
};// eof jQuery.fn.idleTimeout
})(jQuery);
/////////////////////////////////////////
function fnInitialiseAuthUser () {
if (IdleAdminUserReq) {
var $dialog = jQuery('')
$dialog.dialog(dialogOptsadminuserauth);
$dialog.append(adminuserauthbody);
$dialog.dialog("open");
} else {
jQuery(document).idleTimeout("adminuserauth");
}
}
// DIALOG BODY TEMPLATES
var idletimeoutdefaultbody = "You are about to be signed out due to inactivity.
Please re-enter your password for access
' + 'Thank you!
'); jQuery(this).delay(1500).queue(function () { jQuery(this).dialog("close"); jQuery(document).idleTimeout("adminuserauth"); }); } } else if (testremote == "exit") { jQuery("fieldset").html('This Session has timed out - You will now be logged out'); jQuery(this).delay(1500).queue(function () { window.location.replace("/admin/logout.asp"); }); } else { jQuery("#adminpassword").addClass('error').removeClass('checked'); jQuery("#adminpasswordstatus").addClass('errorimg').removeClass('checkedimg'); } }, "Exit": function () { window.location.replace("/admin/logout.asp"); } }, open: function (event, ui) { jQuery(event.target).dialog('option', 'title', 'Confirm Your Login'); jQuery(".ui-dialog-titlebar-close").hide(); //$dialog.load("/includes/template/dialogauthuser.html"); } }; /*============================================================================== Parameters: toCheck - VAT number be checked. This function checks the value of the parameter for a valid European VAT number. If the number is found to be invalid format, the function returns a value of false. Otherwise it returns the VAT number re-formatted. Example call: if (checkVATNumber (myVATNumber)) alert ("VAT number has a valid format") else alert ("VAT number has invalid format"); ------------------------------------------------------------------------------*/ function isvat (fieldvalue) { validvatnum = checkVATNumber (fieldvalue); return validvatnum; } function checkVATNumber (toCheck) { // Array holds the regular expressions for the valid VAT number var vatexp = new Array (); // To change the default country (e.g. from the UK to Germany - DE): // 1. Change the country code in the defCCode variable below to "DE". // 2. Remove the question mark from the regular expressions associated // with the UK VAT number: i.e. "(GB)?" -> "(GB)" // 3. Add a question mark into the regular expression associated with // Germany's number following the country code: i.e. "(DE)" -> "(DE)?" var defCCode = "GB"; // Note - VAT codes without the "**" in the comment do not have check digit // checking. vatexp.push (/^(AT)U(\d{8})$/); //** Austria vatexp.push (/^(BE)(\d{9,10})$/); //** Belgium vatexp.push (/^(BG)(\d{9,10})$/); // Bulgaria vatexp.push (/^(CY)(\d{8}[A-Z])$/); //** Cyprus vatexp.push (/^(CZ)(\d{8,10})(\d{3})?$/); //** Czech Republic vatexp.push (/^(DE)(\d{9})$/); //** Germany vatexp.push (/^(DK)((\d{8}))$/); //** Denmark vatexp.push (/^(EE)(\d{9})$/); //** Estonia vatexp.push (/^(EL)(\d{8,9})$/); //** Greece vatexp.push (/^(ES)([A-Z]\d{8})$/); //** Spain (1) vatexp.push (/^(ES)(\d{8}[A-Z])$/); // Spain (2) vatexp.push (/^(ES)([A-Z]\d{7}[A-Z])$/); //** Spain (3) vatexp.push (/^(EU)(\d{9})$/); //** EU-type vatexp.push (/^(FI)(\d{8})$/); //** Finland vatexp.push (/^(FR)(\d{11})$/); //** France (1) vatexp.push (/^(FR)[(A-H)|(J-N)|(P-Z)]\d{10}$/); // France (2) vatexp.push (/^(FR)\d[(A-H)|(J-N)|(P-Z)]\d{9}$/); // France (3) vatexp.push (/^(FR)[(A-H)|(J-N)|(P-Z)]{2}\d{9}$/); // France (4) vatexp.push (/^(GB)?(\d{9})$/); //** UK (standard) vatexp.push (/^(GB)?(\d{10})$/); //** UK (Commercial) vatexp.push (/^(GB)?(\d{12})$/); //UK (IOM standard) vatexp.push (/^(GB)?(\d{13})$/); //UK (IOM commercial) vatexp.push (/^(GB)?(GD\d{3})$/); //** UK (Government) vatexp.push (/^(GB)?(HA\d{3})$/); //** UK (Health authority) vatexp.push (/^(GR)(\d{8,9})$/); //** Greece vatexp.push (/^(HU)(\d{8})$/); //** Hungary vatexp.push (/^(IE)(\d{7}[A-W])$/); //** Ireland (1) vatexp.push (/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/); //** Ireland (2) vatexp.push (/^(IT)(\d{11})$/); //** Italy vatexp.push (/^(LV)(\d{11})$/); //** Latvia vatexp.push (/^(LT)(\d{9}|\d{12})$/); //** Lithunia vatexp.push (/^(LU)(\d{8})$/); //** Luxembourg vatexp.push (/^(MT)(\d{8})$/); //** Malta vatexp.push (/^(NL)(\d{9})B\d{2}$/); //** Netherlands vatexp.push (/^(PL)(\d{10})$/); //** Poland vatexp.push (/^(PT)(\d{9})$/); //** Portugal vatexp.push (/^(RO)(\d{2,10})$/); //** Romania vatexp.push (/^(SI)(\d{8})$/); //** Slovenia vatexp.push (/^(SK)(\d{9}|\d{10})$/); // Slovakia Republic vatexp.push (/^(SE)(\d{10}\d[1-4])$/); //** Sweden // Load up the string to check var VATNumber = toCheck.toUpperCase(); // Remove spaces from the VAT number to help validation var chars = [" ","-",",","."]; for ( var i=0; i < chars.length; i++) { while (VATNumber.indexOf(chars[i])!= -1) { VATNumber = VATNumber.slice (0,VATNumber.indexOf(chars[i])) + VATNumber.slice (VATNumber.indexOf(chars[i])+1); } } // Assume we're not going to find a valid VAT number var valid = false; // Check the string against the types of VAT numbers for (i=0; i < vatexp.length; i++) { if (vatexp[i].test(VATNumber)) { var cCode = RegExp.$1; // Isolate country code var cNumber = RegExp.$2; // Isolate the number if (cCode.length == 0) cCode = defCCode; // Set up default country code // Now look at the check digits for those countries we know about. switch (cCode) { case "AT": valid = ATVATCheckDigit (cNumber); break; case "BE": valid = BEVATCheckDigit (cNumber); break; case "BG": // The SIMA validation rules are incorrect for Bulgarian numbers. //valid = BGVATCheckDigit (cNumber) valid = true; break; case "CY": valid = CYVATCheckDigit (cNumber); break; case "CZ": valid = CZVATCheckDigit (cNumber); break; case "DE": valid = DEVATCheckDigit (cNumber); break; case "DK": valid = DKVATCheckDigit (cNumber); break; case "EE": valid = EEVATCheckDigit (cNumber); break; case "EL": valid = ELVATCheckDigit (cNumber); break; case "ES": valid = ESVATCheckDigit (cNumber); break; case "EU": valid = EUVATCheckDigit (cNumber); break; case "FI": valid = FIVATCheckDigit (cNumber); break; case "FR": valid = FRVATCheckDigit (cNumber); break; case "GB": valid = UKVATCheckDigit (cNumber); break; case "GR": valid = ELVATCheckDigit (cNumber); break; case "HU": valid = HUVATCheckDigit (cNumber); break; case "IE": valid = IEVATCheckDigit (cNumber); break; case "IT": valid = ITVATCheckDigit (cNumber); break; case "LT": valid = LTVATCheckDigit (cNumber); break; case "LU": valid = LUVATCheckDigit (cNumber); break; case "LV": valid = LVVATCheckDigit (cNumber); break; case "MT": valid = MTVATCheckDigit (cNumber); break; case "NL": valid = NLVATCheckDigit (cNumber); break; case "PL": valid = PLVATCheckDigit (cNumber); break; case "PT": valid = PTVATCheckDigit (cNumber); break; case "RO": valid = ROVATCheckDigit (cNumber); break; case "SE": valid = SEVATCheckDigit (cNumber); break; case "SI": valid = SIVATCheckDigit (cNumber); break; default: valid = true; } // Load new VAT number back into the form element if (valid) valid = VATNumber; // We have found that the number is valid - break from loop break; } } // Return with either an error or the reformatted VAT number return valid; } function ATVATCheckDigit (vatnumber) { // Checks the check digits of an Austrian VAT number. var total = 0; var multipliers = [1,2,1,2,1,2,1]; var temp = 0; // Extract the next digit and multiply by the appropriate multiplier. for (var i = 0; i < 7; i++) { temp = Number(vatnumber.charAt(i)) * multipliers[i]; if (temp > 9) total = total + Math.floor(temp/10) + temp%10 else total = total + temp; } // Establish check digit. total = 10 - (total+4) % 10; if (total == 10) total = 0; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (7,8)) return true else return false; } function BEVATCheckDigit (vatnumber) { // Checks the check digits of a Belgium VAT number. // First character of 10 digit numbers should be 0 if (vatnumber.length == 10 && vatnumber.slice(0,1) != "0") return false; // Nine digit numbers have a 0 inserted at the front. if (vatnumber.length == 9) vatnumber = "0" + vatnumber; // Modulus 97 check on last nine digits if (97 - vatnumber.slice (0,8) % 97 == vatnumber.slice (8,10)) return true else return false; } function BGVATCheckDigit (vatnumber) { // Check the check digit of 10 digit Bulgarian VAT numbers. if (vatnumber.length != 10) return true; var total = 0; var multipliers = [4,3,2,7,6,5,4,3,2]; var temp = 0; // Extract the next digit and multiply by the appropriate multiplier. for (var i = 0; i < 9; i++) { temp = temp + Number(vatnumber.charAt(i)) * multipliers[i]; } // Establish check digit. total = 11 - total % 11; if (total == 10) total = 0; if (total == 11) total = 1; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (9,10)) return true else return false; } function CYVATCheckDigit (vatnumber) { // Checks the check digits of a Cypriot VAT number. // Extract the next digit and multiply by the counter. var total = 0; for (var i = 0; i < 8; i++) { var temp = Number(vatnumber.charAt(i)); if (i % 2 == 0) { switch (temp) { case 0: temp = 1; break; case 1: temp = 0; break; case 2: temp = 5; break; case 3: temp = 7; break; case 4: temp = 9; break; default: temp = temp*2 + 3; } } total = total + temp; } // Establish check digit using modulus 26, and translate to char. equivalent. total = total % 26; total = String.fromCharCode(total+65); // Check to see if the check digit given is correct if (total == vatnumber.substr (8,1)) return true else return false; } function CZVATCheckDigit (vatnumber) { // Checks the check digits of a Czech Republic VAT number. var total = 0; var multipliers = [8,7,6,5,4,3,2]; // Only do check digit validation for standard VAT numbers if (vatnumber.length != 8) return true; // Extract the next digit and multiply by the counter. for (var i = 0; i < 7; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digit. total = 11 - total % 11; if (total == 10) total = 0; if (total == 11) total = 1; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (7,8)) return true else return false; } function DEVATCheckDigit (vatnumber) { // Checks the check digits of a German VAT number. var product = 10; var sum = 0; var checkdigit = 0; for (var i = 0; i < 8; i++) { // Extract the next digit and implement perculiar algorithm!. sum = (Number(vatnumber.charAt(i)) + product) % 10; if (sum == 0) {sum = 10}; product = (2 * sum) % 11; } // Establish check digit. if (11 - product == 10) {checkdigit = 0} else {checkdigit = 11 - product}; // Compare it with the last two characters of the VAT number. If the same, // then it is a valid check digit. if (checkdigit == vatnumber.slice (8,9)) return true else return false; } function DKVATCheckDigit (vatnumber) { // Checks the check digits of a Danish VAT number. var total = 0; var multipliers = [2,7,6,5,4,3,2,1]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 8; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digit. total = total % 11; // The remainder should be 0 for it to be valid.. if (total == 0) return true else return false; } function EEVATCheckDigit (vatnumber) { // Checks the check digits of an Estonian VAT number. var total = 0; var multipliers = [3,7,1,3,7,1,3,7]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 8; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digits using modulus 10. total = 10 - total % 10; if (total == 10) total = 0; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (8,9)) return true else return false; } function ELVATCheckDigit (vatnumber) { // Checks the check digits of a Greek VAT number. var total = 0; var multipliers = [256,128,64,32,16,8,4,2]; //eight character numbers should be prefixed with an 0. if (vatnumber.length == 8) {vatnumber = "0" + vatnumber}; // Extract the next digit and multiply by the counter. for (var i = 0; i < 8; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digit. total = total % 11; if (total > 9) {total = 0;}; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (8,9)) return true else return false; } function ESVATCheckDigit (vatnumber) { // Checks the check digits of a Spanish VAT number. var total = 0; var temp = 0; var multipliers = [2,1,2,1,2,1,2]; var esexp = new Array (); esexp.push (/^[A-H]\d{8}$/); esexp.push (/^[N|P|Q|S]\d{7}[A-Z]$/); esexp.push (/^[0-9]{8}[A-Z]$/); var i = 0; // With profit companies if (esexp[0].test(vatnumber)) { // Extract the next digit and multiply by the counter. for (i = 0; i < 7; i++) { temp = Number(vatnumber.charAt(i+1)) * multipliers[i]; if (temp > 9) total = total + Math.floor(temp/10) + temp%10 else total = total + temp; } // Now calculate the check digit itself. total = 10 - total % 10; if (total == 10) {total = 0;} // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (8,9)) return true else return false; } // Non-profit companies else if (esexp[1].test(vatnumber)) { // Extract the next digit and multiply by the counter. for (i = 0; i < 7; i++) { temp = Number(vatnumber.charAt(i+1)) * multipliers[i]; if (temp > 9) total = total + Math.floor(temp/10) + temp%10 else total = total + temp; } // Now calculate the check digit itself. total = 10 - total % 10; total = String.fromCharCode(total+64); // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (8,9)) return true else return false; } // Personal number (NIF) else if (esexp[2].test(vatnumber)) { return vatnumber.charAt(8) == 'TRWAGMYFPDXBNJZSQVHLCKE'.charAt(Number(vatnumber.substring(0, 8)) % 23); } else return true; } function EUVATCheckDigit (vatnumber) { // We know litle about EU numbers apart from the fact that the first 3 digits // represent the country, and that there are nine digits in total. return true; } function FIVATCheckDigit (vatnumber) { // Checks the check digits of a Finnish VAT number. var total = 0; var multipliers = [7,9,10,5,8,4,2]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 7; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digit. total = 11 - total % 11; if (total > 9) {total = 0;}; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (7,8)) return true else return false; } function FRVATCheckDigit (vatnumber) { // Checks the check digits of a French VAT number. if (!(/^\d{11}$/).test(vatnumber)) return true; // Extract the last nine digits as an integer. var total = vatnumber.substring(2); // Establish check digit. total = (total*100+12) % 97; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (0,2)) return true else return false; } function HUVATCheckDigit (vatnumber) { // Checks the check digits of a Hungarian VAT number. var total = 0; var multipliers = [9,7,3,1,9,7,3]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 7; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digit. total = 10 - total % 10; if (total == 10) total = 0; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (7,8)) return true else return false; } function IEVATCheckDigit (vatnumber) { // Checks the check digits of an Irish VAT number. var total = 0; var multipliers = [8,7,6,5,4,3,2]; // If the code is in the old format, we need to convert it to the new. if (/^\d[A-Z\*\+]/.test(vatnumber)) { vatnumber = "0" + vatnumber.substring(2,7) + vatnumber.substring(0,1) + vatnumber.substring(7,8); } // Extract the next digit and multiply by the counter. for (var i = 0; i < 7; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digit using modulus 23, and translate to char. equivalent. total = total % 23; if (total == 0) total = "W" else total = String.fromCharCode(total+64); // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (7,8)) return true else return false; } function ITVATCheckDigit (vatnumber) { // Checks the check digits of an Italian VAT number. var total = 0; var multipliers = [1,2,1,2,1,2,1,2,1,2]; var temp; // The last three digits are the issuing office, and cannot exceed more 201 temp=Number(vatnumber.slice(0,7)); if (temp==0) return false; temp=Number(vatnumber.slice(7,10)); if ((temp<1) || (temp>201)) return false; // Extract the next digit and multiply by the appropriate for (var i = 0; i < 10; i++) { temp = Number(vatnumber.charAt(i)) * multipliers[i]; if (temp > 9) total = total + Math.floor(temp/10) + temp%10 else total = total + temp; } // Establish check digit. total = 10 - total % 10; if (total > 9) {total = 0;}; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (10,11)) return true else return false; } function LTVATCheckDigit (vatnumber) { // Checks the check digits of a Lithuanian VAT number. // Only do check digit validation for standard VAT numbers if (vatnumber.length != 9) return true; // Extract the next digit and multiply by the counter+1. var total = 0; for (var i = 0; i < 8; i++) total = total + Number(vatnumber.charAt(i)) * (i+1); // Can have a double check digit calculation! if (total % 11 == 10) { var multipliers = [3,4,5,6,7,8,9,1]; total = 0; for (i = 0; i < 8; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; } // Establish check digit. total = total % 11; if (total == 10) {total = 0;}; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (8,9)) return true else return false; } function LUVATCheckDigit (vatnumber) { // Checks the check digits of a Luxembourg VAT number. if (vatnumber.slice (0,6) % 89 == vatnumber.slice (6,8)) return true else return false; } function LVVATCheckDigit (vatnumber) { // Checks the check digits of a Latvian VAT number. // Only check the legal bodies if ((/^[0-3]/).test(vatnumber)) return true; var total = 0; var multipliers = [9,1,4,8,3,10,2,5,7,6]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 10; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digits by getting modulus 11. if (total%11 == 4 && vatnumber[0] ==9) total = total - 45; if (total%11 == 4) total = 4 - total%11 else if (total%11 > 4) total = 14 - total%11 else if (total%11 < 4) total = 3 - total%11; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (10,11)) return true else return false; } function MTVATCheckDigit (vatnumber) { // Checks the check digits of a Maltese VAT number. var total = 0; var multipliers = [3,4,6,7,8,9]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 6; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digits by getting modulus 37. total = 37 - total % 37; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (6,8) * 1) return true else return false; } function NLVATCheckDigit (vatnumber) { // Checks the check digits of a Dutch VAT number. var total = 0; // var multipliers = [9,8,7,6,5,4,3,2]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 8; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digits by getting modulus 11. total = total % 11; if (total > 9) {total = 0;}; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (8,9)) return true else return false; } function PLVATCheckDigit (vatnumber) { // Checks the check digits of a Polish VAT number. var total = 0; var multipliers = [6,5,7,2,3,4,5,6,7]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 9; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digits subtracting modulus 11 from 11. total = total % 11; if (total > 9) {total = 0;}; // Compare it with the last character of the VAT number. If it is the same, then it's a valid // check digit. if (total == vatnumber.slice (9,10)) return true else return false; } function PTVATCheckDigit (vatnumber) { // Checks the check digits of a Portugese VAT number. var total = 0; var multipliers = [9,8,7,6,5,4,3,2]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 8; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digits subtracting modulus 11 from 11. total = 11 - total % 11; if (total > 9) {total = 0;}; // Compare it with the last character of the VAT number. If it is the same, then it's a valid // check digit. if (total == vatnumber.slice (8,9)) return true else return false; } function ROVATCheckDigit (vatnumber) { // Checks the check digits of a Romanian VAT number. var multipliers = [7,5,3,2,1,7,5,3,2,1]; // Extract the next digit and multiply by the counter. var VATlen = vatnumber.length; multipliers = multipliers.slice (10-VATlen); var total = 0; for (var i = 0; i < vatnumber.length-1; i++) { total = total + Number(vatnumber.charAt(i)) * multipliers[i]; } // Establish check digits by getting modulus 11. total = (10 * total) % 11; if (total == 10) total = 0; // Compare it with the last character of the VAT number. If it is the same, then it's a valid // check digit. if (total == vatnumber.slice (vatnumber.length-1, vatnumber.length)) return true else return false; } function SEVATCheckDigit (vatnumber) { // Checks the check digits of a Swedish VAT number. var total = 0; var multipliers = [2,1,2,1,2,1,2,1,2]; var temp = 0; // Extract the next digit and multiply by the appropriate multiplier. for (var i = 0; i < 9; i++) { temp = Number(vatnumber.charAt(i)) * multipliers[i]; if (temp > 9) total = total + Math.floor(temp/10) + temp%10 else total = total + temp; } // Establish check digits by subtracting mod 10 of total from 10. total = 10 - (total % 10); if (total == 10) total = 0; // Compare it with the 10th character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (9,10)) return true else return false; } function SKVATCheckDigit (vatnumber) { // Checks the check digits of a Slovak VAT number. var total = 0; var multipliers = [8,7,6,5,4,3,2]; // Extract the next digit and multiply by the counter. for (var i = 3; i < 9; i++) { total = total + Number(vatnumber.charAt(i)) * multipliers[i-3]; } // Establish check digits by getting modulus 11. total = 11 - total % 11; if (total > 9) total = total - 10; // Compare it with the last character of the VAT number. If it is the same, // then it's a valid check digit. if (total == vatnumber.slice (9,10)) return true else return false; } function SIVATCheckDigit (vatnumber) { // Checks the check digits of a Slovenian VAT number. var total = 0; var multipliers = [8,7,6,5,4,3,2]; // Extract the next digit and multiply by the counter. for (var i = 0; i < 7; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Establish check digits by subtracting 97 from total until negative. total = 11 - total % 11; if (total > 9) {total = 0;}; // Compare the number with the last character of the VAT number. If it is the // same, then it's a valid check digit. if (total == vatnumber.slice (7,8)) return true else return false; } function UKVATCheckDigit (vatnumber) { // Checks the check digits of a UK VAT number. var multipliers = [8,7,6,5,4,3,2]; // Government departments if (vatnumber.substr(0,2) == 'GD') { if (vatnumber.substr(2,3) < 500) return true else return false; } // Health authorities if (vatnumber.substr(0,2) == 'HA') { if (vatnumber.substr(2,3) > 499) return true else return false; } // Standard and commercial numbers if (vatnumber.length == 9 || vatnumber.length == 10) { var total = 0; if (vatnumber.length == 10 && vatnumber.slice (9,10) != '3') return false; // Extract the next digit and multiply by the counter. for (var i = 0; i < 7; i++) total = total + Number(vatnumber.charAt(i)) * multipliers[i]; // Old numbers use a simple 97 modulus, but new numbers use an adaptation of that (less // 55). Our VAT number could use either system, so we check it against both. // Establish check digits by subtracting 97 from total until negative. var cd = total; while (cd > 0) {cd = cd - 97;} // Get the absolute value and compare it with the last two characters of the // VAT number. If the same, then it is a valid traditional check digit. cd = Math.abs(cd); if (cd == vatnumber.slice (7,9)) return true; // Now try the new method by subtracting 55 from the check digit if we can - else add 42 if (cd >= 55) cd = cd - 55 else cd = cd + 42; if (cd == vatnumber.slice (7,9)) return true else return false; } // We don't check 12 and 13 digit UK numbers - not only can we not find any, // but the information found on the format is contradictory. return true; } // iban.html & iban.js 1.5 - Create or check International Bank Account Numbers // JavaScript Object for country specific iban data. function Country(name, code, bank_form, acc_form) { // Constructor for Country objects. // // Arguments: // name - Name of the country // code - Country Code from ISO 3166 // bank_form - Format of bank/branch code part (e.g. "0 4a 0 ") // acc_form - Format of account number part (e.g. "0 11 2n") this.name = name; this.code = code; this.bank = Country_decode_format(bank_form); this.acc = Country_decode_format(acc_form); this.bank_lng = Country_calc_length(this.bank); this.acc_lng = Country_calc_length(this.acc); this.total_lng = 4 + this.bank_lng + this.acc_lng; } function Country_decode_format(form) { var form_list = new Array(); var parts = form.split(" "); for (var i = 0; i < parts.length; ++i) { var part = parts[i]; if (part != "") { var typ = part.charAt(part.length - 1); if (typ == "a" || typ == "n") part = part.substring(0, part.length - 1); else typ = "c"; var lng = parseInt(part); form_list[form_list.length] = new Array(lng, typ); } } return form_list; } function Country_calc_length(form_list) { var sum = 0; for (var i = 0; i < form_list.length; ++i) sum += form_list[i][0]; return sum; } // BBAN data from ISO 13616, Country codes from ISO 3166 (www.iso.org). var iban_data = new Array( new Country("Andorra", "AD", "0 4n 4n", "0 12 0 "), new Country("Albania", "AL", "0 8n 0 ", "0 16 0 "), new Country("Austria", "AT", "0 5n 0 ", "0 11n 0 "), new Country("Bosnia and Herzegovina", "BA", "0 3n 3n", "0 8n 2n"), new Country("Belgium", "BE", "0 3n 0 ", "0 7n 2n"), new Country("Bulgaria", "BG", "0 4a 4n", "2n 8 0 "), new Country("Switzerland", "CH", "0 5n 0 ", "0 12 0 "), new Country("Cyprus", "CY", "0 3n 5n", "0 16 0 "), new Country("Czech Republic", "CZ", "0 4n 0 ", "0 16n 0 "), new Country("Germany", "DE", "0 8n 0 ", "0 10n 0 "), new Country("Denmark", "DK", "0 4n 0 ", "0 9n 1n"), new Country("Estonia", "EE", "0 2n 0 ", "2n 11n 1n"), new Country("Spain", "ES", "0 4n 4n", "2n 10n 0 "), new Country("Finland", "FI", "0 6n 0 ", "0 7n 1n"), new Country("Faroe Islands", "FO", "0 4n 0 ", "0 9n 1n"), new Country("France", "FR", "0 5n 5n", "0 11 2n"), new Country("United Kingdom", "GB", "0 4a 6n", "0 8n 0 "), new Country("Georgia", "GE", "0 2a 0 ", "0 16n 0 "), new Country("Gibraltar", "GI", "0 4a 0 ", "0 15 0 "), new Country("Greenland", "GL", "0 4n 0 ", "0 9n 1n"), new Country("Greece", "GR", "0 3n 4n", "0 16 0 "), new Country("Croatia", "HR", "0 7n 0 ", "0 10n 0 "), new Country("Hungary", "HU", "0 3n 4n", "1n 15n 1n"), new Country("Ireland", "IE", "0 4a 6n", "0 8n 0 "), new Country("Israel", "IL", "0 3n 3n", "0 13n 0 "), new Country("Iceland", "IS", "0 4n 0 ", "2n 16n 0 "), new Country("Italy", "IT", "1a 5n 5n", "0 12 0 "), new Country("Kuwait", "KW", "0 4a 0 ", "0 22 0 "), new Country("Kazakhstan", "KZ", "0 3n 0 ", "0 13 0 "), new Country("Lebanon", "LB", "0 4n 0 ", "0 20 0 "), new Country("Liechtenstein", "LI", "0 5n 0 ", "0 12 0 "), new Country("Lithuania", "LT", "0 5n 0 ", "0 11n 0 "), new Country("Luxembourg", "LU", "0 3n 0 ", "0 13 0 "), new Country("Latvia", "LV", "0 4a 0 ", "0 13 0 "), new Country("Monaco", "MC", "0 5n 5n", "0 11 2n"), new Country("Montenegro", "ME", "0 3n 0 ", "0 13n 2n"), new Country("Macedonia", "MK", "0 3n 0 ", "0 10 2n"), new Country("Mauritania", "MR", "0 5n 5n", "0 11n 2n"), new Country("Malta", "MT", "0 4a 5n", "0 18 0 "), new Country("Mauritius", "MU", "0 4a 4n", "0 15n 3a"), new Country("Netherlands", "NL", "0 4a 0 ", "0 10n 0 "), new Country("Norway", "NO", "0 4n 0 ", "0 6n 1n"), new Country("Poland", "PL", "0 8n 0 ", "0 16n 0 "), new Country("Portugal", "PT", "0 4n 4n", "0 11n 2n"), new Country("Romania", "RO", "0 4a 0 ", "0 16 0 "), new Country("Serbia", "RS", "0 3n 0 ", "0 13n 2n"), new Country("Saudi Arabia", "SA", "0 2n 0 ", "0 18 0 "), new Country("Sweden", "SE", "0 3n 0 ", "0 16n 1n"), new Country("Slovenia", "SI", "0 5n 0 ", "0 8n 2n"), new Country("Slovak Republic", "SK", "0 4n 0 ", "0 16n 0 "), new Country("San Marino", "SM", "1a 5n 5n", "0 12 0 "), new Country("Tunisia", "TN", "0 2n 3n", "0 13n 2n"), new Country("Turkey", "TR", "0 5n 0 ", "1 16 0 ")); // Search the country code in the iban_data list. function CountryData(code) { for (var i = 0; i < iban_data.length; ++i) if (iban_data[i].code == code) return iban_data[i]; return null; } // Modulo 97 for huge numbers given as digit strings. function mod97(digit_string) { var m = 0; for (var i = 0; i < digit_string.length; ++i) m = (m * 10 + parseInt(digit_string.charAt(i))) % 97; return m; } // Convert a capital letter into digits: A -> 10 ... Z -> 35 (ISO 13616). function capital2digits(ch) { var capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (var i = 0; i < capitals.length; ++i) if (ch == capitals.charAt(i)) break; return i + 10; } // Fill the string with leading zeros until length is reached. function fill0(s, l) { while (s.length < l) s = "0" + s; return s; } // Compare two strings respecting german umlauts. function strcmp(s1, s2) { var chars = "AaÄäBbCcDdEeFfGgHhIiJjKkLlMmNnOoÖöPpQqRrSsßTtUuÜüVvWwXxYyZz"; var lng = (s1.length < s2.length) ? s1.length : s2.length; for (var i = 0; i < lng; ++i) { var d = chars.indexOf(s1.charAt(i)) - chars.indexOf(s2.charAt(i)); if (d != 0) return d; } return s1.length - s2.length; } // Create an index table of the iban_data list sorted by country names. function CountryIndexTable() { var tab = new Array(); var i, j, t; for (i = 0; i < iban_data.length; ++i) tab[i] = i; for (i = tab.length - 1; i > 0; --i) for (j = 0; j < i; ++j) if (strcmp(iban_data[tab[j]].name, iban_data[tab[j+1]].name) > 0) t = tab[j], tab[j] = tab[j+1], tab[j+1] = t; return tab; } // Calculate 2-digit checksum of an IBAN. function ChecksumIBAN(iban) { var code = iban.substring(0, 2); var checksum = iban.substring(2, 4); var bban = iban.substring(4); // Assemble digit string var digits = ""; for (var i = 0; i < bban.length; ++i) { var ch = bban.charAt(i).toUpperCase(); if ("0" <= ch && ch <= "9") digits += ch; else digits += capital2digits(ch); } for (var i = 0; i < code.length; ++i) { var ch = code.charAt(i); digits += capital2digits(ch); } digits += checksum; // Calculate checksum checksum = 98 - mod97(digits); return fill0("" + checksum, 2); } // Fill the account number part of IBAN with leading zeros. function FillAccount(country, account) { return fill0(account, country.acc_lng); } // Check if syntax of the part of IBAN is invalid. function InvalidPart(form_list, iban_part) { for (var f = 0; f < form_list.length; ++f) { var lng = form_list[f][0], typ = form_list[f][1]; if (lng > iban_part.length) lng = iban_part.length; for (var i = 0; i < lng; ++i) { var ch = iban_part.charAt(i); var a = ("A" <= ch && ch <= "Z"); var n = ("0" <= ch && ch <= "9"); var c = n || a || ("a" <= ch && ch <= "z"); if ((!c && typ == "c") || (!a && typ == "a") || (!n && typ == "n")) return true; } iban_part = iban_part.substring(lng); } return false; } // Check if length of the bank/branch code part of IBAN is invalid. function InvalidBankLength(country, bank) { return (bank.length != country.bank_lng); } // Check if syntax of the bank/branch code part of IBAN is invalid. function InvalidBank(country, bank) { return (InvalidBankLength(country, bank) || InvalidPart(country.bank, bank)); } // Check if length of the account number part of IBAN is invalid. function InvalidAccountLength(country, account) { return (account.length < 1 || account.length > country.acc_lng); } // Check if syntax of the account number part of IBAN is invalid. function InvalidAccount(country, account) { return (InvalidAccountLength(country, account) || InvalidPart(country.acc, FillAccount(country, account))); } // Check if length of IBAN is invalid. function InvalidIBANlength(country, iban) { return (iban.length != country.total_lng); } // Convert iban from intern value to string format (IBAN XXXX XXXX ...). function extern(intern) { var s = "IBAN"; for (var i = 0; i < intern.length; ++i) { if (i % 4 == 0) s += " "; s += intern.charAt(i); } return s; } // Convert iban from string format to intern value. function intern(extern) { if (extern.substring(0, 4) == "IBAN") extern = extern.substring(4); var s = ""; for (var i = 0; i < extern.length; ++i) if (extern.charAt(i) != " ") s += extern.charAt(i); return s; } // Calculate the checksum and assemble the IBAN. function CalcIBAN(country, bank, account) { var fill_acc = FillAccount(country, account); var checksum = ChecksumIBAN(country.code + "00" + bank + fill_acc); return country.code + checksum + bank + fill_acc; } function CalcAltIBAN(country, bank, account) { var fill_acc = FillAccount(country, account); var checksum = ChecksumIBAN(country.code + "00" + bank + fill_acc); checksum = fill0("" + mod97(checksum), 2); return country.code + checksum + bank + fill_acc; } // Check the checksum of an IBAN. function IBANokay(iban) { return ChecksumIBAN(iban) == "97"; } // Check the syntax and the checksum of the IBAN. function CheckIBAN(ibanvalue) { // var form = document.ibanform; var iban = intern(ibanvalue); var code = iban.substring(0, 2); var checksum = iban.substring(2, 4); var bban = iban.substring(4); var country = CountryData(code); var err = null; if (country == null) err = _("Unknown Country Code: ") + code; else if (InvalidIBANlength(country, iban)) err = _("IBAN length ") + iban.length + _(" is not correct for ") + country.name + " (" + country.total_lng + ")"; else { var bank_lng = country.bank_lng; var bank = bban.substring(0, bank_lng); var account = bban.substring(bank_lng); if (InvalidBank(country, bank)) err = _("Bank/Branch Code ") + bank + _(" is not correct for ") + country.name; else if (InvalidAccount(country, account)) err = _("Account Number ") + account + _(" is not correct for ") + country.name; else if (!IBANokay(iban)) err = _("Checksum of IBAN incorrect"); } if (err) { return false; } else { return true; } } // Examples of IBANs for each country. var examples = new Array( new Array("AD", "00012030", "200359100100", "12"), new Array("AL", "21211009", "0000000235698741", "47"), new Array("AT", "19043", "00234573201", "61"), new Array("BA", "129007", "9401028494", "39"), new Array("BE", "539", "007547034", "68"), new Array("BG", "BNBG9661", "1020345678", "80"), new Array("CH", "00762", "011623852957", "93"), new Array("CY", "00200128", "0000001200527600", "17"), new Array("CZ", "0800", "0000192000145399", "65"), new Array("DE", "37040044", "0532013000", "89"), new Array("DK", "0040", "0440116243", "50"), new Array("EE", "22", "00221020145685", "38"), new Array("ES", "21000418", "450200051332", "91"), new Array("FI", "123456", "00000785", "21"), new Array("FO", "6460", "0001631634", "62"), new Array("FR", "2004101005", "0500013M02606", "14"), new Array("GB", "NWBK601613", "31926819", "29"), new Array("GE", "NB", "0000000101904917", "29"), new Array("GI", "NWBK", "000000007099453", "75"), new Array("GL", "6471", "0001000206", "89"), new Array("GR", "0110125", "0000000012300695", "16"), new Array("HR", "1001005", "1863000160", "12"), new Array("HU", "1177301", "61111101800000000", "42"), new Array("IE", "AIBK931152", "12345678", "29"), new Array("IL", "010800", "0000099999999", "62"), new Array("IS", "0159", "260076545510730339", "14"), new Array("IT", "X0542811101", "000000123456", "60"), new Array("KW", "CBKU", "0000000000001234560101", "81"), new Array("KZ", "125", "KZT5004100100", "86"), new Array("LB", "0999", "00000001001901229114", "62"), new Array("LI", "08810", "0002324013AA", "21"), new Array("LT", "10000", "11101001000", "12"), new Array("LU", "001", "9400644750000", "28"), new Array("LV", "BANK", "0000435195001", "80"), new Array("MC", "1273900070", "0011111000h79", "11"), new Array("ME", "505", "000012345678951", "25"), new Array("MK", "250", "120000058984", "07"), new Array("MR", "0002000101", "0000123456753", "13"), new Array("MT", "MALT01100", "0012345MTLCAST001S", "84"), new Array("MU", "BOMM0101", "101030300200000MUR", "17"), new Array("NL", "ABNA", "0417164300", "91"), new Array("NO", "8601", "1117947", "93"), new Array("PL", "10901014", "0000071219812874", "61"), new Array("PT", "00020123", "1234567890154", "50"), new Array("RO", "AAAA", "1B31007593840000", "49"), new Array("RS", "260", "005601001611379", "35"), new Array("SA", "80", "000000608010167519", "03"), new Array("SE", "500", "00000058398257466", "45"), new Array("SI", "19100", "0000123438", "56"), new Array("SK", "1200", "0000198742637541", "31"), new Array("SM", "U0322509800", "000000270100", "86"), new Array("TN", "10006", "035183598478831", "59"), new Array("TR", "00061", "00519786457841326", "33")); // Test data for each country. var test_data = new Array( new Array("XY", "1", "2", "33"), new Array("AD", "11112222", "C3C3C3C3C3C3", "11"), new Array("AD", "1111222", "C3C3C3C3C3C3", "11"), new Array("AD", "X1112222", "C3C3C3C3C3C3", "11"), new Array("AD", "111@2222", "C3C3C3C3C3C3", "11"), new Array("AD", "1111X222", "C3C3C3C3C3C3", "11"), new Array("AD", "1111222@", "C3C3C3C3C3C3", "11"), new Array("AD", "11112222", "@3C3C3C3C3C3", "11"), new Array("AD", "11112222", "C3C3C3C3C3C@", "11"), new Array("AL", "11111111", "B2B2B2B2B2B2B2B2", "54"), new Array("AL", "1111111", "B2B2B2B2B2B2B2B2", "54"), new Array("AL", "X1111111", "B2B2B2B2B2B2B2B2", "54"), new Array("AL", "1111111@", "B2B2B2B2B2B2B2B2", "54"), new Array("AL", "11111111", "@2B2B2B2B2B2B2B2", "54"), new Array("AL", "11111111", "B2B2B2B2B2B2B2B@", "54"), new Array("AT", "11111", "22222222222", "17"), new Array("AT", "1111", "22222222222", "17"), new Array("AT", "X1111", "22222222222", "17"), new Array("AT", "1111@", "22222222222", "17"), new Array("AT", "11111", "X2222222222", "17"), new Array("AT", "11111", "2222222222@", "17"), new Array("BA", "111222", "3333333344", "79"), new Array("BA", "11122", "3333333344", "79"), new Array("BA", "X11222", "3333333344", "79"), new Array("BA", "11@222", "3333333344", "79"), new Array("BA", "111X22", "3333333344", "79"), new Array("BA", "11122@", "3333333344", "79"), new Array("BA", "111222", "X333333344", "79"), new Array("BA", "111222", "3333333@44", "79"), new Array("BA", "111222", "33333333X4", "79"), new Array("BA", "111222", "333333334@", "79"), new Array("BE", "111", "222222233", "93"), new Array("BE", "11", "222222233", "93"), new Array("BE", "X11", "222222233", "93"), new Array("BE", "11@", "222222233", "93"), new Array("BE", "111", "X22222233", "93"), new Array("BE", "111", "222222@33", "93"), new Array("BE", "111", "2222222X3", "93"), new Array("BE", "111", "22222223@", "93"), new Array("BG", "AAAA2222", "33D4D4D4D4", "20"), new Array("BG", "AAAA222", "33D4D4D4D4", "20"), new Array("BG", "8AAA2222", "33D4D4D4D4", "20"), new Array("BG", "AAA@2222", "33D4D4D4D4", "20"), new Array("BG", "AAAAX222", "33D4D4D4D4", "20"), new Array("BG", "AAAA222@", "33D4D4D4D4", "20"), new Array("BG", "AAAA2222", "X3D4D4D4D4", "20"), new Array("BG", "AAAA2222", "3@D4D4D4D4", "20"), new Array("BG", "AAAA2222", "33@4D4D4D4", "20"), new Array("BG", "AAAA2222", "33D4D4D4D@", "20"), new Array("CH", "11111", "B2B2B2B2B2B2", "60"), new Array("CH", "1111", "B2B2B2B2B2B2", "60"), new Array("CH", "X1111", "B2B2B2B2B2B2", "60"), new Array("CH", "1111@", "B2B2B2B2B2B2", "60"), new Array("CH", "11111", "@2B2B2B2B2B2", "60"), new Array("CH", "11111", "B2B2B2B2B2B@", "60"), new Array("CY", "11122222", "C3C3C3C3C3C3C3C3", "29"), new Array("CY", "1112222", "C3C3C3C3C3C3C3C3", "29"), new Array("CY", "X1122222", "C3C3C3C3C3C3C3C3", "29"), new Array("CY", "11@22222", "C3C3C3C3C3C3C3C3", "29"), new Array("CY", "111X2222", "C3C3C3C3C3C3C3C3", "29"), new Array("CY", "1112222@", "C3C3C3C3C3C3C3C3", "29"), new Array("CY", "11122222", "@3C3C3C3C3C3C3C3", "29"), new Array("CY", "11122222", "C3C3C3C3C3C3C3C@", "29"), new Array("CZ", "1111", "2222222222222222", "68"), new Array("CZ", "111", "2222222222222222", "68"), new Array("CZ", "X111", "2222222222222222", "68"), new Array("CZ", "111@", "2222222222222222", "68"), new Array("CZ", "1111", "X222222222222222", "68"), new Array("CZ", "1111", "222222222222222@", "68"), new Array("DE", "11111111", "2222222222", "16"), new Array("DE", "1111111", "2222222222", "16"), new Array("DE", "X1111111", "2222222222", "16"), new Array("DE", "1111111@", "2222222222", "16"), new Array("DE", "11111111", "X222222222", "16"), new Array("DE", "11111111", "222222222@", "16"), new Array("DK", "1111", "2222222223", "79"), new Array("DK", "111", "2222222223", "79"), new Array("DK", "X111", "2222222223", "79"), new Array("DK", "111@", "2222222223", "79"), new Array("DK", "1111", "X222222223", "79"), new Array("DK", "1111", "22222222@3", "79"), new Array("DK", "1111", "222222222X", "79"), new Array("EE", "11", "22333333333334", "96"), new Array("EE", "1", "22333333333334", "96"), new Array("EE", "X1", "22333333333334", "96"), new Array("EE", "1@", "22333333333334", "96"), new Array("EE", "11", "X2333333333334", "96"), new Array("EE", "11", "2@333333333334", "96"), new Array("EE", "11", "22X33333333334", "96"), new Array("EE", "11", "223333333333@4", "96"), new Array("EE", "11", "2233333333333X", "96"), new Array("ES", "11112222", "334444444444", "71"), new Array("ES", "1111222", "334444444444", "71"), new Array("ES", "X1112222", "334444444444", "71"), new Array("ES", "111@2222", "334444444444", "71"), new Array("ES", "1111X222", "334444444444", "71"), new Array("ES", "1111222@", "334444444444", "71"), new Array("ES", "11112222", "X34444444444", "71"), new Array("ES", "11112222", "3@4444444444", "71"), new Array("ES", "11112222", "33X444444444", "71"), new Array("ES", "11112222", "33444444444@", "71"), new Array("FI", "111111", "22222223", "68"), new Array("FI", "11111", "22222223", "68"), new Array("FI", "X11111", "22222223", "68"), new Array("FI", "11111@", "22222223", "68"), new Array("FI", "111111", "X2222223", "68"), new Array("FI", "111111", "222222@3", "68"), new Array("FI", "111111", "2222222X", "68"), new Array("FO", "1111", "2222222223", "49"), new Array("FO", "111", "2222222223", "49"), new Array("FO", "X111", "2222222223", "49"), new Array("FO", "111@", "2222222223", "49"), new Array("FO", "1111", "X222222223", "49"), new Array("FO", "1111", "22222222@3", "49"), new Array("FO", "1111", "222222222X", "49"), new Array("FR", "1111122222", "C3C3C3C3C3C44", "44"), new Array("FR", "111112222", "C3C3C3C3C3C44", "44"), new Array("FR", "X111122222", "C3C3C3C3C3C44", "44"), new Array("FR", "1111@22222", "C3C3C3C3C3C44", "44"), new Array("FR", "11111X2222", "C3C3C3C3C3C44", "44"), new Array("FR", "111112222@", "C3C3C3C3C3C44", "44"), new Array("FR", "1111122222", "@3C3C3C3C3C44", "44"), new Array("FR", "1111122222", "C3C3C3C3C3@44", "44"), new Array("FR", "1111122222", "C3C3C3C3C3CX4", "44"), new Array("FR", "1111122222", "C3C3C3C3C3C4@", "44"), new Array("GB", "AAAA222222", "33333333", "45"), new Array("GB", "AAAA22222", "33333333", "45"), new Array("GB", "8AAA222222", "33333333", "45"), new Array("GB", "AAA@222222", "33333333", "45"), new Array("GB", "AAAAX22222", "33333333", "45"), new Array("GB", "AAAA22222@", "33333333", "45"), new Array("GB", "AAAA222222", "X3333333", "45"), new Array("GB", "AAAA222222", "3333333@", "45"), new Array("GE", "AA", "2222222222222222", "98"), new Array("GE", "A", "2222222222222222", "98"), new Array("GE", "8A", "2222222222222222", "98"), new Array("GE", "A@", "2222222222222222", "98"), new Array("GE", "AA", "X222222222222222", "98"), new Array("GE", "AA", "222222222222222@", "98"), new Array("GI", "AAAA", "B2B2B2B2B2B2B2B", "72"), new Array("GI", "AAA", "B2B2B2B2B2B2B2B", "72"), new Array("GI", "8AAA", "B2B2B2B2B2B2B2B", "72"), new Array("GI", "AAA@", "B2B2B2B2B2B2B2B", "72"), new Array("GI", "AAAA", "@2B2B2B2B2B2B2B", "72"), new Array("GI", "AAAA", "B2B2B2B2B2B2B2@", "72"), new Array("GL", "1111", "2222222223", "49"), new Array("GL", "111", "2222222223", "49"), new Array("GL", "X111", "2222222223", "49"), new Array("GL", "111@", "2222222223", "49"), new Array("GL", "1111", "X222222223", "49"), new Array("GL", "1111", "22222222@3", "49"), new Array("GL", "1111", "222222222X", "49"), new Array("GR", "1112222", "C3C3C3C3C3C3C3C3", "61"), new Array("GR", "111222", "C3C3C3C3C3C3C3C3", "61"), new Array("GR", "X112222", "C3C3C3C3C3C3C3C3", "61"), new Array("GR", "11@2222", "C3C3C3C3C3C3C3C3", "61"), new Array("GR", "111X222", "C3C3C3C3C3C3C3C3", "61"), new Array("GR", "111222@", "C3C3C3C3C3C3C3C3", "61"), new Array("GR", "1112222", "@3C3C3C3C3C3C3C3", "61"), new Array("GR", "1112222", "C3C3C3C3C3C3C3C@", "61"), new Array("HR", "1111111", "2222222222", "94"), new Array("HR", "111111", "2222222222", "94"), new Array("HR", "X111111", "2222222222", "94"), new Array("HR", "111111@", "2222222222", "94"), new Array("HR", "1111111", "X222222222", "94"), new Array("HR", "1111111", "222222222@", "94"), new Array("HU", "1112222", "34444444444444445", "35"), new Array("HU", "111222", "34444444444444445", "35"), new Array("HU", "X112222", "34444444444444445", "35"), new Array("HU", "11@2222", "34444444444444445", "35"), new Array("HU", "111X222", "34444444444444445", "35"), new Array("HU", "111222@", "34444444444444445", "35"), new Array("HU", "1112222", "X4444444444444445", "35"), new Array("HU", "1112222", "3X444444444444445", "35"), new Array("HU", "1112222", "344444444444444@5", "35"), new Array("HU", "1112222", "3444444444444444X", "35"), new Array("IE", "AAAA222222", "33333333", "18"), new Array("IE", "AAAA22222", "33333333", "18"), new Array("IE", "8AAA222222", "33333333", "18"), new Array("IE", "AAA@222222", "33333333", "18"), new Array("IE", "AAAAX22222", "33333333", "18"), new Array("IE", "AAAA22222@", "33333333", "18"), new Array("IE", "AAAA222222", "X3333333", "18"), new Array("IE", "AAAA222222", "3333333@", "18"), new Array("IL", "111222", "3333333344", "64"), new Array("IL", "11122", "3333333344", "64"), new Array("IL", "X11222", "3333333344", "64"), new Array("IL", "11@222", "3333333344", "64"), new Array("IL", "111X22", "3333333344", "64"), new Array("IL", "11122@", "3333333344", "64"), new Array("IL", "111222", "X333333333333", "64"), new Array("IL", "111222", "333333333333@", "64"), new Array("IS", "1111", "223333333333333333", "12"), new Array("IS", "111", "223333333333333333", "12"), new Array("IS", "X111", "223333333333333333", "12"), new Array("IS", "111@", "223333333333333333", "12"), new Array("IS", "1111", "X23333333333333333", "12"), new Array("IS", "1111", "2@3333333333333333", "12"), new Array("IS", "1111", "22X333333333333333", "12"), new Array("IS", "1111", "22333333333333333@", "12"), new Array("IT", "A2222233333", "D4D4D4D4D4D4", "43"), new Array("IT", "A222223333", "D4D4D4D4D4D4", "43"), new Array("IT", "82222233333", "D4D4D4D4D4D4", "43"), new Array("IT", "AX222233333", "D4D4D4D4D4D4", "43"), new Array("IT", "A2222@33333", "D4D4D4D4D4D4", "43"), new Array("IT", "A22222X3333", "D4D4D4D4D4D4", "43"), new Array("IT", "A222223333@", "D4D4D4D4D4D4", "43"), new Array("IT", "A2222233333", "@4D4D4D4D4D4", "43"), new Array("IT", "A2222233333", "D4D4D4D4D4D@", "43"), new Array("KW", "AAAA", "B2B2B2B2B2B2B2B2B2B2B2", "93"), new Array("KW", "AAA", "B2B2B2B2B2B2B2B2B2B2B2", "93"), new Array("KW", "8AAA", "B2B2B2B2B2B2B2B2B2B2B2", "93"), new Array("KW", "AAA@", "B2B2B2B2B2B2B2B2B2B2B2", "93"), new Array("KW", "AAAA", "@2B2B2B2B2B2B2B2B2B2B2", "93"), new Array("KW", "AAAA", "B2B2B2B2B2B2B2B2B2B2B@", "93"), new Array("KZ", "111", "B2B2B2B2B2B2B", "21"), new Array("KZ", "11", "B2B2B2B2B2B2B", "21"), new Array("KZ", "X11", "B2B2B2B2B2B2B", "21"), new Array("KZ", "11@", "B2B2B2B2B2B2B", "21"), new Array("KZ", "111", "@2B2B2B2B2B2B", "21"), new Array("KZ", "111", "B2B2B2B2B2B2@", "21"), new Array("LB", "1111", "B2B2B2B2B2B2B2B2B2B2", "88"), new Array("LB", "111", "B2B2B2B2B2B2B2B2B2B2", "88"), new Array("LB", "X111", "B2B2B2B2B2B2B2B2B2B2", "88"), new Array("LB", "111@", "B2B2B2B2B2B2B2B2B2B2", "88"), new Array("LB", "1111", "@2B2B2B2B2B2B2B2B2B2", "88"), new Array("LB", "1111", "B2B2B2B2B2B2B2B2B2B@", "88"), new Array("LI", "11111", "B2B2B2B2B2B2", "73"), new Array("LI", "1111", "B2B2B2B2B2B2", "73"), new Array("LI", "X1111", "B2B2B2B2B2B2", "73"), new Array("LI", "1111@", "B2B2B2B2B2B2", "73"), new Array("LI", "11111", "@2B2B2B2B2B2", "73"), new Array("LI", "11111", "B2B2B2B2B2B@", "73"), new Array("LT", "11111", "22222222222", "15"), new Array("LT", "1111", "22222222222", "15"), new Array("LT", "X1111", "22222222222", "15"), new Array("LT", "1111@", "22222222222", "15"), new Array("LT", "11111", "X2222222222", "15"), new Array("LT", "11111", "2222222222@", "15"), new Array("LU", "111", "B2B2B2B2B2B2B", "27"), new Array("LU", "11", "B2B2B2B2B2B2B", "27"), new Array("LU", "X11", "B2B2B2B2B2B2B", "27"), new Array("LU", "11@", "B2B2B2B2B2B2B", "27"), new Array("LU", "111", "@2B2B2B2B2B2B", "27"), new Array("LU", "111", "B2B2B2B2B2B2@", "27"), new Array("LV", "AAAA", "B2B2B2B2B2B2B", "86"), new Array("LV", "AAA", "B2B2B2B2B2B2B", "86"), new Array("LV", "8AAA", "B2B2B2B2B2B2B", "86"), new Array("LV", "AAA@", "B2B2B2B2B2B2B", "86"), new Array("LV", "AAAA", "@2B2B2B2B2B2B", "86"), new Array("LV", "AAAA", "B2B2B2B2B2B2@", "86"), new Array("MC", "1111122222", "C3C3C3C3C3C44", "26"), new Array("MC", "111112222", "C3C3C3C3C3C44", "26"), new Array("MC", "X111122222", "C3C3C3C3C3C44", "26"), new Array("MC", "1111@22222", "C3C3C3C3C3C44", "26"), new Array("MC", "11111X2222", "C3C3C3C3C3C44", "26"), new Array("MC", "111112222@", "C3C3C3C3C3C44", "26"), new Array("MC", "1111122222", "@3C3C3C3C3C44", "26"), new Array("MC", "1111122222", "C3C3C3C3C3@44", "26"), new Array("MC", "1111122222", "C3C3C3C3C3CX4", "26"), new Array("MC", "1111122222", "C3C3C3C3C3C4@", "26"), new Array("ME", "111", "222222222222233", "38"), new Array("ME", "11", "222222222222233", "38"), new Array("ME", "X11", "222222222222233", "38"), new Array("ME", "11@", "222222222222233", "38"), new Array("ME", "111", "X22222222222233", "38"), new Array("ME", "111", "222222222222@33", "38"), new Array("ME", "111", "2222222222222X3", "38"), new Array("ME", "111", "22222222222223@", "38"), new Array("MK", "111", "B2B2B2B2B233", "41"), new Array("MK", "11", "B2B2B2B2B233", "41"), new Array("MK", "X11", "B2B2B2B2B233", "41"), new Array("MK", "11@", "B2B2B2B2B233", "41"), new Array("MK", "111", "@2B2B2B2B233", "41"), new Array("MK", "111", "B2B2B2B2B@33", "41"), new Array("MK", "111", "B2B2B2B2B2X3", "41"), new Array("MK", "111", "B2B2B2B2B23@", "41"), new Array("MR", "1111122222", "3333333333344", "21"), new Array("MR", "111112222", "3333333333344", "21"), new Array("MR", "X111122222", "3333333333344", "21"), new Array("MR", "1111@22222", "3333333333344", "21"), new Array("MR", "11111X2222", "3333333333344", "21"), new Array("MR", "111112222@", "3333333333344", "21"), new Array("MR", "1111122222", "X333333333344", "21"), new Array("MR", "1111122222", "3333333333@44", "21"), new Array("MR", "1111122222", "33333333333X4", "21"), new Array("MR", "1111122222", "333333333334@", "21"), new Array("MT", "AAAA22222", "C3C3C3C3C3C3C3C3C3", "39"), new Array("MT", "AAAA2222", "C3C3C3C3C3C3C3C3C3", "39"), new Array("MT", "8AAA22222", "C3C3C3C3C3C3C3C3C3", "39"), new Array("MT", "AAA@22222", "C3C3C3C3C3C3C3C3C3", "39"), new Array("MT", "AAAAX2222", "C3C3C3C3C3C3C3C3C3", "39"), new Array("MT", "AAAA2222@", "C3C3C3C3C3C3C3C3C3", "39"), new Array("MT", "AAAA22222", "@3C3C3C3C3C3C3C3C3", "39"), new Array("MT", "AAAA22222", "C3C3C3C3C3C3C3C3C@", "39"), new Array("MU", "AAAA2222", "333333333333333DDD", "37"), new Array("MU", "AAAA222", "333333333333333DDD", "37"), new Array("MU", "8AAA2222", "333333333333333DDD", "37"), new Array("MU", "AAA@2222", "333333333333333DDD", "37"), new Array("MU", "AAAAX222", "333333333333333DDD", "37"), new Array("MU", "AAAA222@", "333333333333333DDD", "37"), new Array("MU", "AAAA2222", "X33333333333333DDD", "37"), new Array("MU", "AAAA2222", "33333333333333@DDD", "37"), new Array("MU", "AAAA2222", "3333333333333338DD", "37"), new Array("MU", "AAAA2222", "333333333333333DD@", "37"), new Array("NL", "AAAA", "2222222222", "57"), new Array("NL", "AAA", "2222222222", "57"), new Array("NL", "8AAA", "2222222222", "57"), new Array("NL", "AAA@", "2222222222", "57"), new Array("NL", "AAAA", "X222222222", "57"), new Array("NL", "AAAA", "222222222@", "57"), new Array("NO", "1111", "2222223", "40"), new Array("NO", "111", "2222223", "40"), new Array("NO", "X111", "2222223", "40"), new Array("NO", "111@", "2222223", "40"), new Array("NO", "1111", "X222223", "40"), new Array("NO", "1111", "22222@3", "40"), new Array("NO", "1111", "222222X", "40"), new Array("PL", "11111111", "2222222222222222", "84"), new Array("PL", "1111111", "2222222222222222", "84"), new Array("PL", "X1111111", "2222222222222222", "84"), new Array("PL", "1111111@", "2222222222222222", "84"), new Array("PL", "11111111", "X222222222222222", "84"), new Array("PL", "11111111", "222222222222222@", "84"), new Array("PT", "11112222", "3333333333344", "59"), new Array("PT", "1111222", "3333333333344", "59"), new Array("PT", "X1112222", "3333333333344", "59"), new Array("PT", "111@2222", "3333333333344", "59"), new Array("PT", "1111X222", "3333333333344", "59"), new Array("PT", "1111222@", "3333333333344", "59"), new Array("PT", "11112222", "X333333333344", "59"), new Array("PT", "11112222", "3333333333@44", "59"), new Array("PT", "11112222", "33333333333X4", "59"), new Array("PT", "11112222", "333333333334@", "59"), new Array("RO", "AAAA", "B2B2B2B2B2B2B2B2", "91"), new Array("RO", "AAA", "B2B2B2B2B2B2B2B2", "91"), new Array("RO", "8AAA", "B2B2B2B2B2B2B2B2", "91"), new Array("RO", "AAA@", "B2B2B2B2B2B2B2B2", "91"), new Array("RO", "AAAA", "@2B2B2B2B2B2B2B2", "91"), new Array("RO", "AAAA", "B2B2B2B2B2B2B2B@", "91"), new Array("RS", "111", "222222222222233", "48"), new Array("RS", "11", "222222222222233", "48"), new Array("RS", "X11", "222222222222233", "48"), new Array("RS", "11@", "222222222222233", "48"), new Array("RS", "111", "X22222222222233", "48"), new Array("RS", "111", "222222222222@33", "48"), new Array("RS", "111", "2222222222222X3", "48"), new Array("RS", "111", "22222222222223@", "48"), new Array("SA", "11", "B2B2B2B2B2B2B2B2B2", "46"), new Array("SA", "1", "B2B2B2B2B2B2B2B2B2", "46"), new Array("SA", "X1", "B2B2B2B2B2B2B2B2B2", "46"), new Array("SA", "1@", "B2B2B2B2B2B2B2B2B2", "46"), new Array("SA", "11", "@2B2B2B2B2B2B2B2B2", "46"), new Array("SA", "11", "B2B2B2B2B2B2B2B2B@", "46"), new Array("SE", "111", "22222222222222223", "32"), new Array("SE", "11", "22222222222222223", "32"), new Array("SE", "X11", "22222222222222223", "32"), new Array("SE", "11@", "22222222222222223", "32"), new Array("SE", "111", "X2222222222222223", "32"), new Array("SE", "111", "222222222222222@3", "32"), new Array("SE", "111", "2222222222222222X", "32"), new Array("SI", "11111", "2222222233", "92"), new Array("SI", "1111", "2222222233", "92"), new Array("SI", "X1111", "2222222233", "92"), new Array("SI", "1111@", "2222222233", "92"), new Array("SI", "11111", "X222222233", "92"), new Array("SI", "11111", "2222222@33", "92"), new Array("SI", "11111", "22222222X3", "92"), new Array("SI", "11111", "222222223@", "92"), new Array("SK", "1111", "2222222222222222", "66"), new Array("SK", "111", "2222222222222222", "66"), new Array("SK", "X111", "2222222222222222", "66"), new Array("SK", "111@", "2222222222222222", "66"), new Array("SK", "1111", "X222222222222222", "66"), new Array("SK", "1111", "222222222222222@", "66"), new Array("SM", "A2222233333", "D4D4D4D4D4D4", "71"), new Array("SM", "A222223333", "D4D4D4D4D4D4", "71"), new Array("SM", "82222233333", "D4D4D4D4D4D4", "71"), new Array("SM", "AX222233333", "D4D4D4D4D4D4", "71"), new Array("SM", "A2222@33333", "D4D4D4D4D4D4", "71"), new Array("SM", "A22222X3333", "D4D4D4D4D4D4", "71"), new Array("SM", "A222223333@", "D4D4D4D4D4D4", "71"), new Array("SM", "A2222233333", "@4D4D4D4D4D4", "71"), new Array("SM", "A2222233333", "D4D4D4D4D4D@", "71"), new Array("TN", "11222", "333333333333344", "23"), new Array("TN", "1122", "333333333333344", "23"), new Array("TN", "X1222", "333333333333344", "23"), new Array("TN", "1@222", "333333333333344", "23"), new Array("TN", "11X22", "333333333333344", "23"), new Array("TN", "1122@", "333333333333344", "23"), new Array("TN", "11222", "X33333333333344", "23"), new Array("TN", "11222", "333333333333@44", "23"), new Array("TN", "11222", "3333333333333X4", "23"), new Array("TN", "11222", "33333333333334@", "23"), new Array("TR", "11111", "BC3C3C3C3C3C3C3C3", "95"), new Array("TR", "1111", "BC3C3C3C3C3C3C3C3", "95"), new Array("TR", "X1111", "BC3C3C3C3C3C3C3C3", "95"), new Array("TR", "1111@", "BC3C3C3C3C3C3C3C3", "95"), new Array("TR", "11111", "@C3C3C3C3C3C3C3C3", "95"), new Array("TR", "11111", "B@3C3C3C3C3C3C3C3", "95"), new Array("TR", "11111", "BC3C3C3C3C3C3C3C@", "95"), new Array("DE", "12345678", "5", "06"), new Array("DE", "12345678", "16", "97"), new Array("DE", "12345678", "16", "00"), new Array("DE", "12345678", "95", "98"), new Array("DE", "12345678", "95", "01")); // Translation table and translation function for localized versions var trans_tab = new Array(); function _(s) { var t = trans_tab[s]; if (t) s = t; return s; } // Fill the translation table function fill_trans_tab(trans_data) { for (var i = 0; i < trans_data.length / 2; ++i) trans_tab[trans_data[2 * i]] = trans_data[2 * i + 1]; // Translate the country names in the iban_data list for (var i = 0; i < iban_data.length; ++i) iban_data[i].name = _(iban_data[i].name); } function debug_iban_data() { var s = ""; for (var i = 0; i < iban_data.length; ++i) { var country = iban_data[i]; s += country.name + " / " + country.code + " / "; for (var f = 0; f < country.bank.length; ++f) s += country.bank[f][0] + country.bank[f][1]; s += " = " + country.bank_lng + " / "; for (var f = 0; f < country.acc.length; ++f) s += country.acc[f][0] + country.acc[f][1]; s += " = " + country.acc_lng + " / " + country.total_lng + "\n"; } alert(s); } function debug_check_vars() { var o = false; var s = ""; for (var v in window) { if (o) s += "" + v + "=" + window[v] + "\n"; if (v == "debug_check_vars") o = true; } if (s != "") alert("vars:\n" + s); else alert("no vars"); } var passwordstrengthlevel = ''; jQuery.validator.setDefaults({ ignore: ':hidden', rules: { username: { required: true, minlength: 2, remote: "./includes/scripts/ajax_affdetails.asp" }, emailaddress: { minlength: 2, remote: "../includes/scripts/ajax_affdetails.asp" }, verificationimg: { minlength: 1, remote: "./includes/scripts/ajax_affdetails.asp" }, passwordretype: { required: true, equalTo: "#password" } }, messages:{ verificationimg:"Please enter the text as it appears in the image above." }, /*submitHandler: function(form) { alert("Validation has completed - submit form now"); form.submit(); },*/ // the errorPlacement has to take the table layout into account errorPlacement: function(error, element) { jQuery("#" + element.attr('id') + "status").html(''); error.appendTo(jQuery("#" + element.attr('id') + "status")); var thislabel = "#" + element.attr('id') + "req"; jQuery(thislabel).addClass("error"); var Adderrorfield = ""; if ( element.attr('id') =="securityquestion" || element.attr('id') =="securityquestioncustom") { Adderrorfield = "securityquestioncustom"; } //if (element.attr('id') =="securityquestioncustom"){ Adderrorfield = "securityquestion";} if (Adderrorfield.length>0){ error.appendTo(jQuery("#" + Adderrorfield + "status")); var thislabel = "#" + Adderrorfield + "req"; jQuery(thislabel).addClass("error"); } }, // set this class to error-labels to indicate valid fields success: function(label) { // set as text for IE //label.html(" ").addClass("checked"); var thislabel = "#" + label.attr('for') + "status"; jQuery(thislabel).html(label.html(" ").addClass("checked")); var Adderrorfield = ""; if (label.attr('for') =="securityquestion"){ Adderrorfield = "securityquestioncustom";} if (label.attr('for') =="securityquestioncustom"){ Adderrorfield = "securityquestion";} if (Adderrorfield.length>0){ var thislabel = "#" + Adderrorfield + "status"; jQuery(thislabel).html(" ").addClass("checked"); } } }); jQuery.extend(jQuery.validator.messages, { required: "This field is required.", remote: "Already exists - Please enter a Different value.", email: "Please enter a valid email address", url: "Please enter a valid URL", date: "Please enter a valid date.", dateISO: "Please enter a valid date (ISO).", number: "Please enter a valid number.", digits: "Please enter only digits.", creditcard: "Please enter a valid credit card number.", equalTo: "Please enter the same value again", accept: "Please enter a value with a valid extension.", maxlength: jQuery.validator.format("Please enter no more than {0} characters."), minlength: jQuery.validator.format("Please enter at least {0} characters. No spaces allowed"), rangelength: jQuery.validator.format("Please enter a value between {0} and {1} characters long."), range: jQuery.validator.format("Please enter a value between {0} and {1}."), max: jQuery.validator.format("Please enter a value less than or equal to {0}."), min: jQuery.validator.format("Please enter a value greater than or equal to {0}.") }); jQuery(function() { // Add Program Specific validation jQuery.validator.addMethod("notEqualTo", function(value, element, param) { return this.optional(element) || value != jQuery(param).val(); }, "This value is not allowed"); jQuery.validator.addMethod("notValue", function(value, element, param ) { return this.optional(element) || value != param; }, "This value is not allowed"); jQuery.validator.addMethod("reqLengths", function(value, element, param ) { validlength = false; var length = this.getLength(jQuery.trim(value), element); var i=0; for (i=0;i<=param.length;i++) { if (length == param[i]) validlength=true; } jQuery.validator.messages.reqLengths = "The Length appears to be invalid" + param.join(","); return validlength; }, jQuery.validator.format("The Length appears to be invalid")); jQuery.validator.addMethod("maxDecimalPoints", function(value, element, param ) { var valNumPlaces = true; if (value.indexOf(".") != -1) { if(value.substring(value.indexOf("."), value.length).length -1 > param) { valNumPlaces = false; } } return this.optional(element) || valNumPlaces; }, "Too many decimal places."); jQuery.validator.addMethod("noDecimals", function(value, element, param ) { return value.indexOf(".") == -1; }, "Number cannot be a decimal."); jQuery.validator.addMethod("isUploadValidationNeed", function (value, element) { var reg =/[\;\s\@\!\#\$\£\€\%\^\&\*\(\)\=\+\']/i; var filenamenopath = stripFilePath(value); if (filenamenopath.match(reg) == null) { jQuery(element).removeClass("error"); return true; } else { jQuery(element).removeClass("valid"); jQuery(element).addClass("error"); alert("File name cannot contains these characters: \r\n BlanckSpace ;@!#$£€%^&*()=+."); return false; } }, "File name cannot contains these characters: BlanckSpace @!#$£€%^&*()=+." ); jQuery.validator.addMethod("sqlInt", function (value, element) { // Integer (whole number) data from -2^31 (-2,147,483,648) through 2^31 - 1 (2,147,483,647). var req=((this.optional(element)== false)? (/^\d+$/.test(value)): (value.length==0) ) ; if (req) { var num = parseInt(value); req = (((-2147483648) > num || (2147483647) < num) ? false : req); } return req; }, "Please enter only digits." ); jQuery.validator.addMethod("alphaNumeric", function (value, element) { return this.optional(element) || /^(.*)+$/.test(value); }, "Field can only contain only letters, numbers." ); jQuery.validator.addMethod("allowedstring", function(value, element) { return this.optional(element) || (/^[a-zA-Z0-9 ._@#*&,\/-]+$/i.test(value)); },jQuery.validator.format("Field can contain only letters and numbers."," ._@#*&,\/-") ); jQuery.validator.addMethod("allowedstring2", function(value, element) { return this.optional(element) || (/^[a-zA-Z0-9\%|\^|\*|\(|\)|\+|\=|\[|\]|\\\|\'|\{|\}|\"|\:|\<|\>|\?]+$/i.test(value)); },jQuery.validator.format("Field can contain only letters and numbers.","\%|\^|\*|\(|\)|\+|\=|\[|\]|\\\|\'|\{|\}|\"|\:|\<|\>|\?") ); jQuery.validator.addMethod("isphone", function(value, element) { return this.optional(element) || /^[ .+()0-9-]+$/.test(value); },jQuery.validator.format("Please check the Phone number") ); jQuery.validator.addMethod("alphabetic", function(value, element) { return this.optional(element) || /^[^0-9()]+$/.test(value); },jQuery.validator.format("Field can not contain numbers") ); jQuery.validator.addMethod("isvat", function(value, element) { return this.optional(element) || checkVATNumber (value); },"Check the VAT value" ); jQuery.validator.addMethod("isiban", function(value, element) { return this.optional(element) || CheckIBAN(value); },"jscheckiban" ); jQuery.validator.addMethod("is14digits", function(value, element) { return this.optional(element) || /([0-9()]{14})+$/.test(value); },"Enter 14 digits" ); jQuery.validator.addMethod("is8digits", function(value, element) { return this.optional(element) || /([0-9()]{8})+$/.test(value); },"Enter only 8 digits" ); jQuery.validator.addMethod("is6digits", function(value, element) { return this.optional(element) || /([0-9()]{6})+$/.test(value); },"Enter only 6 digits" ); jQuery.validator.addMethod("isbicswift", function(value, element) { var regSWIFT = /^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/; return this.optional(element) || regSWIFT.test(value); },"Check the BIC/Swift entered." ); jQuery.validator.addMethod("isKeyword", function(value, element) { var regTest = /[\?\%\;*&,\.\"\/\\]+/; return value.length==0 || (regTest.test(value)? false:true); },"jsisKeyword" ); jQuery.validator.addMethod("Bdate", function(date, element) { return this.optional(element) || date.match(/^(([012]\d)|3[01])((0\d)|(1[012]))(\d{2})(-([0-9()]{4}))$/); },"Please specify a valid date followd by sequence number [DDMMYY]-[SSSS]"); jQuery.validator.addMethod("BdateBKUP", function(date, element) { return this.optional(element) || date.match(/^\d{2}((0\d)|(1[012]))(([012]\d)|3[01])(-([0-9()]{4}))$/); },"Please specify a valid date followd by sequence number [YYMMDD]-[SSSS]"); jQuery.validator.addMethod("Bdatea", function(date, element) { return this.optional(element) || date.match(/^\d{2}((0\d)|(1[012]))(([012]\d)|3[01])$/); },"The valid date is (CPR): DDMMYY-SSSS"); jQuery.validator.addMethod("PhoneFormat", function(date, element) { return this.optional(element) || date.match(/^([\+|00]\d{1,2})(-\d{1,10})$/); },"The valid phone number is +XX-XXXXXXXXXX or 00X-XXXXXXXXXX"); jQuery.validator.addMethod("checkpaymentCountry", function(value, element) { return false; },"Please enter the country." ); jQuery.validator.addMethod("ispassword", function(value, element) { if (passwordstrengthlevel>0) { var checkstrength = testPassword(value); if (passwordstrengthlevel> (checkstrength+1)){ return false; } else{ return true; } } else{ return true; } } ,"The Password is too weak - try using both upper and lower case letters, numbers and include Characters like !@#$_~" ); jQuery.validator.addMethod("securityquestions", function (value, element) { var securityquestiondropdown = jQuery("#securityquestion").val(); var securityquestioncustom = jQuery("#securityquestioncustom").val(); if(securityquestiondropdown.length==0 && securityquestioncustom.length==0 ) { return false; }else { return true; } }, "Please select a security question" ); jQuery.validator.addMethod("securityquestions2", function (value, element) { var securityquestiondropdown = jQuery("#securityquestion").val(); var securityquestioncustom = jQuery("#securityquestioncustom").val(); if( ((securityquestiondropdown.length>0) || (securityquestioncustom.length>0)) && (value.length==0) ) { return false; }else { return true; } }, "Check security question answer" ); jQuery.validator.addMethod("iscrsize", function(value, element) { if (value.length>0){ return /^\d+$/.test(value); } else { var e = jQuery(element); var form = e.closest('form')[0]; if (( jQuery('#displaytype').val()=='banner') && (jQuery('#' + form.id + ' select[name="SELfiletype"]').val()=="File" )) {// width/height is option if we have a file1value , required if fileurl is in use return true; } else { return /^\d+$/.test(value); } } },jQuery.validator.format("Please enter a valid number.") ); jQuery.validator.addMethod("website", function(value, element) { return this.optional(element) || /(https|http):\/\/([_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+)(([_a-zA-Z\d\-\\\.\/]+[_a-zA-Z\d\-\\\/])+)*/.test(value); ; },jQuery.validator.format("Please enter a valid URL") ); jQuery.validator.addMethod("dob", function(value, element) { if (value.length>0) return true; return false; },jQuery.validator.format("JQValidatedateofbirth") ); //TT8820 - this value will check the VAT status and VAT number jQuery.validator.addMethod("ukvatrequirement", function(value, element) { if (value.trim() == "UK Company – UK VAT Registered including Isle Of Man") { //VAT number will be required if this status chosen, otherwise optional jQuery("input[isvat='true']").rules("add", {required:true}); jQuery("input[isvat='true']").valid(); } else { jQuery("input[isvat='true']").rules("add", {required:false}); } if(value.trim() == "") { return false; } return true; },"jscheckvatstatus" ); }); // jQuery.validator.addClassRules jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/; while(xWeakest |
Weak |
Improving |
Strong |
Strongest |