Div close button issue


I have a div that appears as you scroll to the bottom of the page and then fades out as you scroll back up. I would like to add a close button to the div which I have done and sort of works. It closes the div, but if you scroll, it appears again.

This is my code:

function toggle() {
	var ele = document.getElementById("offerbox");
	var text = document.getElementById("displayText");
	if(ele.style.display == "block") {
    		ele.style.display = "none";
		text.innerHTML = "show";
	else {
		ele.style.display = "block";
		text.innerHTML = "hide";
  // get the height of #wrap
  var h = $('#wrapper').height();
  var y = $(window).scrollTop();
  if( y > (h*.25) && y < (h*.75) ){
   // if we are show keyboardTips
  } else {

Any ideas whats wrong?



Could you post a link to a page where I could see this in action?