
// blink effect
var effectBlinkQueue = new Array();
var effectBlinkTimes = 3;
var effectBlinkInterval = 300;

function effectBlink(obj) {
	var i = new Number(0);
	obj.blinkSwitch = 1;
	for (i = 0; i < (effectBlinkTimes*2); i++) {
		effectBlinkQueue.push(obj);
		window.setTimeout("effectBlinkDequeue();", effectBlinkInterval*i);
	}
}
function effectBlinkDequeue() {
	if (effectBlinkQueue.length) {
		obj = effectBlinkQueue.pop();
		obj.blinkSwitch *= -1;
		if (obj.blinkSwitch < 0)
			elementSetAlpha(obj, 0.2);
		else
			elementSetAlpha(obj, 1);
		obj.focus();
	}
}


var effectFadeObjects = new Array();
var effectFadeSteps = 5;

function effectFade(obj, direction, callback) {
	obj.fade = new Object();
	obj.fade.steps = direction ? new Number(0) : new Number(effectFadeSteps);
	obj.fade.direction = direction ? new Number(1) : new Number(-1);
	obj.fade.callback = callback;
	obj.fade.parent = obj;
	effectFadeObjects.push(obj);
	effectFadeTimer(effectFadeObjects.length-1);
}
function effectFadeTimer(obj_id) {
	var obj = effectFadeObjects[obj_id];

	if (obj) {
		if (obj.fade.steps) {
			obj.fade.steps += obj.fade.direction;
			elementSetAlpha(obj, (effectFadeSteps-obj.fade.steps)/effectFadeSteps);
 			if (obj.fade.steps >= 0 && obj.fade.steps <= effectFadeSteps)
				window.setTimeout("effectFadeTimer('"+obj_id+"');", 100);
			else {
				effectFadeObjects[obj_id] = 0;
				//if (obj.fade.callback)
					//obj.fade.callback();
			}
		}
	}
}