// JavaScript Document
var myBgName=readCookie("PortCityJavaBg");
function readCookie(name)

{

  var cookieValue = "";

  var search = name + "=";

  if(document.cookie.length > 0)

  { 

    offset = document.cookie.indexOf(search);

    if (offset != -1)

    { 

      offset += search.length;

      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;

      cookieValue = unescape(document.cookie.substring(offset, end))

    }

  }

  return cookieValue;

}

//check to see if cookie exist
if(myBgName=="")
{ 
//if doesn't exist write default BG
document.write("<style type='text/css'>body {background-image: url(../images/background/redstripe.gif);}</style>");}
else
{
//if exists write new BG
document.write("<style type='text/css'>body {background-image: url(../images/background/"+myBgName+");}</style>");
}

//when called this function grabs the variable, sets the cookie and refreshes the page.
function changeBg(what)
{
	
pageBg=what;		

 writeCookie("PortCityJavaBg", pageBg, 24);

// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.

function writeCookie(name, value, hours)

{

  var expire = "";

  if(hours != null)

  {

    expire = new Date((new Date()).getTime() + hours * 3600000);

    expire = "; expires=" + expire.toGMTString();

  }
	var path = "; path=/;";
  document.cookie = name + "=" + escape(value) + expire +"; path=/" 

}
//refresh page
window.location=self.location 
}// JavaScript Document