// Public module (aka global) javascript file.
var $j = jQuery.noConflict();
var $ = jQuery.noConflict();

// Feature js
var count = new Array();
var timer = new Array();
var limit = new Array();
function change(to, featnum){
	$j('#feature_items'+featnum+' li').css('display', 'none');
	$j('#feature_index'+featnum+' li').removeClass('selected');
	
	// Set the desired item to display
	$j('#item'+featnum+'x'+to).css('display', 'block');
	$j('#index'+featnum+'x'+to).addClass('selected');
}
// Timer for feature
function stop_auto(featnum){
	clearTimeout(timer[featnum]);
	timer[featnum] = false;
}
function toggle_auto(featnum){
	if(!timer[featnum]){
		$j('#toggle_switch'+featnum).html('Pause');
		auto(featnum);
	} else {
		$j('#toggle_switch'+featnum).html('Play');
		stop_auto(featnum);
	}
}
function auto(featnum){
	var n = count[featnum];
	change(n, featnum);
	if(n == limit[featnum]){
		count[featnum] = 0;
	} else {
		count[featnum] = n+1;
	}
	timer[featnum] = setTimeout(function() {auto(featnum);}, 9000);
}

