// JavaScript - Image Loop 


var frames;
images=new Array(4);
images[0]=new Image();
images[0].src="images/image_1.jpg";
images[0].url="Explore/charting.html";
images[1]=new Image();
images[1].src="images/image_2.jpg";
images[1].url="Explore/conversions.html";
images[2]=new Image();
images[2].src="images/image_3.jpg";
images[2].url="Explore/new_office.html";

frames=0;

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
} 

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 

function animateImages()
{
   var image_url = document.getElementById("image_url");
   if(document.image_placeholder && image_url)
   {
    document.image_placeholder.src=images[frames].src;
	image_url.href = images[frames].url;
    frames=(frames+1)%3;
    opacity('image_placeholder', 0, 100, 1000);
    timeout_id=setTimeout("animateImages()",4000);
    setTimeout("opacity('image_placeholder', 100, 0, 1000)",3000);

   }
}


 
