Hello i need help with javascript on how to show and hide ads as i ont know much about javascript

<html>
<h2>Hide Div in JavaScript</h2>
<script language=javascript type='text/javascript'> 
function hideDiv() { 
if (document.getElementById) { 
document.getElementById('div').style.visibility = 'hidden'; 
} 
} 
function showDiv() { 
if (document.getElementById) { 
document.getElementById('div').style.visibility = 'visible'; 
} 
} 
</script> 
<body onload="javascript:showDiv()">
<button onclick="javascript:hideDiv()">Hide</button> 
<button onclick="javascript:showDiv()">Show</button>


<div id="div">

<script type="text/javascript"><!--
google_ad_client = "ca-pub-xxxxxxxx";
google_ad_slot = "xxxxxxx";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlexxxxxxx.com/pagead/xxxxxx.js">
</script>

</div>
</body>
</html>

Above code works if i put hellow world between div but it doeesnt if i put ad code. ads never get hide

ads never get hide

Probably in the Google script. I don't think hiding ads is allowed by the ToS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.