$(document).ready(function() {

	/* Link Vorschlagen Formular ausklappen */
	$('#suggest_link').click(function() {
		if ($('#suggest').css('display') == 'none') {
		$('#suggest').slideDown('fast');
		$(this).css('color', '#FFF');
		$(this).css('background-color', '#ff3b8c');
		}
		else if ($('#suggest').css('display') == 'block') {
		$('#suggest').slideUp('fast');
		$(this).css('color', '#0077DA');
		$(this).css('background-color', '#D8ECFB');
		}
	});

            /**
             * Callback function that displays the content.
             *
             * Gets called every time the user clicks on a pagination link.
             *
             * @param {int} page_index New Page index
             * @param {jQuery} jq the container with the pagination links as a jQuery object
             */
            function pageselectCallback(page_index, jq){
                jQuery('#projects div.project').hide().slice(3 * page_index, 3 * page_index+3).show();
                return false;
            }

            /**
             * Initialisation function for pagination
             */
            function initPagination() {
                // count entries inside the hidden content
                var num_entries = jQuery('#projects div.project').length;
                // Create content inside pagination element
                $("#pagination").pagination(num_entries, {
                    callback: pageselectCallback,
                    items_per_page:3
                });

                pageselectCallback(0);
             }

            // When document is ready, initialize pagination
            $(document).ready(function(){
                initPagination();
            });

	    $('.accordeon').each(function() {
			var $ac = $(this);

			$('.bigslogan, .smallslogan', $ac).click(function() {
				var $cur = $(this);

				if ($cur.is('.active')) {
					$('.accontent', $ac).slideUp('slow', function() {
						$(this).addClass('hide');

						$('.bigslogan').removeClass('hide').removeClass('active');
						$('.smallslogan').addClass('hide');
					});
				} else {
					$('.accontent:not(.hide)').slideUp('slow', function() {
						var $this = $(this);

						$this.addClass('hide');
					});

					$('.accontent', $ac).slideDown('slow', function() {
						var $this = $(this);

						$this.removeClass('hide');
						$('.bigslogan', $ac).addClass('active').removeClass('hide');
						$('.smallslogan', $ac).addClass('hide');

						$('.accordeon').has('.accontent.hide')
							.find('.bigslogan')
								.removeClass('active')
								.addClass('hide')
								.end()
							.find('.smallslogan')
								.removeClass('hide');

						var offset = $ac.offset();
						$(document).scrollTop(offset.top);
					});
				}

				return false;
			});
	    });
});

