MDanz 0 Junior Poster

Can i get help correcting the code below? You can just copy and paste and try it yourself. Onmouseover the popup div appears. If i click(X) the popup div should close but it doesn't. Only doubleclicking (X) closes the popup div. Onmouseover it should always display a popup div though.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

</head>
<style type="text/css">
.container {
display:block;
width:500px;
height:200px;
border:1px solid green;
}
.advert {
float:right;
overflow:hidden;
width:100px;
height:30px;
border:1px solid red;
}
.close {
float:right;
width:20px;
height:28px;
cursor:pointer;
border:1px solid black;
}
</style>
<body>

<div class="container" onmouseover='getad(39);' onmouseout='hidead(39);changeback(39);'>
<div class='advert' id="39"  style="display:none;"><div class="close"><a href="javascript:closead(39)">X</a></div></div>
<input type="text" value="1" id="ad39" />
</div>


<div class="container" onmouseover='getad(40);' onmouseout='hidead(40);changeback(40);'>
<div class='advert' id="40" style="display:none;"><div class="close"><a href="javascript:closead(40)">X</a></div></div>
<input type="text" value="1" id="ad40" />
</div>

<script type="text/javascript">

function getad(number) {
		
	if(document.getElementById('ad'+number).value==1) {
		if(document.getElementById(number).style.display == "none") {
		document.getElementById(number).style.display = "block";
		
		}
	}
	
} 

function hidead(number) {
	
	if(document.getElementById('ad'+number).value==1) {
		if(document.getElementById(number).style.display == "block") {
		document.getElementById(number).style.display = "none";
		
		}
	}
} 

function closead(number) {
	
	document.getElementById('ad'+number).value = 0;
	if(document.getElementById(number).style.display == "block") {
		document.getElementById(number).style.display = "none";
		
		}

	
	
	}

	function changeback(number) {
	
	if(document.getElementById('ad'+number).value==0) {

	
	document.getElementById('ad'+number).value = 1;
	
	}
	}
</script>
</body>
</html>