var ERR_MISSING_CREDITCARD                = 1001;
var ERR_FAILED_PAYMENT                    = 1002;
var ERR_MISSING_SEND_CHANNEL              = 1003;
var ERR_INCOMPLETE_ADDRESS                = 1004;
var WARNING_BAD_PAYMENTDUES               = 1005;
var WARNING_ARCHIVED_CAMPAIGN             = 1006;
var WARNING_READ_ONLY                     = 1007;
var ERR_TOO_MANY_CC_PAYMENTS              = 1008;
var WARNING_PLEASE_SAVE_BEFORE_QUITTING   = 1009;
var ERR_MISSING_CHEQUE_NUMBER             = 1015;
var ERR_PRICING_POLARITY_CHANGE           = 1020;
var ERR_CANNOT_MIX_WL_STAYS_WITH_NORMAL_STAYS = 4101;

var textFormats = {
   'text' : /^\w*$/,
   'text_point' : /^[\w\.]*$/,
   'int' : /^\d*$/,
   'uint' : /^\-?\d*$/,
   'positiv_int' : /^[1-9]\d*$/,
   'positiv_int_include_zero' : /^[0-9]\d*$/,
   'float' : /^\d*\.?\d*$/,
   'ufloat' : /^\-?\d*\.?\d*$/,
   'money' : /^\d+\.\d{2,2}$/,
   'smoney' : /^\-?\d+\.\d{2,2}$/,
   'money_special' : /^\d+\.\d{2,2}|\-$/,
   'step' : /^[1-9]\d?$/,
   'step0' : /^\d{1,2}$/,
   'stay' : /^[1-9]\d{0,2}$/,
   'product_code' : /^[0-9A-Z_]{1,9}$/,
   'char2' : /^[0-9A-Z_]{1,2}$/,
   'char4' : /^[0-9A-Z_]{1,4}$/,
   'char9' : /^[0-9A-Z_]{1,9}$/,
   'char10' : /^[0-9A-Z_]{1,10}$/,
   'char30' : /^.{0,30}$/,
   'alpha10' : /^[0-9A-Za-z\/_]{1,10}$/,
   'num4' : /^[0-9]{1,4}$/,
   'num3' : /^[0-9]{1,3}$/,
   'num2' : /^[0-9]{1,2}$/,
   'color_code' : /^[0-9A-F]{6,6}$/,
   'quantity' : /^\d{1,3}\.\d{2,2}$/,
   'squantity' : /^\-?\d{1,3}\.\d{2,2}$/,
   'squantitydif0' : /^\-?[1-9][0-9]{0,2}\.\d{2,2}$/,
   'customer_code' : /^[0-9A-Z_\/]{1,9}$/,
   'amount_pct' : /^%\d{1,2}\.\d{2,2}|\d{1,2}\.\d{2,2}%|%100\.00|100\.00%|\d+\.\d{2,2}$/,
   'amount_pct_hyphen' : /^%\d{1,2}\.\d{2,2}|\d{1,2}\.\d{2,2}%|%100\.00|100\.00%|\d+\.\d{2,2}|-$/,
   'pct' : /^%\d{1,2}\.\d{2,2}|\d{1,2}\.\d{2,2}%|%100\.00|100\.00%$/,
   'pctb' : /^\d{1,2}\.\d{2,2}|\d{1,2}\.\d{2,2}|100\.00|100\.00$/,
   'avaibility_pct' : /^%\d{1,2}\.\d{2,2}|\d{1,2}\.\d{2,2}%|%100\.00|100\.00%|\d+$/,
   'age' : /^\d{1,2}\.?\d?$/,
   'hour' : /^[0-2]?[0-9]\:[0-5]?[0-9]$/,
   'visa' : /^4(\d){15}$/,
   'cb' : /^4(\d){15}$/,
   'mastercard' : /^5(\d){15}$/,
   'amex' : /^3(\d){14}$/,
   'aurore' : /^(\d){19}$/,
   'email' : /^[a-zA-Z0-9\-_\.]+@[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,5}$/
};

/*
  The array of fields to be checked:
  0 - Is empty allowed
  1 - If empty message
  2 - Text format name
  3 - If bad format message
  4 - Function name to be called (param�tres: inputName, formName)
  5 - Is check active
  6 - Array of valid actions (if null then any action is valid)
*/
var fields = new Array();
var multipleFields = new Array();


function setInputChecker( inputName, isEmptyAllowed, emptyMessage, textFormat, formatMessage, functionName, actionName, bFocus )
{
  fields[ inputName ] = new Array( isEmptyAllowed, emptyMessage, textFormat, formatMessage, functionName, bFocus );
  if( actionName != null )
  {
    fields[ inputName ][ 6 ] = new Array( );

    for( var i = 6 ; i < setInputChecker.arguments.length ; i++ )
    {
      fields[ inputName ][ 6 ][ fields[ inputName ][ 6 ].length ] = setInputChecker.arguments[ i ];
    }
  }
}

function setCheckSubstitute(inputNameSub, inputNameDiscount, inputNameSup, MsgErreur)
{
  var SubPrice = fields[ inputNameSub ];
  if(SubPrice != 0 && SubPrice)
  {
    var Discount = fields[ inputNameDiscount];
    var Sup = fields[ inputNameSup ];
    if((Discount != 0 && Discount) || (Sup != 0 && Sup))
    {
      alert(MsgErreur);
      return false;
    }
  }
  return true;
}

function isInputChecker( inputName )
{
  return fields[ inputName ] ? true : false;
}

function copyInputChecker( inputNameSrc, inputNameDest )
{
  fields[ inputNameDest ] = fields[ inputNameSrc ];
}

function disableInputChecker( inputName )
{
  //alert( 'disableInputChecker=' + inputName  );
  if( fields[ inputName ] != null )
  {
    fields[ inputName ][ 5 ] = false;
  }
}

function enableInputChecker( inputName )
{
  if( fields[ inputName ] != null )
  {
    //alert( 'enableInputChecker=' + inputName  );
    fields[ inputName ][ 5 ] = true;
  }
}

function removeInputChecker( inputName )
{
  if( fields[ inputName ] != null )
  {
    delete fields[ inputName ];
  }
}

function validateForm( formName, actionName )
{
  if( !formName || !getForm( formName ))
  {
    return true;
  }

  var elements = getForm( formName ).elements;

  //alert( elements + ' length=' + elements.length );

  for( var i = 0 ; i < elements.length ; i++ )
  {
    var element = elements[ i ];

    //alert( element.name );

    if( actionName != null )
    {
      if( !isValidAction( element.name, actionName ) )
      {
        continue;
      }
    }

    if( !checkInput( element.name, formName ) )
    {
      return false;
    }
  }

  if( !validateMultipleInputs( formName ) )
  {
    return false;
  }

  return true;
}

function validateAction( formName, actionName )
{
  if( formName == null )
  {
    return;
  }

  var elements = getForm( formName ).elements;

  for( var i = 0 ; i < elements.length ; i++ )
  {
    var element = elements[ i ];

    if( isValidAction( element.name, actionName ) )
    {
      if( !checkInput( element.name, formName ) )
      {
        return false;
      }
    }
  }

  return true;
}

function setValidAction( inputName, actionName )
{
  if( fields[ inputName ][ 6 ] == null )
  {
    fields[ inputName ][ 6 ] = new Array();
  }
  if( !isValidAction( inputName, actionName ) )
  {
    fields[ inputName ][ 6 ][ fields[ inputName ][ 6 ].length ] = actionName;
  }
}

function isValidAction( inputName, actionName )
{
  if( fields[ inputName ] == null )
  {
    return false;
  }

  if( fields[ inputName ][ 6 ] == null )
  {
    return false;
  }

  for( var i=0 ; i < fields[ inputName ][ 6 ].length ; i++ )
  {
    if( fields[ inputName ][ 6 ][ i ] == actionName )
    {
      return true;
    }
  }

  return false;
}

function checkInput( inputName, formName )
{
  var element = getFormObject( inputName, formName );
  //alert( element + ' ' + inputName + ' ' + fields[ element.name ] );

  if( fields[ element.name ] == null ||
      element.disabled == true )
  {
    //alert( 'TRUE: fields[ element.name ] == null || element.disabled == true ---> ' + fields[ element.name ] + ' ' + element.disabled );
    return true;
  }

  var isCheckActive = fields[ element.name ][ 5 ];
  if( isCheckActive == false )
  {
    //alert( 'TRUE: isCheckActive == false ---> ' + element.name + ' ' + isCheckActive );
    return true;
  }

  var isEmptyAllowed = fields[ element.name ][ 0 ];
  var bFocus = fields[ element.name ][ 5 ]; 
  //alert( ( getInputValue( element.name, formName ) == '' ) + ' ' + (isEmptyAllowed != null) + ' ' + (isEmptyAllowed != '') + ' isEmptyAllowed=' + isEmptyAllowed );

  var sInputValue = getInputValue( element.name, formName );
  if( ( sInputValue == '' || sInputValue == null ) && isEmptyAllowed != null )
  {
    //alert( 'isEmptyAllowed ---> ' + isEmptyAllowed );
    if( !isEmptyAllowed )
    {
      //alert( 'Empty not allowed for: ' + fields[ element.name ]);
      alert( fields[ element.name ][ 1 ] );
      focusObject( element, bFocus );
      return false;
    }
    else
    {
      var functionName = fields[ element.name ][ 4 ];
      //alert( element.name + ' ' + functionName );
      if( functionName != null && functionName != '' )
      {
        var ret = evalFunc( functionName, inputName, formName );
        return ret;
      }
      return true;
    }
  }

  if ( element.type == 'text' ||
       element.type == 'password' ||
       element.type == 'textarea' )
  {
    var textFormat = textFormats[ fields[ element.name ][ 2 ] ];
    if( textFormat != '' && textFormat != null )
    {
      //alert( 'Format checked for: ' + textFormats[ fields[ element.name ][ 2 ] ] );
      if( element.value.match( textFormat ) != element.value )
      {
        alert( fields[ element.name ][ 3 ] );
        focusObject( element );
        return false;
      }
    }
  }

  var functionName = fields[ element.name ][ 4 ];
  //alert( element.name + ' ' + functionName );
  if( functionName != null && functionName != '' )
  {
    var ret = evalFunc( functionName, inputName, formName );
    return ret;
  }

  return true;
}

function focusObject( obj, bDoNotShowLayer)
{
  // if the form object is disabled, it cannot get focus.
  if(!obj || obj.disabled)
    return;
  if(bDoNotShowLayer)
  {
    var parentNode = obj.parentNode;
    var bCanFocus = true;
    while(parentNode)
    {
      if( parentNode.style != null )
      {
        if( parentNode.style.display == 'none' )
        {
          bCanFocus = false;
          return;
        }
      }
      parentNode = parentNode.parentNode;
    }
  }  
  else
  {
    var parentNode = obj.parentNode;
    while(parentNode)
    {
      if( parentNode.style != null )
      {
        if( parentNode.style.display == 'none' )
        {
          parentNode.style.display = '';
        }
      }
    
      parentNode = parentNode.parentNode;
    }
  }
  if(obj.type != 'hidden')
          obj.focus();
  if( obj.select )
  {
    obj.select();
  }
}

function setMultipleChecker( fieldName, errorMessage )
{
  multipleFields[ fieldName ] = new Array( errorMessage, true );
  multipleFields[ fieldName ][ 2 ] = new Array();
  var bMax = null;
  for( var i = 2 ; i < setMultipleChecker.arguments.length ; i++ )
  {
    if( i == ( setMultipleChecker.arguments.length - 1 ) )
    {
      //alert( setMultipleChecker.arguments[ i ] + ' ' + ( new String( setMultipleChecker.arguments[ i ] ) ).match( /^\d+$/ ) );
      if( ( new String( setMultipleChecker.arguments[ i ] ) ).match( /^\d+$/ ) )
      {
	bMax = setMultipleChecker.arguments[ i ];
      }
      else
      {
	multipleFields[ fieldName ][ 2 ][ multipleFields[ fieldName ][ 2 ].length ] = setMultipleChecker.arguments[ i ];
      }
    }
    else
    {
      multipleFields[ fieldName ][ 2 ][ multipleFields[ fieldName ][ 2 ].length ] = setMultipleChecker.arguments[ i ];
    }
  }

  multipleFields[ fieldName ][ 3 ] = bMax;
}

function enableMultipleChecker( fieldName )
{
  if( multipleFields[ fieldName ] != null )
  {
    multipleFields[ fieldName ][ 1 ] = true;
  }
}

function disableMultipleChecker( fieldName )
{
  if( multipleFields[ fieldName ] != null )
  {
    multipleFields[ fieldName ][ 1 ] = false;
  }
}

function checkMultipleInput( fieldName, formName )
{
  var fields = multipleFields[ fieldName ][ 2 ];
  var cnt = 0;
  for( var i = 0 ; i < fields.length ; i++ )
  {
    if( getInputValue( fields[ i ], formName ) != '' )
    {
      cnt++;
    }
  }

  //alert( 'cnt=' + cnt );

  if( cnt == 0 )
  {
    alert( multipleFields[ fieldName ][ 0 ] );
    focusObject( getFormObject( multipleFields[ fieldName ][ 2 ][ 0 ], formName ) );
    return false;
  }

  if( multipleFields[ fieldName ][ 3 ] != null )
  {
    if( cnt > multipleFields[ fieldName ][ 3 ] )
    {
      alert( multipleFields[ fieldName ][ 0 ] );
      focusObject( getFormObject( multipleFields[ fieldName ][ 2 ][ 0 ], formName ) );
      return false;
    }
  }

  return true;
}

function validateMultipleInputs( formName )
{
  for( var fieldName in multipleFields )
  {
    if( multipleFields[ fieldName ][ 1 ] == true )
    {
      if( !checkMultipleInput( fieldName, formName ) )
      {
        return false;
      }
    }
  }

  return true;
}

function checkFormDateFormat(inputName, formName)
{
  var bOK = checkAndUpdateDateField( getFormObject(inputName, formName), null, true );
  return bOK;
}

function checkFormHourFormat(inputName, formName)
{
  var bOK = checkAndUpdateHourField( getFormObject(inputName, formName), null, true );
  return bOK;
}

function getUserMessage(sMessageID, hParameters)
{
  var args = getUserMessage.arguments;
  var sMessage = "_"+sMessageID+"_";
  if(window[sMessageID])
    sMessage = window[sMessageID];
  for(var sKey in hParameters)
  {
    //var re = getRegExp("\\\\\\["+sKey+"\\\\\\]");
    var re = getRegExp("\\["+sKey+"\\]");
    sMessage = sMessage.replace(re, hParameters[sKey])
  }
  return sMessage;
}

function showUserMessage(sMessageID, pWindow, hParameters)
{
  showMessage(getUserMessage(sMessageID, hParameters), pWindow);
}

function showMessage(sMessage, pWindow)
{
  if(!pWindow)
    pWindow = window;
  pWindow.alert(sMessage);
}

function confirmUserMessage(sMessageID, paParams)
{
  return confirm(getUserMessage(sMessageID, paParams));
}

function confirmMessage(sMessage)
{
  return confirm(sMessage);
}

function checkEmailAddress( pEmailAddressField, bNoAlert )
{
  var emailAddress = pEmailAddressField.value;
  if(emailAddress == "")
    return true;
  
  var bEmailAddressOK = true;
  sEmailAddress = new String( emailAddress );

  var aEmailAddress = sEmailAddress.split(';');
  // Expression reguliere inspiree de http://www.regular-expressions.info/email.html afin de respecter au plus pres la RFC 2822.
  var filter = /[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,6}$/gi;
  for ( var i = 0; i < aEmailAddress.length; i++ )
  {
    var sEmailAddress = aEmailAddress[ i ];
    if(!filter.test(sEmailAddress))
    {
      bEmailAddressOK = false; 
      break;
    }
    filter.compile(filter);
  }

  if(bEmailAddressOK)
    return true;

  if ( !bNoAlert )
    alert( LANG_incorrect_email_address_format );

  focusObject( pEmailAddressField ); 
  pEmailAddressField.select();

 return false;
}

function checkName( pNameField, bNoAlert )
{
  var name = pNameField.value;
  if(name == "")
    return true;
  
  sName = new String( name );
  if( trim(sName) != "" )
    return true;

  focusObject( pNameField );  
  pNameField.select();
  
  return false;
}

function checkLogin( pLoginField, bNoAlert )
{
  var login = pLoginField.value;
  if(login == "")
    return true;
  
  slogin = new String( login );
  if( trim(slogin) != "" )
    return true;

  focusObject( pLoginField );  
  pLoginField.select();
  
  return false;
}

function checkCreditCardNumber( sFormName, sTypeCreditCardField, sNumCCField, bNoAlert )
{
  var sCreditCardType = getInputValue( sTypeCreditCardField, sFormName );
  var sNumCC          = new String( getInputValue( sNumCCField, sFormName ));

  if ( (sCreditCardType == 1 && sNumCC.match(textFormats[ 'visa' ] )) || 
       (sCreditCardType == 2 && sNumCC.match(textFormats[ 'mastercard' ]))  || 
       (sCreditCardType == 3 && sNumCC.match(textFormats[ 'amex' ]))  || 
       (sCreditCardType == 4 && sNumCC.match(textFormats[ 'aurore' ]))   || 
       (sCreditCardType == 5 && sNumCC.match(textFormats[ 'cb' ]) ))    
      return true;
  
  
  if ( !bNoAlert )
    alert( "Le numero de carte bleu est invalide" );


  return false;
}

function Configuration()
{
  this.aVars = new Array();
}

Configuration.prototype.addVar = function(sVarID, sVarValue)
{
  this.aVars[sVarID] = sVarValue;
};

Configuration.prototype.getVarValue = function(sVarID)
{
  return this.aVars[sVarID];
};

Configuration.prototype.getChildAgeMax = function(sCampaignCode, sVarID)
{
  var nChildCampaign = this.aVars[sCampaignCode];
  if(nChildCampaign == null)
  {
    nChildCampaign = this.aVars[sVarID];
  }
  return nChildCampaign;
};

function CheckerException( sMessageID, sGUIID, sFormFieldName, sFormName, pDocument, nErrorNumber, pWindow, hMessageParameters )
{
  this.sMessageID = sMessageID;
  this.hMessageParameters = hMessageParameters;
  this.sMessage = null;
  this.sGUIID = sGUIID;
  this.sFormFieldName = sFormFieldName;
  this.sFormName = sFormName;
  this.pDocument = pDocument;
  this.nErrorNumber = nErrorNumber;
  this.pWindow = pWindow;
}

CheckerException.prototype.showUser = function(pWindow)
{
  if(pWindow == null)
  {
    if(this.pWindow)
    {
      pWindow = this.pWindow;
    }
    else if(this.pDocument && this.pDocument.parentWindow)
    {
      pWindow = this.pDocument.parentWindow;
    }
  }
  if(this.getLayer())
    showLayer(this.getLayer());
  var bTabActivated = false;
  if(this.sTabsID && this.sTabID)
  {
    activateTab(this.sTabsID, this.sTabID, true);
    bTabActivated = true;
  }

  if(this.getFormFieldName() && this.getFormName())
    focusObject(getFormObject( this.getFormFieldName(), this.getFormName(), pWindow ? pWindow.document : (this.pDocument ? this.pDocument : null)), bTabActivated);
  this.showUserMessage(pWindow);
};

CheckerException.prototype.showUserMessage = function(pWindow)
{
  showMessage(this.getMessage(), pWindow);
};

CheckerException.prototype.getMessageID = function()
{
  return this.sMessageID;
};

CheckerException.prototype.getMessageParameters = function()
{
  return this.hMessageParameters;
};

CheckerException.prototype.getMessage = function()
{
  if(this.sMessage)
    return this.sMessage;
  return getUserMessage(this.getMessageID(), this.getMessageParameters());
};

CheckerException.prototype.getErrorNumber = function()
{
  return this.nErrorNumber;
};

CheckerException.prototype.setErrorNumber = function( nErrorNumber )
{
  this.nErrorNumber = nErrorNumber;
};

CheckerException.prototype.getGUIID = function()
{
  return this.sGUIID;
};

CheckerException.prototype.setGUIID = function(sGUIID)
{
  this.sGUIID = sGUIID;
};

CheckerException.prototype.getFormFieldName = function()
{
  return this.sFormFieldName;
};

CheckerException.prototype.setFormFieldName = function(sFormFieldName)
{
  this.sFormFieldName = sFormFieldName;
};

CheckerException.prototype.setFormName = function(sFormName)
{
  this.sFormName = sFormName;
};

CheckerException.prototype.getFormName = function()
{
  return this.sFormName;
};

CheckerException.prototype.setTab = function(sTabsID, sTabID)
{
  this.sTabsID = sTabsID;
  this.sTabID = sTabID;
};

CheckerException.prototype.setFormField = function(sFormFieldName, sFormName)
{
  this.sFormFieldName = sFormFieldName;
  this.sFormName = sFormName;
};

CheckerException.prototype.getLayer = function()
{
  return this.sLayer;
};

CheckerException.prototype.setLayer = function(sLayer)
{
  this.sLayer = sLayer;
};

CheckerException.prototype.setDocument = function(pDocument)
{
  this.pDocument = pDocument;
};

CheckerException.prototype.getDocument = function()
{
  return this.pDocument;
};

CheckerException.prototype.getWindow = function()
{
  return this.pWindow;
};

CheckerException.prototype.setWindow = function(pWindow)
{
  this.pWindow = pWindow;
};

function checkForbiddenValues(inputName, sFormName )
{
  var value = getInputValue(inputName, sFormName);
  
  if ( value )
  {
    for (var i=0; i < aForbiddenValue.length; ++i )
    {
      if( aForbiddenValue[i] == value )
      {
        alert(sErrorMsg);      
        return false;
      }
    }  
  }
  return true;
}

function checkAndUpdatePhoneField( pPhoneField, sDelimiter, bNoAlert )
{
  if(pPhoneField.value == "")
    return true;
  
  // check si c'est le bon format
  var sPhone = new String( pPhoneField.value );
  if( sPhone.match("^([0-9][0-9][. ]){4}[0-9][0-9]$") )
  {
    return true;
  }
  
  // garde seulement les chiffres
  var sOnlyDigits = sPhone.replace( /[^\d]/g, '');
  var nNbDigits = sOnlyDigits.length;

  // s'il n'y a que des chiffres, on reformate le num�ro de t�l�phone
  if ( nNbDigits > 0 && nNbDigits == sPhone.length)
  {
    var sFormatedPhone = '';
    // on regroupe les chiffres par paire, et on s�pare par sDelimiter
    for ( var i = nNbDigits; i >= 1; i = i-2 )
    {
      var s2digits = sOnlyDigits.substring( i-2, i );
      sFormatedPhone = sDelimiter + s2digits + sFormatedPhone;
    }
    
    pPhoneField.value = sFormatedPhone.substring(1, sFormatedPhone.length);
  }
  
  return true;
}

//pour utiliser ce checker, il faut que les champs aient des noms bien spécifiques (liste dans aCheckFields)
function checkAddBankAccountForm( sFormName, sPrefix )
{
  if( sPrefix == null || sPrefix == '' )
  {
    sPrefix = 'add_bank_account_';
  }
  
  var aRIBCheckFields = new Array( 'Label', 'BankCode', 'AgencyCode', 'AccountNumber', 'RIBKey' );
  var aRIBNbCharMax = new Array( -1, 5, 5, 64, 2 );
  var aIBANCheckFields = new Array( 'Label', 'AccountNumber', 'BICCode', 'IBAN' );
  var aIBANNbCharMax = new Array( -1, 64, 20, 36 );
  var aCheckFields;
  var aNbCharMax;

  // RIB (1) ou IBAN (2)
  var nType = getInputValue( sPrefix+'Type', sFormName );
  if( nType == 1 )
  {
    aCheckFields = aRIBCheckFields;
    aNbCharMax = aRIBNbCharMax;
  }
  else
  {
    aCheckFields = aIBANCheckFields;
    aNbCharMax = aIBANNbCharMax;
  }
  
  for( var nI = 0; nI < aCheckFields.length; nI++ )
  {
    var sValue = getInputValue( sPrefix+aCheckFields[ nI ], sFormName );
    //la valeur est-elle vide ?
    if( !sValue )
    {
      alert( LANG_webres_please_fill );
      getFormObject( sPrefix+aCheckFields[ nI ], sFormName ).focus();
      return false;
    }
    //la valeur dépasse-t-elle la limite de nb de caractères ?
    else if( aNbCharMax[ nI ] != -1 && sValue.length > aNbCharMax[ nI ] )
    {
      alert( LANG_webres_error_entry );
      getFormObject( sPrefix+aCheckFields[ nI ], sFormName ).focus();
      return false;
    }
  }
  return true;
}

function checkVatCode(inputobj) {
	//see "Validation du numero de TVA par VIES", 
	//http://ec.europa.eu/taxation_customs/vies/lang.do?fromWhichPage=vieshome&selectedLanguage=FR
	//http://ec.europa.eu/taxation_customs/vies/faqvies.do#item11
	//From http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl :
	if (!/[A-Z]{2}[0-9A-Za-z\+\*\.]{2,12}/.test(inputobj.value.toUpperCase()))
	{
		alert(LANG_vat_invalidvat);
		return false;
	}
	inputobj.value = inputobj.value.toUpperCase();
	return true; 
}
