function pageselectCallback(page_index, jq){
	var new_content = $('#hiddenresult div.result:eq('+page_index+')').clone();
	$('#Searchresult').empty().append(new_content);
	return false;
}

function initPagination() {
	var num_entries = $('#hiddenresult div.result').length;
	// Create pagination element
	$("#Pagination").pagination(num_entries, {
		num_edge_entries: 2,
		num_display_entries: 6,
		callback: pageselectCallback,
		items_per_page:1
	});
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

$(document).ready(function() {

    jQuery('#mycarousel').jcarousel({
        auto: 1,
		animation: 6500,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });


	//hide message_body after the first one
	$(".message_list .message_body:gt(-1)").hide();
	
	//toggle message_body
	$(".message_head").click(function(){
		$(this).next(".message_body").slideToggle(500)
		return false;
	});

	//collapse all messages
	$(".collpase_all_message").click(function(){
		$(".message_body").slideUp(500)
		return false;
	});

	//show all messages
	$(".show_all_message").click(function(){
		$(this).hide()
		$(".show_recent_only").show()
		$(".message_list li:gt(4)").slideDown()
		return false;
	});

	//show recent messages only
	$(".show_recent_only").click(function(){
		$(this).hide()
		$(".show_all_message").show()
		$(".message_list li:gt(4)").slideUp()
		return false;
	});

	initPagination();
	

});

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 1,
		animation: '6500',
        wrap: 'first',
        initCallback: mycarousel_initCallback
    });
});

jQuery(document).ready(function() {
     jQuery('a[rel*=facebox]').facebox(); 
});

