New Revised CSS Library Forums Web Tools
FAQs Awards Usage Terms Contact

<html>

<head>
<script type="text/javascript">

/***********************************************
* Frequency Cap Content script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* 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 > 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('<style type="text/css">\n')

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

document.write('</style>')

</script>
</head>

<body>

<div id="myad">

//some content
//some content

</div>

<table id="mynote">

//rest of table here

</table>

</body>
</html>