function resizeElement(){
	var logoposition = $("#logoHome").offset();
	$("div.ball").each(function(){
		rely = logoposition.top + parseInt($(this).attr("rely"));
		relx = logoposition.left + parseInt($(this).attr("relx"));
		$(this).css({
				top: rely+"px",
				right: relx+"px"
		});
	});
}
$(document).ready(function(){
	var logoposition = $("#logoHome").offset();
	$("div.ball").each(function(){
		ballposition = $(this).position();
		$(this).attr("relx", $(this).css("right").replace("px", ""));
		$(this).attr("rely", $(this).css("top").replace("px", ""));
		var startright =Math.floor(Math.random()*$(window).width());
		var starttop = Math.floor(Math.random()*$(window).height());
		$(this).css( {
			top: starttop + "px",
			right: startright + "px"
			});
		rely = logoposition.top + parseInt($(this).attr("rely"));
		relx = logoposition.left + parseInt($(this).attr("relx"));
		$(this).animate({
				top: rely+"px",
				right: relx+"px"
			}, 1500+Math.floor(Math.random()*1500), "easeInCirc", function(){
					if($(this).hasClass("hide")){
						$(this).hide();
					}
				});
	});
	$("div.ball").mouseenter(function(){
		$(this).find("div.on").show();
	}).mouseleave(function(){
		$(this).find("div.on").hide();
		});
		
	$("a.onoff").mouseenter(function(){
			$(this).find(".off").hide();
			$(this).find(".on").show();
		}).mouseleave(function(){
			$(this).find(".off").show();
			$(this).find(".on").hide();
		});
	$(window).bind("resize", function(){ resizeElement(); });
});
