function cursor()
{
	$('.cursor').fadeOut(1000).fadeIn(2000);
	setTimeout(eval("cursor"),"500");
}

jQuery.fn.center = function () 
{
 	var w = $(window).width();
    var h = $(window).height();
    
	w = (w/2) - (this.width()/2);
    h = (h/2) - (this.height()/2);
    this.css("left",w + "px");
    this.css("top",h + "px");
    return this;
}

$(document).ready(function() 
{
 	cursor();
    $('#sombra-pop').css('height', $('html').height());
    $("#tubo-pop").center();
    $("#botton").click(function () 
	{	      	
 		scrollCachePosition = $(window).scrollTop();
		//Envío el scroll a la posición 0 (left), 0 (top), es decir, arriba de todo.
		window.top.scroll(0,0);
        $("#sombra-pop").fadeIn(800, function(){$("#tubo-pop").fadeIn(400);});
        return false;
    });

	$("#close").click(function () 
	{
    	$("#tubo-pop").fadeOut(800, function(){$("#sombra-pop").fadeOut(400);});

        if (scrollCachePosition > 0) 
		{
	    	window.top.scroll(0,scrollCachePosition);
	        //Reseteamos la variable scrollCachePosition a 0 para poder ejecutar el script tantas veces sea necesario.
	        scrollCachePosition = 0;
	    }
    	return false;
  	});
    
	$(window).bind('resize', function() 
	{
		$("#tubo-pop").center();
    });
});
