$(document).ready(function()
{
	/* menú principal */
	$(".menu-item").bind('mouseover', function()
	{
		$('#arealegal-menu').css({ display: 'none' });			
		$('#services-menu').css({ display: 'none' });	
		$('#services-submenu').css({ display: 'none' });	
	});	

	$("#menu-1").bind('mouseover', function() 
	{
		var mLeft = 0;
		$('#arealegal-menu').css({ display: 'block', 'margin-left': mLeft + 'px', 'z-index': 1000 });
	});
	
	$("#menu-2").bind('mouseover', function() 
	{
		var mLeft = $('.menu td').eq(0).width();
		//var mLeft = $("#menu-2").position().left;
		$('#services-menu').css({ display: 'block', 'margin-left': mLeft + 'px', 'z-index': 1000 });
	});	
		
	$(".content").bind('mouseover', function()
	{
		$('#arealegal-menu').css({ display: 'none' });			
		$('#services-menu').css({ display: 'none' });	
		$('#services-submenu').css({ display: 'none' });	
	});	
	
	/* submenú 2 */

	$("#services-menu a").bind('mouseover', function()
	{
		// ok, posem les opcions corresponents al menú que s'està mostrant
		var id = (this.id).split('-');
			id = parseInt(id[2]) - 1;
		var idx = 1;
		
		$('#services-submenu').html('');
		
		for(so in subopts)
		{
			if(subopts[so].parent==id)
			{
				$('#services-submenu').append('<a href="'+subopts[so].url+'">'+subopts[so].name+'</a>');
				//$('#services-submenu-' + idx).attr('href', subopts[so].url).html(subopts[so].name);
				idx++;
			}
		}
		
		if(idx > 1)
		{		
			// mostrar el submenú
			var mLeft = $('.menu td').eq(0).width() + $('#services-menu').width() + 2;
			$('#services-submenu').css({ display: 'block', 'margin-left': mLeft + 'px', 'z-index': 1000 });	
		}
		else
		{
			$('#services-submenu').css({ display: 'none'});
		}
		
	});
	
	// slideshow
	
	/*
	$("#slideshow").slideshow(
	{
		pauseSeconds: 5,
		height: 224,
		width: 775,
		fadeSpeed: 0.8,
		caption: false
	});
	*/
	
	/*
	$("#slideshow ul").css('display', 'none');
	*/
	
	/*
	$('#slideshow').cycle(
	{
		fx: 'none',
		timeout: 5000,
		width: 775,
		height: 224			
	});		
	*/

	/*
	$('#slideshow').fadeOut(0).fadeIn(2000, function() 
	{
		
	});
	*/
	
	$("#slideshow a.slideshow-link").each(function(a, b) { if($(b).attr('href')=='#') $(b).css({'cursor': 'default'}); } );
	
	if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version == 8)
	{
		//$('#services-menu').css('opacity', 0.95);
		//$('#services-submenu').css('opacity', 0.95);		
	}
	else
	{
		$('#services-menu').css('opacity', 0.95);
		$('#services-submenu').css('opacity', 0.95);
		$('#arealegal-menu').css('opacity', 0.95);
	}
/*	
	if($(document.body).height() < 620) $(document.body).css('height', '620px');
	else								$(document.body).css('height', 'auto');
	var bwh = $(window).height() - $('.wrapper').height();
	if(bwh < 0) bwh = 0;
	if(bwh > 0) $('#bottom_wrapper').css('height', bwh + 'px');
*/	
});
	
/*	
$(window).bind('resize', function()
{
	if($(document.body).height() < 620) $(document.body).css('height', '620px');
	else								$(document.body).css('height', 'auto');
	var bwh = $(window).height() - $('.wrapper').height();
	if(bwh < 0) bwh = 0;
	if(bwh > 0) $('#bottom_wrapper').css('height', bwh + 'px');
});
*/
