function run(){
        runAnnouncements();
		getBirthdays(); //call the getBirthdays function to populate the bDays span
        //changeSize();
}

   var counter = 0;
   var max = 1;
   var go;
   var ann = new Array();
   ann[0] = "First Fear Factor Service this month! July 28th.";
   ann[1] = "Youth & Young Adults Activity Night -- Volleyball, basketball, food, etc...7PM July 23 at the Church!";
   ann[2] = "";
   ann[3] = "";
  

   
   function runAnnouncements(){
        go = setInterval("write()", 7000);
        document.getElementById('ann').innerHTML = ann[counter];
        counter++;
        if(counter > max){
                counter = 0;
        }//reset counter to beginning after reaches the end of announcments
   }
   function write(){
        document.getElementById('ann').innerHTML = ann[counter];
        counter++;
        if(counter > max){
                counter = 0;
        }//reset counter to beginning after reaches the end of announcments
   }
   function play(){
        runAnnouncements();
        document.getElementById('pauseplay').innerHTML = '<img src="http://www.praiseagyouth.com/images/Pause.gif" alt="Pause/Play" id="pause_play" onclick="change()" />';
   }
   function change(){
        clearInterval(go);
        document.getElementById('pauseplay').innerHTML = '<img src="http://www.praiseagyouth.com/images/Play.gif" alt="Pause/Play" id="pause_play" onclick="play()" />';
   }
   function nextAnn(){
        document.getElementById('ann').innerHTML = ann[counter];
        counter++;
        if(counter > max){
                counter = 0;
        }//reset counter to beginning after reaches the end of announcments
   }
	 
//BEGIN ILLUMINATE AND LIGHTEN SECTION---------------------------------
var hex = 255;
var set;
var id = "";
var id2 = "";
var ids = new Array();
ids[0] = 'box';
ids[1] = 'box2';
ids[2] = 'box3';
ids[3] = 'box4';
ids[4] = 'box5';
ids[5] = 'box6';
ids[6] = 'box7';
ids[7] = 'box8';
ids[8] = 'box9';

function illuminate(number){
        id = ids[number];
        light();
}
function darken(number){
        id2 = ids[number];
        reset();
}
        
function light(){
        if(hex > 0){
                hex -= 5;
                document.getElementById(id).style.color = "rgb("+hex+", 255, 255)";
                set = setTimeout("light()", 20);
        }else{
                hex = 255;
        }
        }
function reset(){
        clearTimeout(set);
        hex = 255;
        document.getElementById(id2).style.color = "rgb(255, 255, 255)";
}
//END ILLUMINATE AND LIGHTEN

//CHANGE BACKGROUND COLOR SECTION-----------------------------------------------------------
var col = new Array();
col[0] = '0';
col[1] = '1';
col[2] = '2';
col[3] = '3';
col[4] = '4';
col[5] = '5';
col[6] = '6';
col[7] = '7';
col[8] = '8';
col[9] = '9';
col[10] = 'a';
col[11] = 'b';
col[12] = 'c';
col[13] = 'd';
col[14] = 'e';
col[15] = 'f';
function changeBackgroundColor(){
		 var color = "";
		 
		 for(i=0; i<6; i++){
		 			var randomnumber=Math.floor(Math.random()*16);
					color += col[randomnumber];
		 }
		 
		 document.getElementById('body').style.backgroundColor = '#'+color;
}

//CHANGE BACKGROUND-IMAGE SECTION------------------------------------------------------------------------------------
var bac = new Array();
bac[0] = 'Background1.gif';
bac[1] = 'Background2.gif';
bac[2] = 'Background5.gif';
bac[3] = 'Background6.gif';
bac[4] = 'Background7.gif';
bac[5] = 'Background8.gif';
bac[6] = '6';
bac[7] = '7';
bac[8] = '8';
bac[9] = '9';
bac[10] = 'a';
bac[11] = 'b';
bac[12] = 'c';
bac[13] = 'd';
bac[14] = 'e';
bac[15] = 'f';

function changeBackground(){
		 var background = "";
		 
		 var randomnumber=Math.floor(Math.random()*6);
		 background = bac[randomnumber];
		 
		 document.getElementById('body').style.backgroundImage = "url(http://www.praiseagyouth.com/images/" + background + ")";
}      

//SCRIPTURE OF THE WEEK SECTION------------------------------------------------------------------
var scriptureArray = new Array();
    scriptureArray[0] = "John 4:35  Say not ye, There are yet four months, and then cometh harvest? behold, I say unto you, Lift up your eyes, and look on the fields; for they are white already to harvest.";
    scriptureArray[1] = "Galatians 2:20  I am crucified with Christ: nevertheless I live; yet not I, but Christ liveth in me: and the life which I now live in the flesh I live by the faith of the Son of God, who loved me, and gave himself for me.";
    scriptureArray[2] = "Joshua 1:8  This book of the law shall not depart out of thy mouth; but thou shalt meditate therein day and night, that thou mayest observe to do according to all that is written therein: for then thou shalt make thy way prosperous, and then thou shalt have good success.";
    scriptureArray[3] = "Philippians 4:8  Finally, brethren, whatsoever things are true, whatsoever things are honest, whatsoever things are just, whatsoever things are pure, whatsoever things are lovely, whatsoever things are of good report; if there be any virtue, and if there be any praise, think on these things.";
    scriptureArray[4] = "Philippians 4:9  Those things, which ye have both learned, and received, and heard, and seen in me, do: and the God of peace shall be with you.";
    scriptureArray[5] = "Isaiah 26:3  Thou wilt keep him in perfect peace, whose mind is stayed on thee: because he trusteth in thee.";
    scriptureArray[6] = "1Samuel 15:22  And Samuel said, Hath the LORD as great delight in burnt offerings and sacrifices, as in obeying the voice of the LORD? Behold, to obey is better than sacrifice, and to hearken than the fat of rams. ";
    scriptureArray[7] = "Romams 5:8  But God commendeth his love toward us, in that, while we were yet sinners, Christ died for us. ";
    scriptureArray[8] = "Psalms 55:22  Cast thy burden upon the LORD, and he shall sustain thee: he shall never suffer the righteous to be moved.";
    scriptureArray[9] = "Matthew 11:29-30  Take my yoke upon you, and learn of me; for I am meek and lowly in heart: and ye shall find rest unto your souls.  (30)  For my yoke is easy, and my burden is light.";
    scriptureArray[10] = "2 Corinthians 5:7  (For we walk by faith, not by sight:)";
    scriptureArray[11] = "Habakkuk 2:3  For the vision is yet for an appointed time, but at the end it shall speak, and not lie: though it tarry, wait for it; because it will surely come, it will not tarry.";
    scriptureArray[12] = "Ephesians 6:18  Praying always with all prayer and supplication in the Spirit, and watching thereunto with all perseverance and supplication for all saints;";
    scriptureArray[13] = "Hebrews 10:19  Having therefore, brethren, boldness to enter into the holiest by the blood of Jesus,";
    scriptureArray[14] = "Revelations 2:7  He that hath an ear, let him hear what the Spirit saith unto the churches; To him that overcometh will I give to eat of the tree of life, which is in the midst of the paradise of God. ";
    scriptureArray[15] = "2 Corinthians 4:10  Always bearing about in the body the dying of the Lord Jesus, that the life also of Jesus might be made manifest in our body.";
    scriptureArray[16] = "Ephesians 1:18  The eyes of your understanding being enlightened; that ye may know what is the hope of his calling, and what the riches of the glory of his inheritance in the saints,";
    scriptureArray[17] = "2 Peter 1:4  Whereby are given unto us exceeding great and precious promises: that by these ye might be partakers of the divine nature, having escaped the corruption that is in the world through lust.";
    scriptureArray[18] = "Romans 8:35  Who shall separate us from the love of Christ? shall tribulation, or distress, or persecution, or famine, or nakedness, or peril, or sword?";
    scriptureArray[19] = "Romans 8:39  Nor height, nor depth, nor any other creature, shall be able to separate us from the love of God, which is in Christ Jesus our Lord.";
    scriptureArray[20] = "John 3:16  For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. ";
    scriptureArray[21] = "1 Peter 3:15  But sanctify the Lord God in your hearts: and be ready always to give an answer to every man that asketh you a reason of the hope that is in you with meekness and fear: ";
    scriptureArray[22] = "Proverbs 1:7  The fear of the LORD is the beginning of knowledge: but fools despise wisdom and instruction. ";
    scriptureArray[23] = "Isaiah 54:17  No weapon that is formed against thee shall prosper; and every tongue that shall rise against thee in judgment thou shalt condemn. This is the heritage of the servants of the LORD, and their righteousness is of me, saith the LORD. ";
    scriptureArray[24] = "2 Chronicles 7:14  If my people, which are called by my name, shall humble themselves, and pray, and seek my face, and turn from their wicked ways; then will I hear from heaven, and will forgive their sin, and will heal their land. ";
    scriptureArray[25] = "Jeremiah 29:11  For I know the thoughts that I think toward you, saith the LORD, thoughts of peace, and not of evil, to give you an expected end.";
    scriptureArray[26] = "Matthew 6:33  But seek ye first the kingdom of God, and his righteousness; and all these things shall be added unto you.";
    scriptureArray[27] = "Matthew 6:25  Therefore I say unto you, Take no thought for your life, what ye shall eat, or what ye shall drink; nor yet for your body, what ye shall put on. Is not the life more than meat, and the body than raiment?";
    scriptureArray[28] = "Hebrews 4:7  Again, he limiteth a certain day, saying in David, Today, after so long a time; as it is said, Today if ye will hear his voice, harden not your hearts.";
    scriptureArray[29] = "2 Corinthians 6:2  (For he saith, I have heard thee in a time accepted, and in the day of salvation have I succored thee: behold, now is the accepted time; behold, now is the day of salvation.)";
    scriptureArray[30] = "2 Timothy 3:16  All Scripture is given by inspiration of God, and is profitable for doctrine, for reproof, for correction, for instruction in righteousness:";
    scriptureArray[31] = "2 Timothy 1:7  For God hath not given us the spirit of fear; but of power, and of love, and of a sound mind.";
    scriptureArray[32] = "John 16:33  These things I have spoken unto you, that in me ye might have peace. In the world ye shall have tribulation: but be of good cheer; I have overcome the world.";
    scriptureArray[33] = "John 14:2-3  In my Father's house are many mansions: if it were not so, I would have told you. I go to prepare a place for you.  (3)  And if I go and prepare a place for you, I will come again, and receive you unto myself; that where I am, there ye may be also.";
    scriptureArray[34] = "1Thessalonians 5:23  And the very God of peace sanctify you wholly; and I pray God your whole spirit and soul and body be preserved blameless unto the coming of our Lord Jesus Christ.";
    scriptureArray[35] = "Matthew 4:4  But he answered and said, It is written, Man shall not live by bread alone, but by every word that proceedeth out of the mouth of God. ";
    scriptureArray[36] = "Matthew 11:12  And from the days of John the Baptist until now the kingdom of heaven suffereth violence, and the violent take it by force. ";
    scriptureArray[37] = "Phillippians 3:14  I press toward the mark for the prize of the high calling of God in Christ Jesus.";
    scriptureArray[38] = "Psalms 37:23  The steps of a good man are ordered by the LORD: and he delighteth in his way.";
    scriptureArray[39] = "Isaiah 54:17  No weapon that is formed against thee shall prosper; and every tongue that shall rise against thee in judgment thou shalt condemn. This is the heritage of the servants of the LORD, and their righteousness is of me, saith the LORD.";
    scriptureArray[40] = "1 John 2:5  But whoso keepeth his word, in him verily is the love of God perfected: hereby know we that we are in him. ";
    scriptureArray[41] = "Psalms 101:3  I will set no wicked thing before mine eyes: I hate the work of them that turn aside; it shall not cleave to me. ";
    scriptureArray[42] = "Philippians 2:12  Wherefore, my beloved, as ye have always obeyed, not as in my presence only, but now much more in my absence, work out your own salvation with fear and trembling. ";
    scriptureArray[43] = "Philippians 2:3  Let nothing be done through strife or vainglory; but in lowliness of mind let each esteem other better than themselves.";
    scriptureArray[44] = "1Thessalonians 4:16  For the Lord himself shall descend from heaven with a shout, with the voice of the archangel, and with the trump of God: and the dead in Christ shall rise first: ";
    scriptureArray[45] = "Ephesians 5:16  Redeeming the time, because the days are evil.";
    scriptureArray[46] = "Romans 8:28  And we know that all things work together for good to them that love God, to them who are the called according to his purpose. ";
    scriptureArray[47] = "2Corinthians 9:8  And God is able to make all grace abound toward you; that ye, always having all sufficiency in all things, may abound to every good work: ";
    scriptureArray[48] = "Matthew 5:48  Be ye therefore perfect, even as your Father which is in heaven is perfect.";
    scriptureArray[49] = "Jeremiah 1:5  Before I formed thee in the belly I knew thee; and before thou camest forth out of the womb I sanctified thee, and I ordained thee a prophet unto the nations.";
    scriptureArray[50] = "Matthew 5:41  And whosoever shall compel thee to go a mile, go with him twain.";
    scriptureArray[51] = "1 John 2:2  And he is the propitiation for our sins: and not for ours only, but also for the sins of the whole world.";
    
function getScriptureOfTheWeek(){
        document.getElementById('scripture').innerHTML = scriptureArray[getWeeks()];
}//close function
    
function getWeeks(){
        var startDate = new Date();
        startDate.setFullYear(2010);
        startDate.setMonth(0);
        startDate.setDate(1);

        var todaysDate = new Date();

        var startMillis = startDate.getTime();
        var currentMillis = todaysDate.getTime();

        var minutes = 1000*60
        var hours = minutes*60
        var days = hours*24
        
        var timeDifferenceInMillis = currentMillis - startMillis;
        var totalDays = timeDifferenceInMillis/days;
        var weeks = parseInt(totalDays/7);
        
        return weeks;
}//close function

function changeSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    var h = myHeight - 30;
    document.getElementById('sImage').style.height = h;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
    var h = myHeight - 30;
    document.getElementById('sImage').style.height = h;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
    var h = myHeight - 30;
    document.getElementById('sImage').style.height = h;
  }

}

var g;
var w = 1;
var h = 1;
var fs = 0.1;
var isExpanded = 0;
var isRunning = 0;
function showBirthdays(){
        if(isRunning == 0){
                if(isExpanded == 0){
                        document.getElementById('birthdays').style.display = 'block';       
                        g = setInterval('expand()', 5);
                        isExpanded = 1;
                        isRunning = 1;
                }else{     
                        g = setInterval('collapse()', 5);
                        isExpanded = 0;
                        isRunning = 1;
                }
        }else{
                //do nothing because one of the scripts is running
        }
}

function expand(){
        w += 1.5;
        h += 1;
        if(w < 50){
                fs += 0.025;
        }else{
                fs += 0.1;
        }
                
        if(w <= 300){
                document.getElementById('birthdays').style.width = w;
                document.getElementById('birthdays').style.height = h;
                document.getElementById('bdayImage').style.width = w;
                document.getElementById('bdayImage').style.height = h;
                document.getElementById('bDays').style.fontSize = fs;
        }else{
                document.getElementById('close').innerHTML = '<a href="javascript: showBirthdays();"><img src="http://www.praiseagyouth.com/images/close.gif" alt="close the box" style="position: absolute; top: 5px; right: 5px;" /></a>';
                clearInterval(g);
                isRunning = 0;
        }
}

function collapse(){
        w -= 1.5;
        h -= 1;
        if(w < 50){
                fs -= 0.025;
        }else{
                fs -= 0.1;
        }
        if(w > 1){
                document.getElementById('close').innerHTML = "";
                document.getElementById('birthdays').style.width = w;
                document.getElementById('birthdays').style.height = h;
                document.getElementById('bdayImage').style.width = w;
                document.getElementById('bdayImage').style.height = h;
                document.getElementById('bDays').style.fontSize = fs;
        }else{
                document.getElementById('birthdays').style.display = 'none';
                clearInterval(g);
                isRunning = 0;
        }
}

//section for ajax and php

var request = null;

try{
	request = new XMLHttpRequest();
}catch (trymicrosoft) {
	try{
		request = new ActiveXObject("Msxm12.XMLHTTP");
	}catch (othermicrosoft) {
		try{
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}catch (failed) {
			request = null;
		}
	}
}

function getBirthdays(){ //calls the php script GetBirthdays.php to get a list of birthdays for the specified month
	var d = new Date(); //get a reference to a new Date object
	var month = d.getMonth() + 1; //use getMonth to get the current month and add 1 -- months are in an array starting at 0
	var url = "http://www.praiseagyouth.com/Ajax/GetBirthdays.php?month=" + month;
	request.open("get", url, true);
	request.onreadystatechange = updatePage;
	request.send(null);
}

function updatePage(){  //function that server calls to update page with guessed number results
	if(request.readyState == 4){  //if the php script is done -- readystate = 4
		if(request.status == 200){
			var bithdays = request.responseText;  //get returned values from php in responseText property of request object
			var element = document.getElementById('bDays'); //create a reference to the bDays span area
			var updateBDays = document.createTextNode(birthdays); //create a new Text node to add to bDays as firstChild
			element.firstChild = updateBDays;  //update the bDays span area by replacing its first child with the responseText
		} else {
			alert('The server had a problem with your request.');
		}//end if/else
	}//end if
}//end updatePage
