//ST MICHAELS SHARED SCRIPTS @@@@@@@@@@@@@@@@


        // MENU @@@
  function clearMenu() {
    var all=div_menu.getElementsByTagName("div");
    for(i=0;i<all.length;i++){ if(all[i].className=='div_menuitems'){all[i].style.display='none';};  };
    };
        
  function opensubmenu() {
    var sub=document.getElementById("div_services")
    sub.style.display='block';
    };
    
    
  function getLatestNews() {
    var latest_news='';
    var lastnight = new Date (2009,08,28);
    var barndance = new Date(2009,09,04);
    
    var celebration = new Date(2010,01,21);
    var agm = new Date(2010,03,13);
    var conf = new Date(2010,03,19);
 
    var strawberry = new Date(2010,06,18)
    var songsofpraise = new Date(2010,08,05); 
    var backtochurch = new Date(2010,08,27);
    var harvest = new Date(2010,09,04);
    var lastnight = new Date (2010,10,14);
  
    var preadvent= new Date(2010,10,14);    
    var advent = new Date(2010,10,28);
    var chfayre = new Date(2010,11,05);
    var christmas = new Date(2010,11,25);
    var easter = new Date(2011,03,24);
    var sfayre = new Date(2011,05,19);
    
        
    today= new Date();
    
    if (today>sfayre) {  
        latest_news = 'Watch this space for events in 2011. ';} 
        
    else if (today>easter) {
      latest_news = 'Saturday 18th June St Michael\'s Summer Fayre. ';}          
    else if (today>christmas) {
      latest_news = 'St Michael\'s AGM 17th April after 10am Sunday Service. ';}        
    else if (today>chfayre) {
      latest_news = '24th December 11:30pm First Communion of Christmas at St. Michaels. ';}
    else if (today>advent) {
      latest_news = 'Christmas Fayre on Saturday 4th December from 10:00am until 1:00pm ';}
    else if (today>lastnight) {
      latest_news = 'Advent Sunday 28th November, 10:00am Holy Communion';}  
                  
    else if (today>harvest) {  
        latest_news = 'Last Night of the Proms 13th November 2010 at 19:30. ';}           
    else if (today>backtochurch) {
      latest_news = 'Harvest Festival Sunday 3rd October 10:00am and 6:00pm. ';}            
    else if (today>songsofpraise) {
      latest_news = 'Back to Church Sunday 26th September. ';}     
    else if (today>strawberry) {
      latest_news = 'St Michael\'s Song of Praise, Sunday 5th September 6:00pm. ';}
    else if (today>sfayre) {
      latest_news = 'Strawberry Fayre Saturday 17th July 2:00pm until 4:00pm. ';}      

    else if (today>agm) {
      latest_news = '18th April 11:00am at St Michael\'s, Confirmation Service with Bishop Stephen. ';}  
    else if (today>celebration) {
      latest_news = 'St Michael\'s AGM Monday 12th April. ';}
    else if (today>christmas) {
      latest_news = 'Celebration East Ardsley, Saturday 20th February 6:30pm. ';}

    else {
      latest_news = '';};
    
    return latest_news;
    };
    
  
  function getLiturgicalWeek() {
    var liturgicalWeek='';
  
    var newyear= new Date(2012,00,01);
    var baptism = new Date(2012,00,08);
    var epiphany2 = new Date(2012,00,15);
    var epiphany3 = new Date(2012,00,22);
    var epiphany4 = new Date(2012,00,29);
     
    var candlemas = new Date(2012,01,05)
 /*
    var lent5b = new Date(2012,01,06);
    var lent4b = new Date(2012,01,13);
    var lent3b = new Date(2012,01,20);
 */  
    var lent2b = new Date(2012,01,12);
    var lent1b = new Date(2012,01,19); 
   
    var lent = new Date (2012,01,22);
/*
    
    var lent1 = new Date(2011,02,13);
    var lent2 = new Date(2011,02,20);
    var lent3 = new Date(2011,02,27);
    var lent4 = new Date(2011,03,03);
    var lent5 = new Date(2011,03,10);
    var holyweek = new Date(2011,03,17);
 /*   
    var easter = new Date(2011,03,24);
    var ascension = new Date(2011,05,02);
    var ascensiontide = new Date(2011,05,03);
    var pentecost = new Date(2011,05,12);
    var trinitysun = new Date(2011,05,19);
    
    var trinity1 = new Date(2011,05,26);
    var trinity2 = new Date(2011,06,03);
    var trinity3 = new Date(2011,06,10);
    var trinity4 = new Date(2011,06,17);
    var trinity5 = new Date(2011,06,24);
    
    var trinity6 = new Date(2011,06,31);
    var trinity7 = new Date(2011,07,07);
    var trinity8 = new Date(2011,07,14);
    var trinity9 = new Date(2011,07,21);
    var trinity10 = new Date(2011,07,28);
    
    var trinity11 = new Date(2011,08,04);
    var trinity12 = new Date(2011,08,11);
    var trinity13 = new Date(2011,08,18);
    var trinity14 = new Date(2011,08,25);
    var trinity15 = new Date(2011,09,02);
    
    var trinity16 = new Date(2011,09,09);
    var trinity17 = new Date(2011,09,16); 
    var trinity18 = new Date(2010,09,03);
    var trinity19 = new Date(2010,09,10);
    var trinity20 = new Date(2010,09,17);
   
    var trinitylast = new Date(2011,09,23);     
    var advent4b = new Date(2011,09,30);
    
    var advent3b = new Date(2011,10,06);
    var advent2b = new Date(2011,10,13);
    var advent1b = new Date(2011,10,20);
    var advent= new Date(2011,10,27);
      
    var advent2= new Date(2011,11,04);   
    var advent3= new Date(2011,11,11);  
    var dec17 = new Date(2011,11,17); 
    var dec18 = new Date(2011,11,18); 
     
   //var advent4= new Date(2010,11,19); 
    var dec19 = new Date(2011,11,19); 
    var dec20 = new Date(2011,11,20); 
    var dec21 = new Date(2011,11,21); 
    var dec22 = new Date(2011,11,22); 
    var dec23 = new Date(2011,11,23); 
    var dec24 = new Date(2011,11,24);
   
    var christmas= new Date(2011,11,25);
 */
 
        

    today= new Date();
    
    if (today>lent) {
        liturgicalWeek=' to the Season of Lent';}    
    else if (today>lent1b) {
        liturgicalWeek=' to the week of Sunday before Lent';}     
    else if (today>lent2b) {
        liturgicalWeek=' to the week of 2 before Lent';} 
        
 /*       
    else if (today>lent3b) {
        liturgicalWeek=' to the week of 3 before Lent';} 
    else if (today>lent4b) {
        liturgicalWeek=' to the week of 4 before Lent';}      
    else if (today>lent5b) {
        liturgicalWeek=' to the week of 5 before Lent';}   
 */ 
     
    else if (today>candlemas) {
        liturgicalWeek=' to the week of Candlemas';}  
    else if (today>epiphany4) {
        liturgicalWeek=' to the week of Epiphany 4';}          
    else if (today>epiphany3) {
        liturgicalWeek=' to the week of Epiphany 3';}  
    else if (today>epiphany2) {
        liturgicalWeek=' to the week of Epiphany 2';}  
    else if (today>baptism) {
        liturgicalWeek=' to the week of the Baptism of Christ';}   
 
 /*   
    else if (today>newyear) {
        liturgicalWeek=' and wishes you a Happy New Year';}     
    else if (today>christmas) {
        liturgicalWeek=' and wishes you a Merry Christmas';}  
    else if (today>dec24) {
        liturgicalWeek=' to Christmas Eve';}
    else if (today>dec23) {
        liturgicalWeek=' to the 4th week of Advent - O Emmanuel';}  
    else if (today>dec22) {
        liturgicalWeek=' to the 4th week of Advent - O Rex gentium';}
    else if (today>dec21) {
        liturgicalWeek=' to the 4th week of Advent - O Oriens';}
    else if (today>dec20) {
        liturgicalWeek=' to the 4th week of Advent - O Clavis David';}
    else if (today>dec19) {
        liturgicalWeek=' to the 4th week of Advent - O Radix Jesse';}
    else if (today>dec18) {
        liturgicalWeek=' to the 4th week of Advent - O Adonai';}
    else if (today>dec17) {
        liturgicalWeek=' to the 3rd week of Advent - O Sapientia';}
    else if (today>advent3) {
        liturgicalWeek=' to the 3rd week of Advent';} 
    else if (today>advent2) {
        liturgicalWeek=' to the 2nd week of Advent';}   

    else if (today>advent) {
        liturgicalWeek=' to the Season of Advent';}  
    else if (today>advent1b) {
        liturgicalWeek=' to the week of next before Advent';}     
    else if (today>advent2b) {      
        liturgicalWeek=' to the week of 2 before Advent';}
    else if (today>advent3b) {   
        liturgicalWeek=' to the week of 3 before Advent';}
    else if (today>advent4b) {   
        liturgicalWeek=' to the week of 4 before Advent';}    
    else if (today>trinitylast) {   
        liturgicalWeek=' to the week of Last Sunday after Trinity';}   
        
    else if (today>trinity20) {   
        liturgicalWeek=' to the week of Trinity 20';}
    else if (today>trinity19) {   
        liturgicalWeek=' to the week of Trinity 19';}
    else if (today>trinity18) {   
        liturgicalWeek=' to the week of Trinity 18';}
    else if (today>trinity17) {   
        liturgicalWeek=' to the week of Trinity 17';}
    else if (today>trinity16) {   
        liturgicalWeek=' to the week of Trinity 16';}
        
    else if (today>trinity15) {   
        liturgicalWeek=' to the week of Trinity 15';}
    else if (today>trinity14) {   
        liturgicalWeek=' to the week of Trinity 14';}
    else if (today>trinity13) {   
        liturgicalWeek=' to the week of Trinity 13';}
    else if (today>trinity12) {  
        liturgicalWeek=' to the week of Trinity 12';}
    else if (today>trinity11) {   
        liturgicalWeek=' to the week of Trinity 11';} 
        
    else if (today>trinity10) {   
        liturgicalWeek=' to the week of Trinity 10';}
    else if (today>trinity9) {
        liturgicalWeek=' to the week of Trinity 9';}
    else if (today>trinity8) {
        liturgicalWeek=' to the week of Trinity 8';}
    else if (today>trinity7) {
        liturgicalWeek=' to the week of Trinity 7';}
    else if (today>trinity6) {
        liturgicalWeek=' to the week of Trinity 6';} 
        
    else if (today>trinity5) {
        liturgicalWeek=' to the week of Trinity 5';}
    else if (today>trinity4) {
        liturgicalWeek=' to the week of Trinity 4';}
    else if (today>trinity3) {
        liturgicalWeek=' to the week of Trinity 3';}
    else if (today>trinity2) {
        liturgicalWeek=' to the week of Trinity 2';}
    else if (today>trinity1) {
        liturgicalWeek=' to the week of Trinity 1';}
    else if (today>trinitysun) {
        liturgicalWeek=' to the week of Trinity Sunday';}
 
    else if (today>pentecost) {
        liturgicalWeek=' to the Feast of Pentecost';}
    else if (today>ascensiontide) {
        liturgicalWeek=' to the days following the Ascension';}
    else if (today>ascension) {
        liturgicalWeek=' to Ascension Day';}        
    else if (today>easter) {
        liturgicalWeek=' and wishes you a Joyful Eastertide';}
    else if (today>holyweek) {
        liturgicalWeek=' and wishes you a Blessed Holy Week';}
        
    else if (today>lent5) {
        liturgicalWeek=' to the week of Lent 5';} 
    else if (today>lent4) {
        liturgicalWeek=' to the week of Lent 4';} 
    else if (today>lent3) {
        liturgicalWeek=' to the week of Lent 3';} 
    else if (today>lent2) {
        liturgicalWeek=' to the week of Lent 2';} 
    else if (today>lent1) {
        liturgicalWeek=' to the week of Lent 1';}    
 
 */
 
    else {
      liturgicalWeek='';};
    
    return liturgicalWeek;

    };
 

    
  function loadXMLDoc(fname){
    var xmlDoc;
    if (window.ActiveXObject) {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");}  // code for IE
    else if (document.implementation && document.implementation.createDocument){
      xmlDoc=document.implementation.createDocument("","",null);} // code for Mozilla
    else {
      alert ('Your browser cannot handle this script');};
    xmlDoc.async=false;
    xmlDoc.load(fname);
    return(xmlDoc);
    };
    
   
  function clearnews(){
    window.document.getElementById("div_newsFeed").innerHTML='';
    //window.document.getElementById("div_newsFeed").style.display='block';
    };

   
  function newsFeed(){
    clearnews();
  
    xml=loadXMLDoc("rss/news.xml");
    xsl=loadXMLDoc("scripts/news_feeds.xsl");
    
    if (window.ActiveXObject){ 
      ex=xml.transformNode(xsl); 
      window.document.getElementById("div_newsFeed").innerHTML=ex;}  // code for IE
    else if (document.implementation && document.implementation.createDocument){
      xsltProcessor=new XSLTProcessor();
      xsltProcessor.importStylesheet(xsl);
      resultDocument=xsltProcessor.transformToFragment(xml,document);
      document.getElementById("div_newsFeed").appendChild(resultDocument);
      };  // code for Mozilla
    };
      
    
