Hi everybody..
I have been looking for a code to retain page position when a link is clicked, I have a website programmed with PHP and has many dynamic and static links.

I fond a javascript code that retains page scroll position, but this code doesn't work unless I remove this line from the page code:

HTML Code:
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 2.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
So I searched online to find out why doe's the line above prevents the javascript code from doing what it suppose to do, then I found that this javascript code contains syntax error and/or + (px) that refers to pixels (or such thing) is missing where it should be.

Here is the javascript code embedded in html document just for a quick test:

HTML Code:
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 2.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#container{
    width:400px;
}
#main{
    width:300px;
    float:right;
}
</style>

<script type="text/javascript"><!-- This javascript code retains page scroll bar in it's position on page refresh-->

cookieName="page_scroll"
expdays=365

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"
}

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

var x = (document.pageXOffset?document.pageXOffset:document.body.scrollLeft)
var y = (document.pageYOffset?document.pageYOffset:document.body.scrollTop)
Data=x + "_" + y
setCookie(cookieName,Data,expdate)
}

function loadScroll(){ // added function
inf=getCookie(cookieName)
if(!inf){return}
var ar = inf.split("_")
if(ar.length == 2){
window.scrollTo(parseInt(ar[0]), parseInt(ar[1]))
}
}

</script>
</head>

<body onload="loadScroll()" onunload="saveScroll()" >

<h1>A tetsing link is at the bottom of this page</h1>
<div id="container" style="height:1600px;background-color:#b64100">
    <div id="main" style="margin-top:1550px">
		<a href="" style="Color:#ffffff; font-size:18px;">Test</a>
    </div>
</div>
</body>
</html>
Can any body fix these errors and add what ever is missing to this code to make it completely and valid?