//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
Info = function() {
	Info.superClass.apply( this, [ 'div', { id: 'info', 'class': 'hidden png' }, document.body ] );

	this.Id = 'Info';
	this.ie6 = ( '\v' == 'v' && typeof document.documentElement.style.maxHeight == "undefined" );
	this.pad = this.createNode( 'div', { id: 'info-pad' }, this.element );	
	this.inner = this.createNode( 'div', { 'class': 'inner' }, this.pad );
	this.content = this.createNode( 'div', { 'class': 'content' }, this.inner );

	this.close = this.createNode( 'div', { 'class': 'close' }, false, '<img class="png" height="12" width="12" alt="закрыть" title="закрыть" src="/images/results/close.png"/>' );
	this.addHandler( this.close, 'click', this.hide );
	if( this.ie6 ) {
		this.addHandler( window, 'resize', this.setTopPosition );
		this.addHandler( window, 'scroll', this.setTopPosition );
	}
}
Info.inheritsFrom( HTMLGlif );

//----------------------------------------------------------------------------//

Info.prototype.hide = function() {
	var html = document.body.parentNode;
	this.setClassName( 'hidden', true );
	this.setClassName( 'crop', false, html );

	this.notify( 'InfoClosed' );
}

//----------------------------------------------------------------------------//

Info.prototype.show = function() {
	this.setClassName( 'hidden', false );

	var html = document.body.parentNode;


	this.setClassName( 'crop', true, html );
	
	this.topOffset();
	if( this.ie6 ) {
		this.setTopPosition();
	}
}
//----------------------------------------------------------------------------//

Info.prototype.setTopPosition = function() {
	this.setStyle({ 'top': ( document.documentElement.scrollTop || document.body.scrollTop || 0 ) + 'px' });
}

//----------------------------------------------------------------------------//

Info.prototype.setClosable = function( flag ) {
	this.closable = flag;
	if( flag == true && this.close ) {
		this.append( this.pad, this.close );
	} else if( flag == false && this.close.parentNode != null ) {
		this.close = this.pad.removeChild( this.close );
	}
}

//----------------------------------------------------------------------------//

Info.prototype.addRedirect = function( url ) {
	this.addHandler( this.close, 'click', function() {
		window.location.href = url;
	});
}

//----------------------------------------------------------------------------//

Info.prototype.fill = function( HTML ) {
	this.setContent( HTML, this.content );
	this.topOffset();
}

//----------------------------------------------------------------------------//

Info.prototype.topOffset = function() {
	this.setClassName( 'overflow', false, this.content );
	this.setStyle( { height: 'auto' }, this.content );
	
	padHeight = this.pad.offsetHeight;
	innerHeight = ( this.content.firstChild ? this.content.firstChild.offsetHeight : 0 );
	
	var availableHeight = document.body.parentNode.offsetHeight;
	
	if( padHeight >= availableHeight - 100 ) {
		this.setStyle({ 'marginTop': -1*( parseInt( ( availableHeight - 100 )/2 ) + 12 ) + 'px' }, this.pad );
		this.setClassName( 'overflow', true, this.content );
		this.setSize( false, availableHeight - 166, this.content );
	} else {
		this.setStyle({ 'marginTop': -1*parseInt( padHeight/2 ) + 'px' }, this.pad );
	}
}