// Category code copyright (C) Steve Levine, 2009
// Don't reproduce without permissions!
//
areaWidth = 800;
areaHeight = 200;

numCats = 5;
catSize = 100;

catLocs = new Array(numCats);
catHeight = 0;

function setupCats() {
	space = (areaWidth - numCats * catSize) / (numCats + 1);
	catHeight = (areaHeight - catSize) / 2;
	for(c = 0; c < numCats; c++) {
		catLocs[c] = (space + (space + catSize) * c);
		thisCat = getCat(c);
		new Effect.Move(thisCat,  {
			x: catLocs[c],
			y: (areaHeight + catSize + 5),
			mode: 'absolute',
			transition: Effect.Transitions.full,
			duration: 0.0,
		});
		new Effect.Appear(thisCat, {
			duration: 0.0,
			queue: 'end',
		});
	}
	setTimeout("chainPeakABoo(0);", 500);
	return false;
}		

function chainPeakABoo(i) {
	thisCat = getCat(i);
	new Effect.Move(thisCat, {
		x: catLocs[i],
		y: catHeight,
		mode: 'absolute',
		transition: Effect.Transitions.spring,
		duration: 1.5,
	});

	if (i + 1 < numCats) {
		setTimeout('chainPeakABoo('+(i+1)+');',100);
	}	
}

function hoverIn(i) {
	//Remove any other effects that are in process
	var queue = Effect.Queues.get(getCat(i));
	queue.each(function(effect) {effect.cancel(); });
	//Zoom in on this picture
	new Effect.Morph(getCat(i), {
		style: {
			left: (catLocs[i] - catSize/2) + "px",
			top: (catHeight - catSize / 2) + "px",
			height: 2*catSize + "px",
			width: 2*catSize + "px",
		},
		duration: 0.2,	
		queue: {position: 'end', scope: getCat(i)},
	});
}

function hoverOut(i) {
	//Remove any pending effects in progress
	var queue = Effect.Queues.get(getCat(i));
	queue.each(function(effect) {effect.cancel(); });
	// Zoom out
	new Effect.Morph(getCat(i), {
		style: {
			left: catLocs[i] + "px",
			top: catHeight + "px",
			height: catSize + "px",
			width: catSize + "px",
		},
		duration: 0.2,
		queue: {position: 'end', scope: getCat(i)},
	});
}


function getCat(i) {
	return ('box' + i);
}

