step=1
timeout=100
timer=""
expdays=365
cookieName="divscroller2"

function popupContactUs()
{
	popupWindow = window.open('index.php?.p=contact','test','height=480,width=640,resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=yes,directories=no,status=yes')
}

function initDivScroller(){
divScroller=document.getElementById("scroll")

posY=getCookie(cookieName)
posY = 0;
if(posY){
divScroller.scrollTop=posY
}

scrollDivUp()

}

function scrollDivUp(){
clearTimeout(timer) 
divScroller.scrollTop+=step

if(divScroller.scrollTop>=divScroller.scrollHeight-divScroller.offsetHeight){
divScroller.scrollTop=0
}

timer=setTimeout("scrollDivUp()",timeout)
}

function savePosY(){ // added function
var expdate = new Date ()
expdate.setTime (expdate.getTime() + (expdays*24*60*60*1000))

var y = (document.getElementById("scroll").scrollTop)
Data=y
setCookie(cookieName,Data,expdate)
}

// An adaptation of Dorcht's cookie functions.

function setCookie(name, value, expires, path, domain, secure){
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){
document.cookie = name + "=" +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
"; expires=Thu, 01-Jan-00 00:00:01 GMT"
}
