$().ready(function(){

    /*initiate on load functions */
    if ($('.step-arrows li:eq(1)').hasClass("active")) {
        var self = $('.step-arrows li:eq(1)');
        $(self).prev().removeClass("starter").addClass("starter-active");
        if ($(self).next().hasClass("arrowhead")) {
            $(self).next().addClass("arrowhead-state-02");
        }
        var sThisHref = $(self).find("a").attr("href");
        $(self).parent().next().find(sThisHref).show().find("div").show();
    }
    ///
    $('.step-arrows li a').each(function(){
        if ($(this).parent().hasClass("active")) {
            var sTmpHref = $(this).attr("href");
            $(sTmpHref).show();
        }
    });
    
    
    $('.step-arrows li a').click(function(){
        $(this).parent().parent().find("li").removeClass("active");
        $(this).parent().addClass("active");
        $(this).parent().parent().find("li").each(function(){
            if ($(this).attr("class").indexOf("arrowhead") >=0 ) $(this).attr("class","").addClass("arrowhead");
        });
        var bPrevArrowhead = ( $(this).parent().prev().attr("class").indexOf("arrowhead") >=0 );
        if (bPrevArrowhead) $(this).parent().prev().attr("class","").addClass("arrowhead-state-01");
        var bNextArrowhead = ( $(this).parent().next().attr("class").indexOf("arrowhead") >=0 );
        if (bNextArrowhead) $(this).parent().next().attr("class","").addClass("arrowhead-state-02");
        var bIsFirstLi = ($(this).parent().prev().attr("class").indexOf("starter") >=0 );
        if (bIsFirstLi) $(this).parent().prev().attr("class","starter-active");
        else $(this).parent().parent().find(".starter-active").attr("class", "starter");
        var bIsLastLi = ($(this).parent().next().attr("class").indexOf("end") >=0 );
        if (bIsLastLi) $(this).parent().next().attr("class","end-active");
        else $(this).parent().parent().find(".end-active").attr("class", "end");
        
        $(this).parent().parent().next().children("div").hide();
        var sThisHref = $(this).attr("href");
        $(this).parent().parent().next().find(sThisHref).show().find("div").show();
        return false;
    });
    
    /* Kreditanfrage stellen Info Stack (sliders) */
    $('.info-stack>ul>li>a').click(function(){
        
        if (!$(this).hasClass("active")) {
            $('.info-stack>ul>li>a.active').next('div').toggle();
            $('.info-stack>ul>li>a').removeClass("active");
            $(this).addClass("active").next("div").toggle();
        }
        return false; 
        
    });
    
    /* rc slider */
    $('.rc_contact_callback_slider_opener').click(function(){
        
        if ($(this).parent().prev(".down-arrow").is(":visible")) $(this).parent().prev(".down-arrow").hide();
        else $(this).parent().prev(".down-arrow").show();
        $(this).parent().parent().find(".callback_request_form").slideToggle("fast");
        return false;
    });
    
    $('.rc_callback_ssh .down-arrow, .rc_callback .down-arrow').click(function(){
        $(this).parent().find('.rc_contact_callback_slider_opener').click();
        return false;
    });
    
});