$(document).ready(function(){
	$("#slide li").css({position: 'absolute', zIndex: 2});
	
	$("#menu ul").hide();
	$("#menu li").hover(
		function(){ $( this ).find('ul').slideDown(); },
		function(){ $( this ).find('ul').hide(); }
	);
	
	$("a[rel='externo']").click(function( e ){
		e.preventDefault();
		window.open( $( this ).attr('href') );
	});
	$('.l-clientes a').hover(
		function(){
			$( this ).next('span').show();	
			$( this ).next('span').animate({bottom: '0px'}, 500);
		},
		function(){
			$( this ).next('span').css({bottom: '-30px'});
			$( this ).next('span').hide();		
		}
	);

	$("#f-grandes").append( '<img src="admin/images/lightbox-ico-loading.gif" alt="" style="border: none; margin-top: 70px;" />' );
	
	var first_a = $("#f-minis a").eq( 0 );
	var src = $( first_a ).attr('href');
	load_img( src );
	$("#f-desc").html( $( first_a ).attr('title') );
	

	
	$("#f-minis a").click(function( e ){
		e.preventDefault();
			
		var src = $( this ).attr('href');
		if( src != $('#f-grandes img').attr('src') )
		{
			
			$("#f-grandes").html( '<img src="admin/images/lightbox-ico-loading.gif" alt="" style="border: none; margin-top: 70px;" />' );
			
			load_img( src )
			$("#f-desc").html( $( this ).attr('title') );
			
			window.location.href = '#bread';
		}
	});
	$("#f-minis li").hover(
		function(){
			$( this ).css({borderColor: '#ce108c'});
		},
		function(){
			$( this ).css({borderColor: '#d4d2d3'});
		}
	);

	$("#nav li").hover(
		function(){
			var position = $( this ).attr('id');
			$( this ).find('a').css({color: '#fff'});
			$("#nav").css({backgroundPosition: position});
		},
		function(){
			$( this ).find('a').css({color: '#524f4f'});
			$("#nav").css({backgroundPosition: 'left top'});			
		}
	);
});
window.setInterval('troca()',4000);
var i = 0;
function troca()
{
	$("#slide li").eq( i ).fadeIn(3000);
	$("#slide li").not( $("#slide li").eq( i ) ).fadeOut(2500);
	i++;
	if( ($("#slide li").length) == i ) i=0;
}
function load_img( src )
{
	var img = new Image();
	img.src = src;
	img.onload = function()
	{
		$("#f-grandes").hide();
		$("#f-grandes").fadeIn('slow').html( '<img src="'+src+'" alt="" />' );
	}
}
