(function($){
$(document).ready(function () {

var $panels = $('#user-groups .scrollContainer > li');
var $container = $('#user-groups .scrollContainer');

var horizontal = true;

if (horizontal) {
  $panels.css({
    'float' : 'left',
    'position' : 'relative' 
  });

  $container.css('width', $panels[0].offsetWidth * $panels.length);
}

var $hmscroll = $('#user-groups .home-scroll').css('overflow', 'hidden');

function selectNav() {
  $(this)
    .parents('ul:first')
      .find('a')
        .removeClass('selected')
      .end()
    .end()
    .addClass('selected');
}

$('#user-groups .navigation').find('a').click(selectNav);

function trigger(data) {
  var el = $('#user-groups .navigation').find('a[href$="' + data.id + '"]').get(0);
  selectNav.call(el);
}

//if (window.location.hash) {
 // $('#'+window.location.hash).click();
 // doesn't really work because the links don't have any named anchors to link to plus 
 // you don't really want the home jumping around, so there isn't anywhere we can really put them.
//} else {
//}

$('ul.navigation a:first').click();
setTimeout("selectNextAutoScroll(false)", 10000);

$('#user-groups').mouseover(function(){
	selectNextAutoScroll(true)
});	


var offset = parseInt((horizontal ? 
  $container.css('paddingTop') : 
  $container.css('paddingLeft')) 
  || 0) * -1;

var scrollOptions = {
  target: $hmscroll,
  items: $panels,
  navigation: '.navigation a',
  axis: 'xy',
  onAfter: trigger,
  offset: offset,
  duration: 900,
  easing: 'swing'
};

$('#user-groups').serialScroll(scrollOptions);

$.localScroll(scrollOptions);

scrollOptions.duration = 1;
$.localScroll.hash(scrollOptions);

});
})($jQ132);

var mouseOverPause = false;

function selectNextAutoScroll(pause)
{
	return; // Disabled for home scroller

	if(pause == true) {
		mouseOverPause = pause;
	}
	
	if(mouseOverPause) { 
		return; 
	}
	var first = null;
	var clicked = false;
	$('ul.navigation a.autoscroll').each(function(){
		if(first = null) { first = $(this); }
		if(clicked == false && !$(this).hasClass('selected')) {
			$(this).click();
			clicked = true;
		}
	});
	
	if(first != null) {
		$(first).click();	
	}
	
	setTimeout("selectNextAutoScroll(mouseOverPause)", 10000);
}

