// ArmorAll.com JS for homepage.

$(document).ready(function() {
    
flowplayer("video_player", {src: "swf/flowplayer.commercial-3.0.7.swf", wmode: 'opaque'}, {
    key: '#@d8bfd4e132b932b43fb',
    canvas: {backgroundColor: "#fe7d18"},
    plugins: {
        controls: {
          timeColor: '#ffffff',
          buttonOverColor: '#fe7d18',
          bufferColor: '#fe7d18',
          backgroundColor: '#fe7d18',
          buttonColor: '#ffad11',
          sliderColor: '#ffad11',
          durationColor: '#ffffff',
          progressGradient: 'medium',
        
          sliderGradient: 'none',
          bufferGradient: 'none',
          progressColor: '#fe7d18',
          fullscreen: false,
          opacity:1.0
        }
      },
    clip:{ 
        url: 'swf/exterior/butter_smooth_300x226.flv',
       // autoPlay: true,
        autoBuffering: true,
        onStart: function(clip) { 
          $clxcommon.trackAnalyticsPageView('video','butter_smooth');
        }
      }});
 
   // $('#video_player').hide();

    /* Watch Now switch out */
    $('#promotional_area').click(function(){
      $('#video_player').fadeIn(400);
    });
    
    /* Redo when theres time */
    $("#main-products_interior").hover(function(){ 
      $('#carbutton').attr('src', '/img/new/car_buttons1.png');
    } , function(){
      $('#carbutton').attr('src', '/img/new/car_buttons.png');
    });
    $("#main-products_wheel_tire").hover(function(){ 
      $('#carbutton').attr('src', '/img/new/car_buttons2.png');
    } , function(){
      $('#carbutton').attr('src', '/img/new/car_buttons.png');
    });
    $("#main-products_exterior").hover(function(){ 
      $('#carbutton').attr('src', '/img/new/car_buttons3.png');
    } , function(){
      $('#carbutton').attr('src', '/img/new/car_buttons.png');
    });
    
    $('#slider').anythingSlider({
            easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            delay: 4000,                    // How long between slide transitions in AutoPlay mode
            animationTime: 600,             // How long the slide transition takes
            hashTags: false,                 // Should links change the hashtag in the URL?
            buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
            pauseOnHover: false,             // If true, and autoPlay is enabled, the show will pause on hover
            startText: "",             // Start text
            stopText: "",               // Stop text
            navigationFormatter: null       // Details at the top of the file on this use (advanced use)
    });
    
    /* Slider Tracking */
    $('#start-stop').click(function() {
      if(!$(this).hasClass('playing')) {
        /* stop */
        _gaq.push(['_trackEvent', 'slider', 'slide', 'stop']);
      } else {
        _gaq.push(['_trackEvent', 'slider', 'slide', 'play']);
      }
    });
    
    var i = 1;
    $('#thumbNav > a').each(function() {
      $(this).attr('id', "slider-button-" + i);
      $(this).addClass('event');
      i++;
    });
    
    $('.event').each(function() {
      $(this).click(function() {
      	_gaq.push(['_trackEvent', 'slider', 'slide', $(this).attr('id')]);
      });
    });
        
    $('#nav-buttons > li').children('a').hover(function(){
        var img = $(this).children('img:first-child');
        var curSrc = img.attr('src');
        var newSrc = curSrc.replace('off', "over");
        img.attr('src', newSrc);
        $('.subnav').hide();
        var subNav = $(this).parent().children('.subnav');
        if(subNav) {
          subNav.show(0);
        }
      }, function(){
        var img = $(this).children('img:first-child');
        var curSrc = img.attr('src');
        var newSrc = curSrc.replace('over', "off");
        img.attr('src', newSrc);
      });
      
    $('.subnav > li').children('a').hover(function(){
      var img = $(this).children('img:first-child');
      var curSrc = img.attr('src');
      var newSrc = curSrc.replace('off', "over");
      img.attr('src', newSrc);
    }, function(){
      var img = $(this).children('img:first-child');
      var curSrc = img.attr('src');
      var newSrc = curSrc.replace('over', "off");
      img.attr('src', newSrc);
    });
    
    $('.subnav').hover(null, function(){
      $(this).hide(0);
    });
});
