$.fn.delay = function(time, callback){
    // Empty function:
    jQuery.fx.step.delay = function(){};
    // Return meaningless animation, (will be added to queue)
    return this.animate({delay:1}, time, callback);
}

var lDelay = 0;
var lStart = [];



function migaj () {

	var a;
	a = parseInt(this.id.substr(-1))+1;
	if (a >= 5) a = 0;

	$('#l'+a).animate( { opacity: 0.2 }, 300)
        .animate( { opacity: 1 }, 1000)
	.delay(300,migaj);
}

var flashvars = {};
var params = {};
params.bgcolor = "#000000";
var attributes = {};


$(document).ready( function(){

	$('#home_logos img').css({opacity: '0'});



	$('#button').flash({ swf: '/img/2011_aj_button.swf', background: '#000000', height: 102, width: 123, params: {bgcolor:"#000000"}  });
	
	
	
/*
	var menulinks = $("#menu li:not(#selected) a");
	// menulinks.children('span.blink').css({opacity: '0'});
	menulinks.hoverIntent({sensitivity: 1,interval: 1,over: linkOver,	timeout: 0, out: linkOut}); 

	function linkOver(){$(this).children('span.blink').stop().animate({opacity:"1"}, 150 )};
	function linkOut(){$(this).children('span.blink').animate({opacity:"0"}, 750)};


	function linkOver(){$(this).children('span.blink').css({visibility:"visible"})};
	function linkOut(){$(this).children('span.blink').css({visibility:"hidden"})};
*/

	if (sarea != 'home') {


   
   



	$('#flash').flash({ swf: '/img/2011_aj_racing_page.swf', background: '#000000', height: 340, width: 998, params: {bgcolor:"#000000"},  flashvars: {}   }  );	
	
	$('a[rel=lightbox]').colorbox({
		onOpen: function() {
			$('#flash').children().first().hide();
		},
		onClosed: function() {
			$('#flash').children().first().show();
		}
				
	});

	$('#gal_sel').attr('scrollTop',subMenuScroll);

	$('h4.gal-year').click(function(){
		$('#title ul').hide();
		$(this).next().show();
	});

	$('ul.gal-list a').click(function(){
		document.location.href=this.href.replace('.html',',st,'+this.parentNode.parentNode.scrollTop+'.html');
		return false;
	});

	
	}
	else {

	$('#flash').flash({ swf: '/img/2011_05_aj_racing.swf', background: '#000000', height: 722, width: 998, params: {bgcolor:"#000000"},  flashvars: {  welcome:welcome   }   } );	
	
/*
	$("#home_logos img").each(function(){

		var d = 0;
		if (!lStart[lDelay]) {
			d = lDelay;
			lStart[lDelay] = 1;
			++lDelay;
		
		}

      		 $(this).delay(500+(d*500))
		.animate( { opacity: 1 }, 1000)
		.delay(500+(d*1000));

	});
	$("#l4").delay(3000,migaj);

*/
	}


});


if (sarea != 'home') {

var dejavu = { src: '/font/dejavu.swf' };

sIFR.activate(dejavu);
sIFR.replace(dejavu, {
  opaque: true,
  selector: 'h2',
  css: '.sIFR-root { background-color: #000000; letter-spacing: -3; color: #FF2600; }'
});

sIFR.replace(dejavu, {
  opaque: true,
  selector: 'h1',
  css: '.sIFR-root { background-color: #000000; letter-spacing: -3; color: #FFFFFF; }'
});

sIFR.replace(dejavu, {
  opaque: true,

  selector: 'h3',
  css: '.sIFR-root { background-color: #000000; color: #77CAFF;} .sIFR-root a {letter-spacing: 0; color: #77CAFF; text-decoration: none;} .sIFR-root a:hover {letter-spacing: 0; color: #FFFFFF; text-decoration: none;}'
});

}

$(window).load( function() {


});
