function nextElem(elem) {
    elem.fadeOut(300, function() {
        if(elem.next().length > 0) {
            elem.removeClass('current-item');
            elem.next().addClass('current-item');
            elem.next().fadeIn(300);
            //$('.toolbar-m').html($('.current-item .stock-img div img').attr('title'));
        } else { 
            elem.removeClass('current-item');
            elem.siblings(':first').addClass('current-item');
            elem.siblings(':first').fadeIn(300);
            //$('.toolbar-m').html($('.current-item .stock-img div img').attr('title'));
        }
    });
}

function prevElem(elem) {
    elem.fadeOut(function() {
        if(elem.prev().length > 0) {
            elem.removeClass('current-item');
            elem.prev().addClass('current-item');
            elem.prev().fadeIn(300);
            //$('.toolbar-m').html($('.current-item .stock-img div img').attr('title'));
        } else { 
            elem.removeClass('current-item');
            elem.siblings(':last').addClass('current-item');
            elem.siblings(':last').fadeIn(300);
            //$('.toolbar-m').html($('.current-item .stock-img div img').attr('title'));
        }
    });
}

$(document).ready(function() {
    $(".toolbar").css("opacity", 0.4);
    
    $('.stock-wrapper').each(function(index) {
        if(index == 0) {
            $(this).addClass('current-item');
            //$('.toolbar-m').html($('.current-item .stock-img div img').attr('title'));
        }
        else if(index > 0) {
            $(this).hide();
        }
    });
    
   if($('#switchHeader').children().size() > 1) {
        $('#switchHeader').cycle({
            fx: 'fade' 
        });
    }

    $('#pfeil-rechts').click(function() {
        nextElem($('.current-item'));
    });
    $('#pfeil-links').click(function() {
        prevElem($('.current-item'));
    });
    
    $('.header').hover(function(){
    		$(".toolbar").fadeTo("fast", 1.0); 
    	},function(){
       		$(".toolbar").fadeTo("fast", 0.4);
    	});
    	
    $("a.fancybox").fancybox();
    $("a.download").fancybox();
    

    $('#open_contactform').click(function() {
        $("#contactform").modal({
        	opacity: 60,
        	overlayCss: {backgroundColor:"#666"}
        });
    });
    
    $('.banner-inner ul').cycle({
        fx: 'fade'
    });
});

function enableButton() {
    if(document.getElementById('option').checked) {
    document.getElementById('submit').disabled='';
  } else {
    document.getElementById('submit').disabled='true';
  }
}

