/**
 * @author David Durman
 *
 * Blinding effect toggling children of opt.wrapper.
 *
 * @param opt.wrapper: id or DOM element
 * @param opt.content: string denoting name of children elements (e.g. "div")
 * @param opt.index: should be always zero
 * @param opt.duration: duration of blinding effect is secs. (default 2.0)
 * @param opt.delay: should be 0.0
 * @param opt.effect: should be "blind"
 *
 * Dependency: scriptaculous
 * 
 * Example: blinderStart("wrapper");
 */
function blinderStart(opt){
    if (typeof opt.content == "undefined")
	opt.content = "div";
    if (typeof opt.index == "undefined")
	opt.index = 0;
    if (typeof opt.duration == "undefined")
	opt.duration = 2.0;
    if (typeof opt.delay == "undefined")
	opt.delay = 0.0;
    if (typeof opt.effect == "undefined")
	opt.effect = "blind";

    var divs = $(opt.wrapper).select(opt.content);
    for (var i = divs.length - 1; i > 0; i--){
	Element.toggle(divs[i]);
    } 
    var bid = setInterval(function(){_blinderStart(opt)}, opt.duration * 1000 * 2);  
    return bid;    
}

function blinderPause(blinderId, opt){
    clearInterval(blinderId);
}
function blinderContinue(opt){
    var bid = setInterval(function(){_blinderStart(opt)}, opt.duration * 1000 * 2);  
    return bid;    
}

function _blinderStart(opt){
    var divs = $(opt.wrapper).select(opt.content);
    Effect.toggle(divs[opt.index], opt.effect, {delay: opt.delay, duration: opt.duration});
    opt.index = (opt.index + 1) % (divs.length);
    Effect.toggle(divs[opt.index], opt.effect, {delay: opt.delay, duration: opt.duration});
}

