/*CS Get and write the region release info to the page*/

//Write info to page
function createReleaseDiv(xmlDoc) {

var newDiv = document.createElement('newDiv');
var pressReleases = xmlDoc.getElementsByTagName('regionPressReleases'); 

var region = pressReleases[0].getElementsByTagName("region");	

var prTable = document.createElement('table');
			prTable.setAttribute('id','prTable');
			prTable.setAttribute('cellpadding','0');
			prTable.setAttribute('cellspacing','0');
			prTable.setAttribute('width','100%');	
			var prTbody = document.createElement('tbody');

//Get the number of years for releases
for (j=0; j<region.length; j++) {
		var regionName = region[j].getAttribute("name");			
	
			var newsItem = region[j].getElementsByTagName("newsItem");		
			 
	
	
			for (i=0; i<newsItem.length; i++) {			
			if(regionName == regionPage) {
				var br = document.createElement('br');
			
			var prRow = document.createElement('tr');
			var prCell = document.createElement('td');
			var newsUL = document.createElement('ul');
			newsUL.setAttribute('class','firstLevelUL');
			newsUL.setAttribute('className','firstLevelUL'); //for IE
	
			document.getElementById('pressReleases').appendChild(newDiv);//append table to div
			newDiv.appendChild(prTable);
			prTable.appendChild(prTbody); //append tbody to table
				
	
			prTbody.appendChild(prRow); //append row to tbody
			prRow.appendChild(prCell); //append cell to row
			prCell.appendChild(newsUL); //append news ul to cell
				var newsLi = document.createElement('li');
				newsLi.setAttribute('class','newsFirstLevel');
				newsLi.setAttribute('className','newsFirstLevel'); //for IE
		
				//All the elements from XML to write to the page
				var htmlPath= newsItem[i].getAttribute("html"); //Path to html page
				var headline = document.createTextNode(newsItem[i].getAttribute("headline")); //Headlinetext
				var date = document.createTextNode(newsItem[i].getAttribute("date")); 
		
				var newsIco = document.createElement('img'); //Bullet image
				newsIco.setAttribute('src','/assets/images/news_ico.gif');
				newsIco.setAttribute('id','arrow_02');
				newsIco.setAttribute('class','newsIco');
				newsIco.setAttribute('className','newsIco'); //for IE
				newsIco.setAttribute('name','arrow_02');
				newsIco.setAttribute('width','12');
				newsIco.setAttribute('height','13');
				newsIco.setAttribute('border','0');
	
				//Link for headline	
				var headlineLink = document.createElement('a'); 
				headlineLink.setAttribute('href',htmlPath);
				headlineLink.setAttribute('class','newsFirstLevel_ablock');
				headlineLink.setAttribute('className','newsFirstLevel_ablock'); //for IE
				
				//Span for date info
				var newsDate = document.createElement('span'); 
				newsDate.setAttribute('class','newsDate');
				newsDate.setAttribute('className','newsDate'); //for IE
				
				newsUL.appendChild(newsLi);
				newsLi.appendChild(headlineLink);
				headlineLink.appendChild(newsIco);
				headlineLink.appendChild(headline);
							
				newsLi.appendChild(newsDate);
				newsDate.appendChild(date);

			}
	}
	
}
}