/*******************************************************************
 *    Copyright © 2006 Dragon of The South. All rights reserved.   *
 *    ---------------------------------------------------------    *							
 *******************************************************************/

var xmlDoc 
var xmlfile

xmlfile = "xml/pastEvents.xml";	// location of xml file

// create new xml document to work on, then
// call methods to retreive article/event info
function loadXML()
{
	//load xml filecode for IE
	if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load(xmlfile);
		getArticleInfo();	
	}
	// code for Mozilla, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc= document.implementation.createDocument("","",null);
		xmlDoc.load(xmlfile);
		xmlDoc.onload=getArticleInfo;		
	}
	else
	{
		alert('Your browser cannot handle this script');
	}
}

function getArticleNo()
{

	if(qsParm['articleid']=='DPHQ')	// dorset police HQ
		return 0;
	else if(qsParm['articleid']=='CFAW') //christchurch Food and wine
		return 1;  
	else if(qsParm['articleid']=='BBIC') //bmouth BIC 
		return 2;
}

function getArticleInfo()
{
	//retrieve main article 
	var article_no = getArticleNo();	

	//get default main picture, heading and date
	document.getElementById("heading").innerHTML = xmlDoc.getElementsByTagName("title")[article_no].firstChild.nodeValue	
	document.getElementById("eventdate").innerHTML = xmlDoc.getElementsByTagName("date")[article_no].firstChild.nodeValue
	document.getElementById("mainpic").src = xmlDoc.getElementsByTagName("picture1")[article_no].firstChild.nodeValue

	//get the 5 thumbnail pics
	document.getElementById("thumbnail1").src = xmlDoc.getElementsByTagName("picture2")[article_no].firstChild.nodeValue	
	document.getElementById("thumbnail2").src = xmlDoc.getElementsByTagName("picture3")[article_no].firstChild.nodeValue
	document.getElementById("thumbnail3").src = xmlDoc.getElementsByTagName("picture4")[article_no].firstChild.nodeValue
	document.getElementById("thumbnail4").src = xmlDoc.getElementsByTagName("picture5")[article_no].firstChild.nodeValue

	//get the 5 enlargement pics
	document.getElementById("pic1").src = xmlDoc.getElementsByTagName("picture2")[article_no].firstChild.nodeValue	
	document.getElementById("pic2").src = xmlDoc.getElementsByTagName("picture3")[article_no].firstChild.nodeValue
	document.getElementById("pic3").src = xmlDoc.getElementsByTagName("picture4")[article_no].firstChild.nodeValue
	document.getElementById("pic4").src = xmlDoc.getElementsByTagName("picture5")[article_no].firstChild.nodeValue	

	//retrieve summary info
	getSummaryInfo();
}

function getSummaryInfo()
{			
	// retrieve and bind news summaries information to page elements
	
	// get event pics
	document.getElementById("eventpic1").src = xmlDoc.getElementsByTagName("summarypic")[0].firstChild.nodeValue
	document.getElementById("eventpic2").src = xmlDoc.getElementsByTagName("summarypic")[1].firstChild.nodeValue
	document.getElementById("eventpic3").src = xmlDoc.getElementsByTagName("summarypic")[2].firstChild.nodeValue

	// get event summary text
	document.getElementById("eventstory1").innerHTML = xmlDoc.getElementsByTagName("summary")[0].firstChild.nodeValue
	document.getElementById("eventstory2").innerHTML = xmlDoc.getElementsByTagName("summary")[1].firstChild.nodeValue
	document.getElementById("eventstory3").innerHTML = xmlDoc.getElementsByTagName("summary")[2].firstChild.nodeValue
}

