// Spam Killer Using Intelligence & Shape Heeding (SKUISH)
// Copyright 2007 Matthew Boynes

var thisStep = 0;

function initSKUISH() {
	output = document.getElementById('squish_output');
	output.value = "";
	//setCircle(Math.floor(Math.random()*8+1)+1);
	setCircle(seq.charAt(thisStep++));
}

function processThis(num) {
		clearCircle(seq.charAt(thisStep-1));
		output.value += filterValue(num);
	if (thisStep < 4) {
		//setCircle(Math.floor(Math.random()*8+1)+1);
		setCircle(seq.charAt(thisStep++));
	}
	else {
		hide_map();
	}
}

function hide_map() {
	el = document.getElementById('map');
	el.style.overflow = "hidden";
	hide(el,300,1,15,50,2);
}
function setCircle(num) {
	document.getElementById("img"+num).style.background = "#ececec url('skuish/2.gif') -10px -10px no-repeat";
}

function clearCircle(num) {
	document.getElementById("img"+num).style.background = "#ececec url('skuish/1.gif') -10px -10px no-repeat";
}

function filterValue(num) {
	return code.charAt(num-1);
}

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) {
//Generic Animation Step Value Generator By www.hesido.com
	var delta = maxValue - minValue;
	var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
	return Math.ceil(stepp)
}
//var debug = "";
function hide(elem,startHt,endHt,steps,intervals,powr) {
	if (elem.heightInt) window.clearInterval(elem.heightInt);
	var thisStep = 0;
	elem.heightInt = window.setInterval(
		function() {
			elem.style.height = easeInOut(startHt,endHt,steps,thisStep,powr)+"px";
			//debug += elem.style.opacity+"\n";
			thisStep++;
			if (thisStep > steps) {
			elem.style.display = 'none';
			document.getElementById('directions').innerHTML = "Thank You!";
			document.getElementById('status').style.display = "none";
			window.clearInterval(elem.fadeInt);
			//alert(debug);
			}
		}
		,intervals)
}