
// For IE
if (!Array.indexOf) {
    Array.prototype.indexOf = function(obj, startIndex) {
        for (var i = startIndex || 0; i < this.length; i++) {
            if (this[i] == obj) { return i; }
        }
        return -1;
    }
}

jQuery(document).ready( function() {
	$('.language-selector').each(function() {
		$(this).click(function() {
			$.ajax({
				type: 'POST',
				url: reverse('user.language'),
				data: {
					lang: this.id.slice(0, 5)
				},
				success: function() {
					window.location.search =
						window.location.search.replace(/(\?)?&?lang=\w{2}/, '$1').replace('?&', '?').replace('?$', '');
				}
			});
		});
	});
});