// Jeff
// www.huntingground.freeserve.co.uk

imgArray=new Array()
imgArray[0]="layout-index/header-bottom1.jpg"
imgArray[1]="layout-index/header-bottom2.jpg"

var preloadimgArray=new Array() // preloads images
for (i=0;i<imgArray.length;i++) {
preloadimgArray[i]=new Image()
preloadimgArray[i].src=imgArray[i]
}

expDays=365
cookieName="bgswap2"

function swapBg2(){
count = getCookie(cookieName)
num=Math.floor(Math.random()*imgArray.length)


if(num==count){
swapBg2()
}
else{
//document.body.style.backgroundImage="url("+imgArray[num]+")"

ex1=document.getElementById("header-bottom")
ex1.style.backgroundImage="url("+imgArray[num]+")"
ex1.style.backgroundRepeat="no-repeat"
ex1.style.backgroundPosition="center center"

}

}

function saveBg2(){
var exp = new Date()
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
setCookie(cookieName,num, exp)
}

function setCookie(name, value, expires, path, domain, secure){// An adaptation of Dorcht's function for setting a cookie.
if (!expires){expires = new Date()}
document.cookie = name + "=" + escape(value) +
((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
((secure == null) ? "" : "; secure")
}

function getCookie(name){
var arg = name + "="
var alen = arg.length
var clen = document.cookie.length
var i = 0
while (i < clen) {
var j = i + alen
if (document.cookie.substring(i, j) == arg)
return getCookieVal(j)
i = document.cookie.indexOf(" ", i) + 1
if (i == 0) break
}
return null
}

function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset)
if (endstr == -1)
endstr = document.cookie.length
return unescape(document.cookie.substring(offset, endstr))
}

function deleteCookie(name,path,domain) { // An adaptation of Dorcht's function for deleting a cookie.
document.cookie = name + "=" +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
"; expires=Thu, 01-Jan-00 00:00:01 GMT"
}