// JavaScript Document
var contentPath = "/contents";
var titleNode = xmlDoc.getElementsByTagName('title');
var subTitleNode = xmlDoc.getElementsByTagName('subtitle');
var authorNode = xmlDoc.getElementsByTagName('author');
if (titleNode.length != 0) {
	document.write('<p class="hksoa_blue_bodytext_big">' + titleNode[0].firstChild.nodeValue + '</p>');
}
if (subTitleNode.length != 0) {
	document.write('<p class="hksoa_blue_bodytext"><em><strong>' + subTitleNode[0].firstChild.nodeValue + '</strong><br>');
}
if (authorNode.length != 0) {
	document.write('Article by ' + authorNode[0].firstChild.nodeValue + '</em></p><p class="hksoa_insidebodytext"></p>');
}
var x=xmlDoc.getElementsByTagName('span');
for (i=0;i<x.length;i++){
	var linkNode = x[i].getElementsByTagName('a');
	var imgNode = x[i].getElementsByTagName('img');
	if (linkNode.length != 0) {
		var inlineNode = linkNode[0].parentNode.getElementsByTagName('inline');
		if (inlineNode.length != 0) {
			if (inlineNode[0].firstChild) {
				p1 = inlineNode[0].firstChild.nodeValue;
			} else {
				p1 = "";
			}
			if (inlineNode[1].firstChild) {
				p2 = inlineNode[1].firstChild.nodeValue;
			} else {
				p2 = "";
			}
  document.write('<p><span class="hksoa_insidebodytext">' + p1 + ' <a href="' + linkNode[0].getAttribute('href') + '" class="colourbodytext" target="_blank">' + linkNode[0].firstChild.nodeValue + '</a> ' + p2 + '</span></p>');
		} else {
  document.write('<p><span class="hksoa_insidebodytext"><a href="' + linkNode[0].getAttribute('href') + '" class="colourbodytext" target="_blank">' + linkNode[0].firstChild.nodeValue + "</a></span></p>");
		}
	} else if (imgNode.length != 0) {
		var imgTitleNode = imgNode[0].parentNode.getElementsByTagName("imgTitle");
		if (imgTitleNode.length > 0) {
			imageTitle = imgTitleNode[0].firstChild.nodeValue;
		} else {
			imageTitle = "&nbsp;"
		}
		var imgURL = imgNode[0].getAttribute('imageURL');
		if ((imgURL == "") || (imgURL == null)) {
			imgURL = contentPath + "/upload/" + imgNode[0].getAttribute('src');
		}
  document.write('<span class="bodyimage" style="float:' + imgNode[0].getAttribute('align') + ';"><table width="180" border="0"><tr><td align="center"><a href="' + imgURL + '" target="_blank"><img src="' + contentPath + '/upload/thumbnails/' + imgNode[0].getAttribute('src') + '" border="0" /></a></td></tr><tr><td align="center"><span class="hksoa_blue_captiontext">' + imageTitle + '</span></td></tr></table></span>');
	} else {
	if (x[i].childNodes[0]) {
  document.write('<p><span class="hksoa_insidebodytext">' + x[i].childNodes[0].nodeValue + "</span></p>");
	}
  }
}