var dbPath="";

function setCookie(cookieName, cookieVal) {
	document.cookie = cookieName + "="+escape(cookieVal) + ";path=/;expires=";
}

function doPageHistory (title, ref, flag) {
	myHistory = getCookie("pagehistory");
	list = new Array();
	if ((myHistory == null) || (myHistory == "")) {
		setCookie("pagehistory",title+"@"+ref,365);
		document.writeln("-");
		return true;
	} else {
		list = myHistory.split("@");
		// Check if the list should be diplayed or not
		if (flag) {
			document.writeln("<table border=\"0\">");
			counter = 1;
			for (i=0;i<list.length;i+=2) {
				document.writeln("<tr><td><a class=\"info-form-links\" href=\""+dbPath+list[i+1]+"\">"+counter+". "+list[i]+"&nbsp;<img src=\"/images/global/ico_nav.gif\" border=\"0\"></a></td></tr>");
				counter++;
			}
			document.writeln("</table>");
		}
		for (i=0;i<list.length;i+=2) {
			if (list[i+1] == ref) {
				list.splice(i,2);
				break;
			}
		}
		list.unshift(title,ref) // Adds current to the top of the list
		if (list.length > 10) {
			list = list.slice(0,10);
		}
		// Add current page to list
		setCookie("pagehistory",list.join("@"));
	}
}

function getCookie(cookieName) {
	cookieName = cookieName+"=";
	var allCookies = document.cookie;
	if (allCookies.length > 0) {
		var start = allCookies.indexOf(cookieName);
		if (start != -1) {
			start = start + cookieName.length;
			var end = allCookies.indexOf(";",start);
			if (end == -1) end = allCookies.length;
			return unescape(allCookies.substring(start,end));
		}
	}
	return null;		
}