main=new Object();
main.carousel={
       'container':'#topics',
       'wireUp':function(){
              var that=this;
              that.container=$(that.container);
              that.container.jcarousel({
                     animation:1200,
                     scroll: 2,
                     auto: 6,
                     wrap: "both",
                     initCallback: function(carousel){
						that.container.css('height','auto');
						$('#topics li').css('visibility','visible');
                          carousel.container.click(function(e){
                              carousel.startAuto(0);
                          });
                          // Pause autoscrolling if the user moves with the cursor over the clip.
                          carousel.clip.hover(function() {
                              carousel.stopAuto();
                          }, function() {
                              carousel.startAuto();
                          });
                     }
              });
              
              
              /*
              // Setup the previews
              $('#carousel .thumbnails a').live('click', function(e) {
                      e.preventDefault();
                      var twitterId=$(this).find('div.twitterId').html();
                      main.features.changeUser(twitterId);
                      return false;
              })
              //*/
       }
}
//The box on the right for the featured profile
main.features={
       'container':'#features',
       'wireUp':function(){
              var that=this;
              that.container=$(that.container);
              
              //Register link
              $('#features .register').click(function(e){
                     e.preventDefault();
                     $('#features .profile').fadeOut('fast',function(e){
                            $('#registrationFormContainer').css('display','block');
                     });
              });
       },
       //Changes the user being displayed in the feature area
       'changeUser':function(twitterId){
              var that=this;
              var user=featured_user;
              
              var topicsHTML=new Array();
              for(var i in user.topics){
                     var topic=user.topics[i];
                     topicsHTML.push('<a href="/profile/summary/'+user.screen_name+'">'+topic+'</a>');
              }
              topicsHTML=topicsHTML.join(', ');
              
              that.container.find('.profile')
                     .find('.chicklet img').attr('src',user.profile_image_url).end()
                     .find('.chicklet .kscore').html(user.kscore).end()
                     .find('#display_name a').html(user.name).attr('href','/profile/summary/'+user.screen_name).end()
                     .find('#display_interests p').html(topicsHTML);
              that.container.effect("highlight", {'color':'#00B8F1'}, 800);

       }
                                                        
}

 $(document).ready(function() {
       
	//Some display stuff for IE
	if(!$.browser.msie){
		$('.IE').removeClass('IE');
	}
	
	$('.nojs').removeClass('nojs');
	
	main.carousel.wireUp();
        main.features.wireUp();
        
	
});