var state=0;
var himg = document.getElementById("homeimg");
//setOpacity(himg,25);

setTimeout("checkState()",500);

var fadeTimer;

function checkState(){
	var himg = document.getElementById("homeimg");
	var halt = document.getElementById("homealt");
	if (state==0){
		himg.src = "/images/robot1.jpg";
		//halt.innerHTML = "<h3>Technology</h3><p>Preston Research has years of robotics and artifical intelligence knowledge at it's fingertips. How you use this technology could be the difference between you and your competition.";
		//halt.title="Technology";
		setOpacity(himg,0);
	}
	if (state==1){
		himg.src = "/images/code1.jpg";
		//halt.innerHTML = "<h3>Software</h3><p>Software when done right is a tool that extends your skills, organizes your knowledge, and saves you time. The faster you can do things means more for your business.";
		//halt.title="Software";
		setOpacity(himg,0);
	}
	if (state==2){
		himg.src = "/images/consult1.jpg";
		//halt.innerHTML = "<h3>Consulting</h3><p>Whether you have a short term need, or need to move your organiztion in a new direction. We specialize in Web 2.0, and Open Source based solutions designed to keep your business on the edge, while saving you money.";
		//halt.title="Consulting";
		setOpacity(himg,0);
		state=-1;
	}
	fadeTimer = setTimeout("show()",50);
}

var opacity = 0;

function show() {
	opacity = opacity+1;
	var himg = document.getElementById("homeimg");
	setOpacity(himg,opacity);
	if (opacity < 100) {
		fadeTimer = setTimeout("show()",25);
	} else {
		state++;
		opacity = 100;
		setTimeout("fade()",3000);
	}
}

function fade() {
	opacity = opacity-1;
	var himg = document.getElementById("homeimg");
	setOpacity(himg,opacity);
	if (opacity > 0) {
		fadeTimer = setTimeout("fade()",25);
	} else {
		opacity = 0;
		setTimeout("checkState()",50);
	}
}

function setOpacity(obj,val) {
	val = val/100;
	obj.style.opacity = val;
	obj.style.MozOpacity = val;
	obj.style.filter = "alpha(opacity=" + (val*100) + ")";
}