var gsdlURL = '';
var gsdlOnPageOnLoad = null;
var gsdlServerURL = location.protocol + "//" + location.host;
var gsdlDefaults = { 
	args: { 
		clmd: 0,
		o: 50,
		m: 0,
		s: 0,
		k: 1,
		t: 0
	}
};
if (typeof(Array.prototype.push) == 'undefined')
{
	Array.prototype.push = function(v) {
		this[this.length] = v;
	}
}

if (typeof(Array.prototype.indexOf) == 'undefined')
{
	Array.prototype.indexOf = function(obj) {
		for(var i = 0; i < this.length; ++i) {
			if (this[i] == obj) return i;
		}
		return -1;
	}
}

if (typeof(Array.prototype.remove) == 'undefined')
{
	Array.prototype.remove = function(obj) {
		for(var i = 0; i < this.length; ++i) {
			if (this[i] == obj) {
				this.splice(i, 1);
				return true;
			}
		}
		return false;
	}
}

if (typeof(Array.prototype.splice) == 'undefined')
{
	Array.prototype.splice = function(start, deleteCount) {
		for(var i = start + deleteCount; i < this.length; ++i) {
			this[i - deleteCount] = this[i];
		}
		this.length = this.length - deleteCount;
	}
}

if (typeof(String.prototype.trim) == 'undefined')
{
	String.prototype.trim = function() {
		var rs = new RegExp('^\\s+', '');
		var re = new RegExp('\\s+$', '');
		return this.replace(re, '').replace(rs, '');
	}
}

if (typeof(String.prototype.gsdl_clean) == 'undefined')
{
	String.prototype.gsdl_clean = function() {
		var rs = new RegExp('^\\s+', '');
		var re = new RegExp('\\s+$', '');
		var rd = new RegExp('\\s{2,}', 'g');
		return this.replace(re, '').replace(rs, '').replace(rd, ' ');
	}
}

var OID = {
	oidToSafeIdRegExp: new RegExp('\\.', 'g'),
	safeIdToOIDRegExp: new RegExp('_', 'g'),
	getTop: function(id, sep) {
		if (typeof(sep) == 'undefined' || sep == null) sep = '.';
		var pos = id.indexOf(sep);
		if (pos > 0) 
			return id.substr(0, pos);
		return id;
	},
	getParents: function(id, sep) {
		if (typeof(sep) == 'undefined' || sep == null) sep = '.';
		// the array, start position, end position
		var a = [], sp = 0, ep = 0;
		while ((ep = id.indexOf(sep, sp)) > -1) {
			a.push(id.substring(0, ep));
			sp = ep + 1;
		}
		return a;
	},
	getParent: function(id, sep) {
		if (typeof(sep) == 'undefined' || sep == null) sep = '.';
		var pos = id.lastIndexOf(sep);
		if (pos > -1)
			return id.substr(0, pos);
		return '';
	},
	getLevel: function(id, sep) {
		if (typeof(sep) == 'undefined' || sep == null) sep = '.';
		var l = 1, p = 0;
		while ((p = id.indexOf(sep, p)) > -1) {
			++l;
			++p;
		}
		return l;
	},
	convertToSafeId: function(oid) {
		return oid.replace(OID.oidToSafeIdRegExp, '_');
	},
	convertFromSafeId: function(id) {
		return id.replace(OID.safeIdToOIDRegExp, '.');
	}
};

function changeSection(objSelect) {
	if (!objSelect) return;
	var index = objSelect.selectedIndex;
	var sectionID = objSelect.options[index].value;
	var weaID = "HASH6731e5b341863c8b95d12c";
	if (sectionID.length) sectionID = "." + sectionID;
	if (index > 0)
		gsdl_goto(gsdlURL + cgiarg.l + '/d/' + weaID + sectionID + '/');
}

function gsdlTrimFieldValue(objField) {
	if (objField != null && objField.value != null) {
		objField.value = objField.value.gsdl_clean();
	}
}

function openWindow (address) {
	open(fix_url2(address), '_blank', 'width=600,height=400,menubar=yes,location=yes,status=yes,toolbar=yes,resizable=yes,scrollbars=yes');
}

function openWindow1 (address) {
	open(fix_url2(address), '_blank', 'width=600,height=400,menubar=yes,location=no,status=yes,toolbar=no,resizable=yes,scrollbars=yes');
}

function openWindow2 (address, width, height) {
	if (typeof(width) == 'undefined' || width == null) width = 300;
	if (typeof(height) == 'undefined' || height == null) height = 200;
	open(fix_url2(address), '_blank', 'width='+width+',height='+height+',menubar=no,location=no,status=yes,toolbar=no,resizable=yes,scrollbars=yes');
}

function openWindow3 (address, width, height) {
	if (typeof(width) == 'undefined' || width == null) width = 300;
	if (typeof(height) == 'undefined' || height == null) height = 200;
	open(fix_url2(address), '_blank', 'width='+width+',height='+height+',menubar=yes,location=no,status=yes,toolbar=no,resizable=yes,scrollbars=yes');
}

function openExtLink(address) {
	open(address, '_blank', 'width=600,height=400,menubar=yes,location=yes,status=yes,toolbar=yes,resizable=yes,scrollbars=yes');
}

function openCourseWindow(address, width, height, title) {
	var offset = 25, posX, posY;
	if (screen.availHeight > height) height = screen.availHeight - 2*offset;
	if (screen.availWidth > width) width = screen.availWidth - 2*offset;
	posY = (screen.availHeight - height) / 2;
	posX = (screen.availWidth - width) / 2;
	open(address, '_blank', 'top='+posY+',left='+posX+',width='+width+',height='+height+',menubar=no,location=no,status=no,toolbar=no,resizable=yes,scrollbars=yes');
}

function openFixedWindow (address, width, height) {
	var posX, posY, nHeight, nWidth, offset = 10;
	nHeight = (screen.availHeight > height ? height :  screen.availHeight - 2*offset);
	nWidth = (screen.availWidth > width ? width : screen.availWidth - 2*offset);
	posY = (screen.availHeight - nHeight) / 2;
	posX = (screen.availWidth - nWidth) / 2;
	open(address, '_blank', 'top='+posY+',left='+posX+',width='+width+',height='+height+',menubar=no,location=no,status=no,toolbar=no,resizable=yes,scrollbars=no');
}

function resizeFixedWindow (width, height) {
	var posX, posY, nHeight, nWidth, offset = 10;
	nHeight = (screen.availHeight > height ? height :  screen.availHeight - 2*offset);
	nWidth = (screen.availWidth > width ? width : screen.availWidth - 2*offset);
	posY = (screen.availHeight - nHeight) / 2;
	posX = (screen.availWidth - nWidth) / 2;
	moveTo (posX, posY); resizeTo (nWidth, nHeight);
}

function openModalWindow (address, width, height) {
	if (isGecko) {
		window.open(address, '', 'chrome,modal');
	} else {
		var ret = window.showModalDialog(address, '', 'dialogWidth:'+width+'px;dialogHeight:'+height+'px;center:1;status:0;help:0');
		if (ret != null && typeof(ret) != 'undefined' && ret != "") {
			var idx = ret.indexOf(":");
			if (idx > -1) {
				var strAction = ret.substr(0, idx);
				if (strAction == "reload") {
					window.location.reload(true);
				} else if (strAction == "add") {
					var strURL = gsdlLocationAddParam(window.location, ret.substr(idx+1));
					window.setTimeout("window.location = '" + strURL + "'", 400);
				} else if (strAction == "new") {
					openWindow(ret.substr(idx+1));
				} else if (strAction == "addnew") {
					openWindow(window.location.href + ret.substr(idx+1));
				} else if (strAction == "go") {
					window.setTimeout("window.location = '" + ret.substr(idx+1) + "'", 400);
				} else {
					window.setTimeout("window.location = '" + ret + "'", 400);
				}
			}
		}
	}
}

function openPrintPreviewWindow(address, width, height) {
	if (typeof(width) == 'undefined' || width == null) width = 300;
	if (typeof(height) == 'undefined' || height == null) height = 200;
	if (IE4plus && !IE4) {
		var ampReg = new RegExp('&', 'g');
		address = address.replace(ampReg, "&" + "amp" + ";");
	} else {
		var ampReg = new RegExp('&amp;', 'g');
		address = address.replace(ampReg, "&");
	}
	open(address, '_blank', 'width='+width+',height='+height+',menubar=yes,location=no,status=yes,toolbar=yes,resizable=yes,scrollbars=yes');
}

function openExportWindow(format, encoding, width, height) {
	if (typeof(format) == 'undefined' || format == null) format = 'zip';
	if (typeof(encoding) == 'undefined' || encoding == null) encoding = 'utf-8';
	if (typeof(width) == 'undefined' || width == null) width = 400;
	if (typeof(height) == 'undefined' || height == null) height = 200;
	var strURL = gsdlURL + cgiarg.l + '/p/exportmsg/d,' + cgiarg.d + '.html';
	strURL += '?xf=' + format + '&amp;ew=' + encoding;
	openWindow2(fix_url(strURL), width, height);
}

function openExportHelpWindow() {
	var strURL = gsdlURL + cgiarg.l + '/p/ExportContextHelp/';
	openWindow2(strURL, 480,400);
}

function openAbbreviations(oid) {
	var strURL = gsdlURL + cgiarg.l + '/p/abbr/d,' + oid + '.html';
	openWindow2(strURL, 480, 400);
}

//
// Browser Detection
//
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1)&&(isMac)) ? true : false;
IE4plus = ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1)) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
IE55 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.5")!=-1)) ? true : false;
IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
IE7 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1)) ? true : false;
IE8 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 8.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;
isGecko = (navigator.userAgent.indexOf(' Gecko/')!=-1)?true:false;
IE5plus = IE5 || IE6 || IE7 || IE8;
IE55plus = IE55 || IE6 || IE7 || IE8;
IEMajor = 0;

if (IE4plus)
{
	var start = navigator.appVersion.indexOf("MSIE");
	var end = navigator.appVersion.indexOf(".",start);
	IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
	IE5plus = (IEMajor>=5) ? true : false;
	IE55plus = (IE55 || ((IEMajor>5) ? true : false));
}

function gsdl_encode(parString) {
	if (NS4 || NS6) {
		return escape(parString);
	}
	var str = '';
	for(var i = 0; i < parString.length; ++i) {
		if(parString.charCodeAt(i) < 0x80) {
			str += String.fromCharCode(parString.charCodeAt(i));
		}
		else if (parString.charCodeAt(i) < 0x0800) {
			str += String.fromCharCode(parString.charCodeAt(i)>> 6 | 0xC0);
			str += String.fromCharCode(parString.charCodeAt(i) & 0x3F | 0x80);
		}
		else if (parString.charCodeAt(i) < 0x10000) {
			str += String.fromCharCode(parString.charCodeAt(i)>> 12 | 0xE0);
			str += String.fromCharCode(parString.charCodeAt(i)>> 6 & 0x3F | 0x80);
			str += String.fromCharCode(parString.charCodeAt(i) & 0x3F | 0x80);
		}
		else {
			str += String.fromCharCode(parString.charCodeAt(i)>> 18 | 0xF0);
			str += String.fromCharCode(parString.charCodeAt(i)>> 12 & 0x3F | 0x80);
			str += String.fromCharCode(parString.charCodeAt(i)>> 6 & 0x3F | 0x80);
			str += String.fromCharCode(parString.charCodeAt(i) & 0x3F | 0x80);
		}
	}
	return escape(str);
}

function gsdlLocationAddParam(locationObj, strParams) {
	fix_location_hash(locationObj);
	var strArgs = locationObj.search.substr(1);

	var strNewURL = locationObj.protocol + "//" + locationObj.host;
	strNewURL += locationObj.pathname;
	if (strArgs.length) strArgs += '&';
	strArgs += strParams;

	strNewURL += "?" + strArgs;
	if (locationObj.hash.length) strNewURL += locationObj.hash;
	
 
	if (IE5plus) {
		var ampReg = new RegExp('&', 'g');
		strNewURL = strNewURL.replace(ampReg, "&" + "amp" + ";");
	}
	return strNewURL;
}

function gsdl_goto(strURL) {
	var ampReg = new RegExp('&' + 'amp' + ';', 'g');
	strURL = strURL.replace(ampReg, "&");
	if (IE5plus) {
		var ampReg2 = new RegExp('&', 'g');
		strURL = strURL.replace(ampReg2, "&" + "amp" + ";");
	}
	window.location = strURL;
	return false;
}

function gsdl_goto_ex(obj, strURL) {
	var ampReg = new RegExp('&' + 'amp' + ';', 'g');
	strURL = strURL.replace(ampReg, "&");
	if (IE5plus) {
		var ampReg2 = new RegExp('&', 'g');
		strURL = strURL.replace(ampReg2, "&" + "amp" + ";");
	}
	obj.href = strURL;
	return false;
}

function fix_url(strURL) {
	var ampReg = new RegExp('&' + 'amp' + ';', 'g');
	strURL = strURL.replace(ampReg, "&");
	if (IE5plus) {
		var ampReg2 = new RegExp('&', 'g');
		strURL = strURL.replace(ampReg2, "&" + "amp" + ";");
	}
	return strURL;
}

function fix_url2(strURL) {
	var ampReg = new RegExp('&' + 'amp' + ';', 'g');
	strURL = strURL.replace(ampReg, "&");
	return strURL;
}

function fix_location_hash (oLocationObj) {
	if (IE4 && oLocationObj.search != null) {
		var re = new RegExp ('#.*');
		var arrMatch = oLocationObj.search.match(re);

		if (arrMatch != null && arrMatch.length) {
			oLocationObj.hash = arrMatch[0];
			oLocationObj.search = oLocationObj.search.replace(re, "");
		}
	}
}

var gLocationObj = null;
function clearForm2() { clearForm1(); }
function clearForm1() {
	var date = new Date();
	var queryForm;
	if (cgiarg.a == 'q' || cgiarg.a == 'qcomp') {
		queryForm = gsdlGetElement('QueryPostForm');
		updatefqf();
		g_gsdlPreferenceState.SetFormArgs(queryForm);
		gsdlInitValue(queryForm.comp, gsdlGetCookieInt('comp', 0));
		gsdlInitValue(queryForm.uq, '' + date.getTime());
		gsdlInitValue(queryForm.qu, '' + gsdlNewQueryUniqueId());
		gsdlInitValue(queryForm.r, '1');
		gsdlInitValue(queryForm.qe, '0');
		gsdlInitValue(queryForm.q, '');
		gsdlInitValue(queryForm.fqv, '');
		gsdlInitValue(queryForm.fqf, unescape(argfqf));

		queryForm.submit();
		return false;
	}
	if ((queryForm = gsdlGetElement('QueryForm')) != null) {
		if (typeof(queryForm.fqv) != 'undefined' && queryForm.fqv != null)
			gsdlInitValue(queryForm.fqv, '');
		if (typeof(queryForm.kw) != 'undefined' && queryForm.kw != null)
			gsdlInitValue(queryForm.kw, '');
	}

	if (!gsdlGetCookieBool('qe', false))
		return false;
	gsdlSetCookie('qe', '0');
	updateClearLink();
	clearHighlight();

	var strURL = gsdlURL + cgiarg.l + '/q/';
	var strVars = 'qcount=1&q=&fqv=&fqu=&fqf=&fqc=&fqk=&fqs=&r=1&qe=0&qu=' + gsdlNewQueryUniqueId() + '&uq=' + date.getTime();
	var request = null;
	if (!IE4 && !NS4) request = gsdlGetHttpRequest();
	if (request == null) {
		gsdlGetElement('dataFrame').src = strURL + '?' + strVars;
	} else {
		request.open('POST', strURL, false);
		request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		request.send(strVars);
	}
	return false;
}

function gsdlDefined(field) {
	return typeof(field) != 'undefined' && field != null;
}

function gsdlInitValue(field, value) {
	if (field.type == 'select-one') {
		var i;
		for (i = 0; i < field.options.length; ++i) {
			if (value == field.options[i].value) {
				field.options[i].selected = true;
				break;
			}
		}
	} else if (field.type == 'select-multiple') {
		var i, j;
		var values = value.split('||');
		for (i = 0; i < field.options.length; ++i) {
			value = field.options[i].value;
			for(j = 0; j < values.length; ++j) {
				if (values[j] == value) {
					field.options[i].selected = true;
					break;
				}
			}
		}
	} else if (field.type == 'checkbox' || field.type == 'radio') {
		field.checked = (value == '1' ? true : false);
	} else { // 'text', 'textarea', 'password', 'hidden'
		field.value = value;
	}
}

function gsdlInitRadioValue(field, value) {
	for(var i = 0; i < field.length; ++i) {
		field[i].checked = (field[i].value == value);
	}
}

function gsdlInitSelectText(field, value) {
	if (field.type == 'select-one') {
		var i;
		for (i=0; i < field.options.length; ++i) {
			if (value == field.options[i].text) {
				field.options[i].selected = true;
				break;
			}
		}
	} else { // "text", "textarea", "password", "hidden"
		field.value = value;
	}
}

function gsdlInitIndexed(field, value) {
	if (field.type == 'select-one') {
		var i, arr;
		for (i=0; i < field.options.length; ++i) {
			arr = field.options[i].value.split(';');
			if (value == arr[0]) {
				field.options[i].selected = true;
				break;
			}
		}
	} else{
		alert('Indexed field must be a select box not ' + field.type);
	}
}

function gsdlGetValue(field) {
	if (field.type == 'select-one') {
		return field.options[field.selectedIndex].value;
	} else if (field.type == 'select-multiple') {
		var i;
		var value = '';
		var tmpv;
		for(i = 0; i < field.options.length; ++i) {
			if (field.options[i].selected) {
				tmpv = field.options[i].value;
				if ((tmpv.length == 0) || (tmpv.length > 1 && tmpv.substr(0, 1) == '!'))
					continue;
				if (value.length > 0)
					value += '||';
				value += field.options[i].value;
			}
		}
		return value;
	} else if (field.type == 'checkbox' || field.type == 'radio'){
		return field.checked ? '1' : '0';
	} else {
		return field.value;
	}
}

function gsdlGetSelectText(field) {
	if (field.type == 'select-one') {
		return field.options[field.selectedIndex].text;
	}
	return '';
}

function gsdlGetRadioValue(radioButtons) {
	for (var i=0; i < radioButtons.length; ++i) {
		if (radioButtons[i].checked)
			return radioButtons[i].value;
	}
	return '';
}

function gsdlSetRadioValue(radioButtons, value) {
	if (document.QueryForm.radio[0].checked || document.QueryForm.radio[1].checked) {
		for (var i=0; i < radioButtons.length; ++i) {
			if (radioButtons[i].value == value) {
				radioButtons[i].checked = true;
				break;
			}
		}
	} else {
		radioButtons[1].checked = true;
	}
}

function close_detach() {
	close();
}

var loadedbtn = new Array();
function gbutton(img, onimage) {
	if (img && img.src && (img.out == null || typeof(img.out) == typeof(void(0)))) {
		var s = img.src;
		img.out = new Image();
		img.out.src = s;
		img.over = new Image();
		img.over.src = onimage;
		loadedbtn[img.name] = img;
	}
}

function roll(imagename, over) {
	if (document.images) {
		var img = loadedbtn[imagename];
		if (typeof(img) != 'undefined' && img != null) {
			if (over) img.src = img.over.src;
			else img.src = img.out.src;
		}
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i = 0; i < changeImages.arguments.length; i += 2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		preloadFlag = true;
	}
}

function display_prefs() {
	var win;
	var wndWidth = 375;
	var wndHeight = 80;
	var wndX = (screen.width-wndWidth)/2;
	var wndY = (screen.height-wndHeight)/2;
	var strFeatures = 'location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,width='+wndWidth+',height='+wndHeight+',resizable=yes';
	if (NS4 || NS6) strFeatures += ',screenX='+parseInt(wndX)+',screenY='+parseInt(wndY);
	else if (IE4plus) strFeatures += ',left='+parseInt(wndX)+',top='+parseInt(wndY);

	var strURL = gsdlURL + cgiarg.l + '/p/subjectprefs/';
	win = open(fix_url(strURL), Math.round(Math.random()*10000), strFeatures);
}

function display_docprefs() {
	var win;
	var wndWidth = 620;
	var wndHeight = 50;
	var wndX = (screen.width-wndWidth)/2;
	var wndY = (screen.height-wndHeight)/2;
	var strFeatures = 'location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,width='+wndWidth+',height='+wndHeight+',resizable=yes';
	if (NS4 || NS6) strFeatures += ',screenX='+parseInt(wndX)+',screenY='+parseInt(wndY);
	else if (IE4plus) strFeatures += ',left='+parseInt(wndX)+',top='+parseInt(wndY);

	var strURL = gsdlURL + cgiarg.l + '/p/documentprefs/';
	if (cgiarg.accomp) strURL += 'accomp,' + cgiarg.accomp + ',x,1.html';
	win = open(fix_url(strURL), Math.round(Math.random()*10000), strFeatures);
}

function array_remove_at(arrObject, nIndex, nLength) {
	if (arrObject.splice != null) {
		arrObject.splice(nIndex, nLength);
	} else {
		var carray = new Array();
		if (nIndex == 0) {
			if (nIndex+nLength > arrObject.length) {
			} else {
				carray = arrObject.slice(nLength);
			}
		} else {
			if (nIndex+nLength > arrObject.length) {
				carray = new Array().concat(arrObject.slice(0,nIndex));
			} else {
				carray = new Array().concat(arrObject.slice(0,nIndex), arrObject.slice(nIndex+nLength));
			}
		}
		arrObject.length = 0;
		for(var i=0; i < carray.length; ++i) {
			arrObject[i] = carray[i];
		}
	}
}

function gsdlGetElement(strName, doc) {
	if (typeof(doc) == 'undefined' || doc == null)
		doc = document;
	var elem = null;
	if (doc.getElementById) {
		elem = doc.getElementById(strName);
	} else if (doc.all) {
		elem = doc.all[strName];
	} else {
		eval('elem = doc.' + strName);
	}
	return elem;
}

function gsdlGetArrayElement(strName, max) {
	var elem, a = new Array();
	if (typeof(max) == 'undefined' || max == null)
		max = 1000;
	for (var i = 1; i < max; ++i) {
		elem = gsdlGetElement(strName + i);
		if (elem == null)
			break;
		a.push(elem);
	}
	return a;
}

function getElementsByClassName(oElm, strTagName, strClassName) {
	var arrElements = null;
	if (strTagName == "*" && oElm.all)
		arrElements = oElm.all;
	else if (typeof(oElm.getElementsByTagName) == 'undefined')
		arrElements = oElm.all.tags(strTagName);
	else
		arrElements = oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i = 0; i < arrElements.length; ++i) {
		oElement = arrElements[i];
		if (oRegExp.test(oElement.className)) {
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function ChangeImageSource(strId, strSRC) {
	var objImage = GetImageObject(strId);
	if (objImage != null)
		objImage.src = strSRC;
}

function GetImageObject(strId) {
	var objImage = null;
	if (document.getElementById) {
		objImage = document.getElementById(strId);
	} else if (document.all) {
		objImage = document.all.item(strId);
	} else {
		objImage = document.images[strId];
		if (!objImage) objImage = eval('document.' + strId );
	}
	return objImage;
}

function GetObject(strId) {
	var objLayer = null;

	if (document.getElementById) {
		objLayer = document.getElementById(strId);
	} else if (document.all) {
		objLayer = document.all.item(strId);
	} else {
		objLayer = eval('document.' + strId );
	}
	return objLayer;
}

/* MoveObjectTo():
	moves the objLayer object to (nLeft,nTop) absolute coordinates ...
 */
function MoveObjectTo(objLayer, nLeft, nTop) {
	if (document.getElementById || document.all) {
		objLayer.style.left = nLeft + 'px';
		objLayer.style.top = nTop + 'px';
	} else {
		objLayer.left = nLeft;
		objLayer.top = nTop;
	}
}

/* GetObjectInfo():
	returns an array containing : 0-left, 1-top, 2-width, 3-height ...
 */
function GetObjectInfo(objLayer) {
	var arrInfo = new Array();
	var TempTop, TempHeight;
	if (document.getElementById || document.all) {
		arrInfo[0] = objLayer.offsetLeft;
		TempTop = objLayer.offsetTop;
		TempHeight = objLayer.offsetHeight;
		arrInfo[1] = TempTop + TempHeight;
		arrInfo[2] = objLayer.offsetWidth;
		arrInfo[3] = objLayer.offsetHeight;
	} else {
		arrInfo[0] = objLayer.pageX;
		arrInfo[1] = objLayer.pageY + 14;
	}
	return arrInfo;
}

function ShowObject(objLayer, bShow) {
	if (! objLayer) return false;
	var bVisible, bOldVisible;

	// get current state ...
	if (document.getElementById || document.all)
		bOldVisible = (objLayer.style.visibility == 'visible');
	else
		bOldVisible = (objLayer.visibility == 'show');

	// see if the object should be visible or hidden ...
	if (typeof(bShow) == 'undefined' || bShow == null) {
		bVisible = ! bOldVisible;
	} else {
		bVisible = bShow;
	}

	// set new state ...
	if (document.getElementById || document.all)
		objLayer.style.visibility = (bVisible ? 'visible' : 'hidden');
	else
		objLayer.visibility = (bVisible ? 'show' : 'hide');
	return bOldVisible;
}

var nHideCountryAssociationsTimer = 0;
function DisplayCountryAssociations(nId) {
	cancelEvent();
	if (nHideCountryAssociationsTimer != 0)
		window.clearTimeout(nHideCountryAssociationsTimer);
	var objSpan, objLayer;
	var arrInfo = new Array();
	var isvisible = false;
	
	objSpan = GetObject('x' + nId);
	objLayer = GetObject('ca_' + nId);

	if (objSpan && objLayer) {
		arrInfo = GetObjectInfo(objSpan);
		MoveObjectTo(objLayer, arrInfo[0], arrInfo[1]);
		isvisible = !ShowObject(objLayer);
		if (isvisible) {
			g_aRegisteredLayerHide.Hide();
		}
	} else {
		alert ('Unknown object ' + nId + ' !');
	}
	if (isvisible) {
		g_aRegisteredLayerHide.Register(DisplayCountryAssociations, nId);
	} else {
		g_aRegisteredLayerHide.UnRegister(DisplayCountryAssociations, nId);
	}
}

function StartHideCountryAssociations(nId) {
	if (nHideCountryAssociationsTimer != 0)
		window.clearTimeout(nHideCountryAssociationsTimer);
	nHideCountryAssociationsTimer = window.setTimeout("HideCountryAssociations('" + nId + "')", 1000);
}

function HideCountryAssociations(nId) {
	if (nHideCountryAssociationsTimer != 0)
		window.clearTimeout(nHideCountryAssociationsTimer);
	nHideCountryAssociationsTimer = 0;
	g_aRegisteredLayerHide.Hide();
}

function CancelHideCountryAssociations(nId) {
	if (nHideCountryAssociationsTimer != 0)
		window.clearTimeout(nHideCountryAssociationsTimer);
}

function RegisteredLayersHide() {
	this.functions = new Array();
	this.parameters = new Array();
	this.Register = RegisteredLayersHide_Register;
	this.UnRegister = RegisteredLayersHide_UnRegister;
	this.Hide = RegisteredLayersHide_Hide;
}

function RegisteredLayersHide_Register(func, param) {
	this.functions.push(func);
	this.parameters.push(param);
}

function RegisteredLayersHide_UnRegister(func, param) {
	for(var i = 0; i < this.functions.length; ++i) {
		if (this.functions[i] == func && this.parameters[i] == param) {
			this.functions.splice(i, 1);
			this.parameters.splice(i, 1);
			break;
		}
	}
}

function RegisteredLayersHide_Hide() {
	while (this.functions.length) {
		this.functions[0](this.parameters[0]);
	}
}

var g_aRegisteredLayerHide = new RegisteredLayersHide();

function __coverErrorInit__() {
	var strImg = httpCollectionImage + '/blankcover\\.gif';
	var re = new RegExp('\\/', 'g');
	strImg = strImg.replace(re,'\\/');
	g_imgRegExp = new RegExp(strImg + '$', 'i');
}

var g_imgRegExp = 0;
function CoverError() {
	if (g_imgRegExp != 0 && this.src.search(g_imgRegExp) < 0)
		this.src = httpCollectionImage + '/blankcover.gif';
}

function onDocumentLoad() {
	var book = gsdlGetElement('gsdlbookcover');
	if (book != null) book.onError= CoverError;
	if (cgiarg.a == 'cl') {
		gsdlSetCookie('cl', cgiarg.cl);
	} else if(cgiarg.a == 'd') {
		if (cgiarg.accomp) {
			OnTreePageLoad();
		} else {
			gDocumentTOC = DocumentTree.create('docToc', true, true);
			var topDocumentId = OID.getTop(cgiarg.d.substr(1));
			var obj = gsdlGetElement('l' + topDocumentId);
			if (obj != null) {
				obj.onclick = function(e) {
					closeDocument();
					return cancelEvent(e);
				}
			}
			obj = gsdlGetElement('i' + topDocumentId);
			if (obj != null) {
				obj.onclick = function(e) {
					closeDocument();
					return cancelEvent(e);
				}
			}
			updateButtons();
			if (IE55plus) {
				var obj = gsdlGetElement('courseBuilderAddBtn');
				if (obj != null)
					obj.style.display = '';
			}
		}
		if (gsdlGetCookieBool('qe', false)/* && gsdlGetCookieBool('hl', false)*/) {
			loadHighlightData();
		}
	}
}

function closeDocument() {
	var strCL = gsdlGetCookie('cl', '');
	if (strCL.length == 0) {
		gsdl_goto(gsdlURL + cgiarg.l + '/');
	} else if (strCL == 'search') {
		gsdl_goto(gsdlURL + cgiarg.l + '/q/');
	} else {
		gsdl_goto(gsdlURL + cgiarg.l + '/cl/' + strCL + '/');
	}

}

function expand_warning(strOID) {
	if (strOID == null) strOID = cgiarg.d;
	if (confirm(texts.expand_warning)) {
		var strUrl = gsdlCGI + '/' + cgiarg.l + '/d/';
		var pos;
		if ((pos = strOID.indexOf('.')) > -1) {
			strUrl += strOID.substr(0, pos) + '/' + strOID.substr(pos + 1) + ',';
		} else {
			strUrl += strOID + '/';
		}
		strUrl += 'gt,2';
		if (cgiarg.accomp) strUrl += ',accomp,' + cgiarg.accomp + ',x,1';
		gsdl_goto_ex(location, strUrl + '.html');
	}
}

function PositionBox(nId) {
	var objSpan, objLayer;
	var arrInfo = new Array();
	var arrInfoLayer =  new Array();
	var isvisible = false;

	objSpan = GetObject(nId + 'Bookmark');
	objLayer = GetObject(nId + 'Box');

	if (objSpan && objLayer) {
		arrInfo = GetObjectInfo(objSpan);
		arrInfoLayer = GetObjectInfo(objLayer);
		if (IE4 || IE5)
			MoveObjectTo(objLayer, arrInfo[0] + 100, arrInfo[1] + 5);
		else
			MoveObjectTo(objLayer, arrInfo[0] - arrInfoLayer[2]/2, arrInfo[1] - 25);
		isvisible = !ShowObject(objLayer);
		if (isvisible) {
			g_aRegisteredLayerHide.Hide();
		}
	} else {
		alert ('Unknown object ' + nId + ' !');
	}
	if (IE55plus) {
		var modalFrame = GetObject('overLayer');
		modalFrame.style.top = objLayer.style.top;
		modalFrame.style.left = objLayer.style.left;
		modalFrame.style.width = arrInfoLayer[2];
		modalFrame.style.height = arrInfoLayer[3];
		modalFrame.style.zIndex = objLayer.style.zIndex + 1;
		modalFrame.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
		modalFrame.style.display = isvisible ? 'block' : 'none';
	}
	if (nId == 'description' && !IE55plus && IE4plus) {
		var problematicSelect = GetObject('orgselect');
		problematicSelect.style.display = isvisible ? 'none' : 'block';
	}
	if (isvisible) {
		g_aRegisteredLayerHide.Register(PositionBox, nId);
	}else {
		g_aRegisteredLayerHide.UnRegister(PositionBox, nId);
	}
}

function HideDescriptionBox(nId) {
	g_aRegisteredLayerHide.Hide();
}

function eventTrigger (e) {
	if (! e)
		e = event;
	return e.target || e.srcElement;
}

function checkClick(evt) {
	var obj = eventTrigger (evt);
	var meshvisible = gsdlGetElement('ca_mesh');
	if (meshvisible != null && meshvisible != 'undefined')
	{
		meshvisible = gsdlGetElement('ca_mesh').style.visibility;
		if (obj.id != "ca_mesh" && obj.id != "meshLink")
			HideDescriptionBox('ca_mesh');
	}
}

var nHideCountryAssociationsTimer = 0;
function DisplayBlock(nId) {
	if (nHideCountryAssociationsTimer != 0)
		window.clearTimeout(nHideCountryAssociationsTimer);
	var objSpan, objLayer;
	var arrInfo = new Array();
	var isvisible = false;
	
	objSpan = GetObject(nId);
	objLayer = GetObject('ca_' + nId);

	if (objSpan && objLayer) {
		arrInfo = GetObjectInfo(objSpan);
		MoveObjectTo(objLayer, arrInfo[0] - 220, arrInfo[1] + 13);
		isvisible = !ShowObject(objLayer);
		if (isvisible) {
			g_aRegisteredLayerHide.Hide();
		}
	} else {
		alert ('Unknown object ' + nId + ' !');
	}
	if (isvisible) {
		g_aRegisteredLayerHide.Register(DisplayBlock, nId);
	} else {
		g_aRegisteredLayerHide.UnRegister(DisplayBlock, nId);
	}
}

function updateClearLink() {
	var clearFormLink = gsdlGetElement('clearFormLink');
	if (clearFormLink == null) return;
	var bHasQuery = gsdlGetCookieBool('qe', false);
	clearFormLink.className = 'clearmeniu' + (bHasQuery ? 'active' : 'inactive');
	//clearFormLink.disabled = !bHasQuery;
	if (bHasQuery)
		clearFormLink.href = 'javascript:clearForm2();';
	else
		clearFormLink.href = 'javascript:void(0);';
}

function clearHighlight() {
	if (cgiarg.a != 'd') return;
	var documentContent = gsdlGetElement('documentContent');
	if (documentContent == null) return;
	var elements = getElementsByClassName(documentContent, 'span', 'hl');
	if (elements == null && elements.length == 0) return;
	for(var i = 0; i < elements.length; ++i) {
		elements[i].className = 'hlnone';
	}
}

function gsdlGetHttpRequest() {return null;}
function globalPageInit() {
	if (gsdlCGI.length > 0 && gsdlCGI.substr(0, 1) != '/')
		gsdlCGI = '/' + gsdlCGI;
	gsdlURL = gsdlCGI + '/';
	if (!IE4 && !NS4)
		eval('gsdlGetHttpRequest = function() {var obj = null;if (window.XMLHttpRequest) {obj = new XMLHttpRequest();if (obj.overrideMimeType)obj.overrideMimeType("text/xml");} else if (window.ActiveXObject) {try {obj = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {obj = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}}}return obj;}');
	//alert("gsdlURL=" + gsdlURL + "\ngsdlCGI=" + gsdlCGI);
	cgiarg.comp = gsdlGetCookieInt('comp', 0);
	updateClearLink();
	__coverErrorInit__();
	if (IE55plus) {
		var navCourseBuiderBtn = gsdlGetElement('navCourseBuiderBtn');
		if (navCourseBuiderBtn != null)
			navCourseBuiderBtn.style.display = 'inline';
	}
	if (typeof(g_gsdlPreferenceState) != 'undefined' && g_gsdlPreferenceState != null)
		g_gsdlPreferenceState.Initialize();
	if (cgiarg.a == 'p') {
		if (cgiarg.p == 'about') {
			gsdlSetCookie('cl', '');
			onLoadPageAbout();
		} else if (cgiarg.p == 'documentprefs') {
			if (cgiarg.accomp) {
				if (gsdlGetCookie('ctrycs', 'c') == 'c')
					document.GeneralForm.ctrycs[1].checked = true;
				else
					document.GeneralForm.ctrycs[0].checked = true;
			} else {
				if (gsdlGetCookieBool('gca', false))
					document.GeneralForm.gca[0].checked = true;
				else
					document.GeneralForm.gca[1].checked = true;
			}
		}
	} else if (cgiarg.a == 'cl' || cgiarg.a == 'd' || cgiarg.a == 'm') {
		onDocumentLoad();
	} else if (cgiarg.a == 'q' || cgiarg.a == 'qcomp') {
		gsdlSetCookie('cl', 'search');
		query_initialize();
	}
	if (!gsdlGetCookieBool('sd', true) && gsdlGetElement('pagedescription') != null) {
		showDescription();
	}
	if (gsdlOnPageOnLoad != null) gsdlOnPageOnLoad();
	gsdlBindPageEvents();
}

function gsdlBindPageEvents() {
	document.onclick = checkClick;
	var obj = gsdlGetElement('descriptionLink');
	if (obj != null) obj.onclick = function(e) { DisplayCountryAssociations('description'); return cancelEvent(e); }
	obj = gsdlGetElement('meshLink');
	if (obj != null) {
		if (cgiarg.a == 'd' || cgiarg.a == 'm')
			obj.onclick = function(e) { DisplayCountryAssociations('mesh'); return cancelEvent(e); }
		else
			obj.onclick = function(e) { DisplayBlock('mesh'); return cancelEvent(e); }
	}
}

function getPageCLMD() {
	var pageCLMD = gsdlDefaults.args.clmd;
	var r = /\/clmd,([0-9]+)/;
	var a = r.exec(window.location.href);
	if (a != null && a.length > 1) {
		pageCLMD = parseInt(a[1], 10);
	}
	return pageCLMD;
}

function getLocalizedImagesURL() {
	if (cgiarg.l == 'en')
		return httpCollectionImage;
	return httpCollectionImage + '/' + cgiarg.l;
}

function gsdlGetQueryUniqueId() {
	return gsdlGetCookieInt('qu', 0);
}

function gsdlNewQueryUniqueId() {
	var queryUniqueId = 1 + gsdlGetCookieInt('qu', 0);
	if (queryUniqueId == 2147483646) queryUniqueId = 1;
	gsdlSetCookie('qu', queryUniqueId);
	return queryUniqueId;
}

var g_hCookies = {
	'init': false
};

function gsdlGetCookie(name, defaultValue) {
	if (!g_hCookies.init)
		gsdlParseCookies();
	var value = g_hCookies['__' + name];
	if (typeof(value) == 'undefined') {
		if (typeof(defaultValue) == 'undefined' || defaultValue == null)
			return null;
		return '' + defaultValue;
	} else {
		return value;
	}
}

function gsdlGetCookieInt(name, defaultValue) {
	if (!g_hCookies.init)
		gsdlParseCookies();
	var value = g_hCookies['__' + name];
	if (typeof(value) == 'undefined') {
		if (typeof(defaultValue) == 'undefined' || defaultValue == null)
			return null;
		if (typeof(defaultValue) == 'number')
			return defaultValue;
		if (typeof(defaultValue) == 'boolean')
			return defaultValue ? 1 : 0;
		return parseInt('' + defaultValue, 10);
	} else {
		return parseInt(value, 10);
	}
}

function gsdlGetCookieBool(name, defaultValue) {
	if (!g_hCookies.init)
		gsdlParseCookies();
	var value = g_hCookies['__' + name];
	if (typeof(value) == 'undefined') {
		if (typeof(defaultValue) == 'undefined' || defaultValue == null)
			return null;
		if (typeof(defaultValue) == 'number')
			return defaultValue != 0;
		if (typeof(defaultValue) == 'boolean')
			return defaultValue;
		defaultValue = '' + defaultValue;
		return (defaultValue == 'yes' || defaultValue == '1' || defaultValue == 'true');
	} else {
		return (value == 'yes' || value == '1' || value == 'true');
	}
}

function gsdlSetCookie(name, value) {
	if (!g_hCookies.init)
		gsdlParseCookies();
	if (value == null) {
		g_hCookies['__' + name] = value;
	} else {
		if (typeof(value) == 'boolean')
			value = value ? '1' : '0';
		else
			value = '' + value;
		g_hCookies['__' + name] = value;
	}
	gsdlBuildCookies();
}

//GSDL-ARGS=bo|0/pr|6/sid|XQAWEJ3I2130706433X00000664X4804A896
function gsdlParseCookies() {
	g_hCookies.init = true;
	if (document.cookie == null || document.cookie.length == 0)
		return;
	var i, aCookies, gsdlArgs = null, name, value, nPos;
	aCookies = document.cookie.split(';');
	for(i = 0; i < aCookies.length; ++i) {
		aCookies[i] = aCookies[i].trim();
		if (aCookies[i].indexOf('GSDL-ARGS=') == 0) {
			gsdlArgs = aCookies[i].substr(10).trim();
			break;
		}
	}
	if (gsdlArgs == null || gsdlArgs.length == 0)
		return;
	aCookies = gsdlArgs.split('/');
	for(i = 0; i < aCookies.length; ++i) {
		aCookies[i] = aCookies[i].trim();
		nPos = aCookies[i].indexOf('|');
		if (nPos > -1) {
			name  = unescape(aCookies[i].substr(0, nPos)).trim();
			value = unescape(aCookies[i].substr(nPos + 1)).trim();
			g_hCookies['__' + name] = value;
		}
	}
}

function gsdlBuildCookies() {
	if (!g_hCookies.init)
		return;
	var i, aCookies, gsdlArgs = '', strArg, strCookie = '', value;
	for (strArg in g_hCookies) {
		if (strArg.length > 2 && strArg.substr(0, 2) == '__') {
			value = g_hCookies[strArg];
			if (value != null && value.length > 0) {
				if (gsdlArgs.length > 0) gsdlArgs += '/';
				gsdlArgs += escape(strArg.substr(2)) + '|' + escape(value);
			}
		}
	}
	if (gsdlArgs.length > 0) {
		strCookie += 'GSDL-ARGS=' + gsdlArgs;
	}
	document.cookie = strCookie + ';path=' + escape(gsdlCGI) + ';expires=Fri, 31 Dec 2099 23:59:59 GMT;';
}

function gsdlUpdateLinksForCLMD(value) {
	if (typeof(value) == 'undefined' || value == null)
		value = gsdlGetCookieInt('clmd', gsdlDefaults.args.clmd);
	var re = new RegExp('x');
	re.compile('\\/clmd,[0-9]+(,clr,[0-9]+)?(,cldc,[0-9]+)?');
	var np = '/clmd,' + value;
	for (var i = 0; i < document.links.length; ++i) {
		document.links[i].href = document.links[i].href.replace(re, np);
	}
}

function showDescription() {
	var obj = gsdlGetElement('pagedescription');
	if (typeof(obj) == 'undefined' || obj == null)
		return;
	var bVisible;
	if (typeof(obj.style.display) != 'undefined' && obj.style.display == 'none')
		bVisible = true;
	else
		bVisible = false;
	obj.style.display = (bVisible ? '' : 'none');

	var iobj = gsdlGetElement('sdShowPageBtn');
	if (typeof(iobj) != 'undefined' && iobj != null)
	{
		iobj.src = httpCollectionImage + '/' + (bVisible ? 'sdclose.gif' : 'sdshow.gif');
		if (IE4) {
			gsdlGetElement('sdShowPageLink').innerHTML = '<img src="' + httpCollectionImage +  '/' + (bVisible ? 'sdclose.gif' : 'sdshow.gif') + '" alt="' + (bVisible ? texts.iconpagedescopen : texts.iconpagedescclosed) + '" title="' + (bVisible ? texts.iconpagedescopen : texts.iconpagedescclosed) + '" border="0" align="middle" id="sdShowPageBtn">';
		} else {
			iobj.title = bVisible ? texts.iconpagedescopen : texts.iconpagedescclosed;
			iobj.alt = bVisible ? texts.iconpagedescopen : texts.iconpagedescclosed;
		}
	}
	gsdlPrefUpdateArg('sd' , bVisible ? 1 : 0 );
}

function cancelEvent(e) {
	if(!e) e = window.event;
	if(!e) e = window.Event;
	if(e) {
		if (typeof(e.cancelBubble) != 'undefined')
			e.cancelBubble = true;
		if (typeof(e.returnValue) != 'undefined')
			e.returnValue = false;
		if (typeof(e.stopPropagation) != 'undefined' && e.stopPropagation)
			e.stopPropagation();
	}
	return false;
}

function iebody() {
    // Sense the difference between Strict and Quirks mode
	return (document.compatMode != "BackCompat"? document.documentElement : document.body);
}

function FloatTopDiv(id) {
	this.marginX = 0;
	this.marginY = 80;
	this.sleep = false;
	this.fblObj = gsdlGetElement(id);
	if (this.fblObj != null) {
		this.fblObj.sP = function(x, y) {
			this.style.left = x + 'px';
			this.style.top= y + 'px';
		};
		this.fblObj.x = this.marginX;
		this.fblObj.y = this.marginY;
		if (IE4 || IE5 || IE6) {
			if (!FloatTopDiv.WatchDogInstalled) {
				FloatTopDiv.WatchDogInstalled = true;
				if (IE6)
					iebody().onscroll = FloatTopDiv.watchDog;
				else {
				document.body.onscroll = FloatTopDiv.watchDog;
				window.onscroll = FloatTopDiv.watchDog;
				}
			}
		} else {
			this.fblObj.style.position = 'fixed';
		}
		this.fblObj.style.display = 'none';
	}
}

FloatTopDiv.WatchDogInstalled = false;
FloatTopDiv.WatchList = [];

FloatTopDiv.watchDog = function() {
	if (FloatTopDiv.WatchList.length > 0) {
		for(var i = 0; i < FloatTopDiv.WatchList.length; ++i) {
			FloatTopDiv.WatchList[i].onScroll();
		}
	}
};

FloatTopDiv.prototype.onScroll = function() {
	if (this.sleep || this.fblObj == null)
		return;
	//var pY = document.body.scrollTop;
	if (IE6) {
		this.fblObj.y = iebody().scrollTop + this.marginY;
		this.fblObj.sP(this.fblObj.x, this.fblObj.y);
	}
	else {
		this.fblObj.y = document.body.scrollTop + this.marginY;
		this.fblObj.sP(this.fblObj.x, this.fblObj.y);
	}
};

FloatTopDiv.prototype.start = function() {
	this.sleep = false;
	if (this.fblObj != null) {
		if (FloatTopDiv.WatchList.indexOf(this) == -1)
			FloatTopDiv.WatchList.push(this);
		this.onScroll();
		this.fblObj.style.display = 'block';
	}
	//document.body.style.cursor = 'wait';
};

FloatTopDiv.prototype.stop = function() {
	this.sleep = true;
	if (this.fblObj != null) {
		FloatTopDiv.WatchList.remove(this);
		this.fblObj.style.display = 'none';
	}
	//document.body.style.cursor = 'default';
};

window.onload = globalPageInit;

function showCompareQuestion(what) {
	switch(what)
	{
	case 1:
		alert(texts.comparequestion1);
		break;
	case 2:
		alert(texts.comparequestion2);
		break;
	}
}

function updatectrycs(value) {
	var newUrl = opener.parent.location.href;
	var re = new RegExp(",ctrycs,[cr]", "ig");
	
	// remove any bookmark before adding any new argument ...
	var reHash = new RegExp("\#.*", "i");
	newUrl = newUrl.replace (reHash, '');

	// remove any existing 'ctrycs' argument ...
	newUrl = newUrl.replace(re, ',ctrycs,' + value);

	gsdlSetCookie('ctrycs', value);

	//opener.focus();
	window.opener.parent.location.href = fix_url(newUrl);

	window.setTimeout("close()", 400);
}

function updategca(value) {
	if (gsdlDefined(window.opener) && gsdlDefined(window.opener.parent) && gsdlDefined(window.opener.parent.refreshTOCState)) {
		window.opener.parent.refreshTOCState(value);
		window.opener.parent.updateButtons();
	} else {
		alert('Invalid state. You have closed or moved to another page the parent window.');
	}
	window.setTimeout("close()", 400);
}
