$(document).ready(function(){
	
	var startSlide = typeof(startSlideIndex)!='undefined' ? startSlideIndex : Math.round(Math.random()*6);
	$("#headerFlash").flash({
		src: 'banner.swf',
		id: 'fheader',
		wmode: 'transparent',
		width: 978,
		height: 323,
		flashvars: { startSlide: startSlide, expires: 'now', speed: 4200 }
		},
        { version: 8 }
    );
    
    $("#sloganFlash").flash({
		src: 'slogan.swf',
		id: 'fslogan',
		wmode: 'transparent',
		width: 978,
		height: 84 },
        { version: 8 }
    );
    
    $('ul#homeBoxes li:last-child, ul#historia li:last-child, ul#bottomMenu > li:last-child').addClass('last');
    
    $('ul#menu li a:not(.active)')
		.css( {backgroundPosition: "0 -70px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:450})
		})
		.mouseout(function(){   
            if ($(this).parent().attr('class') !== 'hover')
            {
                $(this).stop().animate({backgroundPosition:"(-70px -70px)"}, {duration:300, complete:function(){
                    $(this).css({backgroundPosition: "0 -70px"})
                }});
            }
		})

    $("ul#menul li a:not(.active)").hover(function(){
        $(this).animate({
            paddingLeft: '+=8'
        }, 200);
    },
    function(){
        $(this).animate({
            paddingLeft: '-=8'
        }, 120);
    });
    
	$("ul#menu li").hover(function() {
		$(this).find("ul").delay(440).slideDown(400).show(400, function(){
			$(this).height("auto");
            $(this).parent().addClass("hover");
		});
		
	} , function() {
        $(this).removeClass("hover");
		$(this).find("ul").stop(true, true).slideUp(250);
        $(this).find("a:not(.active)").animate({backgroundPosition:"(-70px -70px)"}, {duration:300, complete:function(){
            $(this).css({backgroundPosition: "0 -70px"})
        }});
	});
});
