var uag = window.navigator.userAgent.toLowerCase();
browser = {
	safari: /safari/.test( uag ) && !/chrome/.test( uag ),
	chrome: /chrome/.test( uag ),
	opera: /opera/.test( uag ),
	msie: /msie/.test( uag ) && !/opera/.test( uag ),
	firefox: /firefox/.test( uag ),
    version: (uag.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1]
};
function H( id )
{
    this.id = id;
    this.f = [];
    this.add = function( f )
    {
        this.f[ this.f.length ] = f;
    }
    this.fire = function( p )
    {
        for( var i = 0; i < this.f.length; i++ )
        {
        	try
        	{
            	this.f[ i ]( p );
            }
            catch( e )
            {
				//alert( 'EVENT: ' + this.id + '\nPARAM: ' + this.fire.arguments + '\n\n' + e.number + '\n' + e.description  + '\n\n' + this.f[ i ]);
            }
        }
    }
}
var E = new function()
{
    this.h = [];
    this.pageLoaded = false;

    this.hook = function( id )
    {
    	if( this.h[ id ] == null )
            this.h[ id ] = new H( id );
    }
    this.set = function( id, f )
    {
        if( f != null )
		{
			if( this.h[ id ] == null )
				this.hook( id );
            this.h[ id ].add( f );
		}
    }
    this.fire = function( id, p )
    {
        if( this.pageLoaded )
            this.h[ id ].fire( p );
    }
    this.clear = function( id )
    {
    	if( this.h[ id ] != null )
            this.h[ id ].f.length = 0;
    }
}
E.hook( "onLoad" );
E.hook( "onMouseMove" );
E.hook( "onClick" );
E.hook( "onKeyDown" );
E.hook( "onMouseDown" );
E.hook( "onResize" );
E.hook( "showPopup" );
document.onclick = function( event )
{
    E.fire( "onClick", event );
}
/*
document.onselectstart = function( event )
{
    var el = ( browser.msie  ? window.event.srcElement : event.target );
    if( el.tagName == 'INPUT' )
        return true;
    else
        return ( getParentDiv( el ).getAttribute( 'SELECT' ) == "true" );
}
*/
document.onmousedown = function( event )
{
    E.fire( "onMouseDown", event );
}

var onmm = function( event )
{
    E.fire( "onMouseMove", event );
}
window.onload = function( event )
{
    E.pageLoaded = true;
    E.fire( "onLoad", event );
    document.body.onmousemove = onmm;
}
document.ondragstart = function()
{
    return false;
}
document.onkeydown = function( event )
{
   	E.fire( "onKeyDown", event );
}
window.onresize = function( event )
{
    E.fire( "onResize", null );
}
document.oncontextmenu = function( event )
{
    var el = ( browser.msie  ? window.event.srcElement : event.target );
    while( el.tagName != "BODY" )
    {
        var pu = el.getAttribute( "POPUP" );
        if( pu != null )
        {
        	var id = el.getAttribute( "ID" );
            E.fire( "showPopup", { "id":id, "popup":pu });
            return false;
        }
        el =  el.parentNode;
    }
    return true;
}
var toUrl = function( url )
{
    document.location.href = url;
}
E.set( "toUrl", toUrl );
var toNewUrl = function( url )
{
    window.open( url );
}
E.set( "toNewUrl", toNewUrl );
var imgPath = '/media/design/';
var IDX = new function Indexer()
{
	var index = 0;

	this.get = function()
	{
		return index++;
	}
	this.over = function()
	{
		return index;
	}
	this.reset = function()
	{
		index = 0;
	}
}
var EF = new function()
{
    this.last = null;
    this.root = "document.body";

    this.create = function( tagName )
    {
        this.last = document.createElement( tagName );
        return this.last;
    }
    this.container = function( cont, el )
    {
        if( cont == null )
            cont = eval( this.root );
        if( el == null )
            cont.appendChild( this.last );
        else
            cont.appendChild( el );
    }
    this.set = function( el )
    {
        this.container( null, el );
    }
    this.createnew = function( tagName )
    {
        this.create( tagName );
        this.set( null );
        return this.last;
    }
    this.remove = function( cont, el )
    {
        if( cont == null )
            cont = eval( this.root );
        cont.removeChild( el );
    }
}
var Control = new function()
{
	this.master = null;

    this.find = function ( type )
    {
		var cont = ( this.master == null )? document.body : this.master;
        return this.findIn( cont, type );
    }
    this.findIn = function ( el, type )
    {
        var els = [];
        var nodes = el.childNodes;
		for( var i = 0; i < nodes.length; i++ )
        {
            var n = nodes[ i ];
			var ntype = n.nodeType;
			if( ntype == 1 && n.parentNode == el )
            {
                var attr = n.getAttribute( "control" );
                if( attr && attr == type )
                    els[ els.length ] = n;
                else
                    if( n.nodeName.toLowerCase() == type )
                        els[ els.length ] = n;
			}
		}
        return els;
    }
    this.findElement = function ( type )
    {
		var cont = ( this.master == null )? document.body : this.master;
        var els = [];
        this.findEl( cont, type, els );
        return els;
    }
    this.findEl = function ( el, name, els )
    {
        var nodes = el.childNodes;
		for( var i = 0; i < nodes.length; i++ )
        {
            var n = nodes[ i ];
            if( n.tagName == name )
            {
                els[ els.length ] = n;

            }
            if( n.nodeType == 1 )
                this.findEl( n, name, els );
        }
    }
}
var blankWindow = function( url, width, height )
{
	return window.open( url, '', 'width=' + width + ',height=' + height + ',toolbar=no,menubar=no,resizable=no,status=no' );
}
var coord = function ( el )
{
    var l = 0;
    var t = 0;

    while( el )
    {
        l += el.offsetLeft;
        t += el.offsetTop;
        el = el.offsetParent;
    }
    return { "left":l, "top":t };
}
var getParentDiv = function( el )
{
	while( el.tagName != "DIV" && el.tagName != "BODY" )
		el = el.parentNode;
    return el;
}
var getParentTable = function( el )
{
	while( el.tagName != "TABLE" && el.tagName != "BODY" )
		el = el.parentNode;
    return el;
}
var tag = function( id )
{
    return document.getElementById( id );
}
var tags = function( name )
{
    return document.getElementsByName( name );
}
var isNull = function( value )
{
    return value == null;
}
var isNullOrSpace = function( value )
{
    return value == null || value == '';
}
var getScrollTop = function()
{
    return self.pageYOffset ||( document.documentElement && document.documentElement.scrollTop )||( document.body && document.body.scrollTop );
}
var getScrollLeft = function()
{
    return self.pageXOffset ||( document.documentElement && document.documentElement.scrollLeft )||( document.body && document.body.scrollLeft );
}
var preloadImages = function()
{
    for( var i = 0; i < arguments.length; i++ )
    {
        this[ i ] = new Image();
        this[ i ].src = imgPath + arguments[ i ];
    }
    return this;
}
var png4ie = function ( obj )
{
    if( /msie/.test( uag ) && !/opera/.test( uag ) && browser.version <= 7 )
	{
		var src;
		if( obj.tagName == 'IMG' )
		{
			if( /\.png$/.test( obj.src ))
			{
				src = obj.src;
				obj.src = "/media/design/blank.gif";
			}
		}
		else
		{
			src = obj.currentStyle.backgroundImage.match( /url\("(.+\.png)"\)/i );
			if( src )
			{
				src = src[ 1 ];
				obj.runtimeStyle.backgroundImage = "none";
			}
		}
		if( src )
            obj.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}
var swapPng = function ( obj, uri )
{
    var ver = (uag.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1];
    if( /msie/.test( uag ) && !/opera/.test( uag ) && ver <= 7 )
        obj.filters(0).src = uri;
    else
        obj.src = uri;
}
var correctValue = function( num, delta )
{
    return ( browser.msie ? num : ( num - delta )) + 'px';
}
var panelState = 0;
var toState1 = function( arg )
{
    var e = arg.e;
    var id = arg.id;
    if( browser.msie )
        e = window.event;
    if( panelState == 0 )
    {
        tag( 'vscroll' ).style.display = 'none';
        tag( 'hscroll' ).style.display = 'block';
        var c = coord( sc.panel.owner );
        var mouseoffset = e.clientX - c.left - sc.panel.shift;
        var picRightPos = id * 70 + 6;
        var offset = mouseoffset - picRightPos;
        var newoffset = id * 130 + 6 + offset * 2 - e.clientX + c.left;
        var el = tag( 'icos' );
        el.className= 'iconb';
        elt = tag( 'tdpic' );
        elt.style.height = '148px';
        if( browser.chrome )
            elt.children[ 0 ].style.height = '148px';
        tag( 'vsp' ).style.display = 'none';
        tag( 'sp' ).style.display = 'block';
        tag( 'vsp' ).innerHTML = '';
        tag( 'sp' ).innerHTML = mc.toHTML( true );
        tag( 'dpic' ).style.height = '136px';
        sc.tostart();
        sc.vertical = false;
        sc.panel.mount( tag( 'sp' ));
        sc.bar.mount( tag( 'sb' ), tag( 'slen' ), 12 );
        sc.setAlpha( tag( 'i3' ), tag( 'i4' ), 60 );
        sc.tostart();
        sc.prepared();
        tag( 'i1' ).style.display = tag( 'i2' ).style.display = tag( 'i5' ).style.display = tag( 'i6' ).style.display = 'none';

        if( mc.count() == ( id + 1 ))
            sc.toend();
        else if ( id != 0 )
            sc.bar.position( newoffset / sc.bar.delta );
        E.fire( "changeState", panelState = 1 );
        E.fire( "showBigHint", id );
    }
}
var toState0 = function()
{
    if( panelState >= 1 )
    {
        tag( 'vscroll' ).style.display = 'none';
        tag( 'hscroll' ).style.display = 'block';
        var c = coord( sc.panel.owner );
        var offset = -sc.panel.shift - 6;
        var newoffset = offset / 130 * 70 + 6;
        var el = tag( 'icos' );
        el.className= 'icona';
        elt = tag( 'tdpic' );
        elt.style.height = '88px';
        if( browser.chrome )
            elt.children[ 0 ].style.height = '88px';
        tag( 'vsp' ).style.display = 'none';
        tag( 'sp' ).style.display = 'block';
        tag( 'vsp' ).innerHTML = '';
        tag( 'sp' ).innerHTML = mc.toHTML( false );
        tag( 'dpic' ).style.height = '73px';
        sc.tostart();
        sc.vertical = false;
        sc.panel.mount( tag( 'sp' ));
        sc.bar.mount( tag( 'sb' ), tag( 'slen' ), 12 );
        sc.setAlpha( tag( 'i1' ), tag( 'i2' ), 30 );
        sc.tostart();
        sc.prepared();
        tag( 'i3' ).style.display = tag( 'i4' ).style.display = tag( 'i5' ).style.display = tag( 'i6' ).style.display = 'none';
        if( newoffset > sc.bar.delta && panelState == 1 )
            sc.bar.position( newoffset / sc.bar.delta );
        E.fire( "changeState", panelState = 0 );
    }
}
var toState2 = function()
{
    if( panelState == 0 || panelState == 1 )
    {
        var vsel = tag( 'vscroll' );
        tag( 'hscroll' ).style.display = 'none';
        var c = coord( sc.panel.owner );
        vsel.style.display = 'block';
        vsel.style.top = c.top + 'px';
        vsel.style.left = ( c.left + sc.panel.visibleWidth - 25 ) + 'px';
        var el = tag( 'icos' );
        el.className= 'iconc';
        elt = tag( 'tdpic' );
        elt.style.height = '383px';
        if( browser.chrome )
            elt.children[ 0 ].style.height = '383px';
        tag( 'sp' ).style.display = 'none';
        tag( 'vsp' ).style.display = 'block';
        tag( 'sp' ).innerHTML = '';
        tag( 'vsp' ).innerHTML = mc.toHTML( true, 7 );
        tag( 'vsp' ).style.marginLeft = '30px';
        tag( 'dpic' ).style.height = '369px';
        sc.tostart();
        sc.vertical = true;
        sc.panel.mount( tag( 'vsp' ));
        sc.bar.mount( tag( 'vsb' ), tag( 'vslen' ), 22 );
        sc.setAlpha( tag( 'i5' ), tag( 'i6' ), 60 );
        sc.tostart();
        sc.prepared();
        tag( 'i1' ).style.display = tag( 'i2' ).style.display = tag( 'i3' ).style.display = tag( 'i4' ).style.display = 'none';
        E.fire( "changeState", panelState = 2 );
    }
}
var scrollSet = function()
{
    if( panelState == 2 )
    {
        var vsel = tag( 'vscroll' );
        var c = coord( sc.panel.owner );
        vsel.style.display = 'block';
        vsel.style.top = c.top + 'px';
        vsel.style.left = ( c.left + sc.panel.visibleWidth - 25 ) + 'px';
    }
}
E.set( "smallPicClick", toState1 );
E.set( "onResize", scrollSet );
var hashint = false;
var hasbighint = false;
var hintid = null;
var bighintid = null;
function MediaObject ( id ) {
    this.id = id;
    this.picture = null;
    this.picture_big = null;
    this.caption = '';
    this.description = '';
    this.hint = '';
    this.link = '';
    this.size = 0;
    this.size_big = 0;
    this.toHTML = function( last )
    {
        var out = '';
        out += '<IMG CLASS="png" ONCLICK="E.fire(\'smallPicClick\', { \'e\':event,\'id\':' + this.id + '})" ID="' + this.id + '" SRC="' + this.picture + '" WIDTH="' + this.size + '" HEIGHT="' + this.size + '" CLASS="' + ( last ? 'meobl' : 'meob') + '" BORDER="0" HINT="' + this.caption + ';' + this.hint + '" />';
        return out;
    }
    this.toHTMLbig = function( last )
    {
        var out = '';
          out += '<IMG CLASS="png" ONCLICK="E.fire(\'bigPicClick\', ' + this.id + ')" ID="' + this.id + '" SRC="' + this.picture_big + '" WIDTH="' + this.size_big + '" HEIGHT="' + this.size_big + '" CLASS="' + ( last ? 'meobl' : 'meob') + '" BORDER="0" HINT="' + this.caption + ';' + this.hint + '" />';
        return out;
    }
}
function MediaCollection () {
    this.mo = [];
    this.addMObject = function ()
    {
        var a = this.addMObject.arguments;
        var id = this.count();
        var m = this.mo[ id ] = new MediaObject( id );
        if( a.length > 0 )
            m.picture = a[ 0 ];
        if( a.length > 1 )
            m.picture_big = a[ 1 ];
        if( a.length > 2 )
            m.size = a[ 2 ];
        if( a.length > 3 )
            m.size_big = a[ 3 ];
        if( a.length > 4 )
            m.caption = a[ 4 ];
        if( a.length > 5 )
            m.hint = a[ 5 ];
        if( a.length > 6 )
            m.link = a[ 6 ];
        if( a.length > 7 )
            m.description = a[ 7 ];
    }
    this.toHTML = function( isBig )
    {
        var a = this.toHTML.arguments;
        var out = '';
        out += '<TABLE>';
        out += '<TR>';
        var len = this.mo.length - 1;
        if( a.length > 1 )
        {
            var k = 0, cols = a[ 1 ];

            for( var i = 0; i<this.mo.length; i++ )
            {
                k++;
                flag = ( k % cols == 0 );
                out += '<TD>' + this.mo[ i ].toHTMLbig( flag ) + '<BR />';
                out += '<DIV STYLE="position: relative; top:0; left: 0; width: 120px; height: 13px; overflow: hidden;" ID="t' + this.mo[ i ].id + '" CLASS="mini' + (isBig ? 'b' : '') + '">' + this.mo[ i ].caption + '</DIV></TD>';
                out += '<TD><IMG SRC="/media/design/blank.gif" width="10" height="1" /></TD>';
                if( flag )
                    out += '</TR><TR>';
            }
        }
        else
        {
            out += '<TD><IMG SRC="/media/design/blank.gif" width="6" height="1" /></TD>';
            for( var i = 0; i<this.mo.length; i++ )
            {
                out += '<TD VALIGN="top" STYLE="padding: 0 5px 0 5px;">' + ( isBig ? this.mo[ i ].toHTMLbig( i == len ) : this.mo[ i ].toHTML( i == len )) + '<BR />';
                out += '<DIV STYLE="position: relative; top:0; left: 0; width: ' + ( isBig ? 120 : 60 ) + 'px; height: 12px; overflow: hidden;" ID="t' + this.mo[ i ].id + '" CLASS="mini' + (isBig ? 'b' : '') + '">' + this.mo[ i ].caption + '</DIV></TD>';
            }
            out += '<TD><IMG SRC="/media/design/blank.gif" width="6" height="1" /></TD>';
        }
        out += '</TR>';
        out += '</TABLE>'
        return out;
    }
    this.count = function()
    {
        return this.mo.length;
    }
    this.last = function()
    {
        return this.mo.length - 1;
    }
    this.get = function( id )
    {
        return this.mo[ id ];
    }
}
var mc = new MediaCollection();
var hfLink = null;
var nel = null;
var showBigHint = function( id )
{
    if( nel != null )
    {
        EF.remove( null, nel );
        nel = null;
    }
    var c = coord( sc.panel.owner );
    var xid = sc.vertical ? id % 7 : id;
    var sps = sc.vertical ? 25 : sc.panel.shift;
    var offset = 130 * xid + sps - 60;
    var newoffset = c.left + offset;
    var el = tag( 'bighint' );
    if( sc.vertical )
        el.style.top = ( c.top - 5 ) + parseInt( id / 7 ) * 142 + sc.panel.shift + 'px';
    else
        el.style.top = ( c.top - 5 ) + 'px';
    if( newoffset < 0 )
        newoffset = 5;
    if(( newoffset + 263 ) > document.body.clientWidth )
        newoffset = document.body.clientWidth - 268;
    el.style.left = newoffset + 'px';
    with( mc.get( id ))
    {
        var out = '';
        tag( 'hinfp' ).src = picture;
        png4ie( tag( 'hinfp' ));
        tag( 'hinfh' ).innerHTML = caption;
        tag( 'hinft' ).innerHTML = '<DIV ID="hinfsa">' + description +  '</DIV>';
        hfLink = link;
//        tag( 'hinfl' ).innerHTML = '<A CLASS="icolnk"> + link.substr( 7 ) + '</A>';
    }
    el.style.display = 'block';
    E.fire( "hideCaption" );
    bighintid = id;
    E.fire( "showCaption" );
    E.fire( "hideHint", null );
    hasbighint = true;
}
var showBigHintCorrect = function()
{
  var el = tag( 'hinft' );
  if( tag( 'hinfsa' ).scrollHeight > 60 )
  {
      el.style.width = 165;
      var c = coord( el );

      nel = EF.create( 'DIV' );
      nel.style.position = 'absolute';
      nel.style.zIndex = '101';
      nel.style.top = c.top + 'px';
      nel.style.left = c.left + 170 + 'px';
      var out = '';
      out += '<TABLE>';
      out += '<TR>';
      out += '<TD>';
      out += '<A HREF="javascript://" ONCLICK="hfsc.offset( -150 ); if( browser.firefox ) this.blur()" ONDBLCLICK="hfsc.tostart()">';
      out += '<IMG SRC="/media/design/hinf/btn_sscr_u.gif" WIDTH="15" HEIGHT="10" ALT="" BORDER="0" />';
      out += '</A>';
      out += '</TD>';
      out += '</TR>';
      out += '<TR>';
      out += '<TD BACKGROUND="/media/design/hinf/bkg_sscr.gif" ALIGN="center">';
      out += '<DIV STYLE="position: relative; top: 0; left: 0; height: 40px; width: 15px; overflow: hidden;">';
      out += '<IMG ID="hinfsb" src="/media/design/hinf/btn_sscrr.gif" WIDTH="11" HEIGHT="6" />';
      out += '</DIV>';
      out += '</TD>';
      out += '</TR>';
      out += '<TR>';
      out += '<TD>';
      out += '<A HREF="javascript://" ONCLICK="hfsc.offset( 150 ); if( browser.firefox ) this.blur()" ONDBLCLICK="hfsc.toend()">';
      out += '<IMG SRC="/media/design/hinf/btn_sscr_d.gif" WIDTH="15" HEIGHT="10" ALT="" BORDER="0" />';
      out += '</A>';
      out += '</TD>';
      out += '</TR>';
      out += '</TABLE>';
      nel.innerHTML = out;
      EF.set( nel );

      hfsc = new scrollControl();
      hfsc.step = 150;
      hfsc.vertical = true;
      hfsc.panel.mount( tag( 'hinfsa' ));
      hfsc.bar.mount2( tag( 'hinfsb' ));
      hfsc.prepared();
  }
}
var closeBigHint = function()
{
    if( hasbighint )
    {
        var el = tag( 'bighint' );
        el.style.display = 'none';
        hasbighint = false;
        E.fire( "hideCaption" );
    }
    if( nel != null )
    {
        EF.remove( null, nel );
        nel = null;
    }
}
var vhintPos = function( e )
{
    var elhint = tag( 'hint' );
    var elhintc = tag( 'hintc' );
    var x = e.clientX + getScrollLeft();
    var y = e.clientY + getScrollTop();
    var w = document.body.clientWidth;
    var dx = e.clientX;
    if( w > 970 )
    {
        dx -= parseInt(( w - 970 ) / 2 );
        w = 970;
    }
    elhint.style.left = x - 10 - 145 * dx / w;
    elhint.style.display = 'block';
    elhint.style.top = y - elhint.offsetHeight - 2;
    elhintc.style.left = x - 7;
    elhintc.style.top = y - 10;
    elhintc.style.display = 'block';
}
var vhint = function( e )
{
    if( browser.msie )
         e = window.event;
    var el = ( browser.msie  ? e.srcElement : e.target );
    var hint = el.getAttribute( 'HINT' );
    if( el.tagName == 'IMG' && hint != null )
    {
        var id = hintid;
        hintid = el.getAttribute( 'ID' );
        if( id != null && id != hintid )
            E.fire( "blurPicture", id );
        var a = hint.split( ';' );
        tag('htext').innerHTML = '<B>' + a[ 0 ] + '</B><BR />' + a [ 1 ];
        vhintPos( e );
        hashint = true;
        hover( hintid );
   }
   else if( hashint && ( el.id == 'hintc' || el.id == 'hint' || el.id == 'hintp' ))
        vhintPos( e );
   else
   {
      if( hintid != null )
        E.fire( "blurPicture", hintid );
      if( hashint )
        E.fire( "hideHint", null );
   }
}
var hover = function( id )
{
    if( id == bighintid )
        return;
    var el = tag( 't' + id );
    if( el.className.indexOf( '_on' ) == -1 )
        el.className = el.className + '_on';
}
var hout = function( id )
{
    if( id == bighintid )
        return;
    var el = tag( 't' + id );
    el.className = el.className.split( '_' )[ 0 ];
    if( id == hintid )
        hintid = null;
}
var hoff = function()
{
    if( hashint )
    {
        tag( 'hint' ).style.display = 'none';
        tag( 'hintc' ).style.display = 'none';
        hashint = false;
    }
}
var showCaption = function()
{
    var el = tag( 't' + bighintid );
    if( el.className.indexOf( '_' ) != -1 )
        el.className = el.className.split( '_' )[ 0 ] + '_a';
    else
        el.className = el.className + '_a';
}
var hideCaption = function()
{
    if( bighintid == null )
        return;
    var el = tag( 't' + bighintid );
    if( el.className.indexOf( '_a' ) != -1 )
        el.className = el.className.split( '_' )[ 0 ];
    bighintid = null;
}
E.hook( "changeState" );
E.hook( "smallPicClick" );
E.hook( "scrollWheel" );
E.set( "bigPicClick", showBigHint );
E.set( "bigPicClick", showBigHintCorrect );
E.set( "blurPicture", hout );
E.set( "hideHint", hoff );
E.set( "hideBigHint", closeBigHint );
E.set( "changeScrollPosition_main", closeBigHint );
E.set( "scrollWheel", vhint );
E.set( "onMouseMove", vhint );
E.set( "showBigHint", showBigHint );
E.set( "showBigHint", showBigHintCorrect );
E.set( "showCaption", showCaption );
E.set( "hideCaption", hideCaption );
E.set( "onResize", hoff );
E.set( "onResize", closeBigHint );
var scx = [];
var scx_cur = null;
var wheelDx = browser.chrome ? 3 : 10;
var scrollControl = function( id )
{
    this.id = id;
    E.hook( "changeScrollPosition_" + this.id );
    this.wheelEvent = false;
    this.drag = false;
    this.bar = new scrollBar( this );
    this.panel = new scrollPanel( this );
    this.firstAlpha = null;
    this.lastAlpha = null;
    this.alphaWidth = 0;
    this.alpha = false;
    this.vertical = false;
    this.step = 10;
    this.wheelDx = browser.chrome ? 3 : 10;
    this.prepared = function()
    {
        this.bar.scroller.onmousedown = this.start;
        this.bar.scroller.onmousemove = window.onmousemove = this.move;
        this.bar.scroller.onmouseup = window.onmouseup = this.stop;
        this.bar.owner.onclick = this.click;
        var down3 = browser.opera || browser.safari || browser.chrome;
        if( this.panel.owner.addEventListener && !down3 )
            this.panel.owner.addEventListener( 'DOMMouseScroll', this.wheel, false );
        else
            this.panel.owner.onmousewheel = this.wheel;
    }
    this.setAlpha = function( firstObj, lastObj, widthObj )
    {
        this.firstAlpha = firstObj;
        this.lastAlpha = lastObj;
        this.alphaWidth = widthObj;
        this.alpha = true;
        this.bar.alpha( this.bar.shift );
        this.prepareAlpha();
    }
    this.prepareAlpha = function()
    {
        var c = coord( this.panel.owner );

        this.firstAlpha.style.left = c.left  + 'px';
        this.firstAlpha.style.top = c.top + 'px';
        if( this.vertical )
        {
            this.lastAlpha.style.left = c.left + 'px';
            this.lastAlpha.style.top = ( this.panel.visibleHeight - this.alphaWidth + c.top ) + 'px';
        }
        else
        {
            this.lastAlpha.style.left = ( this.panel.visibleWidth - this.alphaWidth + c.left ) + 'px';
            this.lastAlpha.style.top = c.top + 'px';
        }
    }
    this.start = function( e )
    {
        if( browser.msie )
             e = window.event;
        var el = ( browser.msie ? e.srcElement : e.target );
        if( el.getAttribute( 'name' ) == 'bar' )
            return false;
        scx_cur = scx[ el.parentNode.id ];
        if( scx_cur == null )
            return false;
        scx_cur.drag = true;
        scx_cur.bar.startShift = ( scx_cur.vertical ? e.clientY : e.clientX ) - scx_cur.bar.shift;
        scx_cur.notBubble( e );
        return false;
    }
    this.move = function( e )
    {
        if( scx_cur == null )
            return;
        if( !scx_cur.drag )
            return;
        if( browser.msie )
             e = window.event;
        scx_cur.bar.position(( scx_cur.vertical ? e.clientY : e.clientX ) - scx_cur.bar.startShift );
        scx_cur.notBubble( e );
        return false;
    }
    this.tostart = function()
    {
        this.bar.position( -1 );
    }
    this.toend = function()
    {
        this.bar.position( this.bar.trackLength + 1 );
    }
    this.stop = function()
    {
        if( scx_cur == null )
            return;
        scx_cur.drag = false;
        scx_cur = null;
        return false;
    }
    this.click = function( e )
    {
        if( browser.msie )
             e = window.event;
        var el = ( browser.msie ? e.srcElement : e.target );
        var elc = ( browser.firefox ? el.childNodes[ 0 ] : el.children[ 0 ]);
        if( elc )
            scx_cur = scx[ elc.id ];
        else
            return false;
        if( scx_cur == null )
            return false;
        var point = scx_cur.vertical ? ( e.clientY + getScrollTop()) : ( e.clientX + getScrollLeft());
        var barStart = scx_cur.bar.shift + scx_cur.bar.start;
        var barFinish = barStart + scx_cur.bar.scrollerLength;
        if( point < barStart )
            scx_cur.offset( -scx_cur.step );
        if( point > barFinish )
            scx_cur.offset( scx_cur.step );
        return false;
    }
    this.wheel = function( e )
    {
        var delta = 0;
        if( browser.msie )
            e = window.event;
        var el = ( browser.msie  ? e.srcElement : e.target );
        while( el.getAttribute( 'name' ) != 'panel' )
            el = el.parentNode;
        scx_cur = scx[ el.className ];
        if( e.wheelDelta )
            delta = e.wheelDelta / 120;
        else if( e.detail )
            delta = - e.detail / 3;

        if( delta )
            scx_cur.bar.position( scx_cur.bar.shift - delta * wheelDx );

        if( scx_cur.wheelEvent )
            E.fire( "scrollWheel", e );
        scx_cur.notBubble( e );
        return false;
    }
    this.notBubble = function( e )
    {
        if( e.stopPropagation )
            e.stopPropagation();
        else
            e.cancelBubble = true;
        if( e.preventDefault )
            e.preventDefault();
        else
            e.returnValue = false;
    }
    this.offset = function( shift )
    {
        this.bar.position( this.bar.shift + parseInt( shift / this.bar.delta ));
    }
}
var scrollPanel = function( control )
{
    this.shift = 0;
    this.control = control;
    this.object = null;
    this.owner = null;
    this.width = 0;
    this.height = 0;
    this.visibleWidth = 0;
    this.visibleHeight = 0;
    this.trackLength = 0;
    this.mount = function( obj )
    {
        var oldWidth = 0, oldHeight = 0;
        this.object = obj;
        this.owner = this.object.parentNode;
        this.width = this.owner.scrollWidth;
        this.height = this.owner.scrollHeight;
        this.visibleWidth = this.owner.offsetWidth;
        this.visibleHeight = this.owner.offsetHeight;
        this.trackLength = this.control.vertical
                            ? ( this.height - this.visibleHeight )
                            : ( this.width - this.visibleWidth );
    }
    this.position = function( shift )
    {
        this.shift = - parseInt( shift );
        if( this.control.vertical )
            this.object.style.marginTop = this.shift + 'px';
        else
            this.object.style.marginLeft = this.shift + 'px';
        E.fire( "changeScrollPosition_" + this.control.id, null );
    }
}
var scrollBar = function( control )
{
    this.start = 0;
    this.shift = 0;
    this.startShift = 0;
    this.control = control;
    this.owner = null;
    this.scroller = null;
    this.width = 0;
    this.height = 0;
    this.scrollerLength = 0;
    this.trackLength = 0;
    this.delta = 0;
    this.mount = function( obj, iobj, addPicSize )
    {
        var c = coord( obj );
        this.start = this.control.vertical ? c.top : c.left;
        this.scroller = obj;
        this.owner = obj.parentNode;
        this.width = this.owner.offsetWidth;
        this.height = this.owner.offsetHeight;
        this.scrollerLength = parseInt( this.control.vertical
                            ? ( this.control.panel.visibleHeight * this.height / this.control.panel.height )
                            : ( this.control.panel.visibleWidth * this.width / this.control.panel.width )
                            );
        if( this.control.vertical && this.height < this.scrollerLength )
            this.scrollerLength = this.height;

        var k = this.scrollerLength - addPicSize;
        this.trackLength = ( this.control.vertical ? this.height : this.width ) - this.scrollerLength;
        if( k < 0 )
            this.trackLength += k - 1;
        if( this.trackLength != 0 )
            this.delta = this.control.panel.trackLength / this.trackLength;
        if( this.control.vertical )
        {
            if( k > 0 )
                iobj.style.height = k + 'px';
        }
        else
        {
            if( k > 0 )
                iobj.style.width = k + 'px';
            obj.style.width = this.scrollerLength + 'px';
        }
        scx[ this.scroller.id ] = this.control;
    }
    this.mount2 = function( obj )
    {
        var c = coord( obj );
        this.start = this.control.vertical ? c.top : c.left;
        this.scroller = obj;
        this.owner = obj.parentNode;
        this.width = this.owner.offsetWidth;
        this.height = this.owner.offsetHeight;
        this.scrollerLength = obj.offsetHeight;
        this.trackLength = ( this.control.vertical ? this.height : this.width ) - this.scrollerLength;
        this.delta = this.control.panel.trackLength / this.trackLength;
        scx[ this.scroller.id ] = this.control;
    }
    this.alpha = function( shift )
    {
        if( shift <= 0 )
        {
            this.shift = 0;
            if( this.control.alpha )
            {
                this.control.firstAlpha.style.display = 'none';
                this.control.lastAlpha.style.display = 'block';
            }
        }
        else if( this.trackLength < shift )
        {
            this.shift = this.trackLength;
            if( this.control.alpha )
            {
                this.control.firstAlpha.style.display = 'block';
                this.control.lastAlpha.style.display = 'none';
            }
        }
        else if( shift != 0 )
        {
            this.shift = shift;
            if( this.control.alpha )
                this.control.firstAlpha.style.display = this.control.lastAlpha.style.display = 'block';
        }
    }
    this.position = function( shift )
    {
        this.alpha( shift );
        if( this.control.vertical )
            this.scroller.style.marginTop = this.shift + 'px';
        else
            this.scroller.style.marginLeft = this.shift + 'px';
        this.control.panel.position( this.shift * this.delta );
    }
}
E.hook( "changeScrollPosition" );
function ComboBoxItem( name, value, disabled )
{
    this.name = name;
    this.value = value;
    this.disabled = ( disabled == null ) ? false : disabled;
}
function ComboBox( id )
{
    this.id = id;
    this.name = null;
    this.element = null;
    this.puelement = null;
    this.puscrelement = null;
    this.options = [];
    this.value = null;
    this.width = 0;
    this.needCalcWidth = true;
    this.code = null;
    this.className = '';
    CBD.register( this );
    this.createFromElement = function( el )
    {
        this.element = el;
        this.name = el.name;
        this.className = el.className;
        E.hook( "comboChange_" + this.name );
        if( el.getAttribute( "ONCHANGE" ))
        {
            if( browser.msie )
            {
                var code = el.getAttribute( "ONCHANGE" ).toString();
                var start = code.indexOf( '{' );
                this.code = code.substr( start );
            }
            else
                this.code = el.getAttribute( "ONCHANGE" ).toString();
            E.set( "comboChange_" + this.name, ComboChange );
        }
        if( el.options.length > 0 )
            for( var i = 0; i < el.options.length; i++ )
                with( el.options[ i ])
                {
                    this.options[ this.options.length ] = new ComboBoxItem( text, value, getAttribute( 'DISABLED' ));
                    if( el.selectedIndex == i )
                        this.value = value;
                }

        var html = this.toHTML();
        if( browser.firefox )
        {
           var r = document.createRange();
           r.setStartBefore( this.element );
           var df = r.createContextualFragment( html );
           this.element.parentNode.replaceChild( df, this.element );
        }
        else
            this.element.outerHTML = html;
    }
    this.addOption = function( name, value )
    {
        this.options[ this.options.length ] = new ComboBoxItem( name, value );
    }
    this.getNameByValue = function( value )
    {
        var name = '';
        if( value != null )
            for( var idx = 0; idx < this.options.length; idx++ )
                if( this.options[ idx ].value == value )
                {
                    name = this.options[ idx ].name;
                    break;
                }
        return name;
    }
    this.getValueByName = function( name )
    {
        var value = null;
        if( name != null )
            for( var idx = 0; idx < this.options.length; idx++ )
                if( this.options[ idx ].name == name )
                {
                    value = this.options[ idx ].value;
                    break;
                }
        return value;
    }
    this.getInput = function()
    {
        return tag( "i_" + this.id );
    }
    this.setInput = function( value )
    {
        tag( "i_" + this.id ).innerHTML = value;
        tag( "hi_" + this.id ).value = this.getValueByName( value );
        E.fire( "comboChange_" + this.name, value );
    }
    this.getWidth = function()
    {
        if( this.needCalcWidth )
        {
            var el = EF.create( "SPAN" );
            el.style.fontFamily = 'Tahoma';
            el.style.fontSize = "12px";
            el.style.visibility = "hidden";
            EF.set( el );
            var elwidth = 0;
            for( var idx= 0; idx< this.options.length; idx++ )
            {
                el.innerHTML = this.options[ idx ].name;
            	elwidth = el.offsetWidth + 2;
                if( this.width < elwidth )
                    this.width = elwidth;
            }
            EF.remove( null, el );
        }
        return this.width;
    }
    this.toHTML = function()
    {
		var clr = ( this.value == null ) ? 'White' : '#4B4B6F';
        var sout = '';
        sout += '<TABLE ID="' + this.id + '">';
        sout += '<TR>';
        sout += '<TD WIDTH="3">';
        sout += '<IMG CLASS="png" SRC="/media/design/cb/pic_cbl.png" WIDTH="3" HEIGHT="20" />';
        sout += '</TD>';
        sout += '<TD>';
        sout += '<INPUT TYPE="hidden" NAME="' + this.name + '" ID="hi_' + this.id + '" VALUE="' + this.value + '">';
        sout += '<DIV CLASS="combo' + (this.className != '' ? ' ' + this.className : '' ) + '" ID="i_' + this.id + '" ONCLICK="E.fire(\'comboDropDown\', \''+ this.id +'\');"  STYLE="padding-left: 2px">';
		if( this.value != null )
        	sout += this.getNameByValue( this.value );
        sout += '</DIV>';
        sout += '</TD>';
        sout += '<TD WIDTH="23">';
        sout += '<A HREF="javascript://" HIDEFOCUS="true" ONCLICK="E.fire(\'comboDropDown\', \''+ this.id +'\'); if( browser.firefox ) blur();">';
        sout += '<IMG CLASS="png comboBtn" SRC="/media/design/cb/btn_cb.png" WIDTH="23" HEIGHT="20" BORDER="0" />';
        sout += '</A>';
        sout += '</TD>';
        sout += '</TR>';
        sout += '</TABLE>';
        return sout;
    }
    this.toHTMLPopup = function()
    {
        var sout = '';
        sout += '<TABLE ID="cbt' + this.id + '">';
        sout += '<TR>';
        sout += '<TD WIDTH="4"><IMG CLASS="png" SRC="/media/design/cb/pic_ul.png" WIDTH="4" HEIGHT="4" /></TD>';
        sout += '<TD STYLE="background-image: url(\'/media/design/cb/bkg_t.gif\')" CLASS="h0"><IMG SRC="/media/design/blank.gif" WIDTH="1" height="1" /></TD>';
        sout += '<TD WIDTH="4"><IMG CLASS="png" SRC="/media/design/cb/pic_ur.png" WIDTH="4" HEIGHT="4"/></TD>';
        sout += '</TR>';
        sout += '<TR>';
        sout += '<TD STYLE="border-left: 1px solid #D9D9D9" BGCOLOR="White"><IMG SRC="/media/design/blank.gif" WIDTH="1" height="1" /></TD>';
        sout += '<TD BGCOLOR="White">';
        sout += '<DIV ID="cbdlt' + this.id + '" CLASS="cbsb' + this.id + '" NAME="panel">';
        sout += '<TABLE WIDTH="100%" ID="cbdl' + this.id + '">';
        for( var idx = 0;   idx< this.options.length; idx++ )
            with( this.options[ idx ])
            {
                sout += '<TR>';
                sout += '<TD NOWRAP CLASS="comboExt cbItem' + (disabled ? 'D' : '') + '" ID="' + this.id + '_' + value + '" VALUE="' + value + '"' + (disabled ? '' : ' ONMOUSEOVER="E.fire(\'comboPUOver\', this)" ONCLICK="E.fire(\'comboPUClick\', this)"') + '>';
                sout += name;
                sout += '</TD>';
                sout += '</TR>';
            }
        sout += '</TABLE>';
        sout += '</DIV>';
        sout += '</TD>';
        sout += '<TD STYLE="border-right: 1px solid #D9D9D9" BGCOLOR="White"><IMG SRC="/media/design/blank.gif" WIDTH="1" height="1" /></TD>';
        sout += '</TR>';
        sout += '<TR>';
        sout += '<TD WIDTH="4"><IMG CLASS="png" SRC="/media/design/cb/pic_dl.png" WIDTH="4" HEIGHT="4" /></TD>';
        sout += '<TD STYLE="background-image: url(\'/media/design/cb/bkg_d.gif\')" CLASS="h0"><IMG SRC="/media/design/blank.gif" WIDTH="1" height="1" /></TD>';
        sout += '<TD WIDTH="4"><IMG CLASS="png" SRC="/media/design/cb/pic_dr.png" WIDTH="4" HEIGHT="4"/></TD>';
        sout += '</TR>';
        sout += '</TABLE>';
        return sout;
    }
    this.toHTMLScroll = function()
    {
        var sout = '';
        sout += '<TABLE HEIGHT="160" WIDTH="15">';
        sout += '<TR HEIGHT="14">';
        sout += '<TD>';
        sout += '<A HREF="javascript://" ONCLICK="cbsc.offset( -150 ); if( browser.firefox ) this.blur()" ONDBLCLICK="cbsc.tostart()">';
        sout += '<IMG CLASS="comboBtn" SRC="/media/design/cb/btn_up.gif" WIDTH="15" HEIGHT="14" BORDER="0" />';
        sout += '</A>';
        sout += '</TD>';
        sout += '</TR>';
        sout += '<TR HEIGHT="132">';
        sout += '<TD CLASS="comboExt" BGCOLOR="#CCCCCC" ALIGN="center" VALIGN="top" ONSELECTSTART="return false;" STYLE="-moz-user-select: none">';
        sout += '<DIV ID="cbsb' + this.id + '" STYLE="display: inline-block" CLASS="comboExt">';
        sout += '<IMG CLASS="comboExt" SRC="/media/design/cb/pic_scr_up.gif" WIDTH="11" HEIGHT="6" /><BR/>';
        sout += '<IMG CLASS="comboExt" ID="cbslen' + this.id + '" SRC="/media/design/cb/bkg_scr.gif" WIDTH="11" HEIGHT="1"  /><BR/>';
        sout += '<IMG CLASS="comboExt" SRC="/media/design/cb/pic_scr_down.gif" WIDTH="11" HEIGHT="6" /><BR/>';
        sout += '</DIV>';
        sout += '</TD>';
        sout += '</TR>';
        sout += '<TR HEIGHT="14">';
        sout += '<TD>';
        sout += '<A HREF="javascript://" ONCLICK="cbsc.offset( 150 ); if( browser.firefox ) this.blur()" ONDBLCLICK="cbsc.toend()">';
        sout += '<IMG CLASS="comboBtn" SRC="/media/design/cb/btn_down.gif" WIDTH="15" HEIGHT="14" BORDER="0" />';
        sout += '</A>';
        sout += '</TD>';
        sout += '</TR>';
        sout += '</TABLE>';
        return sout;
    }
    this.createPopup = function()
    {
		this.element = tag( this.id );
        var c = new coord( this.element );
		with( this.puelement = EF.create( "DIV" ))
		{
        	style.visibility = "visible";
        	style.display = "block";
        	style.zIndex = IDX.over() + 100;
			style.position = 'absolute';

        	style.left = c.left + 'px';
        	style.top = ( c.top + this.element.offsetHeight + 5 ) + 'px';
        	style.width = this.element.offsetWidth + 'px';

        	innerHTML = this.toHTMLPopup();
		}
        EF.set( this.puelement );
        var elt = tag( 'cbdl' + this.id );
        if( elt.offsetHeight > 160 )
        {
            if( this.element.offsetWidth > ( elt.offsetWidth + 37 ))  /* 25 correct 12 */
                elt.style.width = ( this.element.offsetWidth - 37 ) + 'px';
            var eld = tag( 'cbdlt' + this.id );
            var w = parseInt( elt.offsetWidth );
            elt.style.width = ( w + 9 )+ 'px';
            tag( 'cbt' + this.id ).style.width = ( w + 37 ) + 'px';
            this.puelement.style.width = ( w + 37 ) + 'px';
            eld.style.overflow = 'hidden';
            eld.style.height = '160px';
            this.puelement.style.height = '172px';

            with( this.puscrelement = EF.create( "DIV" ))
            {
            	style.display = "block";
            	style.zIndex = IDX.over() + 1001;
    			style.position = 'absolute';
                id = 'vscr' + this.id;
                style.left = ( c.left + w + 17 ) + 'px';
                style.top = ( parseInt( this.puelement.style.top ) + 4 ) + 'px';
                innerHTML = this.toHTMLScroll();
            }
            EF.set( this.puscrelement );
            cbsc = new scrollControl();
            cbsc.step = 150;
            cbsc.vertical = true;
            cbsc.panel.mount( elt );
            cbsc.bar.mount( tag( 'cbsb' + this.id ), tag( 'cbslen' + this.id ), 12 );
            cbsc.prepared();

            cbsc.bar.position( this.position() * 16 / cbsc.bar.delta );
        }
        else if( this.element.offsetWidth > ( elt.offsetWidth + 8 ))
        {
            elt.style.width = ( this.element.offsetWidth - 8 ) + 'px';
        }
    }
    this.removePopup = function()
    {
    	if( this.puelement != null )
    	{
			EF.remove( null, this.puelement )
			this.puelement = null;
		}
    	if( this.puscrelement != null )
    	{
			EF.remove( null, this.puscrelement )
			this.puscrelement = null;
		}
    }
    this.position = function()
    {
        for( var idx = 0; idx < this.options.length; idx++ )
        {
            if( this.options[ idx ].value == this.value )
                return idx;
        }
        return null;
    }
}
var CBD = new function ComboBoxDirector()
{
    this.comboboxFocus = null;
    this.comboboxDropDown = null;
    this.comboboxes = new Array();

    this.create = function()
    {
        var cbs = Control.findElement( "SELECT" );
        if( cbs.length > 0 )
            for( var idx = 0; idx<cbs.length; idx++ )
                this.createComboBoxFromElement( idx, cbs[ idx ]);
    }
    this.createComboBoxFromElement = function( idx, el )
    {
        var cb = new ComboBox( 'cb_' + idx );
        cb.createFromElement( el );
    }
    this.setDropDown = function( id )
    {
        if( id != null && this.comboboxDropDown != id  && this.comboboxDropDown != null )
            E.fire( "comboDropClose", this.comboboxDropDown );
        this.comboboxDropDown = id;
    }
    this.register = function( obj )
    {
        this.comboboxes[ obj.id ] = obj;
    }
    this.get = function( id )
    {
        return this.comboboxes[ id ];
    }
}
function InputField()
{
    this.id = '';
    this.name = '';
    this.type = '';
    this.value = '';
    this.className = '';
    this.format = ''; 	
    this.createFromElement = function( el )
    {
        this.id = el.id;
        this.name = el.name;
        this.type = el.type;
        this.value = el.value;
	this.format = el.getAttribute("FORMAT");
        this.className = el.className;
        var html;
        if( this.type == "text" )
            html = this.toHTML();
        else if( this.type == "password" )
            html = this.toHTML();
        else
            return;

        if( browser.firefox )
        {
           var r = document.createRange();
           r.setStartBefore( el );
           var df = r.createContextualFragment( html );
           el.parentNode.replaceChild( df, el );
        }
        else
            el.outerHTML = html;
    }
    this.toHTML = function()
    {
        var sout = '';

        sout += '<TABLE ID="' + this.id + '">';
        sout += '<TR>';
        sout += '<TD WIDTH="3">';
        sout += '<IMG CLASS="png" SRC="/media/design/cb/pic_cbl.png" WIDTH="3" HEIGHT="20" />';
        sout += '</TD>';
        sout += '<TD>';
        sout += '<DIV CLASS="inpfield">';
        sout += '<INPUT CLASS="inp' + ( this.className != '' ? ' ' + this.className : '' ) + '" TYPE="' + this.type + '" NAME="' + this.name + '" ID="' + this.id + '" VALUE="' + this.value + '" format="'+ this.format + '">';
        sout += '</DIV>';
        sout += '</TD>';
        sout += '<TD WIDTH="23">';
        sout += '<IMG CLASS="png" SRC="/media/design/cb/pic_cbr.png" WIDTH="3" HEIGHT="20" />';
        sout += '</TD>';
        sout += '</TR>';
        sout += '</TABLE>';

        return sout;
    }
}
var FCD = new function FormControlDirector()
{
    this.InF = null;
    this.processPage = function()
    {
        var ip = Control.findElement( "INPUT" );

        if( ip.length > 0 )
        {
            this.InF = new InputField();

            for( var idx = 0; idx<ip.length; idx++ )
                if(( ip[ idx ].className + '' ).indexOf( 'noprocess' ) == -1 )
                    this.InF.createFromElement( ip[ idx ]);
        }
        CBD.create();
    }
}
var ComboDropDown = function ( param )
{
    if( CBD.comboboxDropDown == param )
    {
        ComboDropClose( param );
        return;
    }
    CBD.setDropDown( param );
    var cb = CBD.comboboxes[ param ];
    cb.createPopup();
    E.fire( "comboPUOver", tag( cb.id + '_' + cb.value ));
}
var ComboDropClose = function( param )
{
    var cb = CBD.comboboxes[ param ];
    cb.removePopup();
    CBD.setDropDown( null );
}
var oldPUobj = null;
var ComboPUOver = function( obj )
{
    if( obj == null )
        return;
    if( oldPUobj != null )
        oldPUobj.className = 'cbItem';
    obj.className = 'cbItemOver';
    oldPUobj = obj;
}
var ComboPUClick = function( obj )
{
    var cb = CBD.comboboxes[ CBD.comboboxDropDown ];
    cb.value = obj.getAttribute( "VALUE" );
    cb.setInput( obj.innerHTML.toString());
    E.fire( "comboDropClose", CBD.comboboxDropDown );
}
var hideCombo = function( param )
{
   	if( CBD.comboboxDropDown != null )
   		E.fire( "comboDropClose", CBD.comboboxDropDown );
}
var ComboChange = function ( text )
{
    var cb = CBD.comboboxes[ CBD.comboboxDropDown ];
    this.value = cb.value;
    this.text = text;
    if( cb.code != null )
        eval( cb.code );
}
var clickParser = function ( event )
{
    var el = ( browser.msie  ? window.event.srcElement : event.target );
    if(( el.className + '' ).indexOf( 'combo' ) == -1 )
        hideCombo( event );
}
E.set( "comboDropDown", ComboDropDown );
E.set( "comboDropClose", ComboDropClose );
E.set( "comboPUOver", ComboPUOver );
E.set( "comboPUClick", ComboPUClick );
E.set( "onClick", clickParser );
preloadImages ( 'btn_menu_fix-svyaz_on.gif', 'btn_menu_mob-svyaz_on.gif', 'btn_menu_tv_on.gif', 'btn_menu_catalog_on.gif' );
var loader = function()
{
    tag( 'sp' ).innerHTML = mc.toHTML( false );
    sc = new scrollControl( 'main' );
    sc.wheelEvent = true;
    sc.step = 300;
    sc.panel.mount( tag( 'sp' ));
    sc.bar.mount( tag( 'sb' ), tag( 'slen' ), 12 );
    sc.setAlpha( tag( 'i1' ), tag( 'i2' ), 30 );
    sc.prepared();
    FCD.processPage();
}
var resizer = function()
{
    sc.prepareAlpha();
    hideCombo();
}
var pover = function( obj )
{
    var src = obj.src;
	var k = src.lastIndexOf( "/" );
	var startPath = src.substring( 0, k + 1 );

    src = src.substring( k );
    src = src.split( '.' );
    obj.src = startPath + src[ 0 ] + '_on.' + src[ 1 ];
}
var pout = function( obj )
{
    var src = obj.src;
	var k = src.lastIndexOf( "/" );
	var startPath = src.substring( 0, k + 1 );

    src = src.substring( k );
    src = src.split( '_on.' );
    obj.src = startPath + src[ 0 ] + '.' + src[ 1 ];
}
var cPlus = function( obj )
{
    toState2();
}
var cMinus = function( obj )
{
    if( panelState == 1 || panelState == 2 )
        toState0();
}
var btnOver = function( obj )
{
    if( obj.name == 'bplus' && panelState != 2 )
        tag( 'ptext' ).innerHTML = 'Полный экран';
    if( obj.name == 'bminus' && panelState != 0 )
        tag( 'ptext' ).innerHTML = 'Свернуть';
}
var btnOut = function( obj )
{
    tag( 'ptext' ).innerHTML = '';
}
var btnStateDraw = function( panelState )
{
    var b1 = tag( 'bplus' );
    var b2 = tag( 'bminus' );
    var src = '';

    var src1 = b1.src;
	var k = src1.lastIndexOf( "/" );
	var startPath1 = src1.substring( 0, k + 1 );
    src1 = src1.substring( k );

    var src2 = b2.src;
	k = src2.lastIndexOf( "/" );
	var startPath2 = src2.substring( 0, k + 1 );
    src2 = src2.substring( k );


    switch( panelState )
    {
        case 0:
            if( src1.indexOf( '_on.' ) == -1 )
            {
                src1 = src1.split( '.' );
                b1.src = startPath1 + src1[ 0 ] + '_on.' + src1[ 1 ];
            }
            if( src2.indexOf( '_on.' ) != -1 )
            {
                src2 = src2.split( '_on.' );
                b2.src = startPath2 + src2[ 0 ] + '.' + src2[ 1 ];
            }
            break;
        case 1:
            if( src1.indexOf( '_on.' ) == -1 )
            {
                src1 = src1.split( '.' );
                b1.src = startPath1 + src1[ 0 ] + '_on.' + src1[ 1 ];
            }
            if( src2.indexOf( '_on.' ) == -1 )
            {
                src2 = src2.split( '.' );
                b2.src = startPath2 + src2[ 0 ] + '_on.' + src2[ 1 ];
            }
            break;
        case 2:
            if( src1.indexOf( '_on.' ) != -1 )
            {
                src1 = src1.split( '_on.' );
                b1.src = startPath1 + src1[ 0 ] + '.' + src1[ 1 ];
            }
            if( src2.indexOf( '_on.' ) == -1 )
            {
                src2 = src2.split( '.' );
                b2.src = startPath2 + src2[ 0 ] + '_on.' + src2[ 1 ];
            }
            break;
    }
}
var alfaFix = function()
{
    setTimeout( "sc.prepareAlpha();", 10 );
}
E.set( "changeState", btnStateDraw );
E.set( "changeState", alfaFix );
E.set( "onLoad", loader );
E.set( "onResize", resizer );
