Code:
<body onload="loadall();">
<script type="text/javascript">
var backgroundImages =
[ "images/Crystal_clear_water_Yamma_Sam_Island.jpg",
"images/CrystalForest_Sky.jpg" ];
var backgroundNames =
[ "Default",
"Crystal Forest" ];
var backgroundPositions =
[ "top Left",
"top Center",
"top Right",
"Left",
"Center",
"Right",
"bottom Left",
"bottom Center",
"bottom Right" ];
var backgroundPositionnames =
[ "top Left",
"top Center",
"top Right",
"Left",
"Center",
"Right",
"bottom Left",
"bottom Center",
"bottom Right" ];
function loadall(){
alert(GetCookie("image"));
alert(GetCookie("position"));
getDivBG("image");
loadOptions(document.TheForm.favSelect);
loadpositionopt(document.TheForm.favSelect2);
setDiv("position","repeat");
}
function loadOptions( into )
{
for ( var b = 0; b < backgroundImages.length; ++b )
{
into.options[into.options.length] =
new Option( backgroundNames[b], backgroundImages[b] );
}
}
function loadpositionopt( into1 )
{
for ( var c1 = 0; c1 < backgroundPositions.length; ++c1 )
{
into1.options[into1.options.length] =
new Option( backgroundPositionnames[c1], backgroundPositions[c1] );
}
}
function savepos(){
var favPos = document.forms.TheForm.favSelect2.value;
if ( favPos == "" ) return;
SetCookie("position", favPos, exp);
}
function saverep(rep){
var favrep = rep;
if ( favrep == "" ) return;
SetCookie("repeat", favrep, exp);
return favrep;
}
var expDays = 365;
var exp = new Date();
var favImage = "";
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function setDiv(cookie,cookie2){
document.getElementById("news").style.backgroundPosition=GetCookie(cookie);
document.getElementById("news").style.backgroundRepeat=GetCookie(cookie2);
}
function saveImage()
{
var favImage = document.forms.TheForm.favSelect.value;
if ( favImage == "" ) return;
SetCookie("image", favImage, exp);
getDivBG("image");
}
function menu(){
document.write('<div id="mydiv" style="background-color: white; width: 120px; height: 120px;">\n'
+'</div>\n'
+'<form name="TheForm">\n'
+'<font size="2pt">News Menu | Change Background: <select name="favSelect" onchange="getDivsBG(this.value), saveImage();">\n'
+' <option value="">--choose--</option>\n'
+' </select></font>\n'
+'<select name="favSelect2" onchange="loadpositionopt(this.value), savepos();">\n'
+' <option value="">--choose--</option>\n'
+' </select>\n'
+'</form>\n'
+'');
}
var expDays = 365;
var exp = new Date();
var favImage = "";
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function GetCookie(name)
{
var cookies = document.cookie.split(/; /g);
var arg = name + "=";
for ( var c = 0; c < cookies.length; ++c )
{
var ck = cookies[c];
if ( ck.indexOf(arg) == 0 )
{
var temp = ck.split(/=/);
return unescape(temp[1]);
}
}
return "";
}
function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name)
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function getBodyBG(cookie)
{
document.body.style.backgroundImage="url('" + GetCookie(cookie) + "')";
}
function getDivsBG(pic)
{
if ( pic != ""){
document.getElementById("mydiv").style.backgroundImage="url('" + pic + "')";
//document.getElementById("blahnews").style.backgroundImage="url('" + pic + "')";
}
}
function getDivBG(cookie)
{
document.getElementById("mydiv").style.backgroundImage="url('" + GetCookie(cookie) + "')";
//document.getElementById("blahnews").style.backgroundImage="url('" + GetCookie(cookie) + "')";
}
function getnews(newsbody){
checkxmlhttprequest();
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "myremotefile.txt", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4) { // Makes sure the document is ready to parse.
if (txtFile.status === 200) { // Makes sure it's found the file.
allText = txtFile.responseText;
lines = txtFile.responseText.split(/\r?\n/g); // Will separate each line into an array
document.getElementById(newsbody).innerHTML = lines;
} else {
document.getElementById(newsbody).innerHTML = 'News file not found';
}
}
}
txtFile.send();
}
function gettitle(newstitle){
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "myremotetitle.ini", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4) { // Makes sure the document is ready to parse.
if (txtFile.status === 200) { // Makes sure it's found the file.
allText = txtFile.responseText;
lines = txtFile.responseText.split("\n"); // Will separate each line into an array
document.getElementById(newstitle).innerHTML = lines;
} else {
document.getElementById(newstitle).innerHTML = 'News file not found';
}
}
}
txtFile.send();
}
function checkxmlhttprequest(){
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
} else {
alert('Sorry, your browser doesn\'t support XMLHTTPRequests');
return null;
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('Sorry, your browser doesn\'t support XMLHTTPRequests');
return null;
}
}
</script>
<Center><p align="Center">
<table border="1" style="background-Color: #44CFFC;" width="400" height="300" name="about"><tr><td valign="top">
<div id="news" style="height: 30%; background-Color: #44CF00;">
<script type="text/javascript">menu();</script>
</div><hr>
</table></td></tr>
</p></Center>
</body>
ANY help is GREATLY appreciated!
Bookmarks