/**
 * onlineList javascript functions
 * @version $Id: online.js 2 2009-03-20 16:56:45Z kamilag $
 */
	var membersOnLine = {
	
		init: function( options )
		{
			this.options = Object.extend( {
				resizeDuration: 400,
				resizeTransition: Fx.Transitions.sineInOut,
				initialWidth: 500,
				initialHeight: 500,
				animateCaption: true
			}, options || {} );
			
			//if( content = $( 'olContent' ) )
			if( content = $( 'olContent' ) )
			{
				el01 = $( 'showOnLine01' );
				el01.onclick = this.click.pass( el01, this );
				this.eventKeyDown = this.keyboardListener.bindAsEventListener( this );
				this.eventPosition = this.position.bind( this );
				//this.width = 505;
				
				this.overlay = new Element( 'div' ).setProperty( 'id', 'olOverlay' ).injectInside( document.body );
				
				//this.center = new Element('div').setProperty('id', 'olCenter' ).setStyles({ display: 'none', marginLeft: '-'+(this.width/2)+'px', width: ''+(this.width)+'px'}).injectInside(document.body)
				this.center = new Element( 'div' ).setProperty( 'id', 'map' ).setStyles( { display: 'none', width: '505px', height: '505px' } ).injectInside( document.body );
				var header = new Element( 'div' ).setProperty( 'class', 'backgroundColor' ).injectInside( this.center );
				var close = new Element( 'a' ).setProperties( { 'id': 'olCloseLink', href: '#' } ).injectInside( header ).onclick = this.overlay.onclick = this.close.bind( this );
				//var title = new Element('div').setProperties({'id': 'olHead', 'class':'t17'}).injectInside(header).setHTML('hhhhhh');
				//new Element('div').setStyles({clear: 'both', fontSize: '0px', height: '2px'}).injectInside(header);
				content.setStyles( { visibility: 'visible', width: '500px', height: '500px', marginLeft: '125px' } ).injectInside( this.center );
				loadGM( '', '', 'tekst' );
				
				var nextEffect = this.nextEffect.bind( this );
				this.fx = {
					overlay: this.overlay.effect( 'opacity', { duration: 500, onComplete: nextEffect } ).hide()
				};
			}
		},
	
		click: function( link )
		{
			return this.open();
		},
		
		open: function( imageNum )
		{
			this.position();
			this.setup( true );
			this.top = window.getScrollTop()+( window.getHeight()/15 );
			this.center.setStyles( { top: this.top+'px' } );//, display: ''
			this.fx.overlay.start( 0.8 );
			manageFlash2( 0 );
			return this.changeImage();
		},
	
		position: function()
		{
			this.overlay.setStyles( { top: window.getScrollTop()+'px', height: window.getHeight()+'px' } );
		},
	
		setup: function( open )
		{
			var elements = $A( document.getElementsByTagName( 'object' ) );
			if( window.ie ) elements.extend( document.getElementsByTagName( 'select' ) );
			elements.each( function( el ){ el.style.visibility = open ? 'hidden' : ''; } );
			var fn = open ? 'addEvent' : 'removeEvent';
			window[fn]( 'scroll', this.eventPosition )[fn]( 'resize', this.eventPosition );
			document[fn]( 'keydown', this.eventKeyDown );
			this.step = 0;
		},
	
		keyboardListener: function( event )
		{
			switch( event.keyCode )
			{
				case 27: case 88: case 67: this.close(); break;
			}
		},
	
		changeImage: function()
		{
			if( this.step ) return false;
			this.step = 1;
			return false;
		},
	
		nextEffect: function()
		{
			switch( this.step++ )
			{
				case 1:
				case 2:
					this.center.setStyles( { display: '' } );
				case 3:
					this.step = 0;
			}
		},
	
		close: function()
		{
			if( this.step < 0 ) return;
			this.step = -1;
			for( var f in this.fx ) this.fx[f].stop();
			this.center.style.display = 'none';// = this.bottomContainer.style.display
			this.fx.overlay.chain( this.setup.pass( false, this ) ).start( 0 );
			flashesAreManaged2 = setTimeout( 'manageFlash2( 1 )', 1000 );
			return false;
		}
	};
	
	var flashesAreManaged2 = 0;
	
	window.addEvent( 'domready', membersOnLine.init.bind( membersOnLine ) );
	
	
	//Opis: funkcja ukrywa/odkrywa listy rozwijane
	
	function manageFlash2( onOff )
	{
		clearTimeout( flashesAreManaged2 );
		if( onOff == 1 )
		{
			var vis = "visible";
		}
		else
		{
			var vis = "hidden";
		}
		if( oSel = document.getElementsByTagName("EMBED") )
		{
			for( i = 0; i < oSel.length; i++ )
			{
				oSel[i].style.visibility = vis;
			}
		}
		if( oSel = document.getElementsByTagName("OBJECT") )
		{
			for( i = 0; i < oSel.length; i++ )
			{
				oSel[i].style.visibility = vis;
			}
		}
	}
