﻿// JScript File

document.onreadystatechange=fnStartInit;

      
    function fnStartInit()
    {
        if (document.readyState=="complete")
            {
                
                
                showTime()
                checkrotate()
                  
            }
    }

	var Images = new Array("images/styles/entrance_sign.jpg",
	                        "images/styles/lpfount1.jpg",
	                        "images/styles/lpfount2.jpg",
	                        "images/styles/lpfount3.png")
	                        
    var imgCt = Images.length
	var firstTime = true


    function checkrotate()
    
    {
        if(document.title=="Home Page")
        {
            rotate()
        }
        
        else
        
        {
            //Don't rotate the images.
            
            function removeElement()
            {
              
                  //Instead remove the picture if we're not on the Home Page.
                var oChild=headerimgwrapper.children(0);	
                headerimgwrapper.removeChild(oChild);
                var fChild=footer.children(0);
                footer.removeChild(fChild);
            }
                        
            removeElement()
            //document.getElementById("headerimg").style.backgroundImage = 'url(App_Themes/Brown/Images/entrance_sign.jpg)'
            
        }    
        
       
    }

       
	function rotate()
	 {
	   		if (document.images)
    		{
 		       if (firstTime)
 		        {
		            bgimage = Math.floor((Math.random() * imgCt))
		            firstTime = false
	            }
        		else
        		{
            		bgimage++
		            if (bgimage == imgCt)
		             {
                		bgimage = 0
		             }
	            }
	            
	           
                    
        		    document.getElementById("headerimg").style.backgroundImage = 'url('+Images[bgimage]+')'
        
                    setTimeout("rotate()", 3000)
            }
     }
     
     
      function showTime()
    {

        var today=new Date();
        var h=today.getHours();
        var m=today.getMinutes();
        var s=today.getSeconds();
        var y=today.getFullYear();
        var d=today.getDate();
       
        var weekday=new Array(7);
            weekday[0]="Sunday";
            weekday[1]="Monday";
            weekday[2]="Tuesday";
            weekday[3]="Wednesday";
            weekday[4]="Thursday";
            weekday[5]="Friday";
            weekday[6]="Saturday";
            
        var month=new Array(12);
            month[0]="January";
            month[1]="February";
            month[2]="March";
            month[3]="April";
            month[4]="May";
            month[5]="June";
            month[6]="July";
            month[7]="August";
            month[8]="September";
            month[9]="October";
            month[10]="November";
            month[11]="December";

        // add a zero in front of numbers<10

        m=checkTime(m);
        s=checkTime(s);
        document.getElementById('timeinfo').innerHTML=weekday[today.getDay()]+", "+month[today.getMonth()]+" "+d+" "+y+" "+h+":"+m+":"+s;
        t=setTimeout('showTime()',500);
    }

    function checkTime(i)
    {
        if (i<10)
        {
        i="0" + i;
        }
    
        return i;
    }
   
  