﻿/* =========================================================
 // jquery.innerfade.js
 // Datum: 2008-02-14
 // Firma: Medienfreunde Hofmann & Baldes GbR
 // Author: Torsten Baldes
 // Mail: t.baldes@medienfreunde.com
 // Web: http://medienfreunde.com
 // based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
 // and Ralf S. Engelschall http://trainofthoughts.org/
 *
 *  <ul id="news">
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *
 *  $('#news').innerfade({
 *    animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'),
 *    speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'),
 *    timeout: Time between the fades in milliseconds (Default: '2000'),
 *    type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'),
 *      containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *    runningclass: CSS-Class which the container gets applied (Default: 'innerfade'),
 *    children: optional children selector (Default: null)
 *  });
 *
 // ========================================================= */
(function($){

    $.fn.innerfade = function(container, options){
	
	var settings = {
            'speed': 'normal',
            'timeout': 10000,
            'runningclass': 'innerfade',
            'children': null
        };
	
	var elements = $('#mamba_numba').val() - 1;	

	setTimeout(function(){
                $.innerfade.next(elements, settings, 0, 0);
            }, 10000);
            //$(elements[0]).show();
    };
    
    $.innerfade = function(container, options){
        var settings = {
            'speed': 'normal',
            'timeout': 10000,
            'runningclass': 'innerfade',
            'children': null
        };
        if (options) 
            $.extend(settings, options);
        if (settings.children === null) 
            var elements = $(container).children();
        else 
            var elements = $(container).children(settings.children);

        if (elements.length > 1) {
            
            setTimeout(function(){
                $.innerfade.next(elements, settings, 1, 0);
            }, settings.timeout);
            $(elements[0]).show();
            
        }
    };
    
    $.innerfade.next = function(elements, settings, current, last){
        //alert(elements.length);
        var next = current + 1;
        
        //????????????????       
		if ((next) < elements) {
            current = current + 1;
            last = current - 1;
        }
        else {
            current = -1;
            last = elements.length - 1;
        }
        //????????:
        $('.keyvisual-switcher a').removeClass('active');
        $('.keyvisual-image.active').css('display', 'none');
        $('.keyvisual-info-item.active').css('display', 'none');
        $('#rotator_link_'+ next).addClass('active');
        $('.keyvisual-image.active').removeClass('active');
        $('.keyvisual-info-item.active').removeClass('active');
        $('#keyvisual_image_'+ next).fadeIn(300, function(){
            $('#keyvisual_image_'+ next).addClass('active');
        });
        $('#keyvisual_info_'+ next).fadeIn(500, function(){
            $('#keyvisual_info_'+ next).addClass('active');
        });
        setTimeout((function(){
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };
    
})(jQuery);
/*
 ScreenWidth = screen.width;// ????????? ???????, ??????? ?? 1024.
 if(ScreenWidth == 1024){
 $("body,html").css({ "margin-left": "-130px" });
 }
 
 */
// **** remove Opacity-Filter in ie ****
function removeFilter(element){
    if (element.style.removeAttribute) {
        element.style.removeAttribute('filter');
    }
}


