

function buildRefs() {

/*
Build reference links
Input: 
	1. List of references in the ul 'refList'
		eg. <li id=Refn>The Art of Cricket by D.G.Bradman</li>
	2. 'a' tags in the position of the reference
             	eg. <a>Ref:n:Vol.14 P.123</a>

The resulting reference will have a popup title consisting of the related reference, and the detail. It will also link to the related reference. 
*/

	/*Get the 'a' tags and add necessary info.*/
	refNode = document.getElementsByTagName('a');
	
	for(i = 0; i < refNode.length; i++) {
		
		/*Get the info passed.*/
		refInfo = refNode[i].childNodes[0].nodeValue.split(":");

		if (refInfo[0]=='Ref') {

			if (refInfo[2]) {refDetail = '==>'+refInfo[2]}
			else {refDetail = ''};

			refMain = document.getElementById('$Ref'+refInfo[1]).childNodes[0].nodeValue;
			if (refMain == null) { refMain = document.getElementById('$Ref'+refInfo[1]).childNodes[0].childNodes[0].nodeValue}

			refNode[i].className = 'refClass';
			refNode[i].href = '#$'+refInfo[0]+refInfo[1];
			refNode[i].title = refMain+refDetail;
			refNode[i].innerHTML = refInfo[0]+refInfo[1]; 
		}
	}
}

