So you just want to show an element onload and hide after 5 seconds?
<script>
window.onload=function(){
document.getElementById('overlay').style.display = 'block';
setTimeout(function(){
document.getElementById('overlay').style.display = 'none';
},5000);
};
</script>