function setHeight()
{
	var rHeight = $('#rbox').height();
	var lHeight = $('#lbox').height();
	var adHeight = 0;
	
	if ( rHeight > lHeight )
	{
		if ( document.getElementById( 'title_sect' ) )
		{
			adHeight += $('#title_sect').height() + 10;
		}
		if ( document.getElementById( 'g468x60' ) )
		{
			adHeight += $('#g468x60').height() + 10;
		}
	
		$('#lbox > div').each( function()
		{
			//if ( adHeight && ( $(this).height() != ( adHeight - 10 ) ))
			if (( $(this).attr( 'id' ) != 'title_sect' ) && ( ( $(this).attr( 'id' ) != 'g468x60' ) ))
			{
				var headHeight = $(this).children('.box-head').height();
				$(this).children('.inner-box').height( rHeight - adHeight - headHeight - 30 );
			}
		});
	}
}

function setHeight3()
{
	var rHeight = $('#cbox').height();
	var lHeight = $('#lbox').height();
	var adHeight = 0;
	
	if ( rHeight > lHeight )
	{
		if ( document.getElementById( 'g468x60' ) )
		{
			adHeight += $('#g468x60').height() + 10;
		}
	
		$('#lbox > div').each( function()
		{
			//if ( adHeight && ( $(this).height() != ( adHeight - 10 ) ))
			if ( ( $(this).attr( 'id' ) != 'g468x60' ) )
			{
				var headHeight = $(this).children('.box-head').height();
				$(this).children('.inner-box').height( rHeight - adHeight - headHeight - 20 );
			}
		});
	}
	else if ( lHeight > rHeight )
	{
		if ( document.getElementById( 'g468x60' ) )
		{
			adHeight += $('#news').height() + 10;
		}
	
		$('#cbox > div').each( function()
		{
			//if ( adHeight && ( $(this).height() != ( adHeight - 10 ) ))
			if ( ( $(this).attr( 'id' ) == 'thisday' ) )
			{
				var headHeight = $(this).children('.box-head').height();
				$(this).children('.inner-box').height( lHeight - adHeight - headHeight - 30 );
			}
		});
	}
	
}

function showText( link )
{
	//$('#float-title').html( "Link - " + link );
	re = /\/(\w+)\/(\d+)$/;
	res = link.match( re );
	if ( res[0] )
	{ 
		//$('#float-text').html( "Id - " + res[2] + "<br/>Type - " + res[1] );
		$.getJSON('/getfloat', { id: res[2], type: res[1] }, function( json )
		{
			if ( json.floatdata[0].title )
			{
				$('#float-title').html( json.floatdata[0].title );
				$('#float-text').html( json.floatdata[0].text );
			}
		});
	}
	//var hTitle = $('#float-title').height();
	//var hText = $('#float-text').height();
	//$('#float-box').height( hTitle + hText + 60 );
	//$('#inner-float-box').height( hTitle + hText + 20 );
}

function showFloat( href )
{
	$('#floatbox').show( "normal", showText( href ) );
}

function hideFloat()
{
	$('#floatbox').hide();
}

$(document).ready( function()
{
	if ( !document.getElementById( 'cbox' ) )
	{
		setHeight();
	}
	else
	{
		setHeight3();
	}
	
	$('.float-link').mouseenter( function() 
	{
		$('#floatbox').hide();
		var pos = $(this).position();
		var posY = pos.top + 20;
		var posX = pos.left;
		$('#floatbox').css({ 'top' : posY, 'left' : posX });
		setTimeout( "showFloat('" + $(this).attr( "href" ) + "')", 100 );
		//$('#floatbox').show( "normal", showText( $(this).attr( "href" ) ) );
	});
	
	//$('#floatbox').mouseleave( function() 
	//{
	//	$(this).hide( "slow" );
	//});
	
	$('.float-link').mouseleave( function() 
	{
		setTimeout( "hideFloat()", 500 );
	});
	
	$('#floatbox').click( function() 
	{
		hideFloat();
	});
	
	$('.main-menu-el').mouseenter( function()
	{
		$(this).css({ 'background-image' : 'url(/img/br_main_menu_light.gif)' });
	});
	
	$('.main-menu-el').mouseleave( function()
	{
		$(this).css({ 'background-image' : 'url(/img/br_main_menu.gif)' });
	});
});

