//This is a comment
$(document).ready(function() {
  var images = [];
  
  //var imageWidth = $('#header').width();
  //var imageSum = 4;
  //var imageReelWidth = imageSum * imageWidth;
  
  //$('.image_reel').css({'width' : imageReelWidth});
  
  rotate = function(){
    var clicked_thumb = $active.attr("id");
    //var triggerID = $active.attr("rel") - 1;
    var triggerID = clicked_thumb.substr(clicked_thumb.length - 1, clicked_thumb.length) - 1
    //var image_reelPosition = triggerID * imageWidth;
    
    $('.paging a').removeClass('selected');
    $active.addClass('selected');
    
    $('.topic').fadeOut("slow");
    $('#topic_' + (triggerID + 1)).fadeIn("slow");
    
    // $('.image_reel').animate({
    //       left: -image_reelPosition
    //     }, 500);
    $('.banner_pic').fadeOut("slow");
    $('#ctl00_banner_' + (triggerID + 1)).fadeIn("slow");
  };
  
  rotateSwitch = function(){
    play = setInterval(function(){
      $active = $('.paging a.selected').next();
      if ($active.length === 0){
        $active = $('.paging a:first');
      }
      rotate();
    }, 7000);
  };
  
  rotateSwitch();
  
  $(".image_reel a").hover(function(){
    clearInterval(play);
  }, function(){
    rotateSwitch();
  });
  
  $(".paging a").live('click', function(){
    $active = $(this);
    clearInterval(play);
    rotate();
    rotateSwitch();
    return false;
  });
  
  // $('.topic_thumb a').live('click', function(){
  //     var link = jQuery(this);
  //     clicked_thumb = link.attr("id");
  //     clicked_thumb_id = clicked_thumb.substr(clicked_thumb.length - 1, clicked_thumb.length)
  //     //alert(clicked_thumb_id);
  //     $('.banner_pic').fadeOut("slow");
  //     $('#banner_pic_' + clicked_thumb_id).fadeIn("slow");
  //     
  //     $('.topic').fadeOut("slow");
  //     $('#topic_' + clicked_thumb_id).fadeIn("slow");
  //     
  //     $('.topic_thumb').removeClass("selected");
  //     $('#thumb_picture_' + clicked_thumb_id).addClass("selected");
  //     return false;
  //   })
  

  //$('#header').css("background", "transparent url(https://s3.amazonaws.com/prod.assets.fivesenses.com.au/backgrounds/42/original/PNG_Warrior_website.jpg?1312860211) no-repeat scroll top left");
  //$('#picture_1').addClass('selected');
})

