/* made by RJ - emperor */
$(function() {
  var originalWidth = 700;
  var tabWidth = 48;

  var cols = {
    'hydrogel': '#00928f',
    'foam': '#8b408e',
    'alginate': '#00b2dc',
    'aquafiber': '#0eaf48',
    'hydrocolloid': '#ed7b27'
  }
  var bordercols = {
    'hydrogel': '#80C9C7',
    'foam': '#C4AAD1',
    'alginate': '#80d9ee',
    'aquafiber': '#87D7A4',
    'hydrocolloid': '#FDA360'
  }
  
  
  $('#homeAccordian ul li').css('width', tabWidth);
  $('#homeAccordian ul li').eq(0).css('width', originalWidth);
  originalWidth = originalWidth + tabWidth;

  var thisID = $(this).index('#homeAccordian ul li a.header');
  $('#homeAccordian ul li a.header').click(function() {
    thisID = $(this).index('#homeAccordian ul li a.header');
    $('#homeAccordian ul li').removeClass('active');
    $(this).parent('li').addClass('active');
    $('#homeAccordian ul li').each(function() {
      $(this).stop();
      if ($(this).attr('id') == 'first') {
        $(this).animate({
          width: 0
        }, 1000);
      } else if ($(this).attr('class') == 'active') {
        $(this).animate({
          width: originalWidth
        }, 1000);

        var tabName = $(this).attr('id');
        $('.outer_background').stop().animate({
        backgroundColor: cols[tabName]
        }, 1000);
        $('.header_area').stop().animate({
        borderBottomColor: bordercols[tabName]
        }, 1000);
      } else {
        $(this).animate({
          width: tabWidth
        }, 1000);
      }
    });
    return false;
  });
});
