/*-----------------------------------------------------------------------------


@author:		Cesar Ebrat
@contact:		cesar.ebrat@whads.com
@organization:	Whads/Accent SL
@since:			February 2010
-----------------------------------------------------------------------------*/

jQuery(function() {
    
    HOME_TIMEOUT = 2000;
    
    jQuery('.home-slideshow').css('position', 'relative').css('height', 'auto');
    
    var elements = jQuery('.home-slideshow li');
	
    elements.each(function () {
        jQuery(this).css('position', 'absolute').hide();
    });
	jQuery('.home-slideshow li:first').show();

    setTimeout(function() {
            nextf(elements, 0, 1);
        }, HOME_TIMEOUT);

    function nextf(elements, current, next) {
        
        jQuery(elements[next]).fadeIn(2000);
		jQuery(elements[current]).fadeOut(2000);
		
		
        if ((current + 1) < elements.length) {
            current = current + 1;
			next = current + 1;
			if(next  == elements.length) next = 0;
        } else {
			current = 0;
			next = current + 1;
        }		
		
        setTimeout(function() {
            nextf(elements, current, next);
        }, HOME_TIMEOUT);
    }

    // **** remove Opacity-Filter in ie ****
    function removeFilter(element) {
        if(element.style.removeAttribute){
            element.style.removeAttribute('filter');
        }
    }
    

})



