// JavaScript Document
jQuery(document).ready(function () {
	jQuery('header a').bind('click', function() {
		jQuery('.active').removeClass('active');
		jQuery(this).addClass('active');
		jQuery.scrollTo(jQuery(this).attr('href'), 500);
	});
	var _demo = jQuery('#main_demo').html();
	jQuery('#main_demo ul').moodular();
	jQuery('#vertical').click(function () {
		jQuery('#vertical_demo').html(_demo);
		jQuery('#vertical_demo ul').moodular({
			direction: 'top'
		});
		jQuery(this).remove();
	});
	
	
	jQuery('#easing').click(function () {
		jQuery('#easing_demo').html(_demo);
		jQuery('#easing_demo ul').moodular({
			direction: 'bottom',
			easing: 'easeOutBounce'
		});
		jQuery(this).remove();
	});
	jQuery('#starton').click(function () {
		jQuery('#starton_demo').html(_demo);
		jQuery('#starton_demo ul').moodular({
			startOn : 2
		});
		jQuery(this).remove();
	});
	jQuery('#navigation').click(function () {
		jQuery('#navigation_demo').html(_demo);
		jQuery('#navigation_demo ul').moodular({
			controls : 'index',
			auto: false
		});
		jQuery(this).remove();
	});
	jQuery('#reflection').click(function () {
		jQuery('#reflection_demo').html(_demo);
		jQuery('#reflection_demo ul').moodular({
			effects : 'reflection'
		});
		jQuery(this).remove();
	});
	jQuery('#touch').click(function () {
		jQuery('#touch_demo').html(_demo);
		jQuery('#touch_demo ul').moodular({
			effects : 'reflection',
			controls : 'touch',
			auto : false
		});
		jQuery(this).remove();
	});	
	jQuery('#api').click(function () {
		jQuery('#api_demo').html(_demo).append('<a href="#" class="next">next</a>');
		var mood = jQuery('#api_demo ul').moodular({
			auto: false,
			api: true
		});
		jQuery('#api_demo a.next').bind('click', function () { mood.next(); return false; });
		jQuery(this).remove();
	});	
	jQuery('#callback').click(function () {
		jQuery('#callback_demo').html(_demo).append('<a href="#" class="next">next</a>');
		var mood = jQuery('#callback_demo ul').moodular({
			auto: false,
			callbacks: [hasMoved],
			api: true
		});
		jQuery('#callback_demo a.next').bind('click', function () { mood.next(); return false; });
		jQuery(this).remove();
	});	
	jQuery('#fading').click(function () {
		jQuery('#fading_demo').html(_demo);
		jQuery('#fading_demo ul').moodular({
			effects: 'fade',
			controls: 'index',
			auto: false
		});		
		jQuery(this).remove();
	});
	jQuery('#stopOver').click(function () {
		jQuery('#stopOver_demo').html(_demo);
		jQuery('#stopOver_demo ul').moodular({
			controls: 'stopOver'
		});		
		jQuery(this).remove();
	});
	
	
});
function hasMoved(moodular) {
	alert("I've moved to item number " + moodular.current);
}

