function getLang() {
	var lan, temp3;
	
	// get the language
	lan = readCookie("xgovd2v");
	temp3 = getQueryVariable("xgovd2v");
	if (temp3) lan = temp3;

	return (lan);
}

function getBranding() {
	var branding, temp, lan, temp3;
	branding = readCookie("xgovk3w");

	// override: read the config from the url
	temp = getQueryVariable("xgovk3w"); // is this correct?  branding may be set by another variable in xgovf0p
	if (temp) branding = temp;

	// select the correct return link text depending on the text
	// can also change the actual link here if required
	if (getLang() == "cy" & branding == "bl230") branding = "bl230w";

	return (branding);
}

function getReturnUrl() {
	var temp2, dp, tx, sc, ru, lan;

	ru = returnLinks[getBranding()];
	if (ru == null) ru = returnLinks["bl1000"];

	// append the department.
	dp = readCookie("xgovs9k");
	if (dp == null) dp = 'anydept';
	ru += "?xgovs9k=" + dp;

	// append the transaction.
	tx = readCookie("xgovr3h");
	if (tx == null) tx = 'anytxn';
	ru += "&xgovr3h=" + tx;

	// now pull out the siteContext and append that too.
	sc = readCookie("xgovf0p");
	temp2 = getQueryVariable("xgovf0p");

	if (temp2) sc = temp2; 		// again, override cookie with querystring
	if (sc != null) ru += "&xgovf0p=" + sc;

	lan = getLang();
	if (lan != null) ru += "&xgovd2v=" + lan;

	return (ru);
}

function getReturnText() {
	var rt;

	rt = returnText[getBranding()];
	if (rt == null) rt = returnText["bl1000"];
	return (rt);
}

function logout() {
	eraseCookie('user');
	document.location = getReturnUrl();
}