<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
<!--
function bakeCookie(name,value){
args=arguments;argc=args.length;
expires=(argc>2) ? args[2] : null;
path=(argc>3) ? args[3] : null;
domain=(argc>4) ? args[4] : null;
secure=(argc>5) ? args[5] : false;
expDate=new Date();day=24*60*60*1000;
if(expires){expDate.setTime(expDate.getTime()+expires*day);}
document.cookie=name+"="+escape(value)+
((expires===null) ? "" : ("; expires="+expDate.toUTCString()))+
((path===null) ? "" : ("; path="+path))+
((domain===null) ? "" : ("; domain="+domain))+
((secure===true) ? "; secure" : "");
}
function eatCookieVal(name) {
endstr=document.cookie.indexOf(";",name);
if(endstr===-1) {endstr=document.cookie.length;}
return unescape(document.cookie.substring(name,endstr));
}
function eatCookie(name) {
arg=name+"="; alen=arg.length;
clen=document.cookie.length; i=0;
while (i<clen) {
j=i+alen;
if(document.cookie.substring(i,j)===arg){
return eatCookieVal(j);
}
i=document.cookie.indexOf(" ",i)+1;
if(i===0){break;}
}
}
/* Additional function added for deleting cookies */
function deleteCookie(name) {
document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT' + '; path='; }
function newColor(entry,areaID){ // use DOM method
bakeCookie("colorSet",entry,7); // save for a week
if (!areaID){areaID="body";} // default to whole body
document.getElementById(areaID).style.background=entry;
}
function newFont(entry,areaID){ // use DOM method
bakeCookie("fontSet",entry,7); // save for a week
if (!areaID){areaID="body";} // default to whole body
document.getElementById(areaID).style.fontFamily=entry;
}
function isColorSet(areaID) { // points at color element
colorSet=null;
if(!(colorSet=eatCookie("colorSet"))){colorSet=null;}
if(colorSet!==null){newColor2(colorSet,areaID);}
fontSet=null;
if(!(fontSet=eatCookie("fontSet"))){fontSet=null;}
if(fontSet!==null){newFont(fontSet,areaID);}
}
function resetLists(){
document.forms[0].select1.selectedIndex = 0;
document.forms[0].select2.selectedIndex = 0;
if ((document.forms[0].select1.selectedIndex == 0) && (document.forms[0].select2.selectedIndex == 0)) {
deleteCookie('colorSet');
deleteCookie('fontSet');
document.body.style.backgroundColor = '#FFF';
document.body.style.color = '#000';
document.body.style.fontSize = '80%';
alert(document.cookie); }
}
//-->
</script>
</head>
<!--Start the html body-->
<body id="body" onload="isColorSet()">
<h3>Sample</h3>
<form action="#" onsubmit="return false;">
<select name="select1" onchange="newColor(this.value);">
<option value="">Background Color</option>
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="Orange">Orange</option>
<option value="Red">Red</option>
<option value="Violet">Violet</option>
<option value="Yellow">Yellow</option>
</select>
<select name="select2" onchange="newFont(this.value);">
<option value="">Font Family</option>
<option value="Arial">Arial</option>
<option value="Helvetica">Helvetica</option>
<option value="Tahoma">Tahoma</option>
<option value="Times New Roman">Times New Roman</option>
<option value="Verdana">Verdana</option>
</select>
</br>
</br>
BLA BLA BLA BLA BLABLA BLA BLA BLA
</form>
<button onclick="resetLists()">Reset</button>
</body>
</html>