////////////////////////////////////////////////////////////////////////////////////////
//......................................................................................
//  This is a part of UI Soft Web Services.                                            .
//  Copyright © 2002 Arthur Amshukov                                                   .
//......................................................................................
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND         .
//  EVERYONE IS PERMITTED TO USE, MODIFY, COPY AND DISTRIBUTE THIS SOFTWARE FREE OF    .
//  CHARGE AND WITHOUT ANY RETRICTIONS                                                 .
//                                                                                     .
//  DO NOT REMOVE MY NAME AND THIS NOTICE FROM THE SOURCE                              .
////////////////////////////////////////////////////////////////////////////////////////
// initialization of uisoft library
// -------------- -- ------ -------
// note: the 'apply' and 'call' methods of Function objects must be patched 
//       unless you are using IE5.5+ and/or NS4.06+ (JavaScript 1.3+ or JScript 5.5+)
//      'Professional Javascript' 2nd edition by 'www.wrox.com'.
function dhtml_apply(_this_object, _args)
{
    var object = is_valid(_this_object) ? _this_object : window;
    var args = is_valid(_args) ? _args : [];

    object.temp = this;

    var str = 'object.temp(';

    for(var i = 0, n = args.length; i < n; i++)
    {
        str += 'args['+i+']';
        
        if(i+1 < n)
        {
            str += ',';
        }
    }
    
    str += ');';

    var rc = eval(str);
    
    delete object.temp;

    return rc;
}

if(!is_valid(Function.prototype.apply))
{
    Function.prototype.apply = dhtml_apply;
}

function dhtml_call(_this_object, _arg1, _arg2, _argN)
{
    return this.apply(_this_object, Array.apply(null, arguments).slice(1));
}

if(!is_valid(Function.prototype.call))
{
    Function.prototype.call = dhtml_call;
}

//
window.onload = function()
{
    if(is_valid(window.init_page))
    {
        // custom initialization
        window.init_page();
    }

    // attach objects
    dhtml_initialize();
}

window.onunload = function()
{
    if(is_valid(window.onunload2))
    {
        // custom cleanup
        window.onunload2();
    }
    
    dhtml_uninitialize();
}
////////////////////////////////////////////////////////////////////////////////////////
// dhtml init
// ----- ----
function dhtml_initialize()
{
    // global context for transfering data
    document.dhtml_global_context = null;
}

function dhtml_uninitialize()
{
}
////////////////////////////////////////////////////////////////////////////////////////
// counter
// -------
function counter()
{
    this.count = 0;
}

counter.prototype.get_next = function()
{
    return this.count++;
}

the_counter = new counter;
////////////////////////////////////////////////////////////////////////////////////////
