﻿// This is where the news and events locations are updated from the newsfeatured.html and the eventsfeatured.html


function loadNewsDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && (xmlhttp.status==200 || xmlhttp.status==0))
    {
    document.getElementById("newsFeatured").innerHTML=xmlhttp.responseText;
    document.getElementById("newNews").className = "show";
	document.getElementById("oldNews").className = 'hidden';

    }
  }
xmlhttp.open("GET","newsfeatured.html",true);
xmlhttp.send();
}

function loadEventsDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && (xmlhttp.status==200 || xmlhttp.status==0))
    {
    document.getElementById("eventsFeatured").innerHTML=xmlhttp.responseText;
    document.getElementById("newEvents").className = "show";
	document.getElementById("oldEvents").className = 'hidden';

    }
  }
xmlhttp.open("GET","eventsfeatured.html",true);
xmlhttp.send();
}


	
	/* function changeImage() {
		var showcaseArray = document.getElementById('showcaseImage').children;
		var previous;
		showcaseArray[counter].className = 'show';
		if (counter == 0) {
			previous = 5;
		}
		else { previous = counter - 1; }
		showcaseArray[previous].className = 'hidden';
		
		counter = counter + 1;
		if (counter >=6) { counter = 0}
		else { return; }
	} */
	

// Global Variables set for the timer and calling function to cycle through slides
var interval= setInterval("changeImage()", 7500);
var counter = 5;

	function changeImage() {
		var showCase = document.getElementById('showcase' + counter);

		//fadeEffect.init('showcase' + counter, 0);
		showCase.className = 'hidden';
		showNextImage();
	}
//Showing the next image in the slide
	function showNextImage() {
		counter = (!document.getElementById('showcase' + (counter + 1))) ? 0 : counter + 1;

		showCase = document.getElementById('showcase' + counter);
			
			if (showCase.className == 'hidden') {
				//showCase.style.alpha = 0;
				//showCase.style.opacity = 0;
				showCase.className = 'show';
				}
			
		//fadeEffect.init('showcase' + counter, 1);
	}

//fade function, elements opacity/alpha is controlled to show this

var fadeEffect=function(){
    return{
        init:function(id, flag, target){
            this.elem = document.getElementById(id);
            clearInterval(this.elem.si);
            this.target = target ? target : flag ? 100 : 0;
            this.flag = flag || -1;
            this.alpha = this.elem.style.opacity ? parseFloat(this.elem.style.opacity) * 100 : 0;
            this.si = setInterval(function(){fadeEffect.tween()}, 40);
        },
        tween:function(){
            if(this.alpha == this.target){
            //We've reached our target opacity (either 100% or 0%)!
                clearInterval(this.si);
                if (this.alpha == 0) {
                	this.elem.className = "hidden";
                	showNextImage();
                }
            }else{
                var value = Math.round(this.alpha + ((this.target - this.alpha) * .06)) + (1 * this.flag);
                this.elem.style.opacity = value / 100;
                this.elem.style.filter = 'alpha(opacity=' + value + ')';
                this.alpha = value;
            }
        }
    }
}();




//on hover command was originally written as an onclick hence the function name

	function onClick(pagenumber) {

		document.getElementById('showcase' + counter).className = 'hidden';
		counter = pagenumber;
		document.getElementById('showcase' + counter).className = 'show';
	
		clearInterval(interval);
	}
	
	function mouseOut() {
		interval= setInterval("changeImage()", 7500);
	}	




// This is where the news and events locations are updated from the newsfeatured.html and the eventsfeatured.html
/*
function loadNewsDoc()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && (xmlhttp.status==200 || xmlhttp.status==0))
    {
    document.getElementById("newsFeatured").innerHTML=xmlhttp.responseText;
    document.getElementById("newNews").className = "show";
	document.getElementById("oldNews").className = 'hidden';

    }
  }
xmlhttp.open("GET","newsfeatured.html",true);
xmlhttp.send();
}

function loadEventsDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && (xmlhttp.status==200 || xmlhttp.status==0))
    {
    document.getElementById("eventsFeatured").innerHTML=xmlhttp.responseText;
    document.getElementById("newEvents").className = "show";
	document.getElementById("oldEvents").className = 'hidden';

    }
  }
xmlhttp.open("GET","eventsfeatured.html",true);
xmlhttp.send();
}
*/
