var hovering = false;
function hover(onoff){
	if(onoff == 'on'){
		clearInterval(intIdSpot1);
		clearInterval(intIdSpot2);
	}else{
		intIdSpot1 = setInterval("flicker('visible')", 700);
		intIdSpot2 = setInterval("flicker('hidden')", 900);
	}
}

function homeBtn(onoff){
	if(onoff){
		clearInterval(hoInt1);
		clearInterval(hoInt2);
		clearInterval(hoInt3);
		change('home','home_on');
	}else{
		hoInt1 = setInterval("change('home','home_ho')", 950);
		hoInt2 = setInterval("change('home','home_off')", 5000);
		hoInt3 = setInterval("change('home','home_hot2')", 400);
	}
}

var showInt1;
var showInt2;
function showcaseBtn(onoff){
	clearInterval(showInt1);
	clearInterval(showInt2);
	if(onoff){
		showInt1 = setInterval("showcaseLoop(true)",100);
	}else{
		showInt2 = setInterval("showcaseLoop(false)",100);
	}
}

var showPos = 0;
function showcaseLoop(onoff){
	showPos = (onoff) ? (showPos + 1) : (showPos - 1);
	if(showPos < 0){
		showPos = 0;
	}
	try{
		img = 'showcase_' + showPos;
		change('showcase',img);
		if(showPos >= 9){
			clearInterval(showInt1);
			showPos = 9;
		}else if(showPos <= 0){
			clearInterval(showInt2);
			showPos = 0;
		}
	}catch(e){
		clearInterval(showInt1);
		clearInterval(showInt2);
		showPos = 0;
	}
}

var intIdOn;
var intIdOff;
function contactBtn(onoff){
	var first = randRange(1,3);
	var second = randRange(4,6);
	var speed = randRange(10,300);
	if(onoff){
		intIdOn = setTimeout("contactLoop("+first+","+second+","+onoff+")",speed);
	}else{
		intIdOff = setTimeout("contactLoop("+first+","+second+","+onoff+")",speed);
	}
}

var iter = 0;
function contactLoop(one,two,onoff){
	if(onoff){
		clearInterval(intIdOff);	
	}else{
		clearInterval(intIdOn);	
	}
	first = (onoff) ? one : two;
	second = (onoff) ? two : one;
	last = (onoff) ? "contact_7" : "contact_0";
	var speed = randRange(100,1000);
	if(iter == 0){
		change("contact", "contact_" + first );
		iter = iter + 1;
		int1 = setTimeout("contactLoop("+one+","+two+","+onoff+")", speed);
	}else if(iter == 1){
		change("contact", "contact_" + second );
		iter = iter + 1;
		int1 = setTimeout("contactLoop("+one+","+two+","+onoff+")", speed);
	}else if(iter == 2){
		change("contact",last);
		iter = 0;
	}
}
function change(picName,imgName){
	if (document.images){
		imgOn = eval(imgName + ".src");
		document[picName].src = imgOn;
	}
}
function randRange(low,high){
	return Math.floor(Math.random() * (high - low + 1) + low);	
}



function flicker(visi,obj){
	try{
		var obj = document.getElementById(obj);
		obj.style.visibility = visi;
	}catch(e){}
}

function clearInts(){
	clearInterval(showInt1);
	clearInterval(showInt2);
	clearInterval(hoInt1);
	clearInterval(hoInt2);
	clearInterval(hoInt3);
	clearInterval(intIdOff);
	clearInterval(intIdOn);
	clearInterval(int1);
}
intIdSpot1 = setInterval("flicker('visible','spotlight')", 2700);
intIdSpot2 = setInterval("flicker('hidden','spotlight')", 3800);

hoInt1 = setInterval("change('home','home_ho')", 950);
hoInt2 = setInterval("change('home','home_off')", 5000);
hoInt3 = setInterval("change('home','home_hot2')", 400);






