﻿    function getSidebar(){
    if (Page == "homepage") {
        document.write('<div id="newsbar" class="sidebar">');
        document.write('<div class="top"><div style="margin-top: 35px">The Latest News</div></div>');
        document.write('<div class="scroll" id="scroll"></div>');
        news_items();
        document.write('<p align="center"><!-- ---- Quick-counter.net ---- --><a href="http://www.quick-counter.net/" title="php hit counter - Quick-counter.net"><img src="http://www.quick-counter.net/aip.php?tp=di&tz=Europe%2FLondon" alt="php hit counter - Quick-counter.net" border="0" /></a><!-- ---- Quick-counter.net ---- --></p>');
        document.write('</div>');
    }
    if (Page == "bulletin") {
        document.write('<div id="inserts" class="sidebar" style="height: 400px">');
        document.write('<div class="top"><div>Bulletin Inserts<br />by Week</div></div>');
        document.write('<div class="scroll">');
        document.write('<!-- ');
        document.write('#include');
        document.write('file="bulletin_inserts.asp"');
        document.write('-->');
        //document.getElementById('newsbar').style.display = "none";
        document.write('</div></div>');
    }
}

function changeCSS() {
    var today = new Date();
    var month = today.getMonth() + 1;
    var day = today.getDate();
    //alert(today);
    //alert(month);
    //alert(day);
    if (month == 11 && day >= 28)
        document.getElementById("style1").href = "css/advent/style.css";
    if (month == 12 && day <= 4)
        document.getElementById("style1").href = "css/advent/style.css";
    if (month == 12 && day >= 5)
        document.getElementById("style1").href = "css/advent/style2.css";
    if (month == 12 && day >= 12)
        document.getElementById("style1").href = "css/advent/style3.css";
    if (month == 12 && day >= 19)
        document.getElementById("style1").href = "css/advent/style4.css";
    if (month == 12 && day >= 24)
        document.getElementById("style1").href = "css/christmas/style.css";
    if (month == 1 && day <= 9)
        document.getElementById("style1").href = "css/christmas/style.css";
    if (month >= 3 && day > 9)
        document.getElementById("style1").href = "css/lent/style.css";
    if (month >= 4 && day <= 23)
        document.getElementById("style1").href = "css/lent/style.css";
    if (month == 4 && day == 25)
        document.getElementById("style1").href = "css/easter/style.css";
    if (month == 4 && day >= 26)
        document.getElementById("style1").href = "css/silver/style.css";
    if (month == 5)
        document.getElementById("style1").href = "css/silver/style.css";
    if (month == 6 && day <= 11)
        document.getElementById("style1").href = "css/silver/style.css";
    if (month == 8 && day >= 11)
        document.getElementById("style1").href = "css/rocco/style.css";
    if (month == 8 && day >= 15)
        document.getElementById("style1").href = "css/spiritual/style.css";
    else
        document.getElementById("style1").href = "css/spiritual/style.css";
}

function xmasOn() {
    var today = new Date();
    var month = today.getMonth() + 1;
    var day = today.getDate();
    //alert(today);
    //alert(month);
    //alert(day);
    if (month == 12)
        document.getElementById("xmas_mass").style.display = "block";
    else
        document.getElementById("xmas_mass").style.display = "none";
}

// toggle display of an item display off or on
function showhide(id) {
    if (document.getElementById) {
        obj = document.getElementById(id);
        if (obj.style.display == "none") {
            obj.style.display = "block";
        } else {
            obj.style.display = "none";
        }
    }
}

// turn display of an item off
function hide(id) {
    if (document.getElementById) {
        obj = document.getElementById(id);
        if (obj.style.display == "block") {
            obj.style.display = "none";
        } else {
            obj.style.display = "none";
        }
    }
}
// turn display of an item on
function show(id) {
    if (document.getElementById) {
        obj = document.getElementById(id);
        if (obj.style.display == "none") {
            obj.style.display = "block";
        } else {
            obj.style.display = "block";
        }
    }
}

function insertQuote() {
    document.write('<h2 style="font-style: italic; font-size: 1em; text-align: center; color: #999999">');
    var howMany = 40
    var quote = new Array(howMany + 1)
    quote[0] = "Hail, thou that art highly favoured, the Lord is with thee: blessed art thou among women. [Angel to Virgin Mary] - Luke, 1. 28"
    quote[1] = "Behold the Lamb of God, which taketh away the sin of the world. - John, 1. 29"
    quote[2] = "And all that believed were together, and had all things common. - Acts of the Apostles, 2. 44"
    quote[3] = "Your body is the temple of the Holy Ghost. - Corinthians 6. 19"
    quote[4] = "Peace I leave with you, my peace I give unto you: not as the world giveth, give I unto you. - John, 14. 27"
    quote[5] = "Be of good cheer: it is I; be not afraid. - Matthew, 14. 27"
    quote[6] = "To give light to them that sit in darkness and in the shadow of death, to guide our feet into the way of peace. - Luke, 1. 79"
    quote[7] = "God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. - John, 3. 16"
    quote[8] = "It is more blessed to give than to receive. - Acts of the Apostles, 20. 35"
    quote[9] = "I am made all things to all men. - Corinthians 9. 22"
    quote[10] = "That thou art Peter, and upon this rock I will build my church; and the gates of hell shall not prevail against it. - Matthew, 16. 18"
    quote[11] = "Behold, I bring you good tidings of great joy. [Angels to the shepherds] Luke, 2. 10"
    quote[12] = "Him that cometh to me I will in no wise cast out. John, 6. 37"
    quote[13] = "He that hath ears to hear, let him hear. - Mark, 4. 9"
    quote[14] = "O death, where is thy sting? O grave, where is thy victory? - Corinthians 15. 55"
    quote[15] = "Who hath ears to hear, let him hear. - Matthew, 13. 9"
    quote[16] = "Glory to God in the highest, and on earth peace, good will toward men. [Angels to the shepherds] Like, 2. 14"
    quote[17] = "Verily, verily, I say unto you, He that believeth on me hath everlasting life. - John, 6. 47"
    quote[18] = "Suffer the little children to come unto me, and forbid them not: for of such is the kingdom of God. - Mark, 10. 14"
    quote[19] = "To every thing there is a season, and a time to every purpose under the heaven. - Ecclesiastes 3. 1"
    quote[20] = "Freely ye have received, freely give. - Matthew, 10. 8"
    quote[21] = "Physician, heal thyself. - Luke, 4. 23"
    quote[22] = "One thing I know, that, whereas I was blind, now I see. - John, 9. 25"
    quote[23] = "The sabbath was made for man, and not man for the sabbath. - Mark, 2. 27"
    quote[24] = "He that is born to be hanged shall never be drowned."
    quote[25] = "Judge not, that ye be not judged. - St Matthew, 7. 1 "
    quote[26] = "Love your enemies, do good to them which hate you. - Luke, 6. 27"
    quote[27] = "The truth shall make you free. - John, 8. 32"
    quote[28] = "Ye were as sheep going astray; but are now returned unto the Shepherd and Bishop of your souls. Peter 2. 25"
    quote[29] = "Lord, thou knowest all things; thou knowest that I love thee. [St. Peter to Jesus] - John, 21. 17"
    quote[30] = "Blessed are the pure in heart: for they shall see God. - Matthew, 5. 3"
    quote[31] = "Give, and it shall be given unto you; good measure, pressed down, and shaken together, and running over, shall men give into your bosom. - Luke, 6. 38"
    quote[32] = "Neither do I condemn thee: go, and sin no more. - John, 8. 11"
    quote[33] = "Be ye all of one mind. - Peter, 3. 8"
    quote[34] = "The Lord is my shepherd; I shall not want. - Psalm 23"
    quote[35] = "Rejoice in the Lord always: and again I say, Rejoice. - Philippians, 4. 4"
    quote[36] = "Let your light so shine before men, that they may see your good works. -Matthew, 5. 16"
    quote[37] = "I am the good shepherd: the good shepherd giveth his life for the sheep. - John 10. 11"
    quote[38] = "I am the resurrection, and the life: he that believeth in me, though he were dead, yet shall he live. And whoever liveth and believeth in me shall never die. - John, 11. 25"
    quote[39] = "Friend, go up higher. Luke, 14. 10"
    quote[40] = "Blessed are the peacemakers: for they shall be called the children of God. - Matthew, 5. 3"
    function rndnumber() {
        var randscript = -1
        while (randscript < 0 || randscript > howMany || isNaN(randscript)) {
            randscript = parseInt(Math.random() * (howMany + 1))
        }
        return randscript
    }
    quo = rndnumber()
    quox = quote[quo]
    document.write(quox)
    document.write('</h2>');
}

function reverse(n) {          // Reverse the order of the children of Node n
    //alert('yoop'); 
    var kids = n.childNodes;   // Get the list of children
    var numkids = kids.length; // Figure out how many there are
    for (var i = numkids - 1; i >= 0; i--) {  // Loop through them backwards
        var c = n.removeChild(kids[i]);    // Remove a child
        n.appendChild(c);                  // Put it back at its new position
        //document.getElementById(reversable)
    }
}

/* set the display for each particular xml item set when a control is clicked */
function news_items() {
    var uNum = new Date();  // this is to trick ie into thinking its new data every time
    uNum = uNum.getTime();  // so it doesnt store old info in cache
    document.write('<div id="newsbar" class="sidebar" style="font-size:1.1em;">');
    document.write('<div class="top"><div style="padding-top: 125px">The Latest News</div></div>');
    document.write('<div class="scroll" id="scroll" style="height:500px;overflow: auto"></div>');
    $.ajax({
        type: "GET",
        url: "xml/news.xml",  // this was url: "xml/news.xml", its been changed so ie gets the file as 'new' this time
        dataType: "text/xml",
        success: function(xml) {
            //alert('comes here');
            $(xml).find("myitem").each(function() {
            //alert('comes here');
                var id = $(this).find('ID').text();
                var title = $(this).find('title').text();
                var url = $(this).find('url').text();
                var details = $(this).find('details').text();
                //alert('' + title + '');
                if (details == "" && url == "") {
                    $('<span></span>').html('' + title + '').appendTo('#scroll');
                }
                if (details > "" && url == "") {
                    $('<span></span>').html('' + title + '<div>' + details + '</div>').appendTo('#scroll');
                }
                if (details == "" && url > "") {
                    $('<span></span>').html('' + title + '<div><a href="' + url + '" target="_blank"> more >>></a></div>').appendTo('#scroll');
                }
                if (details > "" && url > "") {
                    $('<span></span>').html('' + title + '<div>' + details + '<br /><a href="' + url + '" target="_blank"> more >>></a></div>').appendTo('#scroll');
                }
            });
            $('<span></span>').html('This Week at St Mary\'s<div><a href="http://www.mychurchevents.com/calendar/calendar.aspx?ci=L6I3H2I3J4K5G1G1" target="_blank"> more >>></a></div>').appendTo('#scroll');
            reverse(document.getElementById('scroll'));
        }
    });
    document.write('<p align="center"><!-- ---- Quick-counter.net ---- --><a href="http://www.quick-counter.net/" title="php hit counter - Quick-counter.net"><img src="http://www.quick-counter.net/aip.php?tp=di&tz=Europe%2FLondon" alt="php hit counter - Quick-counter.net" border="0" /></a><!-- ---- Quick-counter.net ---- --></p>');
    document.write('</div>');
}

function displayNAV() {
    if (MainNavigationItem == "home") {
        document.getElementById('home_nav').style.display = 'block';
    }
    else {
        if (MainNavigationItem == "home") {
            document.getElementById('home_nav').style.display = 'block';
        }
        else {
            if (MainNavigationItem == "advent") {
                document.getElementById('advent_nav').style.display = 'block';
            }
            else {
                if (MainNavigationItem == "christmas") {
                    document.getElementById('christmas_nav').style.display = 'block';
                }
                else {
                    if (MainNavigationItem == "mass") {
                        document.getElementById('mass_nav').style.display = 'block';
                    }
                    else {
                        if (MainNavigationItem == "about") {
                            document.getElementById('about_nav').style.display = 'block';
                        }
                        else {
                            if (MainNavigationItem == "parishnurse") {
                                document.getElementById('parishnurse_nav').style.display = 'block';
                            }
                            else {
                                if (MainNavigationItem == "calendar") {
                                    document.getElementById('calendar_nav').style.display = 'block';
                                }
                                else {
                                    if (MainNavigationItem == "sacrament") {
                                        document.getElementById('sacrament_nav').style.display = 'block';
                                    }
                                    else {
                                        if (MainNavigationItem == "religioused") {
                                            document.getElementById('religioused_nav').style.display = 'block';
                                        }
                                        else {
                                            if (MainNavigationItem == "ministries") {
                                                document.getElementById('ministry_nav').style.display = 'block';
                                            }
                                            else {
                                                if (MainNavigationItem == "youth") {
                                                    document.getElementById('youth_nav').style.display = 'block';
                                                }
                                                else {
                                                    if (MainNavigationItem == "bulletin") {
                                                        document.getElementById('bulletin_nav').style.display = 'block';
                                                    }
                                                    else {
                                                        if (MainNavigationItem == "prayerrequest") {
                                                            document.getElementById('prayerrequest_nav').style.display = 'block';
                                                        }
                                                        else {
                                                            if (MainNavigationItem == "suggestion") {
                                                                document.getElementById('suggestion_nav').style.display = 'block';
                                                            }
                                                            else {
                                                                if (MainNavigationItem == "community") {
                                                                    document.getElementById('community_nav').style.display = 'block';
                                                                }
                                                                else {
                                                                    if (MainNavigationItem == "joinparish") {
                                                                        document.getElementById('joinparish_nav').style.display = 'block';
                                                                        document.getElementById('friend_invite').style.display = 'block';
                                                                    }
                                                                    else {
                                                                        if (MainNavigationItem == "photos") {
                                                                            document.getElementById('photonav_nav').style.display = 'block';
                                                                        }
                                                                        else {
                                                                            if (MainNavigationItem == "links") {
                                                                                document.getElementById('links_nav').style.display = 'block';
                                                                            }
                                                                            else {
                                                                                if (MainNavigationItem == "strocco") {
                                                                                    document.getElementById('strocco_nav').style.display = 'block';
                                                                                }
                                                                                else {
                                                                                    if (MainNavigationItem == "olivebranch") {
                                                                                        document.getElementById('olivebranch_nav').style.display = 'block';
                                                                                    }
                                                                                    else {
                                                                                        if (MainNavigationItem == "weave") {
                                                                                            document.getElementById('weave_nav').style.display = 'block';
                                                                                        }
                                                                                        else {
                                                                                            if (MainNavigationItem == "contact") {
                                                                                                document.getElementById('contact_nav').style.display = 'block';
                                                                                                document.getElementById('friend_invite').style.display = 'block';
                                                                                            }
                                                                                            else {
                                                                                                if (MainNavigationItem == "universal") {
                                                                                                    document.getElementById('universal_nav').style.display = 'block';
                                                                                                }
                                                                                                else {
                                                                                                    if (MainNavigationItem == "arise") {
                                                                                                        document.getElementById('friend_invite').style.display = 'block';
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
