/*
 *	jQuery fadeGallery v1.0.0
 *
 *	Copyright (c) 2008 Alex Miller
 *	email: alex@citizen.kharkov.ua
 *	Licensed under the MIT License:
 *	http://www.opensource.org/licenses/mit-license.php
 */
jQuery.fn.fadeGallery = function(options){
	
    // default setting
    var options = jQuery.extend({
	timeOut: '1000' // delay time | default '1000'
    },options);
    
    var timer = '';
    var active = 1;
    var last = 0;
    
    var imgList = jQuery(this);
    var imgs = imgList.find('div.fade-box').get();
    imgList.css('position', 'relative');
    // set the first image on top
    jQuery(imgs[0]).css('zIndex', '1');
    jQuery(imgs[imgs.length]).css('zIndex', '1');
    
    var slide = function() {
	// hide all images
	for(i=0; i<imgs.length; i++) {
	    jQuery(imgs[i]).css('display', 'none');
	}
	// show background 'last' image
	jQuery(imgs[last]).css('display', 'block').css('zIndex', '0');
	// show active image
	jQuery(imgs[active]).css('zIndex', '1').fadeIn('10000');
	if ( ( active + 1 ) < imgs.length ) {
	    active = active + 1;
	    last = active - 1;
	} else {
	    active = 0;
	    last = imgs.length - 1;
	}
	// next step sliding
	timer = setTimeout(slide, options.timeOut);
    }
    return this.each(function() {
	// slide
	timer = setTimeout(slide, options.timeOut);
    });
};
function initPage()
{
    $('.truefalse-box').fadeGallery({
	timeOut: 5000 // change slide every 5 seconds
    });
}
if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
	window.attachEvent("onload", initPage);	