var myObj;
var isOn = 1;
var sponIndex = 0;

function nextImage(){
	var sponsors = new Array();
	sponsors[0] = "/images/sponsors/stepsMarketing.png";
	sponsors[1] = "/images/sponsors/deloitte.jpg";
	sponsors[2] = "/images/sponsors/steltzner.jpg";
	sponsors[3] = "/images/sponsors/subway.jpg";
	sponsors[4] = "/images/sponsors/macys.jpg";
	sponsors[5] = "/images/sponsors/bankofthewest.jpg";
	sponsors[6] = "/images/sponsors/allstate.jpg";
	var imgRet = sponsors[sponIndex];
	sponIndex++;
	if(sponIndex >= sponsors.length){
		sponIndex=0;
	}
	return imgRet;
}

function turnOn2(){
	turnOn('sponsorSpace',null);
}

function turnOn(obj,e){
	myObj = obj;
	if(isOn == 1){
		turnOff();
		setTimeout("document.getElementById(myObj).src=nextImage()",900);
		setTimeout("doTurnOn()",1000);
	}else{
		doTurnOn();
	}
}

function doTurnOn(){
	document.getElementById(myObj).style.visibility = "visible";
	opacity(myObj, 0, 100, 800);
	isOn = 1;
}

function turnOff(){
	opacity(myObj, 100, 0, 800);
	setTimeout("document.getElementById(myObj).style.visibility = \"hidden\"",1000);
	isOn = 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++;
        }
    }
}
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 + ")";
}