
function expandSummary(img) {
	var row = img.parentNode.parentNode;
	if (row.nextSibling.style.display == 'none') {
		row.nextSibling.style.display = '';
		img.src = '/news/img/minus.png';
	} else {
		row.nextSibling.style.display = 'none';
		img.src = '/news/img/plus.png';
	}
}

function expandAllSummaries(img) {
	var table = img.parentNode.parentNode.parentNode.parentNode;
	var tbodies = table.getElementsByTagName('tbody');
	if (img.nextSibling.nodeValue == ' Expand all') {
		img.nextSibling.nodeValue = ' Collapse all';
		img.src = '/news/img/minus.png';
		var display = '';
	} else {
		img.nextSibling.nodeValue = ' Expand all';
		img.src = '/news/img/plus.png';
		var display = 'none';
	}
	for (var i = 0; i < tbodies.length; i++) {
		if (tbodies[i].parentNode == table) {
			tbodies[i].childNodes[1].style.display = display;
			tbodies[i].firstChild.getElementsByTagName('IMG')[0].src = img.src;
		}
	}
}

function unhashEmail(a) {
	if (a.href && a.href.indexOf('mailto:') != -1 && hashkey) {
		idkey = a.href.substr(7);
		key = hashkey;
		var xorkey = "";
		var idx = 0;
		while (xorkey.length < idkey.length) {
			if (idx > key.length) idx = 0;
			xorkey+= key.substr(idx, 1);
			idx++;
		}
		var hashed = idkey;
		var string = "";
		var count = 0;
		for (i=0; i < hashed.length; i+=2) {
			string+= String.fromCharCode(parseInt('0x'+hashed.substr(i,2)) ^ xorkey.charCodeAt((i/2)%xorkey.length));
		}
		a.href = 'mailto:'+string;
	}
}

function unhashEmailText(key) {
	var tags = document.getElementsByTagName('A');
	for (i=0; i < tags.length; i++) {
		var s = tags[i];
		if (s.className == 'unhashme') {
			hashval = s.innerHTML;
			var xorkey = "";
			var idx = 0;
			while (xorkey.length < hashval.length) {
				if (idx > key.length) idx = 0;
				xorkey+= key.substr(idx, 1);
				idx++;
			}
			var hashed = hashval;
			var string = "";
			var count = 0;
			for (o=0; o < hashed.length; o+=2) {
				string+= String.fromCharCode(parseInt('0x'+hashed.substr(o,2)) ^ xorkey.charCodeAt((o/2)%xorkey.length));
			}
			s.innerHTML = string;
		}
	}
}

