        // Wrapper
        (function() {
            this.timeout = 2;
            this.maxout = 500;
            this.loop = setInterval(function() { this.check(); }, 1000);
            this.test = undefined;
            
            // On load
            var expires = new Date();
			expires.setDate(expires.getDate()+1);
            $.cookie("nov_survey", ($.cookie("nov_survey") === null) ? "0" : $.cookie("nov_survey"), { path: "/", expires: expires.toUTCString() });

            // On unload
            $(window).unload(function() {
                var expires = new Date();
				expires.setDate(expires.getDate()+1);
                $.cookie("nov_survey", (parseInt($.cookie("nov_survey")) !== this.maxout && parseInt($.cookie("nov_survey")) < this.timeout) ? this.test : $.cookie("nov_survey"), { path: "/", expires: expires.toUTCString() });
			});
            
            // Check method
            this.check = function() {
                // Do not activate on chapter sites
                if(location["pathname"].indexOf("chapters") > -1) {
                    clearInterval(this.loop);
                    return true;
                }
                
                // Update the counter and stop the interval if the cookie is maxed out
                this.test = (typeof this.test === "undefined")? (isNaN(parseInt($.cookie("nov_survey")))) ? 0 : parseInt($.cookie("nov_survey")) : this.test+1;
				
                if(this.test === this.maxout) {
                    clearInterval(this.loop);
                    return true;
                }
				
                // Show modal
                if(this.test > this.timeout) {
                    clearInterval(this.loop);
                    var content = $("<div id='surveyModal' style='border:3px solid #C0C0C0; background-color: #FFFFFF; width: 364px; height: 400px; position: absolute; top: 0%; left: 50%; margin-top: -400px; margin-left: -182px; z-index: 100000'>" +
                                     + "</div>");
                    $("body").prepend(content);
                    
                    $("#surveyModal").load("/survey.html");
                    
                    $("#surveyModal").animate({top: "50%", marginTop: "-200px"}, "slow", "linear", function() {
                        $("body").prepend("<div id='cover'>&nbsp;</div>");
						$('#cover').css("filter", "alpha(opacity=55)");
                        $("#cover").fadeIn("slow");
                        
						$("#NoThanksBtn").click(function() {
							$("#cover").fadeOut("slow");
							$("#surveyModal").hide();
						});
                    });
					
					var expires = new Date();
					expires.setDate(expires.getDate()+1)
                    $.cookie("nov_survey", "500", { path: "/", expires: expires.toUTCString() });
                }
				
                return true;
            }
        })();