// Title: COOLjsMenu
// URL: http://javascript.cooldev.com/scripts/coolmenu/
// Version: 2.4.8
// Last Modify: 5 Jul 2005
// Author: Alex Kunin <alx@cooldev.com>
// Notes: Registration needed to use this script on your web site.
// Copyright (c) 2001-2005 by CoolDev.Com
// Copyright (c) 2001-2005 by Sergey Nosenko

// Options: PROFESSIONAL, COMPATIBLE



function _isUndefined(_value)
{
        return typeof(_value) == 'undefined';
}

function _isNumber(_value)
{
        return typeof(_value) == 'number';
}

function _isObject(_value)
{
        return typeof(_value) == 'object';
}

_document = document;
_RegExp = RegExp;
_window = window;
_document._getElementById = _document.getElementById;
__getElementById = _document._getElementById ? function (_id) { return _document.getElementById(_id) } : function (_id) { return _document.all[_id] };

_fieldNames = {
        _width:1,
        _height:0,
        _left:3,
        _top:2
};

_reverseFieldNames = {};

for (var i in _fieldNames)
        _reverseFieldNames[_fieldNames[i]] = i;

_STATE_NORMAL = 1;
_STATE_ROLLOVERED = 2;

_window.CMenus = _window.$CM = _window._CMenus = [];

_bw = {};
        _bw._version = navigator.appVersion;
        _bw._agent = navigator.userAgent;
        _bw._opera = _window.opera;
        _bw._operaNew = _bw._agent.match(/opera.[789]/i);
        _bw._operaOld = _bw._opera && !_bw._operaNew;
        _bw._dom = _document._getElementById;
        _bw._ie55 = _bw._version.match(/MSIE 5.5/) && _bw._dom && !_bw._opera;
        _bw._ie5 = _bw._version.match(/MSIE 5/) && _bw._dom && !_bw._ie55 && !_bw._opera;
        _bw._ie6 = _bw._version.match(/MSIE 6/) && _bw._dom && !_bw._opera;
        _bw._ie4 = _document.all && !_bw._dom && !_bw._opera;
        _bw._ie = _bw._ie4 || _bw._ie5 || _bw._ie6;
        _bw._mac = _bw._agent.match(/Mac/);
        _bw._hotjava = _bw._agent.match(/hotjava/i);
        _bw._ns4 = _document.layers && !_bw._dom && !_bw._hotjava;
        _bw._gecko = _bw._agent.match(/gecko/i);
        _bw._filters = _bw._ie && !_bw._mac;

_defaultMenu = {
        zIndex:1000,

        pos:'relative',

        dynamic:true,

        delay:[ 0, 400 ],

        popupoff:[ 0, 0 ],

        blankImage:'b.gif'
}

_defaultLayer = {
        main:false,
        image:null,
        color:'',
        cssStyle:'',
        cssClass:'',
        attributes:'',
        size:['+item','+item'],
        offset:[0,0],
        code:_bw._operaOld ? '&nbsp;' : '',
        _width:0,
        _height:0,
        _left:0,
        _top:0,
        _visible:true,
        align:'left',
        valign:'top',
        _updatePosition:function () {
                with (this) {
                        _updatePosition = _nop;

                        if (!main)
                        {
                                _width = Number.NaN;
                                _height = Number.NaN;

                                _width = size[1](_item, this);
                                _height = size[0](_item, this);

                                if (isNaN(_width) || isNaN(_height))
                                {
                                        _width = _layer._getWidth();
                                        _height = _layer._getHeight();

                                        _width = size[1](_item, this);
                                        _height = size[0](_item, this);
                                }

                                _layer._resize(_width, _height);
                        }

                        _left = offset[1](_item, this) + ((this._shiftable && this._item._contentOffset) || 0);

                        _top = offset[0](_item, this);

                        _layer._move(_left, _top);

                        _item._parent._level._includeRectangle(this);
                }
        },
        _updateVisibility:function () {
                if (this._visible != this._item._shouldBeVisible(this.visibility))
                        this._layer._setVisibility(this._visible = !this._visible);

                this._updatePosition();
        },
        _updateVisibilityFiltered:function () {
                if (this._visible != this._item._shouldBeVisible(this.visibility))
                {
                        this._visible = !this._visible;
                        var _transition = (this._item._parent._level._itemFiltersEnabled && _bw._ie && this[this._visible ? 'fadeIn' : 'fadeOut']) || '';
                        var _filters = (_bw._ie && !_bw._mac && this.filters) || '';
                        if (_transition || _filters)
                                this._layer._style.filter = _transition + ' ' + _filters;

                        with (this._layer)
                        {
                                if (_transition)
                                        _layer.filters[0].apply();
                                _setVisibility(this._visible);
                                if (_transition)
                                        _layer.filters[0].play();
                        }
                }

                this._updatePosition();
        }
}

_defaultStyle = {

}

function _applyDefaults(_object, _template)
{
        for (var i in _template)
                if (_isUndefined(_object[i]))
                        _object[i] = _template[i];
}

BLANK_IMAGE = 'b.gif';

function COOLjsMenuPRO(_name, _items)

{
        _applyDefaults(_items[0], _defaultMenu);

        this._isDynamic = _items[0].dynamic && ((_bw._dom && !_bw._operaOld && !(_bw._ie && _bw._mac)) || _bw._ns4);

        this._autosize = _items[0].autosize;

        this._dynamicHandlerBinding = _bw._ie || _bw._gecko;

        this._body = {};

        _items[0].blankImage = BLANK_IMAGE;

        if (!_name)
        {
                _name = 'menu_';
                do _name += Math.round(Math.random() * 10); while (!_isUndefined(_window._CMenus[_name]))
        }

        _window._CMenus[this._name = _name] = this;
        this._jsPath = '$CM.' + _name;

        this._isPopup = _items[0].popup;
        this._isFramed = _items[0].frames;
        this._isTopFrame = this._isFramed && _items[0].frames[0] == _window.name;
        this._isRelative = !this._isPopup && _items[0].pos == 'relative' && (!this._isFramed || this._isTopFrame);

        this.$root = this._root =
        {
                _menu:this,
                _name:this._name,
                _jsPath:this._jsPath + '.$root',
                _parent:null,
                _left:0,
                _top:0,
                _properties:_items[0],
                frameoff:_items[0].pos?_items[0].pos:[0,0],
                _setState:_nop,
                _index:'R',
                _hasSubmenu:true,
                _depth:-1,
                _rawSubmenu:_items,
                _getRelativePath:function () { return [] },
                _getPath:function () { return [] },
                _getId:_CMenuItem.prototype._getId,
                _reindexTabs:_CMenuItem.prototype._reindexTabs
        };

        if (this._isFramed && !this._isTopFrame)
        {
                this._root._left = 0;
                this._root._top = 0;
        }
        else if (!this._isRelative && !this._isPopup)
        {
                this._root._left = _items[0].pos[0];
                this._root._top = _items[0].pos[1];
        }

        this._ns4OffsetLeft = this._ns4OffsetTop = 0;
        this._root.$level = this._root._level = new _CMenuLevel(this, this._root);

        with (this._root)
        {
                if (_isNumber(_properties.delay))
                        _properties.delay = [ 400, _properties.delay ];

                _properties._dropDownDelay = _properties.delay[0];
                _properties._closeUpDelay = _properties.delay[1];
        }

        this.items = this._items = [];

        this._handlers = '';
        this._timeouts = [];
        this._lastActiveItem = null;
        this._lastShownLevel = null;
        this._selectedItem = null;

        this._triggerLayer = { name:'trigger', size:[ '+item', '+item' ], zIndex:1000, code:'{trigger}' };
        this._processLayer(this._triggerLayer);

        if (_isUndefined(_window._onload)) {
                _window._onload = _window.onload;
                _window.onload = function () {
                        CLoadNotify();
                        if (_window._onload) {
                                var _o = _window._onload;
                                _window._onload = null;
                                return _o();
                        }
                }
        }

        if (_bw._operaOld)
                _Layer = _OldOperaLayer;
        else if (_bw._ns4)
                _Layer = _Ns4Layer;
        else
        {

                _Layer = _CommonLayer;
        }

        _Layer._cache = {};

}

$ = COOLjsMenuPRO.prototype;

$._getId = function (_suffix)
{
        return this._name + '_' + _suffix;
}

$.$ev = $._processEvent = function (_event, _index, _dontContinue)
{
        var _result = true, _item = this._items[_index];

        if (_item)
        {

                _result = this['$' + _event](_item);
                if (this[_event])
                        this[_event](_item);
        }

        return _result;
}

$._getBlankImage = function ()
{
        return this._root._properties.blankImage;
}

$._onload = function ()
{

        if (!this._isPopup)
        {

                if (_bw._ns4 && this._isRelative)
                        with (_document.anchors[this._getId('da')])
                        {
                                this._root._left = x;
                                this._root._top = y;
                        }
                this._show();

        }

        this._onload = _nop;
}

$.initTop = function ()

{

        this._body._width = this._getBodyWidth();
        this._body._height = this._getBodyHeight();

        var w = 0, h = 0, i, s;

        if (!this._dynamicHandlerBinding)
                for (i in this)
                        if (i.match(/^\$(on.*)$/))
                                this._handlers += _attribute(_RegExp.$1, 'return ' + this._jsPath + '.$ev(\'' + _RegExp.$1 + '\', {index})');

        this._root._level._ensureChildren();

        this.root = this._root;
        this.root.cd = this._root._level._children;

        if (this._root._properties.placeholder)
                with (this._root._properties)
                {
                        w = placeholder[1];
                        h = placeholder[0];
                }
        else
                with (this._root._level)
                {
                        var x = 0, y = 0;

                        for (i = 0; i < _children.length; i++)
                        {
                                if (i > 0)
                                {
                                        x += _children[i]._itemOffset[1](_children[i]);
                                        y += _children[i]._itemOffset[0](_children[i]);
                                }

                                w = Math.max(w, x + _children[i]._size[1](_children[i]));
                                h = Math.max(h, y + _children[i]._size[0](_children[i]));
                        }
                }

        this._withPlaceholder = _isNumber(w + h) && w + h == w + h;

        if (!_bw._ns4)
        {
                s = '<div id="' + this._getId('r') + '" style="z-index:' + this._root._rawSubmenu[0].zIndex + ';position:';

                if (this._isRelative)
                        s += 'relative;' + (this._withPlaceholder ? 'width:' + w + 'px;height:' + h + 'px;' : '');
                else

                        s += 'absolute;left:' + this._root._left + 'px;top:' + this._root._top + 'px;';
                s += '">' + (this._isDynamic ? '' : this._root._level._getHtml()) +'</div>';
                _document.write(s);
                this._rootDiv = _Layer._find(this._getId('r'));

        }

        else if (this._isRelative)
                _document.write('<div><a name="' + this._getId('da') + '" href="#"><img src="' + this._getBlankImage() + '"' + (this._withPlaceholder ? 'width="' + w + '" height="' + h + '"' : 'width="1" height="1"') + ' border="0" /></a></div>');

        if (_bw._ie6)
        {
                this.$$$onclick = new Function('return ' + this._jsPath + ".$$onclick(event)");
                this._prevBodyOnClick = _document.body.onclick;
                _document.body.onclick = this.$$$onclick;
        }
        else if (_bw._dom && !_bw._mac)
        {
                this.$$$onclick = new Function('event', 'return ' + this._jsPath + ".$$onclick(event)");
                _document.addEventListener('click', this.$$$onclick, true);
        }

}

$._popup = function (ev, offX, offY)
{
        var x = ev.pageX || ev.x;
        var y = ev.pageY || ev.y;

        if (_bw._ie && _document.body && _document.body.parentElement)
        {
                x += _document.body.parentElement.scrollLeft;
                y += _document.body.parentElement.scrollTop;
        }

        var _popupOffset = this._root._properties.popupoff;

        x += _isUndefined(offX) ? _popupOffset[1] : offX;
        y += _isUndefined(offY) ? _popupOffset[0] : offY;

        this._popupAt(x, y);
}

$._popupAt = function (_x, _y)
{
        this._updatePositions(_x, _y);
        _window.setTimeout(this._jsPath + '._show()', 10);
        this._processExclusive();
}

$._popdown = function ()
{
        this._showLevel(null, this._root._properties._closeUpDelay);
}

$._isEventInner = function (_event)
{
        var _el = _event.srcElement || _event.target;

        while (_el)
        {
                if (_el == this._rootDiv._layer)
                        return true;

                _el = _el.parentNode;
        }

        return false;
}

$.$$onclick = function (_event)
{
        if (!this._isEventInner(_event))
        {
                this._cancelQueued();
                this._showLevel(null);
                this._setActiveItem(null);
        }

        if (this._prevBodyOnClick)
                this._prevBodyOnClick();
}

$._show = function ()
{

        this._showLevel(this._root._level);
}

$.init = _nop;

$.show = $._show;

$.hide = function ()
{
        this._showLevel(null);
}

$.moveXY = function (_x, _y)
{
        this._updatePositions(_x, _y);
}

$._updatePositions = function (_x, _y)
{
        if (_bw._ns4)
        {
                this._ns4OffsetLeft = _x;
                this._ns4OffsetTop = _y;
                this._root._level._ns4UpdatePosition();
        }
        else
                this._rootDiv._move(_x, _y);
}

$._enqueue = function (_method, _parameter, _delay)
{
        this._timeouts[this._timeouts.length] = _window.setTimeout(this._jsPath + '.' + _method + '(' + (_parameter ? _parameter._jsPath : 'null') + ')', _delay);
}

$.cancelQueued = $._cancelQueued = function () {
        for (var i in this._timeouts)
                _window.clearTimeout(this._timeouts[i]);
        this._timeouts = [];
}

$.setActiveItem = $._setActiveItem = function (_item, _delay)
{
        if (_delay)
                this._enqueue('setActiveItem', _item, _delay);
        else
        {
                if (this._itemWantsToGetItsTriggerBack)
                        this._itemWantsToGetItsTriggerBack._showTrigger();

                var _paths = _pathDifference(this._lastActiveItem, _item), i;

                for (i in _paths[0])
                        _paths[0][i]._setState(_STATE_NORMAL);
                for (i in _paths[1])
                        _paths[1][i]._setState(_STATE_ROLLOVERED);

                this._lastActiveItem = _item;

                if (_item)
                        this._processExclusive();

                if (_item && _item._data.hasControls)
                {
                        this._itemWantsToGetItsTriggerBack = _item;
                        _item._hideTrigger();
                } else

                        this._itemWantsToGetItsTriggerBack = null;
        }
}

$.setSelectedItem = $._setSelectedItem = function (_item, _delay)
{
        if (_delay)
                this._enqueue('setSelectedItem', _item, _delay);
        else
        {
                var _previous = this._selectedItem;
                this._selectedItem = _item;
                (_previous || this._root)._setState('', true);
                (_item || this._root)._setState('', true);
        }
}

$.showLevel = $._showLevel = function (_level, _delay)
{
        if (_delay)
                this._enqueue('showLevel', _level, _delay);
        else
        {
                if (_level && _level._dummy)
                        _level = _level._parent._parent._level;

                if (!_level && !this._isPopup)
                        _level = this._root._level;

                var _paths = _pathDifference(this._lastShownLevel, _level), i;

                _setVisibility(_paths[0], false);
                _setVisibility(_paths[1], true);

                this._lastShownLevel = _level;

                this._fixGecko();

        }
}

$._processExclusive = function ()
{
        if (this._root._properties.exclusive)
                for (i in _window._CMenus)
                        if (_window._CMenus[i] != this)
                        {
                                _window._CMenus[i]._showLevel(null);
                                _window._CMenus[i]._setActiveItem(null);
                        }
}

$._fixGecko = function ()
{
        if (_bw._gecko)
        {
                if (this._isRelative)
                {
                        var o = this._rootDiv._layer.parentNode;
                        if (o.tagName != 'BODY')
                        {

                                o.style.width = this._rootDiv._layer.offsetWidth + 'px';
                                o.style.height = this._rootDiv._layer.offsetHeight + 'px';
                        }
                }
        }
}

$.$onfocus = function (_item)
{
        _item._attachHandlers();

        this._cancelQueued();
        this._showLevel(_item._parent._level);
        _item._setStatus(true);
        this._setActiveItem(_item);
}

$.$_onblur = function (_item)
{
        this._cancelQueued();

        if (this._itemWantsToGetItsTriggerBack)
                return true;

        if (!_item._data.sticky)
                this._showLevel(null);
        this._setActiveItem(null);

        _item._setStatus(false);
}

$.$onmouseover = function (_item)
{
        _item._attachHandlers();
        this._cancelQueued();
        this._showLevel(_item._level, this._root._properties._dropDownDelay);
        _item._setStatus(true);
        this._setActiveItem(_item);
        return true;
}

$.$onclick = function (_item)
{
        this._cancelQueued();
        this._setSelectedItem(_item);

        if (_item._data.url)
        {
                _window.open(_item._data.url, _item._data.target || '_' + 'self');
                if (!_item._data.sticky)
                        this._showLevel(null);
        }
        else
        {
                this._showLevel(_item._level._visible ? _item._level._parent._parent._level : _item._level);
        }

        return false;
}

$.$onkeydown = function (_item)
{
        if (_bw._ie)
        {
                var _nextItem = null;

                switch (event.keyCode)
                {
                case 38:
                        _nextItem = _item._getPreviousSibling() || _item._parent._level._getLastChild();
                        break;
                case 40:
                        _nextItem = _item._getNextSibling() || _item._parent._level._getFirstChild();
                        break;
                case 27:
                case 37:
                        if (_item._parent != this._root)
                                _nextItem = _item._parent;
                        else
                        {
                                _item._getAhcnor().blur();
                                this._setActiveItem(null);
                        }
                        break;
                case 39:
                        if (_item._hasSubmenu)
                        {
                                this._showLevel(_item._level);
                                _nextItem = _item._level._getFirstChild();
                        }
                        break;
                case 36:
                        _nextItem = _item._parent._level._getFirstChild();
                        break;
                case 35:
                        _nextItem = _item._parent._level._getLastChild();
                        break;
                }

                if (_nextItem)
                {
                        _nextItem._getAhcnor().focus();
                        return false;
                }
        }

        return true;
}

$.$onmouseout = function (_item)
{
        this._cancelQueued();

        if (this._itemWantsToGetItsTriggerBack)
                return true;

        this._showLevel(this._isPopup && this._lastShownLevel ? this._root._level : null, this._root._properties._closeUpDelay);

        this._setActiveItem(null, this._root._properties._closeUpDelay);
        _item._setStatus(false);
        return true;
}

$.$resizeHandler = function ()
{
        this._body._width = this._getBodyWidth();
        this._body._height = this._getBodyHeight();
        this._root._level._updatePositions();
        return this._previousResizeHandler ? this._previousResizeHandler() : true;
}

$._installResizeHandler = function ()
{
        this._previousResizeHandler = window.onresize;
        window.onresize = new Function('return ' + this._jsPath + '.$resizeHandler()');
        this._installResizeHandler = _nop;
}

$._getBodyWidth = function ()
{
        return document.body.clientWidth;
}

$._getBodyHeight = function ()
{
        return document.body.clientHeight;
}

$._preparePairedCalculator = function (_array, _defaultOrigin)
{
        if (!_isUndefined(_array) && typeof(_array[0]) != 'function')
        {
                _array[1] = this._prepareCalculator(_array[1], _defaultOrigin, 1);
                _array[0] = this._prepareCalculator(_array[0], _defaultOrigin, 0);
        }

        return _array;
}

var _calcCache = {};

$._prepareCalculator = function (_value, _defaultOrigin, _dimension)
{
        var _hash = _value + '|' + _defaultOrigin + '|' + _dimension;
        if (!_isUndefined(_calcCache[_hash]))
                return _calcCache[_hash];

        var _code = 'return Math.round(';

        if (_isNumber(_value))
                _code += _value;
        else
        {
                _code = 'with(i)' + _code;
                var _field = _getFieldName(_dimension), _magnitude, _match;

                while (_match = _value.match(/^([-+\.\d+]*)\*?(\w+)/))
                {
                        if (_match[1] == '')
                                _defaultOrigin = _match[2];
                        else
                                _code += _formatNumber(_match[1]) + (_match[2] == 'px' ? '' : '*' + _match[2] + _field);

                        if (_match[2] == 'body')
                                this._installResizeHandler();

                        _value = _value.slice(_match[0].length);
                }
        }

        if (_defaultOrigin)
        {
                var _fieldName = _getFieldName(_dimension + 2);
                _code += '+i.' + _defaultOrigin + _fieldName;

                switch (_defaultOrigin)
                {
                case 'item':
                case 'previousItem':
                        break;
                case 'parentItem':
                        _code += '+i.parentLevel' + _fieldName;
                default:
                        _code += '-i.level' + _fieldName;
                }
        }

        _code += '+0)';

        var _result = _calcCache[_hash] = new Function('i,self', _code);
        return _result;
}

$._processLayer = function (_layer, _context)
{
        if (!_layer._processed)
        {
                _layer._processed = true;

                if (!_layer.size && (_layer.main || _layer.code))
                        _layer.size = [ '+self', '+self' ];

                _applyDefaults(_layer, _defaultLayer);

                if (_bw._filters && (_layer.fadeIn || _layer.fadeOut))
                        _layer._updateVisibility = _layer._updateVisibilityFiltered;

                with (_layer)
                {

                        if (image)
                                code = '<img src="' + image + '" width="' + size[1] + '" height="' + size[0] + '"' + (_bw._ns4 ? '' : ' style="display:block"') +' />';

                        else if (code && code != '{trigger}')
                                code = '<table cellspacing="0" cellpadding="0" border="0"><tr><td nowrap="nowrap"><div' + _attribute('class', cssClass) + _attribute('style', cssStyle) + '>' + code + '</div></td></tr></table>';

                        code = '<div' + attributes + ' id="" style="position:absolute;' + (_bw._operaOld ? 'width:1px;' : '') + (color ? 'background-color:' + color + ';' : '') + cssStyle + '"' + _attribute('class', cssClass) + '>' + code + '</div>' + "\n";
                        if (_bw._ns4)
                                code = code.replace(/background([-\w]*:)/g, 'layer-background$1');

                        offset = _copyObject(offset);
                        size = _copyObject(size);

                        if (_isNumber(offset[0]))
                                offset[0] = _formatNumber(offset[0]) + 'px';

                        if (_isNumber(offset[1]))
                                offset[1] = _formatNumber(offset[1]) + 'px';

                        ;

                        switch (_layer.align)
                        {
                        case 'center':
                                offset[1] += '+0.5' + _context + '-0.5self';
                                break;
                        case 'right':
                                offset[1] += '+' + _context + '-self';
                                break;
                        }

                        ;

                        switch (_layer.valign)
                        {
                        case 'middle':
                                offset[0] += '+0.5' + _context + '-0.5self';
                                break;
                        case 'bottom':
                                offset[0] = '+' + _context + '-self';
                                break;
                        }

                        if (!_isUndefined(_layer.margin))
                        {
                                var _left, _top, _right, _bottom;
                                if (_isNumber(_layer.margin))
                                        _left = _top = _right = _bottom = _layer.margin;
                                else if (_layer.margin.length == 2)
                                {
                                        _top = _bottom = _layer.margin[0];
                                        _left = _right = _layer.margin[1];
                                }
                                else
                                {
                                        _top = _layer.margin[0];
                                        _right = _layer.margin[1];
                                        _bottom = _layer.margin[2];
                                        _left = _layer.margin[3];
                                }

                                if (_isNumber(size[0]))
                                        size[0] = _formatNumber(size[0]) + 'px';

                                if (_isNumber(size[1]))
                                        size[1] = _formatNumber(size[1]) + 'px';

                                if (!main)
                                {
                                        size[0] += _formatNumber(-_top - _bottom) + 'px';
                                        size[1] += _formatNumber(-_left - _right) + 'px';
                                }
                                offset[0] += _formatNumber(_top) + 'px';
                                offset[1] += _formatNumber(_left) + 'px';
                        }

                        this._preparePairedCalculator(size);
                        this._preparePairedCalculator(offset, 'item');
                }
        }

        return _layer;
}

$._processStyle = function (_style)
{
        if (!_style._processed)
        {
                var i, j;

                _style._processed = true;

                _style.layers = [];
                _style._menu = this;
                _style._add = function (_layer) { this._menu._processLayer(this.layers[this.layers.length] = _layer, 'item') }

                var b = _style.border || 0, _transition = _style.transition || {};

                b = (b && _style.borders) || [ b, b, b, b ];
                var _borderLeft = _style._borderLeft = b[0], _borderTop = _style._borderTop = b[1], _borderRight = _style._borderRight = b[2], _borderBottom = _style._borderBottom = b[3], _borderWidth = _style._borderWidth = _borderLeft + _borderRight, _borderHeight = _style._borderHeight = _borderTop + _borderBottom;

                var _shadowHorizontal = 0, _shadowVertical = 0;

                if (_isNumber(_style.shadow))
                        _shadowHorizontal = _shadowVertical = _style.shadow;
                else if (_isObject(this._properties.shadow))
                {
                        _shadowHorizontal = _style.shadow[0];
                        _shadowVertical = _style.shadow[1];
                }

                if (!_style.color)
                        _style.color = {};

                if (!_style.css)
                        _style.css = {};

                if (_style.color.shadow && (_shadowHorizontal || _shadowVertical))
                        _style._add({
                                _noSubstitute:1,
                                color:_style.color.shadow,
                                offset:[_shadowVertical,_shadowHorizontal]
                        });

                if (_style.color.border && (_borderWidth || _borderHeight))
                        _style._add({
                                _noSubstitute:1,
                                color:_style.color.border
                        });

                _layer =
                {
                        size:['+item-' + _borderHeight + 'px','+item-' + _borderWidth + 'px'],
                        offset:[ _borderTop, _borderLeft ]
                };

                if (_style.color.bgON)
                        _style._add(
                                _copyObject(
                                        _layer,
                                        {
                                                _noSubstitute:1,
                                                color:_style.color.bgON,
                                                visibility:_transition.fadeIn || _transition.fadeOut ? '' : 'n'
                                        }
                                )
                        );

                if (_style.color.bgOVER)
                        _style._add(
                                _copyObject(
                                        _layer,
                                        {
                                                _noSubstitute:1,
                                                color:_style.color.bgOVER,
                                                visibility:'o',
                                                fadeIn:_transition.fadeIn,
                                                fadeOut:_transition.fadeOut
                                        }
                                )
                        );

                if (this._autosize)
                        _layer.size = 0;

                _style._add(
                        _copyObject(
                                _layer,
                                {

                                        main:this._autosize,

                                        code:'<div class="' + _style.css.ON + '">{code}</div>',
                                        visibility:'h',
                                        _shiftable:1
                                }
                        )
                );
                _style._add(
                        _copyObject(
                                _layer,
                                {
                                        code:'<div class="' + _style.css.OVER + '">{ocode}</div>',
                                        visibility:'H',
                                        _shiftable:1
                                }
                        )
                );

                _applyDefaults(_style, _defaultStyle);

        }

        return _style;
}

function _CMenuLevel(_menu, _parent)
{
        this._menu = _menu;
        this._parent = _parent;
        this._isTopLevel = _parent == _menu._root;

        this._isPersistent = !_menu._isPopup && this._isTopLevel;

        this._jsPath = this._parent._jsPath + '.$level';
        this._maxMain = { _width:0, _height:0 };
        this._name = this._menu._getId('l' + this._parent._index);
}

$ = _CMenuLevel.prototype;

$._children = [];
$._left = 0;
$._top = 0;
$._filtered = false;
$._itemFiltersEnabled = false;

$._ensureChildren = function ()
{
        if (!this._children.length)
        {
                var i, _items = this._parent._rawSubmenu, _last = _items.length - 1;

                if (_isUndefined(_items[_last]))
                        _last--;

                this._children = _items.slice(1, _last + 1);

                if (this._children.length == 1 && this._children[0].array)
                {
                        var _definition = this._children[0];
                        this._children = [];

                        for (i = 0; i < _definition.array.count; i++)
                        {
                                this._children[i] = _copyObject(_definition);
                                this._children[i].array.prepare(this._children[i], i);
                        }
                }

                with (this)
                        for (i in _children)
                                _children[i] = new _CMenuItem(_menu, _parent, _children[i], parseInt(i), _menu._items.length);
        }
}

$._getId = function (_suffix)
{
        return this._name + '_' + _suffix;
}

$._getFirstChild = function ()
{
        return this._children[0];
}

$._getLastChild = function ()
{
        return this._children[this._children.length - 1];
}

$._hasIframe = function ()
{
        return !this._isPersistent && (_bw._ie55 || _bw._ie6) && !this._getFilters(true) && !this._getTransition(true) && !this._getTransition(false);
}

$._ns4UpdatePosition = function ()
{
        if (this._dynLayer)
        {
                this._dynLayer._move(this._menu._ns4OffsetLeft, this._menu._ns4OffsetTop);
                for (var i in this._children)
                        this._children[i]._level._ns4UpdatePosition();
        }
}

$._updatePositions = function ()
{
        this._excludeAllRectangles();

        for (var i in this._children)
                this._children[i]._updatePositions();

        this._updateSizeAndPosition();
}

$._getHtml = function ()
{
        this._ensureChildren();

        var i, _result = '<div id="' + this._getId('l') + '" style="position:absolute;visibility:hidden;">';

        for (i in this._children)
                _result += this._children[i]._htmlCode;

        _result += '</div>';

        if (!this._menu._isDynamic)
        {
                _result = '<div id="' + this._getId('d') + '" style="position:absolute;visibility:hidden;left:0;top:0;width:1px;height:1px;">' + _result + '</div>';
                for (i in this._children)
                        _result += this._children[i]._level._getHtml();
        }

        if (this._hasIframe())
                _result = '<iframe tabindex="-1" frameborder="0" id="' + this._getId('f') + '" src="' + (location.protocol == 'https:' ? this._menu._root._properties.https_fix_blank_doc : '') + '" scroll="none" style="filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);visibility:hidden;height:1px;position:absolute;width:1px;"></iframe>' + _result;

        return _result;
}

$._getPath = function ()
{
        with (this._parent)
                return _parent ? _parent._level._getPath().concat([this]) : [this];
}

$._includeRectangle = function (_object)
{
        this._minLeft = Math.min(this._minLeft, _object._left);
        this._minTop = Math.min(this._minTop, _object._top);
        this._maxRight = Math.max(this._maxRight, _object._left + _object._width);
        this._maxBottom = Math.max(this._maxBottom, _object._top + _object._height);
}

$._excludeAllRectangles = function ()
{
        this._minLeft = this._minTop = 65535;
        this._maxRight = this._maxBottom = -65535;
}

$._getFilters = function ()
{
        return _bw._filters ? this._children[0]._properties.filters || '' : '';
}

$._getTransition = function (_isItFadeIn)
{
        return !this._isPersistent && _bw._filters ? this._children[0]._properties[_isItFadeIn ? 'fadeIn' : 'fadeOut'] || '' : '';
}

$._updateSizeAndPosition = function ()
{
        if (!this._isTopLevel)
        {
                this._left += this._children[0]._levelOffset[1](this._children[0]);
                this._top += this._children[0]._levelOffset[0](this._children[0]);
        }
        else if (_bw._ns4)
        {
                this._left = this._menu._root._left;
                this._top = this._menu._root._top;
        }

        this._layer._move(-this._minLeft, -this._minTop);
        this._dynLayer._move(this._left + this._minLeft, this._top + this._minTop);

        this._layer._resize(this._maxRight - this._minLeft, this._maxBottom - this._minTop);
        this._dynLayer._resize(this._maxRight - this._minLeft, this._maxBottom - this._minTop);
        if (_bw._ns4)
        {
                with (this._dynLayer._layer.clip)
                {
                        left = this._minLeft;
                        top = this._minTop;
                }
                with (this._layer._layer.clip)
                {
                        left = this._minLeft;
                        top = this._minTop;
                }
        }

        if (!_bw._ns4 && !_bw._operaOld && this._isPersistent && this._menu._isRelative && !this._menu._withPlaceholder)
                this._menu._rootDiv._resize(this._width, this._height);

                if (this._hasIframe())
                        this._iframe._setVisibility(this._visible);
                else if (this._isPersistent)
                {
                        var i, _list = this._menu._root._properties.forms_to_hide;
                        if (_list)
                                for (i in _list)
                                        _Layer._find(_list[i])._setVisibility(!this._menu._lastShownLevel || this._menu._lastShownLevel == this._menu._root._level);
                }

}

$._setVisibility = function (_value)
{
        if (this._visible != _value)
        {
                this._itemFiltersEnabled = false;

                var i;
                this._visible = _value;
                this._parent._setState('', true);

                if (!this._initialized)
                {
                        this._initialized = true;

                        if (this._menu._isDynamic)
                                this._dynLayer = _Layer._create(this._getHtml(), this._menu._rootDiv || 1);
                        else
                                this._dynLayer = _Layer._find(this._getId('d'));

                        if (this._hasIframe())
                                this._iframe = _Layer._find(this._getId('f'));

                        this._layer = _Layer._find(this._getId('l'));

                        this._excludeAllRectangles();

                        for (i in this._children)
                                this._children[i]._initializeLayers();

                        for (i in this._children)
                                this._children[i]._calculateSizeAndPosition();

                        this._width = this._maxRight - this._minLeft;
                        this._height = this._maxBottom - this._minTop;

                        this._excludeAllRectangles();
                }

                var _filters = '';

                if (_bw._filters)
                {
                        _filters = this._getTransition(_value) + ' ' + this._getFilters();
                        var _filtered = _filters != ' ';

                        if (_filtered != this._filtered)
                        {
                                this._dynLayer._style.filter = _filters;
                                this._filtered = _filtered;
                        }

                        if (_filtered)
                                for (i = 0; i < this._dynLayer._layer.filters.length; i++)
                                        this._dynLayer._layer.filters[i].apply();
                }

                _setVisibility(this._children, _value);

                this._updateSizeAndPosition();

                if (this._hasIframe())
                {
                        this._iframe._move(this._left + this._minLeft, this._top + this._minTop);
                        this._iframe._resize(this._maxRight - this._minLeft, this._maxBottom - this._minTop);
                }

                this._dynLayer._setVisibility(_value);
                this._layer._setVisibility(_value);

                if (_filters)
                        for (var i = 0; i < this._dynLayer._layer.filters.length; i++)
                                this._dynLayer._layer.filters[i].play();
        }

        this._itemFiltersEnabled = _value;
}

function _CMenuItem(_menu, _parent, _data, _minorIndex, _index)
{
        _menu._items[_index] = this;

        this.index = _index;

        if (_isUndefined(_data.ocode))
                _data.ocode = _data.code;
        _data.index = _index;
        _data.$0 = null;

        var _style = this._style = (_data.format || {}).style || _parent._rawSubmenu[0].style || _parent._properties.style;

        this._depth = _parent._depth + 1;

        if (_isObject(_style) && _style.length)
                _style = _style[this._depth] || _style[0];

        this._properties = _copyObject(
                _parent._properties,
                _style == _parent._style ? {} : _menu._processStyle(_style),
                _parent._rawSubmenu[0],
                _data.format || {}
        );

        _applyDefaults(
                this,
                {
                        _menu:_menu,
                        _index:_index,
                        _parent:_parent,
                        _minorIndex:_minorIndex,
                        _name:_menu._getId('i' + _index),
                        _left:0,
                        _top:0,
                        _width:0,
                        _height:0,
                        _jsPath:_menu._jsPath + '.items[' + _index + ']',
                        _main:{},
                        _visible:false,
                        _state:_STATE_NORMAL,
                        _layers:[],
                        _htmlCode:'',
                        _previousItem:_parent._level._children[_minorIndex - 1],
                        _isTopLevel:_parent == _menu._root,
                        _isFirst:_minorIndex == 0,
                        _isLast:_minorIndex == _parent._level._children.length - 1,
                        _data:_copyObject(_data, this._properties.parameters),
                        _rawSubmenu:_data.sub,
                        _hasSubmenu:_data.sub && _data.sub.length > 1,
                        _size:_menu._preparePairedCalculator(this._properties.size),
                        _levelOffset:_menu._preparePairedCalculator(this._properties.leveloff, 'parentItem'),
                        _itemOffset:_menu._preparePairedCalculator(this._properties.itemoff, 'previousItem'),
                        _wrapOffset:_menu._preparePairedCalculator(this._properties.wrapoff, 'previousItem')
                }
        );

        this.$level = this._level = this._hasSubmenu ? new _CMenuLevel(_menu, this) : {
                _dummy:true,
                _parent:this,
                _jsPath:this._jsPath + '.$level',
                _getPath:_CMenuLevel.prototype._getPath,
                _getHtml:_nop,
                _ns4UpdatePosition:_nop,

                _updatePositions:_nop
        };

        this._data.trigger = '<a' + _attribute('class', this._properties.trigger) + _attribute('accesskey', this._data.key) + ' href="' + (this._data.url || '#') + '" ' + _attribute('target', this._data.target) + this._menu._handlers + '>' + (_bw._operaOld ? '' : '<img src="' + this._menu._getBlankImage() + '" width="100%" height="100%"' + _attribute('alt', this._data[this._properties.alt || 'alt']) + ' border="0" />') + '</a>';

        _applyDefaults(
                this,
                {
                        main:this._main,
                        maxMain:_parent._level._maxMain,
                        item:this,
                        previousItem:this._previousItem,
                        level:_parent._level,
                        parentItem:_parent,

                        body:this._menu._body,

                        parentLevel:this._isTopLevel ? null : _parent._parent._level
                }
        );

        var _iconLayers = [], _arrowLayers = [];

        if (this._properties.imgsize && this._properties.image)
        {
                this._contentOffset = this._properties.imgsize[1];
                _iconLayers[0] =
                        _menu._processLayer(
                                {
                                        _noSubstitute:1,
                                        image:this._properties.image,
                                        size:this._properties.imgsize,
                                        offset:[ 0, this._properties._borderLeft ],
                                        valign:'middle',
                                        visibility:'n'
                                },
                                'item'
                        );

                _iconLayers[1] =
                        _menu._processLayer(
                                {
                                        _noSubstitute:1,
                                        image:this._properties.oimage || this._properties.image,
                                        size:this._properties.imgsize,
                                        offset:[ 0, this._properties._borderLeft ],
                                        valign:'middle',
                                        visibility:'o'
                                },
                                'item'
                        );
        }

        if (this._properties.arrsize && this._properties.arrow)
        {
                _arrowLayers[0] =
                        _menu._processLayer(
                                {
                                        image:this._properties.arrow,
                                        size:this._properties.arrsize,
                                        align:'right',
                                        valign:'middle',
                                        visibility:'nc'
                                },
                                'item'
                        );

                _arrowLayers[1] =
                        _menu._processLayer(
                                {
                                        image:this._properties.oarrow || this._properties.arrow,
                                        size:this._properties.arrsize,
                                        align:'right',
                                        valign:'middle',
                                        visibility:'oc'
                                },
                                'item'
                        );
        }

        with (this)
                _addLayers(_properties.levelLayers),
                _addLayers(_properties.itemLayers),
                _addLayers(_properties.layers),

                _addLayers(_iconLayers),
                _addLayers(_arrowLayers),

                _addLayers([_menu._triggerLayer]);
}

$ = _CMenuItem.prototype;

$._getPreviousSibling = function ()
{
        return this._parent._level._children[this._minorIndex - 1] || null;
}

$._getNextSibling = function ()
{
        return this._parent._level._children[this._minorIndex + 1] || null;
}

$._reindexTabs = function (_firstAvailableIndex)
{
        if (this != this._menu._root)
        {
                with (this._getAhcnor())
                {

                        tabIndex = _firstAvailableIndex++;
                }
        }

        if (this._level._visible)
                for (var i in this._level._children)
                        _firstAvailableIndex = this._level._children[i]._reindexTabs(_firstAvailableIndex);

        return _firstAvailableIndex;
}

$._getAhcnor = function ()
{
        return this._layers[this._layers.length - 1]._layer._layer.childNodes[0];
}

$._attachHandlers = function (_onlyRequiredMinimum)
{
        if (this._menu._dynamicHandlerBinding && !this._handlersAttached)
        {
                for (i in _onlyRequiredMinimum ? {$onmouseover:1, $onfocus:1} : this._menu)
                        if (i.match(/^\$(on.*)$/))
                                this._getAhcnor()[_RegExp.$1] = new Function('return ' + this._menu._jsPath + '.$ev(\'' + _RegExp.$1 + '\', ' + this._index + ')');

                this._handlersAttached = !_onlyRequiredMinimum;
        }
}

$._getId = function (_suffix)
{
        return this._name + '_' + _suffix;
}

$.getData = function ()
{
        return this._data;
}

$._setStatus = function (_flag)
{
        var _text = this._data[this._properties.status || 'status'];
        if (_text)
                _window.status = _flag ? _text : _window.defaultStatus;
}

$._getPath = function ()
{
        return this._parent._getPath().concat([this]);
}

$._getRelativePath = function ()
{
        return this._parent._getRelativePath().concat([this._minorIndex]);
}

$._addLayers = function (_list)
{
        for (var i in _list || [])
        {
                var _definition = _list[i];
                if (this._isPotentiallyVisible(_definition.visibility))
                {
                        var i, _code = _definition.code, _match;

                        if (!_definition._noSubstitute)
                        {
                                while (_match = _code.match(/\{([\w\d]+)=([^}]*)\}/))
                                        _code = _code.replace(new _RegExp(_match[0], 'g'), _isUndefined(this._data[_match[1]]) ? _match[2] : this._data[_match[1]]);

                                while (_match = _code.match(/\{([\w\d]+)\}/))
                                {
                                        if (_isUndefined(this._data[_match[1]]))
                                                break;
                                        _code = _code.replace(new _RegExp(_match[0], 'g'), this._data[_match[1]]);
                                }
                        }

                        i = this._layers.length;
                        this._layers[i] = _copyObject(_definition);
                        this._htmlCode += _code.replace('id=""', 'id="' + this._getId(i) + '"');
                }
        }
}

$._initializeLayers = function ()
{
        var i, _previousMainIndex, _self;
        for (i in this._layers)
        {
                with (this._layers[i]._layer = _Layer._find(this._getId(i)))
                        if (this._layers[i].main)
                        {
                                if (!_isUndefined(_previousMainIndex))
                                        this._layers[_previousMainIndex].main = false;

                                _self = { _width:Number.NaN, _height:Number.NaN };
                                this._layers[i]._width = this._main._width = this._layers[i].size[1](this, _self);
                                this._layers[i]._height = this._main._height = this._layers[i].size[0](this, _self);

                                if (isNaN(this._main._width) || isNaN(this._main._height))
                                {
                                        _self = { _width:_getWidth(), _height:_getHeight() };
                                        this._layers[i]._width = this._main._width = this._layers[i].size[1](this, _self);
                                        this._layers[i]._height = this._main._height = this._layers[i].size[0](this, _self);
                                }

                                with (this._parent._level._maxMain)
                                {
                                        _width = Math.max(_width, this._main._width);
                                        _height = Math.max(_height, this._main._height);
                                }
                                _previousMainIndex = i;
                        }

                this._layers[i]._item = this;
        }

        this._attachHandlers(true);
}

$._calculateSizeAndPosition = function ()
{
        with (this)
        {
                _width = _properties.size[1](this);
                _height = _properties.size[0](this);

                if (_previousItem)
                {
                        if (_data.wrapPoint)
                        {
                                _left = _wrapOffset[1](this);
                                _top = _wrapOffset[0](this);
                        }
                        else
                        {
                                _left = _itemOffset[1](this);
                                _top = _itemOffset[0](this);
                        }
                }

                _parent._level._includeRectangle(this);
        }
}

$._setVisibility = function (_value)
{
        this._visible = _value;
        this._setState(this._state, true);
}

$._isPotentiallyVisible = function (_string)
{
        if (_string)
        {
                var j, _value, _negate = false;

                for (j = 0; j < _string.length; j++)
                {
                        _value = null;

                        switch (_string.charAt(j))
                        {
                        case '!':
                                _negate = !_negate;
                                break;
                        case 'G':
                                _value = !!_bw._gecko;
                                break;
                        case 'c':
                                _value = !!this._hasSubmenu;
                                break;
                        case 'C':
                                _value = _negate != !!this._hasSubmenu;
                                break;
                        case 'H':
                                _value = !this._data.hasControls && !_negate;
                                break;
                        case 'h':
                        case 's':
                        case 'n':
                        case 'N':
                        case 'o':
                        case 'O':
                                _value = !_negate;
                                break;
                        case 'f':
                                _value = this._isFirst;
                                break;
                        case 'l':
                                _value = this._isLast;
                                break;
                        default:
                                _value = _string.charAt(j) == this._depth;
                                break;
                        }

                        if (_value !== null)
                                if (_value == _negate)
                                        return false;
                                else
                                        _negate = false;
                }
        }

        return true;
}

$._shouldBeVisible = function (_string)
{
        if (!this._visible)
                return false;

        if (_string)
        {
                var j, _value, _negate = false;

                for (j = 0; j < _string.length; j++)
                {
                        _value = null;

                        switch (_string.charAt(j))
                        {
                        case '!':
                                _negate = !_negate;
                                break;

                        case 'G':
                                _value = !!_bw._gecko;
                                break;
                        case 'C':
                                _value = !!(this._hasSubmenu && this._level._visible);
                                break;
                        case 's':
                                _value = this._menu._selectedItem == this;
                                break;
                        case 'h':
                                _value = this._data.hasControls ? !_negate : this._state == _STATE_NORMAL;
                                break;
                        case 'n':
                                _value = this._state == _STATE_NORMAL;
                                break;
                        case 'N':
                                _value = this._parent._state == _STATE_NORMAL;
                                break;
                        case 'H':
                        case 'o':
                                _value = this._state == _STATE_ROLLOVERED;
                                break;
                        case 'O':
                                _value = this._parent._state == _STATE_ROLLOVERED;
                                break;

                        default:

                                _value = !_negate;
                                break;
                        }

                        if (_value !== null)
                                if (_value == _negate)
                                        return false;
                                else
                                        _negate = false;
                }
        }

        return true;
}

$._setState = function (_value, _force)
{
        with (this)
                if (_value != _state || _force)
                {
                        if (_value)
                                _state = _value;

                        for (var i in _layers)
                                _layers[i]._updateVisibility();
                }
}

$._updatePositions = function ()
{
        this._calculateSizeAndPosition();

        for (var i in this._layers)
        {
                this._layers[i]._updatePosition = _defaultLayer._updatePosition;
                this._layers[i]._updatePosition();
        }

        if (this._level._initialized)
                this._level._updatePositions();
}

$._showTrigger = function ()
{
        this._layers[this._layers.length - 1]._layer._setVisibility(true);
}

$._hideTrigger = function ()
{
        this._layers[this._layers.length - 1]._layer._setVisibility(false);
}

_Layer = _nop;

function _gatherNs4Layers(_collection)
{
        for (var i in _collection)
        {
                _Layer._cache[_collection[i].id] = _collection[i];
                if (_collection[i].layers && _collection[i].layers.length)
                        _gatherNs4Layers(_collection[i].layers);
        }
}

function _CommonLayer()
{
}

$ = _CommonLayer.prototype;

_CommonLayer._find = function (_id)
{
        var _result = new _CommonLayer;
        _result._layer = __getElementById(_id);
        _result._init();
        return _result;
}

_CommonLayer._create = function (_html, _parent)
{
        _result = new _CommonLayer;
        _result._layer = _document.createElement('div');
        with (_result._layer.style)
        {
                position = 'absolute';
                left = top = -1000;
                visibility = 'hidden';
        }
        _result._layer.innerHTML = _html;
        _parent._layer.appendChild(_result._layer);
        _result._init();
        return _result;
}

$._init = function ()
{
        this._style = this._layer.style;
        this._firstChild = _bw._mac ? this._layer : this._layer.childNodes[0];
}

$._setVisibility = function (_value) { this._style.visibility = _value ? 'inherit' : 'hidden'; }
$._getWidth = function () { return this._firstChild.offsetWidth; }
$._getHeight = function () { return this._firstChild.offsetHeight; }
$._move = function (_left, _top) { with (this._style) { left = _left + 'px'; top = _top + 'px'; } }
$._resize = function (_width, _height) { with (this._style) { width = _width + 'px'; height = _height + 'px'; } }

function _OldOperaLayer()
{
}

$ = _OldOperaLayer.prototype;

_OldOperaLayer._find = function (_id)
{
        var _result = new _OldOperaLayer;
        _result._layer = __getElementById(_id);
        _result._style = _result._layer.style;
        return _result;
}

$._setVisibility = function (_value) { this._style.visibility = _value ? 'visible' : 'hidden'; }
$._getWidth = function () { return this._style.pixelWidth; }
$._getHeight = function () { return this._style.pixelHeight; }
$._move = function (_left, _top) { with (this._style) { left = _left; top = _top; } }
$._resize = function (_width, _height) { with (this._style) { width = _width; height = _height; } }

function _Ns4Layer()
{
}

$ = _Ns4Layer.prototype;

_Ns4Layer._find = function (_id)
{
        var _result = new _Ns4Layer;
        _result._layer = _Layer._cache[_id];
        return _result;
}

_Ns4Layer._create = function (_html)
{
        var _result = new _Ns4Layer;
        _resize._layer = new Layer(1000);
        with (_result._layer)
        {
                visibility = 'hide';
                document.open('text/html');
                document.write(_id);
                document.close();
                _gatherNs4Layers(layers);
        }
        return _result;
}

$._setVisibility = function (_value) { this._layer.visibility = _value ? 'inherit' : 'hide'; }
$._getWidth = function () { return this._layer.clip.width; }
$._getHeight = function () { return this._layer.clip.height; }
$._move = function (_left, _top) { this._layer.moveTo(_left, _top); }
$._resize = function (_width, _height) { this._layer.resize(_width, _height); }

function _nop()
{
        return '';
}

function _attribute(_name, _value)
{
        return _value ? ' ' + _name + '="' + _value + '"' : '';
}

function _copyObject (_object)
{
        if (!_isUndefined(_object.length) && _object.concat)
                return ([]).concat(_object);

        var i, j, _result = {};

        for (j = 0; j < arguments.length; j++)
                if (_isObject(arguments[j]))
                        for (i in arguments[j])
                                _result[i] = arguments[j][i];

        return _result;
}

function _getFieldName(_index)
{
        return '.' + _reverseFieldNames[_index];
}

function _formatNumber(_value)
{
        switch (_value) {
        case '':
                _value = '+';
        case '-':
        case '+':
                return _value + 1;
        default:
                return (_value >= 0 ? '+' : '') + parseFloat(_value);
        }
}

function _pathDifference(_object1, _object2)
{
        var _path1 = _object1 ? _object1._getPath() : [], _path2 = _object2 ? _object2._getPath() : [], i = 0;
        while (i < _path1.length && i < _path2.length && _path1[i] == _path2[i])
                i++;

        return [ _path1.slice(i), _path2.slice(i) ];
}

function _setVisibility(_objects, _value)
{
        for (var i in _objects)
                _objects[i]._setVisibility(_value);
}

function CMenuPopUp(_menu, _evn, _offX, _offY)
{
        _window._CMenus[_menu]._popup(_evn, _offX, _offY);
}

function CMenuPopUpXY(_menu, _x, _y)
{
        _window._CMenus[_menu]._popupAt(_x, _y);
}

function CMenuPopDown(_menu)
{
        _window._CMenus[_menu]._popdown();
}

function mEvent(_menuName, _itemIndex, _event)
{
        with (_CMenus[_menuName])
                switch (_event)
                {
                case 'o':
                        $onmouseover(_items[_itemIndex]);
                        break;
                case 't':
                        $onmouseout(_items[_itemIndex]);
                        break;
                }
}

function CLoadNotify()
{
        for (var i in _window._CMenus)
                _window._CMenus[i]._onload();
}

