function loadXMLDoc(fname)
{
  var xmlDoc;
	var currentTime = new Date();
	var month = currentTime.getMonth() + 1
	var day = currentTime.getDate()
	var year = currentTime.getFullYear()
	var dateString = year + "_" + month + "_" + day;

  // code for IE
  try{
		  if (window.ActiveXObject)
		  {
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		  }
		  // code for Mozilla, Firefox, Opera, etc.
		  else if (document.implementation
		  && document.implementation.createDocument)
		  {
			xmlDoc=document.implementation.createDocument("","",null);
		   }
		  else
		  {
			alert('Your browser cannot handle this script');
		  }
		xmlDoc.async=false;
		xmlDoc.load(fname + "?date=" + dateString);
    }catch(e)
        {
                var xmlhttp = new window.XMLHttpRequest();
                xmlhttp.open("GET",fname + "?date=" + dateString,false);
                xmlhttp.send(null);
                xmlDoc = xmlhttp.responseXML.documentElement;
        }

return(xmlDoc);
}
function displayPrimarycontent(name){
         displayResult(name,name,"primarycontainer");
}

function displaySecondarycontent(name){
         displayResult(name,"secondary","secondarycontentText");
        setSecondaryHeight();

}

function displayAgenda(){
         displayResult("agenda","agenda","secondarycontentText");
        setSecondaryHeight();

}


function initPage(){
        displayResult("footer","footer","footerWrapper");
}




function displayResult(xmlName,xlsName, parent)
{
	xml=loadXMLDoc("xml_content/"+xmlName+".xml");
	xsl=loadXMLDoc("xsl_templates/"+xlsName+".xsl");
// code for IE
if (window.ActiveXObject)
  {
    ex=xml.transformNode(xsl);
    document.getElementById(parent).innerHTML=ex;
  }
  // code for Mozilla, Firefox, Opera, etc.
  else if (document.implementation
  && document.implementation.createDocument)
  {
    xsltProcessor=new XSLTProcessor();
    xsltProcessor.importStylesheet(xsl);
    resultDocument = xsltProcessor.transformToFragment(xml,document);
    document.getElementById(parent).appendChild(resultDocument);
  }
}

function setSecondaryHeight() {
 var primarycontainer = document.getElementById('primarycontainer');
 var height = primarycontainer.offsetHeight;
 var secondarycontent = document.getElementById('secondarycontent');
 secondarycontent.style.height=height+"px";
 var secondarycontentText = document.getElementById('secondarycontentText');
 secondarycontentText.style.height=(height-45)+"px";
 var secondary_centered = document.getElementById('secondary_centered');
 if(secondary_centered != null){
     secondary_centered.style.height=(height-45)+"px";
 }

}