Here is the code:
function initPage() {
setCookie("region", "US", getExpDate(10 * 365))
removeFromSession("region")
document.forms[0].SESSION.value += "region=US;"
var url = getDocumentLocation()
var offset = url.indexOf("?")
if (offset == -1) return
var params = "&" + url.substring(offset + 1)
var indexStr = "&index="
if ((offset = params.indexOf(indexStr)) != -1) {
var index = params.substring(offset + indexStr.length)
if ((offset = index.indexOf("&")) != -1) {
index = index.substring(0, offset)
}
index = parseInt(index)
if (index == 0) {
setCookie("timer", new Date().getTime(), "")
}
var form = getForm()
var menu = form.countryList
if (index < menu.options.length) {
menu.selectedIndex = index
fields["reportType"].setValue("BOTH")
if (doSubmit()) {
form.action = "agentLinkResults.asp?index=" + index
form.submit()
}
} else {
var startTime = parseInt(getCookie("timer"))
alert(((new Date().getTime()) - startTime)/1000)
}
}
}
function customValidation() {
var form = getForm()
var type = fields["reportType"].getValue()
var countryList = getListValues(form.countryList, type)
form.SESSION.value = "NEW_DISPLAY=" + countryList + ";" + form.SESSION.value
}
function getListValues(listObj, type) {
var result = ""
for (var i = 0; i < listObj.options.length; i++) {
if (listObj.options[i].selected) {
result += (result != "" ? "," : "") + listObj.options[i].value + "_" + (type == "BOTH" ? "CSL" : type)
if (type == "BOTH") {
result += "," + listObj.options[i].value + "_EAD"
}
}
}
return result
}