//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 backtochurch = new Date(2009,06,14);
    var lastnight = new Date (2009,08,28);
    var barndance = new Date(2009,09,04);
    var preadvent= new Date(2009,10,01);    
    var advent = new Date(2009,10,29);
    var chfayre = new Date(2009,11,06);
    var christmas = new Date(2009,11,25);
    var celebration = new Date(2010,01,21);
    var agm = new Date(2010,03,13);
    var conf = new Date(2010,03,19);
    var sfayre = new Date(2010,05,20); 
    var strawberry = new Date(2010,06,18)   
    
    today= new Date();
    
    if (today>strawberry) {
      latest_news = 'Watch this space for events in 2010. ';}
      
    else if (today>sfayre) {
      latest_news = 'Strawberry Fayre Saturday 17th July 2:00pm until 4:00pm. ';}      
      
    else if (today>conf) {
      latest_news = 'Saturday 19th June St Michael\'s Summer Fayre. ';}  
    
    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 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 5th December from 10:00am until 1:00pm ';
    }
    else if (today>preadvent) {
      latest_news = 'Advent Sunday 29th November, 10:00am Holy Communion';
    }
    else if (today>barndance) {
      latest_news = 'Barn Dance, 23rd October at 7:00pm';
    }
    else if (today>lastnight) {
      latest_news = 'Last Night of Proms, 3rd October at 7:30pm';
    }
    else {
      latest_news = '';
    };
    
    return latest_news;
    };
    
  
  function getLiturgicalWeek() {
    var liturgicalWeek='';
  
    var advent= new Date(2009,10,29);
    var advent2= new Date(2009,11,06);   
    var advent3= new Date(2009,11,13);  
    var dec17 = new Date(2009,11,17); 
    var dec18 = new Date(2009,11,18); 
    var dec19 = new Date(2009,11,19); 
    var dec20 = new Date(2009,11,20); 
    var dec21 = new Date(2009,11,21); 
    var dec22 = new Date(2009,11,22); 
    var dec23 = new Date(2009,11,23); 
    var dec24 = new Date(2009,11,24);
       
    var advent4= new Date(2009,11,20);    
    var christmas= new Date(2009,11,25);
    var newyear= new Date(2010,00,01);
    
    var baptism = new Date(2010,00,10);
    var epiphany2 = new Date(2010,00,17);
    var epiphany3 = new Date(2010,00,24);
    var candlemas = new Date(2010,00,31);

    var lent2b = new Date(2010,01,07);
    var lent1b = new Date(2010,01,14);
    var lent = new Date (2010,01,17);
    var lent1 = new Date(2010,01,21);
    var lent2 = new Date(2010,01,28);
    var lent3 = new Date(2010,02,07);
    var lent4 = new Date(2010,02,14);
    var lent5 = new Date(2010,02,21);

    var holyweek = new Date(2010,02,28);
    var easter = new Date(2010,03,04);

    var ascension = new Date(2009,04,21);
    var ascensiontide = new Date(2009,04,22);
    
    var pentecost = new Date(2010,04,23);
  
    var trinitysun = new Date(2010,04,30);
    var trinity1 = new Date(2010,05,06);
    var trinity2 = new Date(2010,05,13);
    var trinity3 = new Date(2010,05,20);
    var trinity4 = new Date(2010,05,27);
    var trinity5 = new Date(2010,06,04);
    
    var trinity6 = new Date(2010,06,11);
    var trinity7 = new Date(2010,06,18);
    var trinity8 = new Date(2010,06,25);
    var trinity9 = new Date(2010,07,01);
    var trinity10 = new Date(2010,07,08);
    
    var trinity11 = new Date(2010,07,15);
    var trinity12 = new Date(2010,07,22);
    var trinity13 = new Date(2010,07,29);
    var trinity14 = new Date(2010,08,05);
    var trinity15 = new Date(2010,08,12);
    
    var trinity16 = new Date(2010,08,19);
    var trinity17 = new Date(2010,08,26); 
    var trinity18 = new Date(2010,09,03);
    var trinity19 = new Date(2010,09,10);
    var trinity20 = new Date(2010,09,17);
    
    var advent4b = new Date(2009,10,01);
    var advent3b = new Date(2009,10,08);
    var advent2b = new Date(2009,10,15);
    var advent1b = new Date(2009,10,22);
    
    
    today= new Date();

    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>easter) {
    document.write(' and wishes you a Joyful Eastertide');}
    else {
      liturgicalWeek='';};
    
    return liturgicalWeek;

    };



/*

    else if (today>ascensiontide) {
    document.write(' to the days following the Ascension');
  }
  else if (today>ascension) {
    document.write(' to Ascension Day');  
  else if (today>easter) {
    document.write(' and wishes you a Joyful Eastertide');}
  else if (today>holyweek) {
    document.write(' 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 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>candlemas) {
         liturgicalWeek=' to the week of Candlemas';} 

    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 3rd week of Advent - O Radix Jesse';}
    else if (today>dec18) {
         liturgicalWeek=' to the 3rd we-vek 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';}
  
 */  
    
    
  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 newsFeed(){
  
    xml=loadXMLDoc("rss/news.rss");
    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
    };
      
    