jQuery.fn.center = function(){
	var w = $(window);
	this.css("position","absolute");
	this.css("top",(w.height()-this.height())/2+w.scrollTop() + "px");
	this.css("left",(w.width()-this.width())/2+w.scrollLeft() + "px");
	return this;
}
function doCenter(speed) {
	var w = $(window);
	var xx = (w.width()-$('#box').width())/2+w.scrollLeft();
	var yy = (w.height()-$('#box').height())/2+w.scrollTop();
	$('#box').animate({"left": xx,"top": yy},speed,"easeOutBounce");
}

function show_counter() {  
	$.ajax({  
		url: "counter.php",  
		cache: false,  
		success: function(html){  
			$("#counter").html(html);  
		}  
	});  
}  
  
$(document).ready(function(){

	var resizeTimer = null;
	$(window).bind('resize', function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(doCenter(2000), 500);
	});
	
	$("#box").center();	
	$("body").hide(); 

	$("#box").draggable({ 
		delay: 100,
		stop: function() { doCenter(1000); }
	});


	$('body').animate({ opacity: "show" }, 2000);
	
});