var rotate = true;

(function($) {
	$.fn.selectrandom = function () {
		if(rotate == true){
			setTimeout(function(){
				$('#Tabs').tabs( "select" , Math.ceil(Math.random()*9) ).selectrandom();
			},7000);
		}
	}
})(jQuery);

$(document).ready(function(){


if($('#Tabs').length > 0){
	// $('#Tabs').tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 7000);
	$('#Tabs').tabs({ fx: { opacity: 'toggle' } }).selectrandom();
}

$('.ui-tabs-nav a').click(function(){
	rotate = false;
});

/*
function load_random(){
	 $('#Tabs').tabs( "select" , Math.ceil(Math.random()*9) )
}
*/

	if($('.scrollable').length) $(".scrollable").scrollable({ vertical: false, mousewheel: false });
	
	// Setsup clear field
	$('.clearfield').clearField();
	
	$('.facts_link').click(function(){
		return false;
	});
	
	$('.NutsinthePantryForm').change(function(){
		//alert($(this).attr('value'));
	//	window.location = $(this).attr('value');
	});
	
	$('.NutsinthePantryForm select').change(function(){
		//alert($(this).attr('value'));
		window.location = $(this).attr('value');
	});
	
	$('.RecipeForm select').change(function(){
		$(this).parent().submit();
	});
	
	$('.RecipeTagForm select').change(function(){
		window.location = $(this).attr('value');
	});

});
