/**
 * Copyright (C) 2010 Drumbit - www.drumbit.com
 * 
 * This file is part of FL500
 *
 * FL500 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * FL500 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with FL500.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

$(document).ready(function() {
	$('.forum_question').cluetip({splitTitle: '|',width:400});
    $('.top_content_buttons').each(function(){
      
      $(this).click(function(){
      	$().stopTime('rotator');
        rotatorActivate($(this).attr('rel'));
        $().oneTime(5000, startRotator);
        return false; 
       });
    });
    
    rotatorActivate(1);
    startRotator();
    
//    $('.top_content_buttons:first').click();

    function rotatorActivate(index)
    {
      var href = $('#r_link_'+index).attr('href');
      $('#content').click(function(){ window.location = href; });
      $('.top_content_buttons.active').removeClass('active');
      $('.top_content_buttons[rel="'+index+'"]').addClass('active');
      $('#content').css('background-image','url(files/section1_top_content_background_image'+index+'.jpg)');
    }
    
    function rotatorNext()
    {
      var index = $('.top_content_buttons.active').attr('rel');
      if (index == 3)
        return 1;
      else 
        return ++index;
    }
    
    function startRotator()
    {
    	$().everyTime(3000,'rotator' , function(){rotatorActivate(rotatorNext())})
    }
 
})


