﻿$('#show-form').click(function(e) {
    $('.b-form').modal({
        overlayClose:true
    });
    return false;
});

$('.b-form-file-input').change(function() {
    var val = this.value;
    $('.fakefile input').val(val);
});

$('.vac-item h4').click(function() {
    $(this).siblings("p").toggle(300);
});

$('.tend-item h5').click(function() {
    $(this).siblings("p").toggle(300);
});

$('.sliding-item').live("mouseenter", function(){
    if (window.slTimeoutId) {clearTimeout(window.slTimeoutId);}

    $('.sliding-item:animated').clearQueue();
    $(this).siblings('.sliding-item').animate({width: 128}, 500);
    $(this).siblings('.sliding-item').removeClass("hovered");
    $(this).animate({width: 510}, 500);
    var t = $(this);
    window.slTimeoutId = setTimeout(function(){t.addClass("hovered")}, 400);
});

$('#scrollbar1').tinyscrollbar();

$(document).ready(function(){
    $('html').ajaxSend(function(event, xhr, settings) {
        function getCookie(name) {
            var cookieValue = null;
            if (document.cookie && document.cookie != '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++) {
                    var cookie = jQuery.trim(cookies[i]);
                    // Does this cookie string begin with the name we want?
                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }

        if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
            // Only send the token to relative URLs i.e. locally.
            xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
        }
    });
});


