Try this:
setTimeout(function() { window.link = true; }, 5000);
This will set the global variable "link" to true after 5 seconds, which will satisfy your if statement.
Edit
This may be a bit complicated if you re a beginner, but a better way to accomplish this is to use function-scope rather than global scope.
In your case, declare the timer function like this:
var timer = (function () {
var link = false;
setTimeout(function() { link = true; }, 5000);
return function() {
alert(link);
};
}());
This way, the anonymous function returns another function which becomes timer(), but this way timer has access to its "private" link variable. For more information, check out Mozilla s article on JavaScript variable scope