/*
 plugin for setting up jcarousels with callbacks
 this is used throughout the site, so dont mess with it without testing extensively
*/
$.fn.jCarouselInit = function(opts){
	var options = jQuery.extend( {
		next: '.next',
		prev: '.prev',
		scroll: 1,
		buttonNextHTML: null,
		buttonPrevHTML: null,
		wrap:'last'
	},opts);

	var jCarouselInitCallback =  function(c){
		jQuery(options.next).bind('click', function() {
			c.next();
			return false;
		})

		jQuery(options.prev).bind('click', function() {
			c.prev();
			return false;
		});
	}
	options.initCallback = jCarouselInitCallback;

	$(this).jcarousel(options)

};

$(document).ready(function() {
	if ($(this).jcarousel){

		$('#twitter-btm-wrapper .tweets').jCarouselInit({
			scroll:2,
			//auto: 2,
			vertical: true,
			next: '#twitter-next',
			prev: '#twitter-previous'
		});

		$('#twitter-callout .tweets').jCarouselInit({
			scroll:1,
			//auto: 2,
			vertical: true,
			next: '#twitter-next',
			prev: '#twitter-previous'
		});

	}

	$('form div.required label').append('<span class="req-mark">*</span>');
	
	
//What You Can Do Page – Ajax Pagination 

	$('#tips-pagination a, #tips_numbers a').live('click', function() {
		$.get(this.href, function(data){
 			$('#tips-container').replaceWith($(data).find('#tips-container'));

			FB.XFBML.parse() // To initialise the FB button
			
			// To initialise the addthis Button
			if (window.addthis)
			{
			   window.addthis.ost = 0;
			   window.addthis.ready();
			}
			
			$.scrollTo('#tips-container', {speed:500});
		});
		return false;
	});
});

