Show interstitial ad once every 10 minutes
<p>I've been struggling dealing with ads and their frequency capping lately.
I'm using Adform (an advertising platform) and I've been demanded to create an interstitial ad for mobile visitor in a way that it should show only once every X minutes. (Getting an interstitial ad each time you read another post on site is annoying).</p>

<p>So far I've been using a premade script and it works fine with img and table tags but not with the script itself!
Here's the script used so far:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;

&lt;head&gt;
&lt;script type="text/javascript"&gt;

/***********************************************
* Frequency Cap Content script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Please keep this notice intact
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//["ID of content to frequency cap", "Display frequency interval (full hours only)"]
var capcontent=new Array()
capcontent[0]=["myad", "1 hr"]
capcontent[1]=["mynote", "3 hr"]

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length &gt; 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function resetcookie(id){
var expireDate = new Date()
expireDate.setHours(expireDate.getHours()-10)
document.cookie = id+"=;path=/;expires=" + expireDate.toGMTString()
}

function showorhide(caparray){
if (get_cookie(caparray[0])!='')
document.write("#"+caparray[0]+"{display: none;}\n") //CSS TO HIDE CONTENT BTW FREQUENCY
else{
var expireDate = new Date()
expireDate.setHours(expireDate.getHours()+parseInt(caparray[1]))
document.cookie = caparray[0]+"="+parseInt(caparray[1])+";path=/;expires=" + expireDate.toGMTString()
}
}

document.write('&lt;style type="text/css"&gt;\n')

for (i=0; i&lt;capcontent.length; i++){
if (get_cookie(capcontent[i][0])!=parseInt(capcontent[i][1]))
resetcookie(capcontent[i][0])
showorhide(capcontent[i])
}

document.write('&lt;/style&gt;')

&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;div id="myad"&gt;

&lt;script type="text/javascript" src="http://adx.adform.net/adx/?mid=303469&amp;rnd=%%ADFRND%%"&gt;&lt;/script&gt;


&lt;/div&gt;

&lt;div id="table"&gt;

&lt;/table&gt;

&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>

<p>As you might notice, inside the div with id "myad" I've inserted the javascript code. If I open the site, the ad shows up,but once closed and reloaded the page, it stil keeps showing up!</p>

<p>Any help please?</p>