// Show hide
var fadelist = new Array
var linklist = new Array
var fadelist2 = new Array
var globalcounter = 0
var globalfade = ""
var globalfade2 = ""
var globalcounterCustomer = 0

fadelist[0] = "image-keephome"
fadelist[1] = "image-payoff"
fadelist[2] = "image-stopdemands"

fadelist2[0] = "testimon-one"
fadelist2[1] = "testimon-two"
fadelist2[2] = "testimon-three"


function startfade() {
globalfade = setInterval("autofade()",6000)
globalcounter = 1
}

function startfadeCustomerStories() {
globalfade2 = setInterval("autofadeCustomer()",6000)
globalcounterCustomer = 1
}

function autofade(){
if (globalcounter > 2){
globalcounter = 1
flipper(linklist[0],fadelist[0])
} 
else
{

flipper(linklist[globalcounter],fadelist[globalcounter])
globalcounter = globalcounter + 1
}
}

function autofadeCustomer(){
if (globalcounterCustomer > 2){
globalcounterCustomer = 1
flipperCustomer(fadelist2[0])
} 
else
{
flipperCustomer(fadelist2[globalcounterCustomer])
globalcounterCustomer =  globalcounterCustomer + 1
}
}



//Routine to fade in layers
var fadeTime = ""
var fadeTime2 = ""
var mozfade = 0
var IEfade = 0
var previous = ""
function flipper(ID,targetID) {
	
   	clearInterval(fadeTime)
   
	document.getElementById(targetID).style.backgroundImage = "url(img/" + targetID + ".png)";
	
   
   if (previous!=targetID){
	document.getElementById("image-keephome").style.zIndex = 1;
	document.getElementById("image-payoff").style.zIndex = 1;
	document.getElementById("image-stopdemands").style.zIndex = 1;

   }
	
	
	if (previous==""){
		previous = "image-keephome"
		document.getElementById(targetID).style.zIndex = 9;
	}
	
	mozfade = 0
	IEfade = 0
	if (previous==targetID){
		document.getElementById(targetID).style.zIndex = 9;

	}
	
	else
	
	{
		fadeTime = setInterval("FadeIn('" + targetID + "')",10)
		document.getElementById(targetID).style.opacity = 0;
		document.getElementById(targetID).style.filter="alpha(opacity=0)";
		document.getElementById(previous).style.zIndex = 2;
		document.getElementById(targetID).style.zIndex = 9;		
	}
	previous = targetID
}


var previouscustomer = ""
function flipperCustomer(targetID) {

   clearInterval(fadeTime2)
     
   if (previouscustomer!=targetID){
	document.getElementById("testimon-one").style.zIndex = 1;
	document.getElementById("testimon-two").style.zIndex = 1;

   }
		
	if (previouscustomer==""){
		previouscustomer = "testimon-one"
		document.getElementById(targetID).style.zIndex = 9;
	}
	
	mozfade2 = 0
	IEfade2 = 0
	if (previouscustomer==targetID){
		document.getElementById(targetID).style.zIndex = 9;

	}
	else	
	{
		fadeTime2 = setInterval("FadeIn2('" + targetID + "')",20)
		document.getElementById(targetID).style.opacity = 0;
		document.getElementById(targetID).style.filter="alpha(opacity=0)";
		document.getElementById(previouscustomer).style.zIndex = 2;
		document.getElementById(targetID).style.zIndex = 9;		
		
	}
	previouscustomer = targetID
}




//Fading function
function FadeIn(targetID) {

		document.getElementById(targetID).style.opacity = mozfade 
		document.getElementById(targetID).style.filter = "alpha(opacity=" + IEfade + ")" 
		mozfade = mozfade + 0.1
		IEfade = IEfade + 10
		
		if (mozfade > 1 || IEfade > 100){
			clearInterval(fadeTime)
		}
	}//Fading function
function FadeIn2(targetID) {

		document.getElementById(targetID).style.opacity = mozfade2 
		document.getElementById(targetID).style.filter = "alpha(opacity=" + IEfade2 + ")" 
		mozfade2 = mozfade2 + 0.1
		IEfade2 = IEfade2 + 10
		
		if (mozfade2 > 1 || IEfade2 > 100){
		    clearInterval(fadeTime2)
		}
	}


function stopme(){
	clearInterval(globalfade)
}
	
loadtest = true
