document.write('<script src="/javascript/CUtils.js"><\/' + 'script>');
var Enumeration = new _Enumeration(null) ;

//Constructor of _Enumeration object (equivalent to a java.util.Enumeration java object)
function _Enumeration(array)
{
    this.m_array = array;
    this.m_currIndex = 0;
    this.getInstance = _Enumeration_getInstance;
    this.hasMoreElements = _Enumeration_hasMoreElements;
    this.nextElement = _Enumeration_nextElement;
    return this;
}

function _Enumeration_getInstance(array)
{
    if( array == null )
    {
        array = new Array();
    }
    return new _Enumeration(array);
}

function _Enumeration_hasMoreElements()
{
    if( this.m_array != null && this.m_array.length > 0 && this.m_currIndex < this.m_array.length )
    {
        return true;
    }
    return false;
}

function _Enumeration_nextElement()
{
    if( this.hasMoreElements() )
    {
        return this.m_array[this.m_currIndex++] ;
    }
    alert("Enumeration._nextElement() : No more elements") ;
    return null;
}

var Vector = new _Vector(null) ;
// Constructor of _Vector object (equivalent to a java.util.Vector java object)
function _Vector(size)
{
    this.m_array = new Array();
    this.m_currentIndex = 0;
    this.getInstance = _Vector_getInstance;
    this.add = _Vector_add;
    this.addElement = _Vector_addElement;
    this.elementAt = _Vector_elementAt;
    this.get = _Vector_get;
    this.size = _Vector_size;
    this.remove = _Vector_remove;
    this.removeElement = _Vector_removeElement;
    this.removeAll = _Vector_removeAll;
    this.insertElementAt = _Vector_insertElementAt;
    this.elements = _Vector_elements;
    this.contains = _Vector_contains;
    this.indexOf = _Vector_indexOf;
    this.toString = _Vector_toString;
    return this;
}

function _Vector_getInstance()
{
    return new _Vector(5);
}

function _Vector_add( aObject )
{
    this.m_array[ this.m_currentIndex++ ] = aObject;
}

function _Vector_addElement( aObject )
{
    this.add( aObject );
}

function _Vector_elementAt( index )
{
    if( index < this.m_currentIndex )
    {
        return this.m_array[ index ];
    }
    return null;
}

function _Vector_get( index )
{
    return this.elementAt(index);
}

function _Vector_size()
{
    return this.m_currentIndex;
}

function _Vector_indexOf(object)
{
    for(var i=0; i<this.m_currentIndex; i++)
    {
        if(this.m_array[i] == object)
        {
            return i;
        }
    }
    return -1;
}

function _Vector_remove( index )
{
    if( index >= 0 && index < this.m_currentIndex )
    {
        this.m_currentIndex--;
        var object = this.m_array[index];
        //Removing an element at index <index>
        if( typeof(this.m_array.splice) == "function" )
        {
            this.m_array.splice(index, 1); //remove one element
        }
        else
        {   //remove if value is found in this array
            for(var i=index; i<this.m_array.length; i++)
            {
               this.m_array[i] = this.m_array[i+1];
            }
            this.m_array.length = this.m_array.length - 1;
        }
        return object;
    }
    return null;
}

function _Vector_removeElement( anObject )
{
    if( anObject )
    {
        var index = this.indexOf(anObject);
        if(index != -1)
        {
            return this.remove(index);
        }
    }
    return null;
}

function _Vector_removeAll()
{
    this.m_array = new Array();
    this.m_currentIndex = 0;
}

function _Vector_insertElementAt(aObject, index)
{
    if( index > this.m_currentIndex || index < 0 )
    {
        return;
    }
    if( index == this.m_currentIndex )
    {
         this.m_array[this.m_currentIndex++] = aObject;
         return;
    }
    if( typeof(this.m_array.splice) == "function" )
    {
        this.m_array.splice(index, 0, aObject);  //add one element
    }
    else
    {
        var _beforeIndexArray = this.m_array.slice(0, index);
        var _afterIndexArray = this.m_array.slice(index, this.m_array.length);
        _beforeIndexArray[index] = aObject;
        this.m_array = _beforeIndexArray.concat(_afterIndexArray);
    }
    this.m_currentIndex++;
}

function _Vector_contains(anObject)
{
    var index = this.indexOf(anObject);
    if( index != -1 )
    {
        return true;
    }
    return false;
}

function _Vector_elements()
{
    return Enumeration.getInstance( this.m_array );
}

function _Vector_toString()
{
    return "[" + this.m_array.length + "]-{" + this.m_array + "}";
}

var CStringTokenizer = new _CStringTokenizer(null, null) ;
// Constructor of CStringTokenizer object (equivalent to a java.util.StringTokenizer java object)
function _CStringTokenizer(str, delim)
{
    this.getInstance = _CStringTokenizer_getInstance;
    this.hasMoreElements = _CStringTokenizer_hasMoreElements;
    this.hasMoreTokens = _CStringTokenizer_hasMoreElements;
    this.nextElement = _CStringTokenizer_nextElement;
    this.nextToken = _CStringTokenizer_nextElement;
    this.countTokens = _CStringTokenizer_countTokens;
    this.getVectorOfValues = _CStringTokenizer_getVectorOfValues;
    this.vectorOfValues = Vector.getInstance();

    if( str == null || delim == null )
    {
        this.tokenCount = 0;
        this.e = Enumeration.getInstance( new Array() );
        return this;
    }
    //split function returns empty srings if first/last char is delimeter
    var array = str.split( delim );
    var new_array = new Array();
    for(var i=0, j=0 ; i<array.length; i++ )
    {
        if( array[i] != "" )
        {   //removing empty strings
            new_array[j++] = array[i];
            this.vectorOfValues.add(CUtils.trim(array[i]));
        }
    }
    this.tokenCount = j;
    this.e = Enumeration.getInstance( new_array  );
    return this;
}

function _CStringTokenizer_getInstance(str, delim)
{
    return new _CStringTokenizer(str, delim);
}

function _CStringTokenizer_countTokens()
{
    return this.tokenCount;
}

function _CStringTokenizer_hasMoreElements()
{
    if( this.e == null )
    {
        return false;
    }
    return this.e.hasMoreElements();
}

function _CStringTokenizer_nextElement()
{
    if( this.hasMoreElements() )
    {
        return this.e.nextElement();
    }
    alert("CStringTokenizer._nextElement() : No more elements");
    return null;
}

function _CStringTokenizer_getVectorOfValues()
{
    return this.vectorOfValues;
}

var Hashtable = new _Hashtable(null) ;

// Constructor of _Hashtable object (equivalent to a java.util.Hashtable java object)
// @param int initial size of the hashtable
function _Hashtable(size)
{
    if( size )
    {
        this.m_vKeys = Vector.getInstance();
        this.m_vValues = Vector.getInstance();
    }
    else
    {
        this.m_vKeys = null;
        this.m_vValues = null;
    }
    this.m_arrayOfkeyValues = new Array();
    this.getInstance = _Hashtable_getInstance;
    this.put = _Hashtable_put;
    this.get = _Hashtable_get;
    this.remove = _Hashtable_remove;
    this.keys = _Hashtable_keys;//returns enumeration of keys
    this.elements = _Hashtable_elements;//returns enumeation of values
    this.values = _Hashtable_values; //returns Vector of values
    this.contains = _Hashtable_contains;
    return this;
}

function _Hashtable_getInstance()
{
    return new _Hashtable(5);
}

function _Hashtable_put(key, value)
{
   // alert("key: "+key)
	if( key == null || value == null )
    {
        return null;
    }
    if( this.m_vKeys.contains( key ) )
    {   //Remove old key and value
        this.m_vKeys.removeElement( key );
        this.m_vValues.removeElement( this.m_arrayOfkeyValues[key] );
    }
    this.m_vKeys.addElement( key );
    this.m_vValues.addElement( value );
    this.m_arrayOfkeyValues[key] = value;
	//alert("value: "+value)
    return value ;
}

function _Hashtable_get(key)
{
    var value = this.m_arrayOfkeyValues[key];
    if(value != null)
    {
        return value;
    }
    return null;
}

function _Hashtable_remove(key)
{
    //alert("remove")
	var removedObject = null;
    if( this.m_vKeys.contains( key ) )
    {
        this.m_vKeys.removeElement( key );
        this.m_vValues.removeElement( this.m_arrayOfkeyValues[key] );
        removedObject = this.m_arrayOfkeyValues[key];
        this.m_arrayOfkeyValues[key] = null;
    }
    return removedObject;
}

function _Hashtable_keys()
{
    return this.m_vKeys.elements();
}

function _Hashtable_elements()
{
    return this.m_vValues.elements();
}

function _Hashtable_values()
{
    return this.m_vValues;
}

function _Hashtable_contains( key )
{
    return this.m_vKeys.contains( key );
}

//This variable is used as a java object. All jsps just include this file and can call CURLEncoder.encode(str) to encode a string
//It can also be created as regual java object using new operator.
var CURLEncoder = new _CURLEncoder();
_CURLEncoder.prototype.encode = _CURLEncoder_encode ;
_CURLEncoder.prototype.getURLEncoder = _CURLEncoder_getURLEncoder ;

function _CURLEncoder()
{
    return this;
}

// This function first encodes the '/' and '=' characters because these characters have special meaning (in linkmanager)then encodes
// the string using URLEncoder scheme.
// @param String string to be encoded
// @return String URLEncoded string
function _CURLEncoder_encode(str)
{
    //some of the characters decoded by NES and not get encoded when these get passed to the weblogic server
    //replace ('/') with "_xsfs"
    var expression = /\//g;
    str = str.replace(expression, "_xsfs");

    //replace ('\') with "_xsfbs"
    expression = /\\/g;
    str = str.replace(expression, "_xsfbs");

    //replace ('=') with "_xsfe"
    expression = /=/g;
    str = str.replace(expression, "_xsfe");

    //replace ('?') with "_xsfq"
    expression = /\?/g;
    str = str.replace(expression, "_xsfq");

    //replace ('&') with "_xsfa"
    expression = /&/g;
    str = str.replace(expression, "_xsfa");

    //replace (':') with "_xsfc"
    expression = /:/g;
    str = str.replace(expression, "_xsfc");

    //replace ('%') with "_xsfp"
    expression = /%/g;
    str = str.replace(expression, "_xsfpc");

    //replace ('+') with "_xsfpl"
    expression = /\+/g;
    str = str.replace(expression, "_xsfpl");

    //replace ('\n') with "_xsfn"
    expression = /\n/g;
    str = str.replace(expression, "_xsfn");

    //replace ('\r') with "_xsfr"
    expression = /\r/g;
    str = str.replace(expression, "_xsfr");

    str = escape(str);
    //'/', '@' characters are not encoded by javascript.escape function.
    //replace  ('@') with "%40"
    var expression = /@/g ;
    str = str.replace(expression, "%40") ;
    return str;
}

// This function creates and returns a CURLEncoder object which is (equivalent to a java object).
function _CURLEncoder_getURLEncoder()
{
    return new _CURLEncoder();
}

//This variable is used as a java object. All jsps just include this file and can call CURLDecoder.decode(str) to encode a string
//It can also be created as regual java object using new operator.
var CURLDecoder = new _CURLDecoder() ;
_CURLDecoder.prototype.decode = _CURLDecoder_decode ;
_CURLDecoder.prototype.getURLDecoder = _CURLDecoder_getURLDecoder ;

function _CURLDecoder()
{
    return this;
}

// This function first decodes decodes using URLDecoder scheme then decodes the  '/' and '=' characters which were
// encoded by CURLEncoder.encode() function.
// @param String string to be decoded
// @return String URLDecoded string
function _CURLDecoder_decode(str)
{
    str = unescape(str); //(equivalent to java.net.URLDecoder.decode())

    //replace "_xsfs" with ('/')
    var expression = /_xsfs/g;
    str = str.replace(expression, "/");

    //replace "_xsfbs" with ('\')
    expression = /_xsfbs/g;
    str = str.replace(expression, "\\");

    //replace  "_xsfe" with '='
    expression = /_xsfe/g;
    str = str.replace(expression, "=");

    //replace  "_xsfq" with '?'
    expression = /_xsfq/g;
    str = str.replace(expression, "?");

    //replace  "_xsfa" with '&'
    expression = /_xsfa/g;
    str = str.replace(expression, "&");

    //replace  "_xsfc" with ':'
    expression = /_xsfc/g;
    str = str.replace(expression, ":");

    //replace  "_xsfp" with '%'
    expression = /_xsfpc/g;
    str = str.replace(expression, "%");

    //replace  "_xsfpl" with '+'
    expression = /_xsfpl/g;
    str = str.replace(expression, "+");

    //replace  "_xsfn" with '\n'
    expression = /_xsfpl/g;
    str = str.replace(expression, "\n");

    //replace  "_xsfpl" with '+'
    expression = /_xsfr/g;
    str = str.replace(expression, "\r");
    return str;
}

// This function creates and returns a CURLDecoder object which is (equivalent to a java object).
function _CURLDecoder_getURLDecoder()
{
    return new _CURLDecoder();
}