/******************************************************************************/
/***********************Hashmap Implementation for Javascript******************/
/******************************************************************************/

function Map()
{
    // members
    this.keyArray = new Array(); // Keys
    this.valArray = new Array(); // Values
        
    // methods
    this.put = put;
    this.get = get;
    this.size = size;  
    this.clear = clear;
    this.keySet = keySet;
    this.valSet = valSet;
    this.showMe = showMe;   // returns a string with all keys and values in map.
    this.findIt = findIt;
    this.remove = remove;
}

function put( key, val )
{
    var elementIndex = this.findIt( key );
    
    if( elementIndex == (-1) )
    {
        this.keyArray.push( key );
        this.valArray.push( val );
    }
    else
    {
        this.valArray[ elementIndex ] = val;
    }
}

function get( key )
{
    var result = null;
    var elementIndex = this.findIt( key );

    if( elementIndex != (-1) )
    {   
        result = this.valArray[ elementIndex ];
    }  
    
    return result;
}

function remove( key )
{
    var result = null;
    var elementIndex = this.findIt( key );

    if( elementIndex != (-1) )
    {
        this.keyArray = this.keyArray.removeAt(elementIndex);
        this.valArray = this.valArray.removeAt(elementIndex);
    }  
    
    return ;
}

function size()
{
    return (this.keyArray.length);  
}

function clear()
{
    for( var i = 0; i < this.keyArray.length; i++ )
    {
        this.keyArray.pop(); this.valArray.pop();   
    }
}

function keySet()
{
    return (this.keyArray);
}

function valSet()
{
    return (this.valArray);   
}

function showMe()
{
    var result = "";
    
    for( var i = 0; i < this.keyArray.length; i++ )
    {
        result += "Key: " + this.keyArray[ i ] + "\tValues: " + this.valArray[ i ] + "\n";
    }
    return result;
}

function findIt( key )
{
    var result = (-1);

    for( var i = 0; i < this.keyArray.length; i++ )
    {
        if( this.keyArray[ i ] == key )
        {
            result = i;
            break;
        }
    }
    return result;
}

function removeAt( index )
{
  var part1 = this.slice( 0, index);
  var part2 = this.slice( index+1 );

  return( part1.concat( part2 ) );
}
Array.prototype.removeAt = removeAt;
/******************************************************************************/

var errorCodes = new Map();

errorCodes.put("systemError","System error has occured. Please try again later.");

/*Validate CC errors*/
errorCodes.put("USR-030201","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-030205","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-030209","Insufficient Funds");
errorCodes.put("USR-030215","Please enter valid Credit Card Number or Expiration Date ");
errorCodes.put("USR-030201","Please enter valid Credit Card Number or Expiration Date ");
errorCodes.put("USR-030216","Please enter valid Credit Card Number or Expiration Date ");
errorCodes.put("USR-030217","Please enter valid Credit Card Number or Expiration Date ");
errorCodes.put("USR-030218","Please enter valid Credit Card Number or Expiration Date ");
errorCodes.put("USR-030219","Please enter valid Credit Card Number or Expiration Date ");
errorCodes.put("USR-030220","Please enter valid Credit Card Number or Expiration Date ");
errorCodes.put("USR-030221","We are sorry; Our online system does not support the currency and card type you have selected. We apologies for the inconvenience. Please contact support at 866-399-3239 to make payment."); 
errorCodes.put("USR-020201","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020202","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020203","Please enter valid Credit Card Number or Expiration Date.");
errorCodes.put("USR-020204","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020205","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020206","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020207","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020208","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020209","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020210","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020211","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020212","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020301","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020302","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020303","Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020304","Please select Your Credit Card billing address - country.");
errorCodes.put("USR-020501","Please enter Credit Card billing address.");
errorCodes.put("USR-020502","Please enter Credit Card billing address - street name/number.");
errorCodes.put("USR-020302"," Please enter valid Credit Card Number or Expiration Date");
errorCodes.put("USR-020503","Please enter Credit Card billing address - city.");
errorCodes.put("USR-020504","Please enter Credit Card billing address - state/province.");
errorCodes.put("USR-020505","Please enter your Credit Card billing address - zipcode.");
errorCodes.put("USR-020506","Please enter a valid Credit Card billing address - zipcode.");
errorCodes.put("USR-020507","Please enter Credit Card billing address - country.");
errorCodes.put("USR-020508","Please select valid Credit Card billing address - country.");
errorCodes.put("USR-020213","Please enter valid Credit Card number or Expiration Date."); 

/*Data related errors*/
errorCodes.put("USR-020101","Please enter valid Credit Card Number or Expiration Date ");
errorCodes.put("USR-020102","Caller Context is required.");
errorCodes.put("USR-020103","Caller Context - application name is required.");
errorCodes.put("USR-020104","Caller Context - user id is required.");
errorCodes.put("USR-020105","Caller Context - user type is required."); 

/*Mapping error codes for Oracle errors*/
errorCodes.put("USR-020253","Sorry, we could not retrive your account information. Please contact one of our client services manager.");
errorCodes.put("USR-020254","Sorry, we could not retrive your account information. Please contact one of our client services manager.");
errorCodes.put("USR-020255","Sorry, we could not retrive your account information. Please contact one of our client services manager.");
errorCodes.put("USR-020256","Sorry, we could not retrive your account information. Please contact one of our client services manager.");
errorCodes.put("USR-020257","Sorry, we could not retrive your credit card information. Please contact one of our client services manager."); 

/*IService Layer SYS Messages*/
errorCodes.put("SYS-010201","Communication to one of our servers is timed out.Please try again later."); 

/*Mapping error codes for Order Management*/ 
errorCodes.put("OMS-SYS-000000","System Failure occured."); 
errorCodes.put("OMS-APP-020102","Caller Context is required.");
errorCodes.put("OMS-APP-020103","Caller Context(application name) is required.");
errorCodes.put("OMS-APP-020104","Caller Context(user id) is required.");
errorCodes.put("OMS-APP-020105","Caller Context(user type) is required.");
errorCodes.put("OMS-APP-020106","Service Type is required.");
errorCodes.put("OMS-APP-020107","Failed to create the order.");
errorCodes.put("OMS-APP-020108"," Input xml for Create order is required.");
errorCodes.put("OMS-APP-020109","input xml has issue.");
errorCodes.put("OMS-SYS-020111"," connection timed out for xml template config web host.");

/*Error messages from BLis call while creating order*/
errorCodes.put("OMS-APP-000001","Account Id or service data is required.");
errorCodes.put("OMS-APP-000002","There is Pending-Order status under this account, so cannot create order.");
errorCodes.put("OMS-APP-000003","Account agent assignment data is wrong.");
errorCodes.put("OMS-APP-000004","Failed to insert data to database.");
errorCodes.put("OMS-APP-000005","Order request conversion failed.");
errorCodes.put("OMS-APP-000006","Order's status is incorrect, cannot accept order.");
errorCodes.put("OMS-APP-000007","Account data is not integrated or Account does not exist.");
errorCodes.put("OMS-APP-000008","cannot get new OrgId.");
errorCodes.put("OMS-APP-000009","the currency code is not consistent with order account.");
errorCodes.put("OMS-APP-000010","Failed to save request to App Audit table.");
errorCodes.put("OMS-APP-000011","The service start date or contract date is empty.");
errorCodes.put("OMS-APP-000012","Error in service start date.");
errorCodes.put("OMS-APP-000013","Error in contract sign date.");
errorCodes.put("OMS-APP-000014","The file does not exist in the file system.");
errorCodes.put("OMS-APP-000015","Get element from XML error.");
errorCodes.put("OMS-APP-000016","Error in draft subscription, check the request subscription node.");
errorCodes.put("OMS-APP-000017","There is no provision info for the language.");
errorCodes.put("OMS-APP-000018","The account don't have the primary billing contact for service.");
errorCodes.put("OMS-APP-000019","Cannot create org by sending SOAP.");
errorCodes.put("OMS-USR-000020","Please enter valid company name");
errorCodes.put("OMS-APP-000021","Error in Organization URL.");
errorCodes.put("OMS-APP-000022","Failed to create account.");
errorCodes.put("OMS-APP-000023","Organization with the given name does not exist.");
errorCodes.put("OMS-USR-000024","Please enter a valid email address");
errorCodes.put("OMS-USR-000025"," Please enter a valid Phone number validation.");
errorCodes.put("OMS-USR-000026"," Please enter a valid Postal code.");
errorCodes.put("OMS-APP-000027","Account type is wrong, support WebEx Direct account.");
errorCodes.put("OMS-APP-000028"," Opportunity ID does not exist. Please enter a valid one.");
errorCodes.put("OMS-APP-000029"," Service start date cannot be before current date.");
errorCodes.put("OMS-USR-000030"," Please enter valid WebEx URL.");

/*These are the error code messages for DataTransformUtils call*/
errorCodes.put("OMS-APP-000040","Tag Service Start Date is not valid.");
errorCodes.put("OMS-APP-000041","Tag Contract Sign date is not valid");
errorCodes.put("OMS-APP-000042","Tag accountID is not valid.");
errorCodes.put("OMS-APP-000043","Tag opportunityID is not valid.");
errorCodes.put("OMS-APP-000044","Tag service is not valid.");
errorCodes.put("OMS-APP-000045","Tag provision is not valid.");
errorCodes.put("OMS-APP-000046","Tag subscription is not valid");
errorCodes.put("OMS-APP-000047","Tag site is not valid.");
errorCodes.put("OMS-APP-000048","Tag webExURL is not valid.");
errorCodes.put("OMS-APP-000049","Tag timeZone is not valid.");
errorCodes.put("OMS-APP-000050","Tag brandSite is not valid.");
errorCodes.put("OMS-APP-000051","Tag language is not valid.");
errorCodes.put("OMS-APP-000052","Tag host is not valid.");
errorCodes.put("OMS-APP-000053","Tag prepayTerm is not valid.");
errorCodes.put("OMS-APP-000054","Tag tollFree is not valid.");
errorCodes.put("OMS-APP-000055","Attribute code is not valid.");
errorCodes.put("OMS-APP-000056","Attribute currency is not valid."); 
errorCodes.put("OMS-APP-000057","Invalid XML input.");
errorCodes.put("OMS-APP-000058","Tag Lang is not valid.");
errorCodes.put("OMS-APP-000059","Tag order is not valid.");
errorCodes.put("OMS-APP-000060","Tag createOrder is not valid.");
/*NEW ERROR CODES*/

/*Create Account*/
errorCodes.put("ACC-SYS-000000","System Failure occurred.");
errorCodes.put("ACC-APP-020102","Caller Context is required.");
errorCodes.put("ACC-APP-020103","Caller Context (application name) is required.");
errorCodes.put("ACC-APP-020104","Caller Context (user id) is required.");
errorCodes.put("ACC-APP-020105","Caller Context (user type) is required.");
errorCodes.put("ACC-APP-020106","Service Type is required.");
errorCodes.put("ACC-APP-020107","Failed to create the account.");
errorCodes.put("ACC-APP-020108","svcconfig is required.");
errorCodes.put("ACC-APP-020109","input xml has issue.");
errorCodes.put("ACC-SYS-020110","connection timed out for access remote host.");
errorCodes.put("ACC-SYS-020111"," connection timed out for xml template config web host.");
errorCodes.put("ACC-APP-000040","Tag org ID is not valid.");
errorCodes.put("ACC-APP-000041","Tag org name is not valid.");
errorCodes.put("ACC-APP-000042","Tag URL is not valid.");
errorCodes.put("ACC-APP-000043","Tag employee number is not valid.");
errorCodes.put("ACC-APP-000044","Tag annual revenue is not valid .");
errorCodes.put("ACC-APP-000045","Tag currency code is not valid.");
errorCodes.put("ACC-APP-000046","Tag opportunity ID is not valid.");
errorCodes.put("ACC-APP-000047","Tag first Name is not valid.");
errorCodes.put("ACC-APP-000048","Tag last Name is not valid.");
errorCodes.put("ACC-APP-000049","Tag email is not valid.");
errorCodes.put("ACC-APP-000050","Tag address1 is not valid.");
errorCodes.put("ACC-APP-000051","Tag address2 is not valid.");
errorCodes.put("ACC-APP-000052","Tag country is not valid.");
errorCodes.put("ACC-APP-000053","Tag city is not valid.");
errorCodes.put("ACC-APP-000054","Tag state is not valid.");
errorCodes.put("ACC-APP-000055","Tag postal code is not valid.");
errorCodes.put("ACC-APP-000056","Tag phone is not valid.");
errorCodes.put("ACC-APP-000057","Tag name is not valid.");
errorCodes.put("ACC-APP-000058","Tag card number is not valid.");
errorCodes.put("ACC-APP-000059","Tag credit card type is not valid.");
errorCodes.put("ACC-APP-000060","Tag cvv code is not valid.");
errorCodes.put("ACC-APP-000061","Tag expiration year is not valid.");
errorCodes.put("ACC-APP-000062","Tag expiration month is not valid.");

/*BLiS specific errors for organizations/accounts creation */ 
errorCodes.put("ACC-USR-0024","Please enter valid Email address.");
errorCodes.put("ACC-USR-0025","Phone number validation failed, check your phone.");
errorCodes.put("ACC-USR-0026","Postal code validation failed, check your postal code.");
errorCodes.put("ACC-USR-0033","this Opportunity ID does not exist. Please enter a valid one.");


/* Service Provisioning */
errorCodes.put("EPV-SYS-000000","System failure occurred.");
errorCodes.put("EPV-USR-010101","Please enter different Site URL.");
errorCodes.put("EPV-USR-010102","Please enter different Site URL.");
errorCodes.put("EPV-APP-020111","Service context is required.");
errorCodes.put("EPV-APP-020103","Request type is required.");
errorCodes.put("EPV-APP-020104","Service type is required.");
errorCodes.put("EPV-APP-020105","Request version is required.");
errorCodes.put("EPV-APP-020106","Request version is not supported.");
errorCodes.put("EPV-APP-020107","Request type is not supported.");
errorCodes.put("EPV-APP-020108","Service type is not supported.");
errorCodes.put("EPV-APP-020109","Provision request is required.");
errorCodes.put("EPV-APP-020110","Caller Context is required.");

/* DNS Errors */
errorCodes.put("DNS-USR-020204","Site URL is too Long.");
errorCodes.put("DNS-USR-020205","Site URL includes inaccurate letter.");
errorCodes.put("DNS-SYS-000000","System Failure occured.");
errorCodes.put("DNS-APP-020101","Requested action is not supported by the DNS service system.");
errorCodes.put("DNS-APP-020102","Caller Context is required.");
errorCodes.put("DNS-APP-020103","Caller Context(application name) is required.");
errorCodes.put("DNS-APP-020104","Caller Context(user id) is required.");
errorCodes.put("DNS-APP-020105","Caller Context(user type) is required");
errorCodes.put("DNS-USR-020201","Site URL is required");
errorCodes.put("DNS-USR-020202","Time Zone is required");
errorCodes.put("DNS-USR-020203","Service Type is required.");
errorCodes.put("DNS-SYS-030001","DataBase connection has issue.");

errorCodes.put("SYS-030214","AUTHERROR : No Value defined for the lookup XXWBX_ONPAY_APPSINIT and lookup value USD.");
/*These error code will be fixed to APP exception in phase2*/
/*
errorCodes.put("ACC-USR-0001","miss account id or Service data when create order.");
errorCodes.put("ACC-USR-0002","there is pending orders under this account, so can't create order on this account again.");
errorCodes.put("ACC-USR-0003","the account agent assignment data is wrong.");
errorCodes.put("ACC-USR-0004","fail to persistent order data to database.");
errorCodes.put("ACC-USR-0005","order request convert failed.");
errorCodes.put("ACC-USR-0006","order's status is incorrect, can't do accept order.");
errorCodes.put("ACC-USR-0007","account data isn't integrated or account doesn't exist.");
errorCodes.put("ACC-USR-0008","can not get new org ID, sql is.");
errorCodes.put("ACC-USR-0009","the order currency code isn't consistent with account.");
errorCodes.put("ACC-USR-0010","fail to save request to app audit table.");
errorCodes.put("ACC-OSS-USR-0011","the service start date or contract date is empty.");
errorCodes.put("ACC-USR-0012","the service start date is error, the request is:[0].");
errorCodes.put("ACC-USR-0013","the contract sign date is error, the request is:[0].");
errorCodes.put("ACC-USR-0014","the file not exist in the file system, the whole path is:[0].");
errorCodes.put("ACC-USR-0015","get element from xml error.");
errorCodes.put("ACC-USR-0016","the draft subscription is error, check the request subscription node.");
errorCodes.put("ACC-USR-0017","the request don't have the provision info for the language:[0].");
errorCodes.put("ACC-USR-0018","the account don't have the primary billing contact for service.");
errorCodes.put("ACC-USR-0019","cannot create Org by sending SOAP.");
errorCodes.put("ACC-USR-0020","checking organization name error, sql is.");
errorCodes.put("ACC-USR-0021","checking organization url error, sql is.");
errorCodes.put("ACC-USR-0022","failed to create account.");
errorCodes.put("ACC-USR-0023","the organization with the given name does not exist.");
errorCodes.put("ACC-USR-0027","account type is wrong, just support WebEx Direct account.");
errorCodes.put("ACC-USR-0028","service start date can't before current date.");
errorCodes.put("ACC-USR-0029","checking agent ID error, sql is.");
errorCodes.put("ACC-USR-0030","Agent is Inactive or not exist, ID is.");
errorCodes.put("ACC-USR-0031","rename opportunity id is failed.");
errorCodes.put("ACC-USR-0032","fail to get opportunity name from Pivotal system.");
errorCodes.put("ACC-USR-0034","provision information isn't integrated.");
*/
/*These error code will be fixed to APP exception in phase2*/



//alert(errorCodes.get("A001"));



//Signup Validate CC
errorCodes.put("SYS_040309","Use the sax to validate xml is failed.");
errorCodes.put("SYS_040316","IO error when do the BRM operate.");

//Signup Process Order


errorCodes.put("SYS_040309","Use the sax to validate xml is failed.");
errorCodes.put("SYS_040316","IO error when do the BRM operate.");

errorCodes.put("APP_020317112501","Change order can not be processed at this time,the subscription is not active, subscriptionCode is:.");

//SYS Error ProcessOrder
errorCodes.put("SYS-04063","[PIN_ERR_NOT_FOUND] - BRM couldn't find a value. This error code doesn't always indicate an error. For example, some opcodes look for a value in the configuration file, but if the value is not there, a default value can be used.");
errorCodes.put("EPV-APP-020109","Provision request is Required.");
errorCodes.put("APP-020321","The subscriptions's except start date couldn't be before today.");
errorCodes.put("SYS-040307","The reqeust is can't validate by the schema 1. cvc-complex-type.2.4.b: The content of element 'contacts' is not complete. One of billingContact is expected");
errorCodes.put("APP_020321","The subscriptions's expected start date couldn't be before today.");
errorCodes.put("USR_020001","Credit card information is invalid. Please check and correct.");
errorCodes.put("USR_020002","Credit card information is invalid. Please check and correct.");

