$(document).ready(function() {

	$.preload( 'img.thumbImg', {
	    find: '.png',
	    replace: '2.png'
	});

	$(function() {
	    $(".thumbImg")
	        .mouseover(function() { 
	            var src = $(this).attr("src").match(/[^\.]+/) + "2.png";
	            $(this).attr("src", src);
	        })
	        .mouseout(function() {
	            var src = $(this).attr("src").replace("2", "");
        	    $(this).attr("src", src);
	        });
	});

	starCurrent = 0;
	timein = 225;
	timeout = 2200;
	fadeSpeedIn = 250;
	fadeSpeedOut = 200;
	randomStart=new Array(11,552,1248,1479,1730,2171,19,640,1337,1556,1734,2003,2412);
	randomDelay = (Math.round(Math.random()*100))*10;

	timein2 = 350;
	timeout2 = 2600;
	fadeSpeedIn2 = 550;
	fadeSpeedOut2 = 400;

	function pulsate(id,timein,timeout,fadeSpeedIn,fadeSpeedOut,randomDelay) {
		starCurrent++;
		randomStretch = (Math.round(Math.random()*100))*10;
		arrayVal = starCurrent - 1;
		var initDelay = randomStart[arrayVal];
		initDelay += randomDelay;
		$(id).delay(initDelay).
		animate({opacity: 1}, (fadeSpeedIn + randomStretch), 'linear').delay(timein).
		animate({opacity: 0}, (fadeSpeedOut + randomStretch), 'linear', function() {
			$(this).delay(timeout);
			randomDelay = (Math.round(Math.random()*100))*25;
			pulsate(id,timein,timeout,fadeSpeedIn,fadeSpeedOut,randomDelay);
		});			
	};	

	$('.logoStar').each(function(index) {
		idtje = $(this).attr('id');
		pulsate("#" + idtje,timein,timeout,fadeSpeedIn,fadeSpeedOut,randomDelay);
	});

	$('.logoStar2').each(function(index) {
		idtje = $(this).attr('id');
		pulsate("#" + idtje,timein2,timeout2,fadeSpeedIn2,fadeSpeedOut2,randomDelay);
	});
});
