﻿


$(document).ready(function() {
    /*$("#contacteer_button").click(function() {
    openContactForm();
    });
    $("#solliciteer_button_black").click(function() {
    openSolliciteerForm();
    });*/
    $("#contact_button, #contact_bar_text").click(function() {
        if ($("#contact_button").attr("class") == "button_open") {
            window.location = "/#/contacteer-ons/";
        } else {
            closeContactForm();
            window.location = "/#/";
        }
    });
    $("#solliciteer_button, #solliciteer_bar_text").click(function() {
        if ($("#solliciteer_button").attr("class") == "button_open") {
            window.location = "/#/solliciteer-bij-cap47/";
        } else {
            closeSolliciteerForm();
            window.location = "/#/";
        }
    });
});

function openContactForm() {
    $("#contact_button").attr("class", "button_close");
    if (allowTransitions()) {
        $("#contact_container").slideDown();
        $("#contact_bar_message").fadeOut(500);
    } else {
        $("#contact_container").show();
        //$(getScrollElement()).scrollTop($("#contact_bar").offset().top );
        $("#contact_bar_message").hide();
    }
    $(getScrollElement()).animate({ scrollTop: $("#contact_bar").offset().top }, 500);
    closeSolliciteerForm();
}
function closeContactForm() {
    $("#contact_button").attr("class", "button_open");
    if (allowTransitions()) {
        $("#contact_container").slideUp();
    } else {
        $("#contact_container").hide();
    }
}

function openSolliciteerForm() {
    var heightContactForm = 0;
    if ($("#contact_container").is(":visible")) {
        closeContactForm();
        heightContactForm = parseFloat($("#contact_container").height());
    }
    $("#solliciteer_button").attr("class", "button_close");
    if (allowTransitions()) {
        $("#solliciteer_container").slideDown();
        $("#solliciteer_bar_message").fadeOut(500);
    } else {
        $("#solliciteer_container").show();
        //$(getScrollElement()).scrollTop($("#solliciteer_bar").offset().top);
        $("#solliciteer_bar_message").hide();
    }
    $(getScrollElement()).animate({ scrollTop: $("#solliciteer_bar").offset().top - heightContactForm }, 500);
}
function closeSolliciteerForm() {
    $("#solliciteer_button").attr("class", "button_open");
    if (allowTransitions()) {
        $("#solliciteer_container").slideUp();
    } else {
        $("#solliciteer_container").hide();
    }
}

function showThanksContactForm() {
    $("#contact_bar_message").fadeIn(500);
    if (allowTransitions()) {
        $(getScrollElement()).animate({ scrollTop: $("#contact_bar").offset().top }, 500);
    } else {
        $(getScrollElement()).scrollTop($("#contact_bar").offset().top);
    }
    closeContactForm();
}
function showThanksSolliciteerForm() {
    $("#solliciteer_bar_message").fadeIn(500);
    if (allowTransitions()) {
        $(getScrollElement()).animate({ scrollTop: $("#solliciteer_bar").offset().top }, 500);
    } else {
        $(getScrollElement()).scrollTop($("#solliciteer_bar").offset().top);
    }
    closeSolliciteerForm();
}


