//	makeRequest(siteroot + 'c/g/'+ sess.mmdd + '.xml?g=' + sess.QS,'','','GET');
//	makeRequest(siteroot + 'f/animals.xml?g=' + sess.QS,'','','GET');
//	makeRequest(siteroot + 'c/' + sess.yy + '/d/' + sess.mmdd + '.xml?g=' + sess.QS,'','','GET');
//	makeRequest(siteroot + 'c/' + sess.yy + '/w/' + sess.ww + '.xml?g=' + sess.QS,'','','GET');
//	makeRequest(siteroot + 'f/astronomy.xml?g=' + sess.QS,'','','GET');
//	makeRequest(siteroot + 'f/fossils.xml?g=' + sess.QS,'','','GET');
//	makeRequest(siteroot + 'c/pepys/'+ sess.mmdd + '.xml?g=' + sess.QS,'','','GET');
//	makeRequest(siteroot + 'c/' + sess.yy + '/m/' + sess.mm + '.xml?g=' + sess.QS,'','','GET');
//							case 'WEEKLY':	processDoc(xmlDoc,true,false,false,true,true,true,true,true,true);    	break;
//							case 'MONTHLY': processDoc(xmlDoc,false,false,false,true,true,true,true,true,true);break;
//   	    			    case 'PEPYS':	processDoc(xmlDoc,true,false,false,true,false,true,true,true,true);		break;
//    	    			    case 'GALLERY':	processDoc(xmlDoc,true,false,false,true,true,true,true,true,true);		break;
//	    	    	    	case 'ANIMALS':
//	    	    	    	case 'ASTRONOMY':
//	    	    	    	case 'FOSSILS':processDoc(xmlDoc,false,false,false,true,true,true,true,true,true,true);   	break;
//							case 'DAILY':	processDoc(xmlDoc,false,false,false,true,true,true,true,true,true);break;
// cookies
// a annoucementno
// b version
// c logins
// d fontfamily
// e fontsize
// f themecolor
// g themebackground
// h guid
// i country
// j articlesread
// k this session articlesread
// l this session date
// m referrer
// n clickouts
// o measurementunits
// p time24
//newnode.appendChild(createNode('div',[0]'storyimgdesc',storychildnode.childNodes[0].nodeValue,true,4));	
//xmlDoc.getElementsByTagName(nodename)[0].childNodes[0].nodeValue,true,4;
//newnode3.onclick=function(){showexternalwindow(this.id);}
//newnode3.setAttribute('href','javascript:void(0)')
//Menu global vars
//timezoneoffsets = [0,-540,840,420,-660,0,0];

ConfigHashTable='';
timezoneoffsets = new Array;
savedworldtimeminutes = -1;
savedworldtimehours = -1;
savedworlddate = -1;
timerRunning 	= false;
timerID 		= null;
dateampm 		= "";
currentweather = 0;
sess=new Object();
isRSS=false;
var editiondate;
var todaysdatestring;
var TimeOut         = 300;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;
XMLConfig=null;
systemwincontents="";
configwincontents="";
contactwincontents='';
articlewincontents = '';
quizwincontents = '';
welcomemessage='';
announcementmessage='';
upgrademessage='';
xmllocation = '';
popupwin =null;
popupwin2=null;
externalwin ='';
homepagewin ='';
targetwin ='';
livesiteroot='';
noofweatheritems=0;
headlinelink=new Array(500);
articlelink=new Array(200);
quizanswers=new Array(200);
answersshowing=false;
headlineid=0;
articlelinksub=0;
quiztotalquestions=0;
pageaddress=document.location.href.split('?');
usersiteroot=pageaddress[0].slice(0,pageaddress[0].lastIndexOf('/'))+'/';
siteroot='http://'+ location.host + '/';
sess.isIE=navigator.userAgent.indexOf("MSIE")==-1?0:1;
sess.isOpera=navigator.userAgent.indexOf("Opera")==-1?0:1;
sess.isSafari=navigator.userAgent.indexOf("Safari")==-1?0:1;
sess.isFirefox=navigator.userAgent.indexOf("Firefox")==-1?0:1;

classNAME=sess.isIE?'className':'class';
textSTYLE=sess.isIE?'cssText':'style';
userLocation=getUserLocation();
XMLDOMver=getXMLDOMver();
HTTPrequestver=getHTTPrequestver();
sitename='';
//var t=setTimeout('checkDate()',3000);
//******************************************************
Date.prototype.dateDiff = function (startccyymmdd,endccyymmdd){
//******************************************************
startccyy = startccyymmdd.substr(0,4);
startmm = startccyymmdd.substr(4,2);
startdd = startccyymmdd.substr(6,2);
endccyy = endccyymmdd.substr(0,4);
endmm = endccyymmdd.substr(4,2);
enddd = endccyymmdd.substr(6,2);
var sDate = new Date(startmm+"/"+startdd+"/"+startccyy);
var eDate = new Date(endmm+"/"+enddd+"/"+endccyy);
var daysApart = Math.abs(Math.round((sDate-eDate)/86400000));
if (eDate < sDate)
daysApart = 0 -daysApart;
return(daysApart);}

//******************************************************
Date.prototype.add = function (sInterval, iNum){
//******************************************************
//sample usage var d = new Date(); var d2 = d.add("d", 3); //+3days //var d3 = d.add("h", -3); //-3hours
var dTemp = this;
if (!sInterval || iNum == 0) return(dTemp);
switch (sInterval.toLowerCase()){
    case "ms":dTemp.setMilliseconds(dTemp.getMilliseconds() + iNum);break;
    case "s":dTemp.setSeconds(dTemp.getSeconds() + iNum);break;
    case "n":dTemp.setMinutes(dTemp.getMinutes() + iNum);break;
    case "h":dTemp.setHours(dTemp.getHours() + iNum);break;
    case "d":dTemp.setDate(dTemp.getDate() + iNum);break;
    case "m":dTemp.setMonth(dTemp.getMonth() + iNum);break;
    case "y":dTemp.setFullYear(dTemp.getFullYear() + iNum);break;}
return(dTemp);}

//******************************************************
function headlineschange(headlineid){
//******************************************************
document.getElementById('animalheads').style.display='none';
document.getElementById('spaceheads').style.display='none';
document.getElementById('fossilheads').style.display='none';


 
switch (headlineid){
    case "0":document.getElementById('animalheads').style.display='block';	document.getElementById('mmenu7').innerHTML='News - Animals';break;
    case "1":document.getElementById('spaceheads').style.display='block';	document.getElementById('mmenu7').innerHTML='News - Space';break;
    case "2":document.getElementById('fossilheads').style.display='block';	document.getElementById('mmenu7').innerHTML='News - Fossils';break;}
mclose();}

//******************************************************
function weatherchange(weatherid){
//******************************************************
currentweather = weatherid;
for(x=0; x < noofweatheritems; x++)
	for(y =0; y < 2; y++)
	targetwin.document.getElementById('weatherframe'+x+'_'+y).style.display='none';
	targetwin.document.getElementById('weatherframe'+weatherid+'_'+sess.measurementunits).style.display='block';
mclose();	}

//******************************************************
function tryquizagain(){
//******************************************************
targetwin.document.getElementById('quizscoreblock').style.display='none';
for(x=0;x < quiztotalquestions;x++){
	targetwin.document.getElementById('explanation-'+x).style.display='none';
	targetwin.document.getElementById('quizscorebox-'+x).className='stylequizcross';
	for(y=0;y < 4;y++)
		targetwin.document.getElementById('quizscoretickbox-'+x+'-'+y).style.visibility='hidden';}	
targetwin.scroll(0,0);}

//******************************************************
function contactus()
//******************************************************
{params = 'fromname='	+ encodeURIComponent(popupwin2.document.getElementById('fromname').value);
params += '&fromaddress=' + encodeURIComponent(popupwin2.document.getElementById('fromaddress').value);
params += '&subject=' + encodeURIComponent(popupwin2.document.getElementById('subject').value);
params += '&message='+ encodeURIComponent(popupwin2.document.getElementById('message').value);
params += '&toaddress='+ encodeURIComponent(popupwin2.document.getElementById('toaddress').value);
params += '&action=0';
makeRequest(siteroot + 's.asp', '', params,'POST');
popupwin2.document.getElementById('fromname').value='';
popupwin2.document.getElementById('fromaddress').value='';
popupwin2.document.getElementById('subject').value='';
popupwin2.document.getElementById('message').value='';
popupwin2.document.getElementById('toaddress').value='';}

//******************************************************
function getFooterLinks(articlefootnotes){
//******************************************************
var newnode=createNode('div','');
newnode.appendChild(getFooterSections(articlefootnotes));
var articlefootnotes=XMLConfig.getElementsByTagName('sponsors');
if(articlefootnotes.length)	newnode.appendChild(getFooterSections(articlefootnotes[0]));
return(newnode);}

//******************************************************
function getFooterSections(articlefootnotes){
//******************************************************
stylegroup ='';
var newnode=createNode('div','');

var sections=articlefootnotes.getElementsByTagName('section');
for(x=0;x<sections.length;x++){
	var newnode2=createNode('div',stylegroup + 'stylefooterlinks');
	newnode2.appendChild(createNode('div',stylegroup + 'stylefooterlinkstitle',sections[x].getAttribute('heading')));
	var footnoteitems=sections[x].getElementsByTagName('footnote');

	for(y=0;y<footnoteitems.length;y++){
		if((isEmpty(footnoteitems[y].getAttribute('location')) || (footnoteitems[y].getAttribute('location')==userLocation))) {
			var newnode3=createNode('div',stylegroup + 'stylefooterlinksitemline');
			if(footnoteitems[y].getElementsByTagName('enclosure').length)
				newnode3.appendChild(showimage('',footnoteitems[y].getElementsByTagName('enclosure')[0],'stylebookcover',footnoteitems[y].getAttribute('link')));		

		if(!isEmpty(footnoteitems[y].getAttribute('link'))){
			var newnode4	=createNode('a', stylegroup + 'stylefooterlink',footnoteitems[y].getAttribute('linkdesc'),'source-' + articlelinksub);
			if(isRSS)
				newnode4.setAttribute('href',"javascript:showexternalwindow('source-" + articlelinksub + "')");
			else
				newnode4.setAttribute('href',"javascript:opener.showexternalwindow('source-" + articlelinksub + "')");

			newnode3.appendChild(newnode4);	
			articlelink[articlelinksub++]=footnoteitems[y].getAttribute('link');}

			var paras=footnoteitems[y].getElementsByTagName('p');
			for(z=0;z < paras.length;z++) newnode3.appendChild(createNode('span','',' - ' + paras[z].childNodes[0].nodeValue));
				newnode2.appendChild(newnode3);
										}
		} 
newnode.appendChild(newnode2);}
return(newnode);}

//******************************************************
function showimage(parentnode,imagenode,stylegroup,imagelink){
//******************************************************

newnode	=createNode('div',stylegroup + 'imgdiv');
newnode=setTagStyle(newnode,'width:'+imagenode.getAttribute('width')+'px;');

if(!isEmpty(imagelink)){
	linknode=createNode('a', stylegroup + 'imglink','','image-' + articlelinksub);
	if(isRSS)
		linknode.setAttribute('href',"javascript:showexternalwindow('image-" + articlelinksub + "')");
	else
		linknode.setAttribute('href',"javascript:opener.showexternalwindow('image-" + articlelinksub + "')");
	articlelink[articlelinksub++]=imagelink;
	linknode.appendChild(createImgNode('img',stylegroup + 'img',imagenode.getAttribute('src'),imagenode.getAttribute('width'), imagenode.getAttribute('height'),imagenode.getAttribute('alt')));	
	newnode.appendChild(linknode);}
else
	newnode.appendChild(createImgNode('img',stylegroup + 'img',imagenode.getAttribute('src'),imagenode.getAttribute('width'), imagenode.getAttribute('height'),imagenode.getAttribute('alt')));	
	
if(imagenode.hasChildNodes()){
	newnode2=createNode('div',stylegroup + 'imgdesc',imagenode.childNodes[0].nodeValue);
	newnode2=setTagStyle(newnode2,'width:'+imagenode.getAttribute('width')+'px;');
	newnode.appendChild(newnode2);}

if(!isEmpty(imagenode.getAttribute('attribution'))){
	newnode2=createNode('div',stylegroup + 'imgattribution',imagenode.getAttribute('attribution'));	
	newnode2=setTagStyle(newnode2,'width:'+imagenode.getAttribute('width')+'px;');
	newnode.appendChild(newnode2);}
	
if(parentnode=='')parentnode=newnode;else parentnode.appendChild(newnode);	
return(parentnode);}

//******************************************************
function scorequiz(showanswers){
//******************************************************
totalanswered 	=0;
totalcorrect 	=0;

if(showanswers)	answersshowing=true;
if(answersshowing)	showanswers=true;
for(x=0;x < quiztotalquestions;x++)
{	aFields=targetwin.document.getElementsByName('radio-' + x);
	if(showanswers){
		targetwin.document.getElementById('explanation-'+x).style.display='block';
		targetwin.document.getElementById('quizscorebox-'+x).className='stylequizcross';	}				

	for(y=0;y < aFields.length;y++){
		if(showanswers)
			targetwin.document.getElementById('quizscoretickbox-'+x+'-'+y).style.visibility='visible';
		 	if(aFields[y].checked) 	{
		  		totalanswered++;
				if(aFields[y].value==quizanswers[x])									{
					totalcorrect++;
					if(showanswers)
						targetwin.document.getElementById('quizscorebox-'+x).className='stylequiztick';	}
									}
										}														
}

targetwin.document.getElementById('quizscoreblock').style.display='block';
totalincorrect=totalanswered - totalcorrect;
totalunanswered=quiztotalquestions - totalanswered;
totalpercentage=(totalcorrect/quiztotalquestions) * 100;
targetwin.document.getElementById('quizpercentagebar').style.width 	=(2*totalpercentage) + 'px';
targetwin.document.getElementById('quizscorequestions').innerHTML			=' ' + quiztotalquestions + ' ';
targetwin.document.getElementById('quizscorecorrect').innerHTML			=' ' + totalcorrect		+ ' '; 
targetwin.document.getElementById('quizbreakdowncorrect').innerHTML		=' ' + totalcorrect		+ ' '; 
targetwin.document.getElementById('quizbreakdownincorrect').innerHTML		=' ' + totalincorrect	+ ' '; 
targetwin.document.getElementById('quizbreakdownunanswered').innerHTML	=' ' + totalunanswered	+ ' '; 
targetwin.document.getElementById('quizpercentage').innerHTML	= totalpercentage	+ '%'; 
targetwin.scroll(0,0);}

//******************************************************
function getdimensions(){
//******************************************************
// fudge for Ie
sess.winX=sess.isIE?parseInt(document.body.clientWidth+40,10) : parseInt(window.innerWidth,10); 
sess.winY=sess.isIE?parseInt(document.body.clientHeight,10) : parseInt(window.innerHeight,10); 
sess.screenX=self.screen.availWidth;
sess.screenY=self.screen.availHeight;
}

//******************************************************
function getquerystring(win){
//******************************************************
var qs=win.document.location.search;
if (xmllocation != '')
	qs=xmllocation;
if(qs.length){
// loose the ?
		qs=unescape(qs.substr(1,qs.length-1));
		sess.qs=qs;
		CreateGlobVars(qs);
		sess.querystring=true;}
	else
		sess.querystring=false;
//we tidyup if article has leading slash
	if (sess.a)
		if (sess.a.indexOf('/') != 0)
			sess.a = '/' + sess.a;
		}

//******************************************************
function writelogodetails(win){
//******************************************************
win.document.getElementById('headerdate1').innerHTML=getDayName(sess.today.getDay())+ ' ' + (sess.dd - 0) + getDaysuffix(sess.dd);
win.document.getElementById('headerdate2').innerHTML=sess.monthdesc; 
win.document.getElementById("copyright").innerHTML=("&copy;"+ sess.ccyy + " " + sitename);}

//******************************************************
function CreateGlobVars(qs){
//******************************************************
qsarr=qs.split('&');
for(x=0;x < qsarr.length;x++)
{	var fieldarr=qsarr[x].split('=');
	var arrayarr=fieldarr[1].split(',');
	if(arrayarr.length > 1) 
		eval("sess." +  fieldarr[0] + "=arrayarr.slice();");
	else
		eval("sess." +  fieldarr[0] + '="' + arrayarr + '"');}}	

//******************************************************
function readCookies(){
//******************************************************
// for safety
sess.measurementunits = 0;
sess.time24 = false;
	sess.announcement=-1;
	sess.logins=0;
	sess.fontfamily=0;
	sess.fontsize=0;
	sess.themecolor=0;
	sess.themebackground=0;
	sess.articlesread=0;
	sess.lastsessionarticlesread=0;
	sess.clickouts=0;
	sess.lastsessiondate=sess.yymmddhhmmss;
	sess.version='3.21';
	sess.GUID = createGUID();
	sess.country = 'xx';
	sess.clickouts=0;
	sess.measurementunits = '0';
	sess.time24 = false;

if (document.cookie.length > 0){
	cookies=document.cookie.split(';');
	for(x=0;x < cookies.length;x++)	{	
		cookies[x] = trim(cookies[x]);
		cookiesplit=cookies[x].split('=');
			switch(cookiesplit[0]){
	   			case 'a':cookiename='announcementno';break;
		   		case 'b':cookiename='version';break;
			   	case 'c':cookiename='logins';break;
		   		case 'd':cookiename='fontfamily';break;
			   	case 'e':cookiename='fontsize';break;
			   	case 'f':cookiename='themecolor';break;
			   	case 'g':cookiename='themebackground';break;
			   	case 'h':cookiename='GUID';break;
		   		case 'i':cookiename='country';break;
		   		case 'j':cookiename='articlesread';break;
		   		case 'k':cookiename='lastsessionarticlesread';break;
		   		case 'l':cookiename='lastsessiondate';break;
		   		case 'm':cookiename='referrer';break;
		   		case 'n':cookiename='clickouts';break;
		   		case 'o':cookiename='measurementunits';break;
		   		case 'p':cookiename='time24';break;
				default:cookiename='z';}
			eval("sess." + cookiename + "='" + cookiesplit[1] + "'");		
			eval("createCookie('" + cookiesplit[0] + "','" + cookiesplit[1] + "')");
								}		
							}
if(isEmpty(sess.logins)){
	createCookie('a',sess.announcement);
	createCookie('c',sess.logins);
	createCookie('d',sess.fontfamily);
	createCookie('e',sess.fontsize);
	createCookie('f',sess.themecolor);
	createCookie('g',sess.themebackground);
	createCookie('h',sess.GUID);
	createCookie('i',sess.country);
	createCookie('j',sess.articlesread);}
	createCookie('k',0);
	createCookie('l',sess.yymmddhhmmss);
	createCookie('n',sess.clickouts);
	createCookie('o',sess.measurementunits);
	createCookie('p',sess.time24);
sess.thissessionarticlesread=0;}

//******************************************************
function createCookie(cookiename,cookievalue){
//******************************************************
var date=new Date();
date.setTime(date.getTime()+(31536000000));
var expires="; expires="+date.toGMTString();
document.cookie=cookiename+"="+cookievalue+expires+"; path=/";}

//******************************************************
function getweekno(thedate) {
//******************************************************
startweek=getstartweek(thedate);
thedatedd=parseInt(startweek.getDate(),10);
thedatemm=parseInt(startweek.getMonth(),10);  
days=[0,31,59,90,120,151,181,212,243,273,304,334,365];
elapseddays=days[thedatemm];
elapseddays += thedatedd;
if(isleapyear())
	if(thedatemm > 01)	elapseddays +=1;
		elapseddays +=- 1;
weekno = addzero(parseInt((elapseddays / 7),10));
return(weekno);}
	
//******************************************************
function setbodytheme(win){
//******************************************************
win.document.getElementsByTagName('body')[0].style.fontFamily	 = getfontfamily(sess.fontfamily);
win.document.getElementsByTagName('body')[0].style.fontSize	 = getfontsize(sess.fontsize);}

//******************************************************
function setCSSRules(){
//******************************************************
if (sess.isIE){
	document.styleSheets[0].rules[0].style.color 		= getthemecolor(sess.themecolor);
	document.styleSheets[0].rules[0].style.background = getthemebackground(sess.themebackground);
	document.styleSheets[0].rules[0].style.borderColor = getthemebackground(sess.themebackground);
	document.styleSheets[0].rules[0].style.borderStyle = 'solid';
	document.styleSheets[0].rules[0].style.borderWidth = '1px';
	document.styleSheets[0].rules[1].style.borderColor = getthemebackground(sess.themebackground);
	document.styleSheets[0].rules[2].style.color 		= getthemecolor(sess.themecolor);
	document.styleSheets[0].rules[2].style.background = getthemebackground(sess.themebackground);}
else{	
	document.styleSheets[0].cssRules[0].style.color 		= getthemecolor(sess.themecolor);
	document.styleSheets[0].cssRules[0].style.background 	= getthemebackground(sess.themebackground);
	document.styleSheets[0].cssRules[0].style.borderColor = getthemebackground(sess.themebackground);
	document.styleSheets[0].cssRules[0].borderStyle = 'solid';
	document.styleSheets[0].cssRules[0].borderWidth = '1px';
	document.styleSheets[0].cssRules[1].style.borderColor = getthemebackground(sess.themebackground);
	document.styleSheets[0].cssRules[2].style.color 		= getthemecolor(sess.themecolor);
	document.styleSheets[0].cssRules[2].style.background 	= getthemebackground(sess.themebackground);}}

//******************************************************
function processPlugin(xmlDoc){
//******************************************************
targetdiv = getNodeValue(xmlDoc,'target');
document.getElementById(targetdiv).innerHTML=getNodeValue(xmlDoc,'data');
if (targetdiv =='Weather') 	weatherchange('0');}
	
//******************************************************
function makeRequest(URL,callingpage,parameters,type){
//******************************************************
	function ajaxBindCallback(){
	var xmlDoc='';
	if(xmlhttp.readyState==4) {
			switch (xmlhttp.status) {
    	         case 200:	xmlDoc=getXMLDoc(xmlhttp.responseText);
							var rssfile=getNodeValue(xmlDoc,'title').split(' ');
							rssfile[0]=trim(rssfile[0].toUpperCase());

						switch (rssfile[0]) {
		    	    	    case 'PLUGIN':	processPlugin(xmlDoc);break;
	    	    	    	case 'ALERT': 	alert(getNodeValue(xmlDoc,'message'));break;
		    	    	    case 'CONFIG':	XMLConfig=xmlDoc;processConfig();getXMLfiles();break;
		    	    	    case 'QUIZ': processQuiz(xmlDoc);   	    	break;
	    		    	    case 'ARTICLE':	processArticleDoc(xmlDoc);   	    	break;
	    		    	    case 'SYSTEM':	processArticleDoc(xmlDoc,popupwin2);   	    	break;
						default:
							docparams=getHashEntries('HTTPFile','id',rssfile[0],true);
							if (docparams.length > 0)
								eval('processDoc(xmlDoc,docparams,' + docparams.item[0].params + ')');
							else
								processArticleDoc(xmlDoc);}
				     	   	break;
	             case 404:	alert("THE FILE WAS NOT FOUND: " + URL);					break;
            	 case 500:	alert('500 Internal Error' + xmlhttp.responseText);		break;
				default:	alert('Unknown error'); 		break;}
		}
	}
//							if (sess.logins==1){
//								if(sess.isSafari || sess.isOpera){
//									welcometext = (new XMLSerializer()).serializeToString(welcomemessage);
//									xmlDocttext = (new XMLSerializer()).serializeToString(xmlDoc);
//									xmlDocttext = xmlDocttext.replace('</webMaster>','</webMaster>'+ welcometext);
//									xmlDoc=getXMLDoc(xmlDocttext);}}
//							if (sess.logins==1)
//								xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].insertBefore(welcomemessage,testnode);
//							else{
//							if (sess.upgrade==true)
//								xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].insertBefore(upgrademessage,xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].getElementsByTagName('webMaster')[0]);
//							if (sess.showannouncement==true)
//								xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].insertBefore(announcementmessage,xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].getElementsByTagName('webMaster')[0]);
//							}
//							if (sess.logins==1)
//								xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].insertBefore(welcomemessage,xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].getElementsByTagName('webMaster')[0]);
//							else{
//							if (sess.upgrade==true)
//								xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].insertBefore(upgrademessage,xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].getElementsByTagName('webMaster')[0]);
//							if (sess.showannouncement==true)
//								xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].insertBefore(announcementmessage,xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].getElementsByTagName('webMaster')[0]);
//							}
//							xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0].appendChild(welcomemessage);						
//							xmlDoc.appendChild(welcomemessage);						
// use a local variable to hold our request and callback until the inner function is called...
//getResponseHeader
var xmlhttp=null; 
xmlhttp=getHTTPrequest();
xmlhttp.onreadystatechange=ajaxBindCallback;
xmlhttp.open(type, URL, true);
if (type == 'POST'){
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	if (!sess.isSafari)
		xmlhttp.setRequestHeader("Content-length", parameters.length);
	xmlhttp.setRequestHeader("Connection", "close");}
xmlhttp.send(parameters);} 

//******************************************************
function getXMLDOMver(){
//******************************************************
//domversions=['MSXML2.DOMDocument.5.0','MSXML2.DOMDocument.4.0','MSXML2.DOMDocument.3.0','MSXML2.DOMDocument','Microsoft.XmlDom']
domversions=['MSXML2.DOMDocument.4.0','MSXML2.DOMDocument.3.0','MSXML2.DOMDocument','Microsoft.XmlDom'];
if(sess.isIE)
	for(x=0; x < domversions.length; x++)
		try	{	var XMLDOM=new ActiveXObject(domversions[x]);
				XMLDOM.async=false;
				return(domversions[x]);
			} catch (error)	{}}

//******************************************************
function getXMLDoc(doc){
//******************************************************
if(sess.isIE)
{	XMLDOM=new ActiveXObject(XMLDOMver);XMLDOM.async=false;XMLDOM.loadXML(doc);return(XMLDOM);}
else
	parser=new DOMParser(); 
return(parser.parseFromString(doc,'text/xml'));}

//******************************************************
function makeArticleDate(ccyymmdd,hhmm){
//******************************************************
articledate=new Date();
articleccyy=ccyymmdd.substring(0,4);
articlemm=ccyymmdd.substring(4,6) -1;
articledd=ccyymmdd.substring(6);
articlehh=hhmm.substring(0,2);
articlemins=hhmm.substring(2);
articledate.setFullYear(articleccyy,articlemm,articledd);
datedesc='Last updated: ' + makedatedesc(articleccyy,articlemm,articledd,articledate.getDay()) + ', ' + articlehh + ':' + articlemins  + 'GMT';
return(datedesc);}

//******************************************************
function getHashEntries(nodename,attributename,attribute,single){
//******************************************************
hashObj=new Object();
hashObj.length = 0;
hashObj.item = new Array();
var hashentries=ConfigHashTable.getElementsByTagName(nodename);
for(x=0; x< hashentries.length; x++)
	if ((isEmpty(attributename)) || (hashentries[x].getAttribute(attributename) == attribute)){
		itemobj = new Object;
		for(y=0; y<hashentries[x].attributes.length;y++){
			evalstr="itemobj."+hashentries[x].attributes[y].nodeName+"='" + hashentries[x].attributes[y].nodeValue + "'";
			eval(evalstr);				}
			itemobj.innerText=hashentries[x].childNodes[0].nodeValue;
			hashObj.item[hashObj.length] =itemobj;
		hashObj.length++;;
		if (single)
			x=hashentries.length+1;	}
return(hashObj);}

//******************************************************
function processConfig(){
//******************************************************
announcementno='';
if (sess.dateoverride == '')
	editiondate = getNodeValue(XMLConfig,'date');
else
	editiondate =sess.dateoverride;

todaysdatestring = getNodeValue(XMLConfig,'date');


ConfigHashTable=getXMLDoc(getNodeValue(XMLConfig,'ConfigHashTable'));
noofweatheritems=getNodeValue(XMLConfig,'noofweatheritems');
systemwincontents = getNodeValue(XMLConfig,'head') + getNodeValue(XMLConfig,'style') + getNodeValue(XMLConfig,'systembody') + getNodeValue(XMLConfig,'foot');
articlewincontents = getNodeValue(XMLConfig,'head') + getNodeValue(XMLConfig,'style') + getNodeValue(XMLConfig,'body') + getNodeValue(XMLConfig,'foot');
quizwincontents = getNodeValue(XMLConfig,'head') + getNodeValue(XMLConfig,'style') + getNodeValue(XMLConfig,'body') + getNodeValue(XMLConfig,'quizbody') + getNodeValue(XMLConfig,'foot');
welcomemessage = XMLConfig.getElementsByTagName('welcomeRSS')[0].childNodes[0];
configwincontents = getNodeValue(XMLConfig,'head') + getNodeValue(XMLConfig,'style') + getNodeValue(XMLConfig,'configbody') + getNodeValue(XMLConfig,'foot');
contactwincontents = getNodeValue(XMLConfig,'head') + getNodeValue(XMLConfig,'style') + getNodeValue(XMLConfig,'contactbody') + getNodeValue(XMLConfig,'foot');
livesiteroot = getNodeValue(XMLConfig,'livesiteroot');


sitename = getNodeValue(XMLConfig,'sitename');

if (isRSS)
	sitename = "emanac.com";
	
version = getNodeValue(XMLConfig,'version');


if (isRSS)
	finishrssinit();
else
	finishinit();


if (XMLConfig.getElementsByTagName('announcementRSS').length){
	announcementno = XMLConfig.getElementsByTagName('announcementRSS')[0].getAttribute('ver');
	announcementmessage = XMLConfig.getElementsByTagName('announcementRSS')[0].childNodes[0];}

if (XMLConfig.getElementsByTagName('upgradeRSS').length)
	upgrademessage = XMLConfig.getElementsByTagName('upgradeRSS')[0].childNodes[0];

if (sess.logins>0){
	if (!isEmpty(announcementno)){
		if (sess.announcementno!=announcementno)
			{sess.showannouncement=true;createCookie('a',announcementno);}
		else{
			sess.showannouncement=false;
			if (sess.version == version)
				sess.upgrade=false;
			else
				sess.upgrade=true;}	}
	else
		if (sess.version == version)
			sess.upgrade=false;
		else
			sess.upgrade=true;
}
else
	{	sess.upgrade=false;
		sess.version = version;
		createCookie('b',sess.version);}

sess.logins = parseInt(sess.logins,10)+1;
createCookie('c',sess.logins);	

sess.launchdate = getNodeValue(XMLConfig,'launchdate');

sess.currentedition = sess.today.dateDiff(sess.launchdate,sess.ccyy+''+sess.realmm+''+sess.dd)+1;
sess.edition = sess.currentedition;

if (targetwin==self && isRSS==false)
	targetwin.document.getElementById('edition').innerHTML='Edition:'+sess.currentedition;

document.title=document.title + ' v' + sess.version;}

//******************************************************
function processQuiz(xmlDoc){
//******************************************************
var quiznode		=createNode('div','');

targetwin.document.title=getNodeValue(xmlDoc,'title');
targetwin.document.getElementById('headline').innerHTML=getNodeValue(xmlDoc,'title');

//targetwin.document.getElementsByTagName("body")[0].style.background = "black"; 

if(xmlDoc.getElementsByTagName('header')[0].getElementsByTagName('enclosure').length){
	newnode=showimage('',xmlDoc.getElementsByTagName('header')[0].getElementsByTagName('enclosure')[0],'stylequizheader');
	targetwin.document.getElementById('quizintroductionimg').innerHTML=newnode.innerHTML;}

targetwin.document.getElementById('quizintroductiondesc').innerHTML=getNodeValue(xmlDoc,'description');

var items=xmlDoc.getElementsByTagName('item');
z=0;
for(x=0; x < items.length; x++){
	var newnode=createNode('div','stylequizitem');
	var newnode2=createNode('div','stylequizquestionbox');
	newnode2.appendChild(createNode('div','styledecoright'+z));
	newnode2.appendChild(createNode('div','styledecoleft'+z));
	newnode2.appendChild(createNode('div','stylequizitemno',x+1));	
	newnode2.appendChild(createNode('div','stylequizquestion','&nbsp;' + getNodeValue(items[x],'question')));	

newnode.appendChild(newnode2);
z++; 
if (z>3) z=0;

var newnode2=createNode('div','stylequizexplanationblock','','explanation-'+x);
var newnode3=createNode('div','stylequizexplanationdetail');

newnode3.appendChild(createNode('div','stylequizscorebox','','quizscorebox-'+x));	

if(haschildnodes(items[x],'explanation'))
	newnode3.appendChild(createNode('div','stylequizexplanation',getNodeValue(items[x],'explanation'),'explanation-'+x));
else
	newnode3.appendChild(createNode('div','stylequizexplanation','' ,'explanation-'+x));

if(items[x].getElementsByTagName('explanation')[0].getElementsByTagName('enclosure').length){
	var newnode4 = createNode('div','stylequizexplanationpicblock');
	newnode4=showimage(newnode4,items[x].getElementsByTagName('explanation')[0].getElementsByTagName('enclosure')[0],'stylequiz');
	newnode3.appendChild(newnode4);}

newnode2.appendChild(newnode3);	
newnode.appendChild(newnode2);
	
if(items[x].getElementsByTagName('question')[0].getElementsByTagName('enclosure').length){

	var newnode2 = createNode('div','stylequizpicblock');
	newnode2=showimage(newnode2,items[x].getElementsByTagName('question')[0].getElementsByTagName('enclosure')[0],'stylequiz');
	newnode.appendChild(newnode2);}

var newnode2		=createNode('div','stylequizchoices');
var choices=items[x].getElementsByTagName('choice');

for(y=0; y < choices.length; y++){
	var newnode3		=createNode('div','stylequizchoice');
	if(choices[y].getAttribute('answer')=='true'){
		quizanswers[x]='radio-' + x + '-' + y;
		newnode3.appendChild(createNode('div','stylequizsmalltick','','quizscoretickbox-'+x+'-'+y));	}
	else
		newnode3.appendChild(createNode('div','stylequizscoretickbox','','quizscoretickbox-'+x+'-'+y));	
		newnode3.appendChild(createinputnode('radio','stylequizinput','radio-'+x,'radio-' + x + '-' + y));
		newnode3.appendChild(createNode('div','stylequizchoiceid',choices[y].getAttribute('id') + ')&nbsp;&nbsp;&nbsp;'));	
		newnode3.appendChild(createNode('div','stylequizchoicetext',choices[y].childNodes[0].nodeValue));	
		newnode2.appendChild(newnode3);}

newnode.appendChild(newnode2);
quiznode.appendChild(newnode);}

targetwin.document.getElementById('quiz').innerHTML=quiznode.innerHTML;
quiztotalquestions=x; 

var sourcesnode		=createNode('div','');
var articlefootnotes=xmlDoc.getElementsByTagName('footnotes');

if(articlefootnotes.length)	
	targetwin.document.getElementById('sources').innerHTML=getFooterLinks(articlefootnotes[0]).innerHTML;	}

//******************************************************
function createinputnode(inputtype,inputclassname,inputname,inputvalue){
//******************************************************
if(sess.isIE)
	var newnode=document.createElement('<input class="' + inputclassname + '" name="' + inputname  + '" value="'  + inputvalue + '" type="' + inputtype + '"></input>');
else{
	var newnode=createNode('input',inputclassname);
	newnode.setAttribute('value',inputvalue);
	newnode.setAttribute('type',inputtype);
	newnode.setAttribute('name',inputname);}
return(newnode);}

//******************************************************
function getsequenceno(){
//******************************************************
pageaddress=sess.a.split('/');
filename=pageaddress[pageaddress.length-1].split('.');
partno=filename[0].split('-');
partno = partno[partno.length-1];
return(partno);}

//******************************************************
function showconfigchange(){
//******************************************************
popupwin2.document.getElementById('styleitem').style.fontFamily = 
getfontfamily(popupwin2.document.getElementById('fontfamilymenu')[popupwin2.document.getElementById('fontfamilymenu').selectedIndex].value);
popupwin2.document.getElementById('styleitem').style.fontSize = 
getfontsize(popupwin2.document.getElementById('fontsizemenu')[popupwin2.document.getElementById('fontsizemenu').selectedIndex].value);
themecolor= getthemecolor(popupwin2.document.getElementById('thememenu')[popupwin2.document.getElementById('thememenu').selectedIndex].value);
themebackground= getthemebackground(popupwin2.document.getElementById('thememenu')[popupwin2.document.getElementById('thememenu').selectedIndex].value);
showconfigitem(themecolor,themebackground);

popupwin2.document.getElementById('fontfamilymenu').blur();
popupwin2.document.getElementById('fontsizemenu').blur();
popupwin2.document.getElementById('thememenu').blur();
popupwin2.document.getElementById('thememenu').className='styletheme' + popupwin2.document.getElementById('thememenu').selectedIndex;}

//******************************************************
function showconfigitem(themecolor,themebackground){
//******************************************************
popupwin2.document.getElementById('styleitemheadanchor').style.color  = themecolor;
popupwin2.document.getElementById('styleitemheadanchor').style.background  = themebackground;
popupwin2.document.getElementById('styleitemheadanchor').style.borderColor  = themebackground;
popupwin2.document.getElementById('styleitem').style.borderColor  = themebackground;
popupwin2.document.getElementById('styleitemhead').style.borderColor  = themebackground;
popupwin2.document.getElementById('styleitemhead').style.background  = themebackground;}

//******************************************************
function defaultconfig(){
//******************************************************
popupwin2.document.getElementById('styleitem').style.fontFamily = 
getfontfamily(popupwin2.document.getElementById('fontfamilymenu')[0].value);
popupwin2.document.getElementById('styleitem').style.fontSize = 
getfontsize(popupwin2.document.getElementById('fontsizemenu')[0].value);
themecolor=getthemecolor(popupwin2.document.getElementById('thememenu')[0].value);
themebackground=getthemebackground(popupwin2.document.getElementById('thememenu')[0].value);
showconfigitem(themecolor,themebackground);
popupwin2.document.getElementById('fontsizemenu').selectedIndex = 0;
popupwin2.document.getElementById('fontfamilymenu').selectedIndex = 0;
popupwin2.document.getElementById('thememenu').selectedIndex = 0;
popupwin2.document.getElementById('thememenu').className='styletheme0';}

//******************************************************
function saveconfig(){
//******************************************************
sess.fontfamily=popupwin2.document.getElementById('fontfamilymenu')[popupwin2.document.getElementById('fontfamilymenu').selectedIndex].value;
sess.fontsize=popupwin2.document.getElementById('fontsizemenu')[popupwin2.document.getElementById('fontsizemenu').selectedIndex].value;
sess.themecolor=popupwin2.document.getElementById('thememenu')[popupwin2.document.getElementById('thememenu').selectedIndex].value;
sess.themebackground=popupwin2.document.getElementById('thememenu')[popupwin2.document.getElementById('thememenu').selectedIndex].value;
sess.themebackground=popupwin2.document.getElementById('thememenu')[popupwin2.document.getElementById('thememenu').selectedIndex].value;
sess.country=popupwin2.document.getElementById('countrymenu')[popupwin2.document.getElementById('countrymenu').selectedIndex].value;
document.getElementsByTagName('body')[0].style.fontSize=getfontsize(sess.fontsize);
document.getElementsByTagName('body')[0].style.fontFamily=getfontfamily(sess.fontfamily);

createCookie('e',sess.fontsize);
createCookie('d',sess.fontfamily);
createCookie('f',sess.themecolor);
createCookie('g',sess.themebackground);
createCookie('i',sess.country);

setCSSRules();

popupwin2.close();
if (!sess.isIE) document.location.href = document.location.href;}

//******************************************************
function changearticle(targetarticle){
//******************************************************
if (targetarticle == 'prev')
	showarticle('sequence-0',true,false);
else
	if (targetarticle == 'next')
		showarticle('sequence-1',true,false);
else
	showarticle('sequence-' + targetwin.document.getElementById('articlemenu')[targetwin.document.getElementById('articlemenu').selectedIndex].value,true,false);
targetwin.document.getElementById('articlemenu').blur();}

//******************************************************
function createarticlemenu(noofparts,partnames,frequency,articlecategory){
//******************************************************
sequencefilename=getsequencefilename();
if (!isEmpty(partnames))
	partname = partnames.split(',');

sequenceno = getsequenceno();

for(x=0;x<noofparts;x++){
	var anOption = targetwin.document.createElement("option"); 
	anOption.value = articlelinksub; 
	articlelink[articlelinksub++]=(sequencefilename+'-'+x+'.xml');
	targetwin.document.getElementById('articlemenu').options.add(anOption); 

	if 	(isEmpty(partnames))
		anOption.innerHTML = 'Part ' + parseInt(x+1,10);
	else
		anOption.innerHTML = partname[x];
	if (x==sequenceno)
		anOption.selected = true;}}
		
//******************************************************
function processArticleDoc(xmlDoc,win){
//******************************************************

var resizevid = "true";	

if (isEmpty(win))win = targetwin;

articlelinksub=0;
noteidsub=0;

var articlenode=createNode('div','articlebody');
var containerdiv=createNode('div','');
// PARTS
noofparts = xmlDoc.getElementsByTagName('item')[0].getAttribute('parts');
if (isEmpty(noofparts)){
// we see if its a periodical publication
//	frequency = getfilefrequency();
//	if (frequency =='m' || frequency =='d' || frequency =='w')
//		periodicaltitle = getperiodicaltitle();
//	createarticlemenu(noofparts,partnames,);
}	
else{	
	if (noofparts>0){
		partnames = xmlDoc.getElementsByTagName('item')[0].getAttribute('partnames');
		if (isEmpty(partnames))
			createarticlemenu(noofparts);
		else	
			createarticlemenu(noofparts,partnames);

	win.document.getElementById('articlemenudiv').style.display='block';}
}

if(xmlDoc.getElementsByTagName('nav')[0]){
rsspref='';
//if (isRSS)
//	rsspref = 'rss';
	
	articlelink[articlelinksub++]=rsspref+'article/?a='+getNodeValue(xmlDoc,'navprev');
	articlelink[articlelinksub++]=rsspref+'article/?a='+getNodeValue(xmlDoc,'navnext');

win.document.getElementById('navdesc').innerHTML = getNodeValue(xmlDoc,'navdesc');
win.document.getElementById('articlenavdiv').style.display='block';}

win.document.getElementById('headline').innerHTML=getNodeValue(xmlDoc,'headline');

if(haschildnodes(xmlDoc,'subheadline'))	articlenode.appendChild(createNode('div','stylesubheadline',getNodeValue(xmlDoc,'subheadline')));	

win.document.title=getNodeValue(xmlDoc,'title');
if(haschildnodes(xmlDoc,'author')){
	authorline='By: ' + getNodeValue(xmlDoc,'author');
	if(haschildnodes(xmlDoc,'authortitle'))
		authorline=authorline + ' (' + getNodeValue(xmlDoc,'authortitle') + ' )';
	articlenode.appendChild(createNode('div','author',authorline));	}

//parastyle='firstpara';

parastyle='para';

var articlebody=xmlDoc.getElementsByTagName('article')[0];
noofitems = articlebody.childNodes.length;

for(x=0; x < noofitems; x++)	{
	if(!isEmpty(articlebody.childNodes[x].hasChildNodes())){

		var paranode	=createNode('p',parastyle);

		if(!isEmpty(articlebody.childNodes[x].getAttribute('heading')))
				articlenode.appendChild(createNode('h2','stylesubheading',articlebody.childNodes[x].getAttribute('heading')));	

		if(!isEmpty(articlebody.childNodes[x].getAttribute('label')))
				paranode.appendChild(createNode('strong','',articlebody.childNodes[x].getAttribute('label')+': '));	
		
		noofsubitems = articlebody.childNodes[x].childNodes.length; 				
		
		for(y=0; y<noofsubitems; y++){

			var articlechildnode=articlebody.childNodes[x].childNodes[y];
			switch (articlechildnode.tagName) {
    	         case 'enclosure':
			 			switch (articlechildnode.getAttribute('type')){
							 case 'html':
								htmlcode = 	getNodeValue(xmlDoc,'inlinehtml');

							if(isRSS)
							{	htmlcode=htmlcode.replace(/opener./g,'');
								htmlcode=htmlcode.replace(/,self/g,'');	}
								articlenode.appendChild(createNode('inlinehtml','',htmlcode));	

							break;
							 case 'table':
								var newnode				=createNode('blockquote','');
								var newnode2			=createNode('table','articletable');
								var articletablelines	=articlechildnode.getElementsByTagName('tr');
 								for(trsub=0; trsub < articletablelines.length; trsub++){
									var newnode3 =createNode('tr','articletd');
									var articletabletds=articletablelines[trsub].getElementsByTagName('td');
	 								for(tdsub=0; tdsub < articletabletds.length; tdsub++)
										newnode3.appendChild(createNode('td','articletr',articletabletds[tdsub].childNodes[0].nodeValue));
									newnode2.appendChild(newnode3);}
									newnode.appendChild(newnode2);
								articlenode.appendChild(newnode);	
								break;

							 case 'inlineimage':
								var newnode		=createNode('div','inlineimgdiv');

								var newnode2	=createImgNode('img','largeimg',articlechildnode.getAttribute('src'),articlechildnode.getAttribute('width'), 
												articlechildnode.getAttribute('height'),articlechildnode.getAttribute('alt'));
								newnode.appendChild(newnode2);	
								articlenode.appendChild(newnode);	
								break;
							 case 'image':articlenode.appendChild(showimage('',articlechildnode,''));break;
							 case 'listpanel':
								var newnode			=createNode('div','listpanel');
								if(!isEmpty(articlechildnode.getAttribute('heading')))
									newnode.appendChild(createNode('div','listpaneltitle',articlechildnode.getAttribute('heading')));	
									var newnode2		=createNode('ul','listpanellist');
								var articleListitems=articlechildnode.getElementsByTagName('li');
 								for(z=0; z < articleListitems.length; z++)	{
									var newnode3		=createNode('li','listitemtitle',articleListitems[z].getAttribute('title'));
									if(articleListitems[z].hasChildNodes())
										newnode3.appendChild(createNode('div','listitemdesc',articleListitems[z].childNodes[0].nodeValue));																			
									newnode2.appendChild(newnode3);	
									newnode.appendChild(newnode2);	}
									
								if(!isEmpty(articlechildnode.getAttribute('attribution')))
									newnode.appendChild(createNode('div','listattribution',articlechildnode.getAttribute('attribution')));	

									articlenode.appendChild(newnode);	
								break;
 							case 'audio':
								resizevid = "false";	
							case 'video':
								var newnode				=createNode('div','largeimgdiv');
								newnode.innerHTML  		= createVideoNode(articlechildnode.getAttribute('src'),articlechildnode.getAttribute('img'),
								articlechildnode.getAttribute('width'),	articlechildnode.getAttribute('height'),resizevid);
								articlenode.appendChild(newnode);	
								break;

							 case 'largeimage':
								var newnode		=createNode('div','largeimgdiv');
								var newnode2	=createImgNode('img','largeimg',articlechildnode.getAttribute('src'),articlechildnode.getAttribute('width'), 
												articlechildnode.getAttribute('height'),articlechildnode.getAttribute('alt'));
								newnode.appendChild(newnode2);
								if(!isEmpty(articlechildnode.getAttribute('attribution')))
									newnode.appendChild(createNode('div','articleimgattribution',articlechildnode.getAttribute('attribution')));	
								if(!isEmpty(articlechildnode.getAttribute('title')))
									newnode.appendChild(createNode('div','articleimgattribution',articlechildnode.getAttribute('title')));	
									
								articlenode.appendChild(newnode);	
								break;


							 case 'textpanel':
								var newnode=createNode('div','textpanel');
								newnode.appendChild(createNode('div','textpaneltext', '"' + articlechildnode.childNodes[0].nodeValue + '"'));	

								if(!isEmpty(articlechildnode.getAttribute('attribution')))
									newnode.appendChild(createNode('div','textpanelattribution',articlechildnode.getAttribute('attribution')));	
								articlenode.appendChild(newnode);	
								break;

							case 'verse':
								var versetext = '"';
								var articleLineitems=articlechildnode.getElementsByTagName('line');
								if (articleLineitems.length == 0)
									var articleLineitems=articlechildnode.getElementsByTagName('l');
								
								var linebreak = '';
 								for(z=0; z < articleLineitems.length; z++){
									versetext +=  linebreak + articleLineitems[z].childNodes[0].nodeValue;
									linebreak = '<br />';}
								versetext += '"';
								var newnode=createNode('blockquote','');
								var newnode2=createNode('div','verse',versetext);

								versetitle = 	articlechildnode.getAttribute('title');
								if (!isEmpty(versetitle))
									newnode.appendChild(createNode('div','versetitle',versetitle));
								
								attribution = 	articlechildnode.getAttribute('attribution');
								if (!isEmpty(attribution))
									newnode2.appendChild(createNode('div','verseattribution',attribution));	

								newnode.appendChild(newnode2);	
								articlenode.appendChild(newnode);
								break;
					case 'blockquote':
							var newnode=createNode('blockquote','');
								blockquotetitle = 	articlechildnode.getAttribute('title');
								if (!isEmpty(blockquotetitle))
									newnode.appendChild(createNode('div','blockquotetitle',blockquotetitle));

							var articleparaitems=articlechildnode.getElementsByTagName('p');

							for(z=0; z < articleparaitems.length; z++){
								var newnode2=createNode('p','');

								for(nodessub=0;nodessub<articleparaitems[z].childNodes.length;nodessub++)
									if (isEmpty(articleparaitems[z].childNodes[nodessub].nodeValue))
										newnode2.appendChild(createNode(articleparaitems[z].childNodes[nodessub].tagName,'', ' ' +   articleparaitems[z].childNodes[nodessub].childNodes[0].nodeValue + ' '));	
									else
										newnode2.appendChild(createNode('span','',  articleparaitems[z].childNodes[nodessub].nodeValue));	
								newnode.appendChild(newnode2);}

								attribution = 	articlechildnode.getAttribute('attribution');
								if (!isEmpty(attribution))
									newnode.appendChild(createNode('div','blockquoteattribution',attribution));	
							articlenode.appendChild(newnode);
							break;
					case 'list': case 'numberedlist':
							var newnode=createNode('blockquote','');

						if (articlechildnode.getAttribute('type') == 'list')
							var newnode2=createNode('ul','');
						else
							var newnode2=createNode('ol','');

							var articlelistitems=articlechildnode.getElementsByTagName('li');

							for(listsub=0; listsub < articlelistitems.length; listsub++){
								listtext='';
								var articleLineitems=articlelistitems[listsub].getElementsByTagName('l');
								var linebreak = '';

								for(z=0; z < articleLineitems.length; z++){
									listtext +=  linebreak + articleLineitems[z].childNodes[0].nodeValue;
									linebreak = '<br />';}
									newnode2.appendChild(createNode('li','',listtext));}

							newnode.appendChild(newnode2);
							articlenode.appendChild(newnode);}
						break;		

				case 'note':
						var noteLineitems=articlechildnode.getElementsByTagName('l');
						var newnode=createNode('span','stylenote');
						var notetext = '';
						var linebreak = '';
						if(isRSS)
							newnode.innerHTML="<span class=\"stylearticlenotelink\"  onmouseout=\"hidenote('note" + noteidsub + "');\" onmouseover=\"shownote('note" + noteidsub + "')\"><img src=\"/i/info.jpg\" /></span>&nbsp;"; 
						else
							newnode.innerHTML="<span class=\"stylearticlenotelink\"  onmouseout=\"opener.hidenote('note" + noteidsub + "');\" onmouseover=\"opener.shownote('note" + noteidsub + "')\"><img src=\"/i/info.jpg\" /></span>&nbsp;"; 

						paranode.appendChild(newnode);	
						
						for(z=0; z < noteLineitems.length; z++){
							notetext +=  linebreak + noteLineitems[z].childNodes[0].nodeValue;
									linebreak = '<br />';}

						paranode.appendChild(createNode('span','stylearticlenote',notetext,'note' + noteidsub++));	
						break;	

				case 'note2':
						var newnode=createNode('span','stylenote');
						if(isRSS)
							newnode.innerHTML=" <span class=\"stylearticlenotelink\"  onmouseout=\"hidenote('note" + noteidsub + "');\" onmouseover=\"shownote('note" + noteidsub + "')\"><img src=\"/i/info.jpg\" /></span> "; 
						else
							newnode.innerHTML=" <span class=\"stylearticlenotelink\"  onmouseout=\"opener.hidenote('note" + noteidsub + "');\" onmouseover=\"opener.shownote('note" + noteidsub + "')\"><img src=\"/i/info.jpg\" /></span> "; 
						paranode.appendChild(newnode);	

						
						paranode.appendChild(createNode('span','stylearticlenote',articlechildnode.childNodes[0].nodeValue,'note' + noteidsub++));	
						break;	
						
				case 'a':
					var newnode=createNode('a','stylelink');
					if (articlechildnode.getAttribute('target')== 'system')
							newnode.setAttribute('href',"javascript:opener.showsystemarticle('" + articlechildnode.getAttribute('href') + "')");
					else{
						if (articlechildnode.getAttribute('target')== 'external')
							if(isRSS)
								newnode.setAttribute('href',"javascript:showexternalwindow('article-" + articlelinksub + "')");
							else
								newnode.setAttribute('href',"javascript:opener.showexternalwindow('article-" + articlelinksub + "')");
						else
							if(isRSS)
								newnode.setAttribute('href',"javascript:showarticle('article-" + articlelinksub + "',true)");
							else
								newnode.setAttribute('href',"javascript:opener.showarticle('article-" + articlelinksub + "',true)",1);}
					newnode.innerHTML=' ' + articlechildnode.childNodes[0].nodeValue + ' ';
					paranode.appendChild(newnode);	
					articlelink[articlelinksub++]=articlechildnode.getAttribute('href').replace(livesiteroot,'').replace('rss','');
					break;
					
				case 'em':	case 'strong': case 'sup':
					paranode.appendChild(createNode(articlechildnode.tagName,'', ' ' + articlechildnode.childNodes[0].nodeValue + ' '));	
					break;

				 case 'source':	paranode.appendChild(createNode('i','articlesource',' ' + articlechildnode.childNodes[0].nodeValue  + ' '));break;
				 
				 case 'quote':
					var newnode=createNode('i','');
					newnode.innerHTML=' "' + articlechildnode.childNodes[0].nodeValue + '" ';
					attribution = 	articlechildnode.getAttribute('attribution');
					if (!isEmpty(attribution))
						newnode.innerHTML=newnode2.innerHTML+ ' - ' + attribution;
					paranode.appendChild(newnode);
					break;
				 case 'email':
					var newnode=createNode('a','stylelink');
					newnode.setAttribute('href','mailto:'+articlechildnode.getAttribute('address'));
					newnode.innerHTML=' ' + articlechildnode.childNodes[0].nodeValue + ' ';
					paranode.appendChild(newnode);	
				default:
					paranode.appendChild(createNode('span','',articlechildnode.nodeValue));	}
								}
					articlenode.appendChild(paranode);		
					parastyle='para';
						}
}
containerdiv.appendChild(articlenode);
var articlefootnotes=xmlDoc.getElementsByTagName('footnotes');
if(articlefootnotes.length)	containerdiv.appendChild(getFooterLinks(articlefootnotes[0]));
win.document.getElementById('article').innerHTML=containerdiv.innerHTML;}

//******************************************************
function createNode(nodetype,nodeclass,nodeinnerHTML,nodeId){
//******************************************************
var newnode=document.createElement(nodetype);
if(!isEmpty(nodeclass))newnode.setAttribute(classNAME,nodeclass);
if(!isEmpty(nodeinnerHTML))newnode.innerHTML=nodeinnerHTML;
if(!isEmpty(nodeId))newnode.setAttribute('id',nodeId);
return(newnode);}

//******************************************************
function createImgNode(nodetype,nodeclass,nodesrc,nodewidth,nodeheight,nodealt){
//******************************************************
nodesrc=nodesrc.replace(livesiteroot,'/');
if (nodesrc.charAt(0) != '/')
	nodesrc = '/'+nodesrc;
var newnode=document.createElement(nodetype);
newnode.setAttribute('src', nodesrc);
newnode.setAttribute('width', nodewidth);
newnode.setAttribute('height', nodeheight);
newnode.setAttribute('alt', nodealt);
if(!isEmpty(nodeclass))newnode.setAttribute(classNAME,nodeclass);
return(newnode);}	


//******************************************************
function createVideoNode(vidloc,vidimgloc,vidwidth, vidheight,vresize){
//******************************************************
//	'<param name="movie" value="player.swf?volume=90&skin=snel.swf&file=' + vidloc + '&image=' + vidimgloc + '" />' + 

if (sess.isFirefox)
	return('<embed type="application/x-shockwave-flash" src="player.swf" id="ply" name="ply" bgcolor="#FFFFFF" quality="high" allowfullscreen="true" allowscriptaccess="always" wmode="window" menu="false" flashvars="skin=snel.swf&file=' + vidloc +  '&image=' + vidimgloc  + '" width="' + vidwidth + '" height="' + vidheight + '">');
else
	return(	'<object id="ply" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="' + vidheight + '" width="' + vidwidth + '" >'+
	'<param name="movie" value="player.swf?file=' + vidloc + '&image=' + vidimgloc + '" />' + 
	'<param name="bgcolor" value="#ffffff" />' + 
	'<param name="quality" value="high" />' + 
	'<param name="allowfullscreen" value="'  + vresize + '" />' + 
	'<param name="allowscriptaccess" value="always" />' + 
	'<param name="wmode" value="window" />' + 
	'<param name="menu" value="false" />' + 
	'</object>'); 
}













//******************************************************
function createVideoNode2(vidloc,vidimgloc,vidwidth, vidheight,vresize){
//******************************************************
//	'<param name="FlashVars" value="file=' + vidloc + '&image=' + vidimgloc + '">' + 
//	'<param name="FlashVars" value="file=/a/video/v/vid1.flv">' + 
//	'<param name="Movie" value="/player.swf" >' + 
///a/video/v/vid1.flv

if (sess.isIE)
return(	'<object id="ply" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="' + vidheight + '" width="' + vidwidth + '" >'+
	'<param name="movie" value="player.swf?volume=90&skin=snel.swf&file=' + vidloc + '&image=' + vidimgloc + '" />' + 
	'<param name="bgcolor" value="#ffffff" />' + 
	'<param name="quality" value="high" />' + 
	'<param name="allowfullscreen" value="'  + vresize + '" />' + 
	'<param name="allowscriptaccess" value="always" />' + 
	'<param name="wmode" value="window" />' + 
	'<param name="menu" value="false" />' + 
	'</object>'); 

return('<embed type="application/x-shockwave-flash" src="player.swf" id="ply" name="ply" bgcolor="#FFFFFF" quality="high" allowfullscreen="true" allowscriptaccess="always" wmode="window" menu="false" flashvars="skin=snel.swf&file=' + vidloc +  '&image=' + vidimgloc  + '" width="' + vidwidth + '" height="' + vidheight + '">');
}
//******************************************************
function getHTTPrequestver(){
//******************************************************
//var httpversions=['MSXML2.XMLHttp.5.0','MSXML2.XMLHttp.4.0','MSXML2.XMLHttp.3.0','MSXML2.XMLHttp','Microsoft.XMLHttp'];
var httpversions=['MSXML2.XMLHttp.4.0','MSXML2.XMLHttp.3.0','MSXML2.XMLHttp','Microsoft.XMLHttp'];

if(sess.isIE)
for(x=0; x < httpversions.length; x++)
	try	{var HTTPver=new ActiveXObject(httpversions[x]);return(httpversions[x]);} catch (error)	{}}

//******************************************************************************************************************************************
function showarticle(articleloc,fromarticle){
//******************************************************************************************************************************************

sess.articlesread = parseInt(sess.articlesread,10) + 1;
sess.thissessionarticlesread = parseInt(sess.thissessionarticlesread,10) + 1;
createCookie('j',sess.articlesread);
createCookie('k',sess.articlesread);
var articlesplit=articleloc.split('-');

if (fromarticle){
	if (articlelink[articlesplit[1]].indexOf("sys.xml")!=-1){

		intarticleloc = articlelink[articlesplit[1]].split('=');
		showsystemarticle(encodeURI(intarticleloc[1]));	}
	else	
		popupwin=popUpWin(encodeURI(articlelink[articlesplit[1]]) ,640,screen.height,true,popupwin);}
else{
	if (headlinelink[articlesplit[1]].indexOf("sys.xml")!=-1){
		intarticleloc = headlinelink[articlesplit[1]].split('=');
		showsystemarticle(encodeURI(intarticleloc[1]));		}
	else			
// we check to see if it is a standard article
//	if (headlinelink[articlesplit[1]].indexOf("article/?a=")!=-1)
//		popupwin=popUpWin(encodeURI(headlinelink[articlesplit[1]]) ,640,screen.height,true,popupwin);	
//	else		
//		showhomepageexternalwindow(encodeURI(headlinelink[articlesplit[1]]));}}

	if (headlinelink[articlesplit[1]].indexOf("article/?a=")==-1 && headlinelink[articlesplit[1]].indexOf("quiz/?a=")==-1)
		showhomepageexternalwindow(encodeURI(headlinelink[articlesplit[1]]));
	else		
		popupwin=popUpWin(encodeURI(headlinelink[articlesplit[1]]) ,640,screen.height,true,popupwin);}}

//******************************************************************************************************************************************
function showexternalwindow(articleloc){
//******************************************************************************************************************************************
// I commented this to get safari to work if(isEmpty(popupwin)) createCookie('m','s');
sess.clickouts = parseInt(sess.clickouts,10)+1;
createCookie('n',sess.clickouts);	
var articlesplit=articleloc.split('-');

if (articleloc.indexOf("/widget/?article")==-1){
	if (articlesplit.length>1)
		var newwin=targetwin.window.open(encodeURI(articlelink[articlesplit[1]]), "_blank", " toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
	else
		var newwin=targetwin.window.open(encodeURI(articleloc), "_blank", "toolbar=no,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
}
	else
		var newwin=targetwin.window.open(encodeURI(articleloc), "_blank", "toolbar=no,menubar=yes,location=yes,scrollbars=yes,resizable=yes");

newwin.focus();
mclose();}

//******************************************************************************************************************************************
function showhomepageexternalwindow(articleloc){
//******************************************************************************************************************************************
// I commented this to get safari to work if(isEmpty(popupwin)) createCookie('m','s');
sess.clickouts = parseInt(sess.clickouts,10)+1;
createCookie('n',sess.clickouts);	

var articlesplit=articleloc.split('-');
if (articlesplit.length>1)
	var newwin=window.open(encodeURI(articlelink[articlesplit[1]]), "_blank", "height=" + screen.height + ",width=1024 toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
else
	var newwin=window.open(encodeURI(articleloc), "_blank", "height" + screen.height + ",width=1024 toolbar=no,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
newwin.focus();
mclose();}

//******************************************************************************************************************************************
function processDoc(xmlDoc,docparams,showheader,showheadertitle,showheaderdesc,showheaderimg,showitemheadline,showitemarticle,showitemimg,headlink,morelink,showdate){
//******************************************************************************************************************************************
//IMPORTANT DO NOT DELETE stylegroup=getNodeValue(xmlDoc,'title'); 
stylegroup='';

descstylegroup = docparams.item[0].style;

var titlearr=getNodeValue(xmlDoc,'title').split(' ');

targetdiv=docparams.item[0].placeholderid;

document.getElementById(targetdiv).innerHTML='';

var channelnode=xmlDoc.getElementsByTagName('rss')[0].getElementsByTagName('channel')[0];
var items 	=channelnode.getElementsByTagName("item");

//********** Show title
if(showheader){
	var headernode				=createNode('div',stylegroup + 'stylecatheader');
	if(showheadertitle) 
		headernode.appendChild(createNode('div',stylegroup + 'styleheadertitle',getNodeValue(channelnode,'title')));
//********************

//****** show main image
if(channelnode.getElementsByTagName("image").length==0)	showheaderimg=false;
	
if(showheaderimg){
		objmainimg=getRSSimg(channelnode.getElementsByTagName("image")[0]);
		if(objmainimg.img)	{
			var newnode				=createNode('div',stylegroup + 'stylecatheaderimg');
			newnode.appendChild(createImgNode('img','stylecatimg',objmainimg.URL, objmainimg.width, objmainimg.height, objmainimg.title));
			headernode.appendChild(newnode);}
	}

if(showheaderdesc) 	headernode.appendChild(createNode('div',stylegroup + 'styleheaderdesc',getNodeValue(channelnode,'description')));
document.getElementById(targetdiv).appendChild(headernode);
}

noofitems = items.length;

for(x=0; x < noofitems; x++){	
	var newitemnode	=createNode('div',stylegroup + 'styleitem');
	pubDatevalue 	=getNodeValue(items[x],'pubDate');
	titlevalue 		=getNodeValue(items[x],'title');
	if (haschildnodes(items[x],'description'))
		descvalue 		=getNodeValue(items[x],'description');
	else
		descvalue =" ";
 	if(items[x].getElementsByTagName('link').length==0 || !haschildnodes(items[x],'link'))	
		{makemorelink=false;makeheadlink=false;}
	else
	{	newlink = getNodeValue(items[x],'link');
		if (newlink.indexOf("domchn=n")==-1)
			headlinelink[headlineid]=newlink.replace(livesiteroot,'').replace('rss','');
		else
			headlinelink[headlineid]=newlink;
		makemorelink=morelink;
		makeheadlink=headlink;}

	if (showdate) {
		var newnode				=createNode('div', stylegroup + 'styleitemdate');
		newnode.innerHTML 		=makeRSSDate(pubDatevalue);
		newitemnode.appendChild(newnode);}

	if (showitemheadline){
		var newnode				=createNode('div', stylegroup + 'styleitemhead');

	if(makeheadlink){
		var newnode2			=createNode('a',stylegroup + 'styleitemheadanchor',titlevalue,'head-' + headlineid);
		newnode2.onclick=function(){showarticle(this.id)};
		newnode2.setAttribute('href','javascript:void(0)');
		newnode.appendChild(newnode2);}
	else
		newnode.innerHTML 		=titlevalue;
		newitemnode.appendChild(newnode);}

var newnode				=createNode('div',descstylegroup + 'styleitemdescgroup');

if(showitemimg)
	if(items[x].getElementsByTagName("enclosure").length){
		itemenclosure 	=items[x].getElementsByTagName("enclosure")[0];
		if(!isEmpty(itemenclosure.getAttribute('url'))){
			objitemimg=getenclosureimg(itemenclosure);
			if(objitemimg.img)	{	
				var newnode3				=createNode('span', stylegroup + 'styleitemimg');
				newnode3.appendChild(createImgNode('img','', objitemimg.URL, objitemimg.w, objitemimg.h,objitemimg.alt));
				if (objitemimg.t){
					var newnode2	=	createNode('div',stylegroup + 'styleitemimgtitle',objitemimg.t);
						newnode2=setTagStyle(newnode2,'width:'+objitemimg.w+'px;');
						newnode3.appendChild(newnode2);	}
				if(makeheadlink){
					var newnode2			=createNode('a',stylegroup + 'styleitemheadanchor','','img-' + headlineid);
					newnode2.onclick=function(){showarticle(this.id)};
					newnode2.setAttribute('href','javascript:void(0)');
					newnode2.appendChild(newnode3);	
					newnode.appendChild(newnode2);	}
				else
					newnode.appendChild(newnode3);
								}}}

var newnode2				= createNode('div',  stylegroup + 'styleitemdesc', descvalue + ' ');
if(makemorelink)
	{		var newnode3			=createNode('a', stylegroup + 'stylelink','more...','more-' + headlineid);
			newnode3.onclick=function(){showarticle(this.id)};
			newnode3.setAttribute('href','javascript:void(0)');
			newnode2.appendChild(newnode3);}

			
			
newnode.appendChild(newnode2);
newitemnode.appendChild(newnode);
document.getElementById(targetdiv).appendChild(newitemnode);

headlineid++;
}
//alert(document.getElementById(targetdiv).innerHTML);
}

//******************************************************
function homepage(){
//******************************************************
if(isRSS)		
	homepagewin=showrssmainwindow(siteroot);
else
{	if(sess.isIE)
		window.document.focus(); 
	else
		window.focus(); }}

//******************************************************
function systemwininit(){
//******************************************************
getquerystring(popupwin2);
setbodytheme(popupwin2);
makesessQS();
writelogodetails(popupwin2);
makeRequest(siteroot  + sess.a + '?g=' + sess.QS,'','','GET');}

//******************************************************
function ainit(isquiz){
//******************************************************
gettargetwin();
getquerystring(targetwin);
setbodytheme(targetwin);
makesessQS();
if (sess.a.indexOf("sys.xml")!=-1)	targetwin = popupwin2;
writelogodetails(targetwin);
makeRequest(siteroot  + sess.a + '?g=' + sess.QS,'','','GET');}

//******************************************************
function rssinit(){
getdimensions();
if  (document.documentElement.clientWidth > 700)
	self.resizeTo(660 ,screen.height);
isRSS=true;

usersiteroot = siteroot;
makeRequest(siteroot + 'devconfig/?g='+sess.QS,'','','GET');}
function finishrssinit(){
//******************************************************
sess.referer='r';
getOS();
gettargetwin();
getquerystring(targetwin);
initDate(sess);
readCookies();
setbodytheme(targetwin);
//getdimensions();
writelogodetails(targetwin);
makesessQS();
self.focus();
}

//******************************************************
function makesessQS(){
//******************************************************
sess.QS= sess.GUID+'-'
+sess.yymmddhhmmss+ '-'
+sess.isIE+'-'
+sess.OS+'-'
+sess.screenX+'-'
+sess.screenY+'-'
+sess.version+'-'
+sess.logins+'-'
+sess.referer+'-'
+sess.fontfamily+'-'
+sess.fontsize+'-'
+sess.themecolor+'-'
+sess.themebackground+'-'
+sess.country+'-'
+sess.articlesread+'-'
+sess.clickouts+'-'
+sess.lastsessionarticlesread+'-'
+sess.lastsessiondate}

//******************************************************
function init(){gettargetwin();getquerystring(targetwin);makeRequest(usersiteroot + 'devconfig/?g='+sess.QS,'','','GET');}
function finishinit(){
//******************************************************
getOS();
sess.referer='m';
initDate(sess);
readCookies();
setbodytheme(targetwin);
setCSSRules();
getdimensions();
makesessQS();
writelogodetails(targetwin);
self.focus();
}

//******************************************************
function getOS(){
//******************************************************
sess.OS = 'xx';
if (navigator.appVersion.indexOf("Win")!=-1) sess.OS="W";
if (navigator.appVersion.indexOf("Mac")!=-1) sess.OS="M";
if (navigator.appVersion.indexOf("X11")!=-1) sess.OS="U";
if (navigator.appVersion.indexOf("Linux")!=-1) sess.OS="L";}

//******************************************************
function makemenu(menutype,menuid,menuparentid,menuclass,submenuclass,menutitle,noofitems){
//******************************************************
menuid = parseInt(menuid,10);
var newnode=createNode('div','');
var newnode2=createNode('ul','','','dd');
var newnode3=createNode('li','');
var newnode4=createNode('a',menuclass,menutitle,'mmenu'+menuid);
newnode4.onmouseover =function(){menuopen(menuid)}; 
newnode4.onmouseout=function(){mclosetime()}; 
newnode4.setAttribute('href','javascript:void(0)');
newnode3.appendChild(newnode4);
newnode3.appendChild(createmenu(menutype,menuid,noofitems,submenuclass));
newnode2.appendChild(newnode3);
newnode.appendChild(newnode2);
document.getElementById(menuparentid).innerHTML='';
document.getElementById(menuparentid).appendChild(newnode);}

//******************************************************
function initDate(obj){
//******************************************************
obj.today =new Date();
obj.override = editiondate;
if (!isEmpty(obj.override))
	{overridedate=obj.override.split('-');obj.today.setFullYear(overridedate[0],overridedate[1],overridedate[2]);}

obj.timezoneOffset=0-obj.today.getTimezoneOffset();

obj.timeoffset=obj.today.getTimezoneOffset();
obj.dd=obj.today.getDate();

obj.mm=obj.today.getMonth();
obj.ww=getweekno(obj.today);
obj.ccyy=obj.today.getFullYear();

obj.yy=obj.ccyy.toString().substring(2);

obj.datedesc=makedatedesc(obj.ccyy,obj.mm,obj.dd,obj.today.getDay());
obj.monthdesc=makemonthdesc(obj.ccyy,obj.mm);
obj.weekdesc=makeweekdesc(obj.today);

obj.dd=addzero(obj.dd);
obj.mm=addzero(obj.mm);
obj.mmdd=obj.mm + obj.dd;

obj.realmm=addzero(obj.today.getMonth()+1);

obj.hh = obj.today.getHours();

obj.min = obj.today.getMinutes();
obj.ss = obj.today.getSeconds();

obj.hh=addzero(obj.hh);
obj.min=addzero(obj.min);
obj.ss=addzero(obj.ss);

obj.yymmddhhmmss = obj.yy+obj.mm+obj.dd+obj.hh+obj.min+obj.ss;}

//******************************************************
function makerandom(){
//******************************************************
ran = Math.floor(Math.random()*1000);
if(ran<10) 
	ran='00'+ ran;
else
	if(ran<100)
		ran='0'+ ran;
return(ran);}

//******************************************************
function createmenu(menutype, menuid,noofitems,submenuclass){
//******************************************************
var menudate = new Date(sess.today);
var newnode=createNode('div',submenuclass,'','menu'+menuid);

newnode.onmouseover=function(){mcancelclosetime()}; 
newnode.onmouseout=function(){mclosetime()}; 

switch (menutype) {
	case 'edition':		dateInterval= "d";			dateNum = -1;		break;
	case 'monthly':	 	menudate.setDate(1);		dateInterval= "m";		dateNum = -1;		break;
	case 'daily':		dateInterval= "d";			dateNum = -1;		break;
	case 'weekly':		dateInterval= "d";			dateNum = -7;		break;}	

if (menutype == 'edition')
{
sess.edition = sess.today.dateDiff(sess.launchdate,sess.ccyy + '' + sess.realmm+''+sess.dd)+1;
y = sess.edition-1;
if (y < 1) y =1;

menuccyy = menudate.getFullYear();
menumm = menudate.getMonth();
menudesc = 	menudate.getDate() + ' ' + getMonthName(menumm,true);
menumm =	addzero(menumm);
menudd = 	addzero(menudate.getDate());

menudatestring = menuccyy+"-"+menumm+"-"+menudd;
if (menudatestring != todaysdatestring)
	newnode.appendChild(createmenuitem(menuid,'Current',todaysdatestring));

menudate = menudate.add("d", -1);

for(x=0; x<noofitems; x++){
	menuccyy 	= menudate.getFullYear();
	menumm 		= menudate.getMonth();
	menudesc 	= menudate.getDate() + ' ' + getMonthName(menumm,true);
	menumm		= addzero(menumm);
	menudd		=addzero(menudate.getDate());
	menudatestring = menuccyy+"-"+menumm+"-"+menudd;
	newnode.appendChild(createmenuitem(menuid,'Edition:' + y,menudatestring));
	menudate = menudate.add(dateInterval,dateNum);
	y--;
	if (y==0)
		x=noofitems;}

return(newnode);}
else
{
for(x=0; x<noofitems; x++){

switch (menutype) {
	case 'monthly':	menudesc = 	getMonthName(menudate.getMonth(),true) + ' ' + menudate.getFullYear().toString().substring(2);break;
	case 'daily':menudesc = 	menudate.getDate() + ' ' + getMonthName(menudate.getMonth(),true);	break;
	case 'weekly':	startweek=getstartweek(menudate);menudesc = 	startweek.getDate() + ' ' + getMonthName(startweek.getMonth(),true);break;}	

	catalogpath = makecatalogpath(menudate,menuid);
	newnode.appendChild(createmenuitem(menuid,menudesc,catalogpath));
	menudate = menudate.add(dateInterval,dateNum);
	menuccyy = 	menudate.getFullYear();
	menumm=addzero(menudate.getMonth() +1);
	menudd=addzero(menudate.getDate());
	if (sess.today.dateDiff(sess.launchdate,menuccyy+''+menumm+''+menudd)<0)x=noofitems;}
return(newnode);}}

//******************************************************
function makecatalogpath (menudate,menuid)
//******************************************************
{	menucc = menudate.getFullYear().toString().substring(0,2);
	menuyy = menudate.getFullYear().toString().substring(2);
	menumm=addzero(menudate.getMonth());
	menudd=addzero(menudate.getDate());
	startweek=getstartweek(menudate);
	menuww=getweekno(startweek);
	catalogpath = menucc+'-'+menuyy+'-'+menumm+'-'+menudd+'-'+menuww+'-'+menuid;
	return(catalogpath);}

//******************************************************
function getXMLfiles(){
//******************************************************
if (targetwin==self && isRSS==true)
	makeRequest(siteroot  + sess.a + '?g=' + sess.QS,'','','GET');
else{
	makemenus();

httpfiles=getHashEntries('HTTPFile');
for(x=0; x<httpfiles.length; x++){
	httpfile= httpfiles.item[x].innerText;
	httpfile=httpfile.replace('MMDD',sess.mmdd);
	httpfile=httpfile.replace('WW',sess.ww);
	httpfile=httpfile.replace('YY',sess.yy);
	httpfile=httpfile.replace('MM',sess.mm);
	makeRequest(siteroot + httpfile + '?g=' + sess.QS,'','','GET');}	}}		
		
//******************************************************
function getenclosureimg(enclosurenode){
//******************************************************
rssenclosure=new Object(); 
rssenclosure.img=true;
imgurl=enclosurenode.getAttribute('url').split('?');
rssenclosure.URL= imgurl[0].replace(livesiteroot,'/');
rssenclosure.w=90;
rssenclosure.h=90;

if (imgurl.length>1){
	imgparams=imgurl[1].split('&');
	for(imgx=0; imgx< imgparams.length;imgx++){
		imgstr ='rssenclosure.' + imgparams[imgx] + "')";
		imgstr=imgstr.replace("=","=unescape('");
		eval(imgstr);}
	}
return(rssenclosure);}

//******************************************************
function getRSSimg(imgnode){
//******************************************************
rssimg=new Object(); 
rssimg.img=true; 	
rssimg.URL=getNodeValue(imgnode,'url').replace(livesiteroot,'/');
rssimg.title=getNodeValue(imgnode,'title');
rssimg.link=getNodeValue(imgnode,'link');
rssimg.width=getNodeValue(imgnode,'width');
rssimg.height=getNodeValue(imgnode,'height');
return(rssimg);}

//******************************************************
function popUpWin(thefile,thewidth,theheight,thescrollbars,thewin,issysarticle){
//******************************************************
// new bit // gets rid of the bad firefiox redraw bug and safari probs

if (!sess.isIE)	
	if(issysarticle)
		closePopUpWin(popupwin2);
	else
		closePopUpWin(popupwin);

fullwinparams='no';
bars=thescrollbars?'yes':'no'; 

stroptions='titlebar=0,location=0,directories=0,'+'height='+theheight+',width='+thewidth +',menubar=' + fullwinparams + ',personalbar=' + fullwinparams + ',resizable=yes,scrollbars='+bars+',status=' + fullwinparams + ',toolbar=' +  fullwinparams; 
		
thelocation=thefile.split("?");

xmllocation = '?'+ thelocation[1];
if (isRSS)
		window.location.href='/'+thelocation[0]+xmllocation;
else {
		if (thefile == 'contact')
			wincontents = contactwincontents;
		else
			if (thefile == 'config')
				wincontents = configwincontents;
			else	
				if(issysarticle)
					wincontents = systemwincontents;
				else
//					if (thelocation[0]=='q.htm')
					if (thelocation[0]=='quiz/')
						wincontents = quizwincontents;
					else
						wincontents = articlewincontents;

if(winexists(thewin) && sess.isIE)	{
	if (isEmpty(wincontents))	
		thewin.location.href=thelocation[0];
	else{	popupwindoc = thewin.document.open("text/html", "replace");
   			popupwindoc.write(wincontents);
    		popupwindoc.close();		}
									}
else{
		if (isEmpty(wincontents))	
			thewin=window.open(thelocation[0],'',stroptions);
		else	{thewin=window.open('','',stroptions);
// a bit nasty but stopped intermitemt ie bug				
				if (issysarticle)
					popupwin2 = thewin;
				else
					popupwin = thewin;
thewin.document.open("text/html", "replace");
thewin.document.write(wincontents);
thewin.document.close();
				}
	}}
if (!isRSS)
	thewin.focus();
return(thewin);}

//******************************************************
function menuopen(n,childwin){
//******************************************************
// Open Hidden Layer
if(childwin){
	listitem  = childwin.document.getElementById("menu"+n);
	menu = childwin.document.getElementById("mmenu"+n);}
else{
	listitem  = document.getElementById("menu"+n);
	menu = document.getElementById("mmenu"+n);}

if(listitem)  {
        mcancelclosetime();
        listitem.style.visibility='visible';
        if(currentLayer && (currentLayerNum != n)) currentLayer.style.visibility='hidden';
        currentLayer = listitem;
        currentitem = menu;
        currentLayerNum = n;  }
    else if(currentLayer)
    {   currentLayer.style.visibility='hidden';
        currentLayerNum = 0;
        currentitem = null;
        currentLayer = null;}
}
// Turn On Close Timer

//******************************************************
function mclose(){
//******************************************************
// Close Showed Layer
if(currentLayer && noClose!=1)    {
        currentLayer.style.visibility='hidden';
        currentLayerNum = 0;
        currentLayer = null;
        currentitem = null;}
else
	       noClose = 0;
    currentLayer = null;
    currentitem = null;}
// Close Layer Then Click-out
//document.onclick = mclose;

//******************************************************
function menuitemclick(elementid,menuid){
//******************************************************
switch (menuid){

case 0:case 1:case 2:
	document.getElementById('mmenu'+menuid).innerHTML = document.getElementById(elementid).innerHTML;

menufiles=getHashEntries('HTTPFile','menuid',menuid);

for(x=0; x<menufiles.length; x++)
{	menudates = elementid.split('-');
	httpfile= menufiles.item[x].innerText;
	httpfile=httpfile.replace('CC',menudates[0]);
	httpfile=httpfile.replace('YY',menudates[1]);
	httpfile=httpfile.replace('MM',menudates[2]);
	httpfile=httpfile.replace('DD',menudates[3]);
	httpfile=httpfile.replace('WW',menudates[4]);
	makeRequest(siteroot + httpfile + '?g=' + sess.QS,'','','GET');}			
	break;

case 3:
if (document.getElementById(elementid).innerHTML == 'Current')
	document.getElementById('edition').innerHTML='Edition:'+sess.currentedition;
else
	document.getElementById('edition').innerHTML=document.getElementById(elementid).innerHTML;
	editiondate=elementid;
	targetwin=self;
	finishinit();
	getXMLfiles();
	break;}
mclose();}

//******************************************************
function configwininit(){
//******************************************************
popupwin2.document.getElementById('fontsizemenu').options[sess.fontsize].selected = true;
popupwin2.document.getElementById('fontfamilymenu').options[sess.fontfamily].selected = true;
popupwin2.document.getElementById('thememenu').options[sess.themecolor].selected = true;
popupwin2.document.getElementById('thememenu').className='styletheme'+sess.themecolor;
menulength = popupwin2.document.getElementById('countrymenu').length;
for(x=0; x<menulength;x++)
	if(popupwin2.document.getElementById('countrymenu')[x].value == sess.country){
		popupwin2.document.getElementById('countrymenu').options[x].selected = true;
		x = menulength++;}

popupwin2.document.getElementById('styleitem').style.fontFamily = getfontfamily(sess.fontfamily);
popupwin2.document.getElementById('styleitem').style.fontSize = getfontsize(sess.fontsize);
showconfigitem(getthemecolor(sess.themecolor),getthemebackground(sess.themebackground));
writelogodetails(popupwin2);}

function getMonthName(mm,len){months=['January','February','March','April','May','June','July','August','September','October','November','December'];if (len) 	return(months[mm].substr(0,3));else		return(months[mm]);}
function getDayName (dayno,len){days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];if (len) 	return(days[dayno].substr(0,3));else		return(days[dayno]);}
function contactwininit(){targetwin=popupwin2;writelogodetails(targetwin);}
function winexists(thewin){return(thewin && thewin.open && !thewin.closed);}
function mclosetime(){closeTimer = window.setTimeout(mclose,TimeOut);}
function closePopUpWin(thewin){if(winexists(thewin)) 	thewin.close();thewin=null;}
function mcancelclosetime(){if(closeTimer){window.clearTimeout(closeTimer);closeTimer = null;    }}
function createGUID(){return(sess.yymmddhhmmss+makerandom()+sess.referer);}
function blurcountry(){targetwin.document.getElementById('countrymenu').blur();}
function isleapyear(ccyy){return((sess.ccyy % 4==0) &&  ((sess.ccyy % 100 !=0) || (sess.ccyy % 400==0)));}
function getstartweek(thedate) {startweek=new Date (thedate);startweek.setDate(startweek.getDate()-startweek.getDay()); return(startweek);}
function makeweekdesc (thedate){startweek=getstartweek(thedate);return(makedatedesc(startweek.getFullYear(),startweek.getMonth(),startweek.getDate(),startweek.getDay()));}
function makedatedesc (ccyy,mm,dd,dayno){return(getDayName(dayno) + ' ' + dd + getDaysuffix(dd) + ' ' + getMonthName (mm) + ' ' + ccyy);}
function makemonthdesc (ccyy,mm){return( getMonthName (mm) + ' ' + ccyy);}
function getDaysuffix (dd){switch (parseInt(dd,10)) {case 1:case 21:case 31:return('st');break;case 2:case 22:return('nd');break;case 3:case 23:return('rd');break;default:return('th');}}
function trim(str){return(str.replace(/^\s+|\s+$/g,""));}
function ltrim(str){return(str.replace(/^\s+/,""));}
function rtrim(str){return(str.replace(/\s+$/,""));}
function setTagStyle(nodename,tagstyle){if(sess.isIE)nodename.style.setAttribute(textSTYLE,tagstyle);else nodename.setAttribute(textSTYLE, tagstyle);return(nodename);}
function cleanup(){closePopUpWin(popupwin);closePopUpWin(popupwin2);}
function getthemecolor(themeindex){color=['white','#ffd134','#cccccc','#ffffcc','#c2deec','#000080','#ffff00'];return(color[themeindex]);}
function getthemebackground(themeindex){color=['black','#a13b0b','#000099','#990000','#0473b8','#dd0000','#666666'];return(color[themeindex]);}
function getfontsize(themeindex){color=['12px','9px','13px','15px','17px'];return(color[themeindex]);}
function getfontfamily(themeindex){themefont=['Arial, Helvetica, sans-serif','Verdana, sans-serif','Comic Sans MS','Courier, Courier New','Georgia, serif','Times New Roman, Times'];return(themefont[themeindex]);}
function getfontsize(themeindex){color=['12px','10px','14px','16px','18px'];return(color[themeindex]);}
function getNodeValue(xmlDoc,nodename){return(xmlDoc.getElementsByTagName(nodename)[0].childNodes[0].nodeValue)}
function getNode(xmlDoc,nodename){return(xmlDoc.getElementsByTagName(nodename)[0].childNodes[0])}
function isEmpty(obj){if(null==obj)return(true);if(obj=='')return(true);return(false);}			 
function getHTTPrequest(){if(sess.isIE)	return(new ActiveXObject(HTTPrequestver));else{HTTPver=new XMLHttpRequest();	if(HTTPver.overrideMimeType)HTTPver.overrideMimeType('text/html'); 	return(HTTPver);}}
function showinternalarticle(internalarticle){popupwin2=popUpWin(internalarticle,640,600,true,popupwin2,true);}
function getUserLocation(){if(sess.timezoneOffset==0 || sess.timezoneOffset==60)	return('UK'); else	return('US');}
function eraseCookie(cookiename){createCookie(cookiename,"",-1);}
function showrssmainwindow(url){var newwin=targetwin.window.open(url, "_blank", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");newwin.focus();}
function gettargetwin(){if(isEmpty(popupwin))	targetwin=self; else		targetwin=popupwin;}
function checkDate(){checkdate=new Date();checkdatedd = checkdate.getDate();if (sess.dd != checkdatedd)	clearTimeout(t); }
function getsequencefilename(){
rss=popupwin?'':'rss';
rss='';
sequencefilename=sess.a.split('-');
return(rss+ 'article/?a=' + sequencefilename[0]);
}
function getfilefrequency(){pageaddress=sess.a.split('/');filename=pageaddress[pageaddress.length-1].split('.');frequency=filename[0].split('-');return(frequency[0]);}
function closeme(win){switch (win){	case 0:	closePopUpWin(popupwin);break; case 1:	closePopUpWin(popupwin2);break;}}
function showsystemarticle(articleloc){
rss=isRSS?'rss':'';
rss='';
var articlesplit=articleloc.split('-');
popupwin2=popUpWin(rss + 'article/?a=' + articleloc,640,600,true,popupwin2,true);
mclose();}
function changeweatherunits(unit){sess.measurementunits = unit;createCookie('o',sess.measurementunits);weatherchange(currentweather);}
function haschildnodes(xmlDoc,thetagname){return(xmlDoc.getElementsByTagName(thetagname)[0].hasChildNodes());}
function shownote(noteid){targetwin.document.getElementById(noteid).style.display='block';}
function hidenote(noteid){targetwin.document.getElementById(noteid).style.display='none';}
function showbookswindow(articleloc){var newwin=window.open(encodeURI(articleloc), "_blank", "height=700,width=910,toolbar=no,menubar=yes,location=yes,scrollbars=yes,resizable=yes");newwin.focus();}
function makeRSSDate(theDate){filebits=theDate.split(":");filebits[0] = filebits[0].slice(0,filebits[0].lastIndexOf(' ')); return(filebits[0]);}
function changetimeunits(time24) {stopclock ();sess.time24 = Boolean(parseInt(time24,10));savedworldtimeminutes = -1;createCookie('p',sess.time24);startclock();}
function createmenuitem(menuid,itemdesc,itemid){var newnode=createNode('a','',itemdesc,itemid);newnode.setAttribute('href','javascript:void(0)');newnode.onclick=function(){menuitemclick(this.id,menuid)};return(newnode);}
function closewin(){if(!isEmpty(popupwin))closePopUpWin(popupwin);else	if(history.length > 1)history.back();else self.close();}
function addzero(str){return ((str < 10) ? '0' : '') + str +'';}
//x as subscript was a problem need to investigate think cos it's an object
function makemenus(){menus=getHashEntries('menu');for(sub1=0; sub1< menus.length; sub1++)makemenu(menus.item[sub1].type,menus.item[sub1].id,menus.item[sub1].placeholderid,menus.item[sub1].menuclass,menus.item[sub1].submenuclass,menus.item[sub1].title,menus.item[sub1].noofitems,menus.item[sub1].title);}

//******************************************************
function startclock(){showtime();}
function stopclock (){if(timerRunning)clearTimeout(timerID);timerRunning = false;}
function showtime () {
//******************************************************
stopclock ();
worldtime = new Date();
timezoneoffsets[0] = worldtime.getTimezoneOffset();

timezoneoffsets[0] = 0 - worldtime.getTimezoneOffset();
savedworldtimeminutes = worldtime.getMinutes(); 
worldtime = worldtime.add('n',worldtime.getTimezoneOffset());
timezoneoffsetslength = timezoneoffsets.length;

for(x = 0; x < timezoneoffsetslength; x++){
	thisworldtime = new Date();
	thisworldtime = thisworldtime.add('n',thisworldtime.getTimezoneOffset());
	thisworldtime = thisworldtime.add('n',timezoneoffsets[x]);

	hours=addzero(thisworldtime.getHours());
	minutes=addzero(thisworldtime.getMinutes());
	date=addzero(thisworldtime.getDate());

	if (sess.time24==false){
		if (hours >= 12) {
			dateampm =  "pm";
			hours = hours - 12;	
			if (hours ==0)
				hours=12;}
		else
			dateampm =  "am";}
	else
		dateampm = "";

	document.getElementById("datemonth_"+x).innerHTML 	=  getMonthName(thisworldtime.getMonth(),true);
	document.getElementById("dateday_"+x).innerHTML 	=  date;
	document.getElementById("datedayweek_"+x).innerHTML =  getDayName(thisworldtime.getDay(),true);
	document.getElementById("datehours_"+x).innerHTML 	=  hours;
	document.getElementById("dateminutes_"+x).innerHTML =  minutes;
	document.getElementById("dateampm_"+x).innerHTML 	=  dateampm;}

timerID = setTimeout("showtime()",55000);
timerRunning = true;}
//******************************************************
function showlinkwizard() {
//******************************************************
linksiteroot = siteroot.toLowerCase();
if (linksiteroot != "http://localhost/")
	linksiteroot = "http://emanac.com/";

splitpos = sess.a.lastIndexOf('/');
if (sess.a.substring(splitpos).indexOf("sys.xml") == -1)
{
rssstring =  sess.a.substring(0,splitpos) + "/rss" + sess.a.substring(splitpos);
rssstring  = rssstring.replace("'","\\'");
//targetwin.document.getElementById("rssembed").innerHTML 	= '<object id="contentarea"  data="' + siteroot + 'widget/?a=/'  + rssstring + '" type="text/html" style="width:200px; height:400px;"></object>';
targetwin.document.getElementById("rssembed").innerHTML 	= '<iframe id="contentarea"  src="' + linksiteroot + 'widget/?a='  + rssstring + '"  style="width:178px; height:380px;" frameborder="0" border="0"></iframe>';

targetwin.document.getElementById("embedcode").innerHTML 	= '&lt;iframe id="contentarea"  src="' + linksiteroot + 'widget/?a='  + rssstring + '" style="width:178px; height:380px;" frameborder="0" border="0">&lt;/iframe>';
targetwin.document.getElementById("directcode").innerHTML 	= linksiteroot + 'article/?a=' + sess.a;
targetwin.document.getElementById("rsscode").innerHTML 	= linksiteroot + rssstring.substr(1);
targetwin.document.getElementById("scriptcode").innerHTML 	= '&lt;script type="text/javascript" src="' + linksiteroot + 'widget/?a='  + rssstring + '&b=auto&script=y">&lt;/script>';

imgstring = rssstring.replace('/rss/','/screen/');
imgstring = imgstring.replace('.xml','.jpg');
targetwin.document.getElementById("imagecode").innerHTML= '&lt;a href="' +  linksiteroot + 'article/?a=' + sess.a +'">' + '&lt;img  src="'+linksiteroot+imgstring.substr(1)+'" border="0" /> &lt;/a>';

//targetwin.document.getElementById("linkcode").innerHTML 	= '&lt;object  data="' + siteroot + 'widget/?a='  + rssstring + '" type="text/html" style="width:200px; height:400px;"&gt;&lt;/object&gt;';

targetwin.document.getElementById('linkwizardblock').style.display='block';}

}
//******************************************************
function hidelinkwizard(){targetwin.document.getElementById('linkwizardblock').style.display='none';}
//******************************************************
function selectall (codediv){
var codedivid;
switch (codediv) {
case 0:codedivid='scriptcode';break;
case 1:codedivid='embedcode';break;
case 2:codedivid='imagecode';break;
case 3:codedivid='directcode';break;
case 4:codedivid='rsscode';break;}
targetwin.document.getElementById(codedivid).focus();	
targetwin.document.getElementById(codedivid).select();}

//******************************************************
function showwidgetwizard(){
//******************************************************

rssstring =  sess.a.substring(0,splitpos) + "/rss" + sess.a.substring(splitpos);
rssstring =  rssstring + '&t=' +  encodeURIComponent(targetwin.document.getElementById('headline').innerHTML);
showexternalwindow('/widget/?article=' + rssstring);}

//******************************************************
function rssunload(){
//******************************************************
//function resizeWin(x,y) {

//self.resizeTo(parseInt(x) + 20 ,parseInt(y) + 200);
}

