var testimonials = [
  '<h2 class="quote">&#147;It’s the most versatile and easy to adjust brass catcher on the market!&#148;</h2><h3 class="author"><span class="name">John Bacarella</span><br />President/CEO, Sportsmen\'s Direct Inc<br /><a style="color: #000" href="http://www.sportsmensdirect.com">www.sportsmensdirect.com</a></div>'
  ,'<h2 class="quote">&#147;No matter what handgun I\'m shooting, I\'m able to easily catch my brass!&#148;</h2><h3 class="author"><span class="name">Manny J.</span><br />New York</h3>'
  ,'<h2 class="quote">&#147;When I\'m pumping hot loads out of my 1911-A1, the Brass Grabber does the job.&#148;</h2><h3 class="author"><span class="name">John Bacarella</span><br />President/CEO, Sportsmen\'s Direct Inc<br /><a style="color: #000" href="http://www.sportsmensdirect.com">www.sportsmensdirect.com</a></h3>'
  ,'<h2 class="quote">&#147;The Brass Grabber is a savior!&#148;</h2><h3 class="author"><span class="name">Manny J.</span><br />New York</h3>'
  ,'<h2 class="quote">&#147;Many thanks. Great product. Happy customer!&#148;</h2><h3 class="author"><span class="name">Victor H.</span></h3>'
]
function sizeCheck() {

  if ( $('size').value.length == 0 ) {
    alert('Please choose a glove size before ordering.');
    return false;
  } else {
    return true;
  }

}

window.addEvent('domready',function(){
  var quoteindex = 0;
  var qbox = $('testimonialHandle');
  var qboxanim = new Fx.Tween(qbox,{ link: 'chain'});
  function rotatequote() {
    qboxanim.start('opacity',0).chain(function() {
      quoteindex++;
      if ( quoteindex > testimonials.length - 1 ) quoteindex = 0;
      qbox.innerHTML = testimonials[quoteindex];
      qboxanim.callChain();
    }).start('opacity',1).chain(function() {
      setTimeout(rotatequote,4500);
    });
  }

  setTimeout(rotatequote,4500);

  $('features').addEvent('click',function() {
    rotatequote();
  });

  $$('img.rollover,input.rollover').each(function(img) {
    var src = img.getProperty('src');
    var extension = src.substring(src.lastIndexOf('.'),src.length)
    img.addEvent('mouseenter', function() { img.setProperty('src',src.replace(extension,'.hover' + extension)); });
    img.addEvent('mouseleave', function() { img.setProperty('src',src); });
  });

  var quantity = $('quantity');
  var size = $('size');
  var gquantity = $('googleform').item_quantity_1;
  var pquantity = $('paypalform').quantity;
  var gshipping = $('googleform').item_price_2;
  var pshipping = $('paypalform').shipping;
  var gdesc = $('googleform').item_name_1;
  var pdesc = $('paypalform').item_name;

  quantity.addEvent('change',function() {
    updateq();
  });

  size.addEvent('change',function() {
    updatep();
  });

  function updatep() {
    var desc = "Size " + size.value + " Brass Grabber";
    gdesc.value = desc;
    pdesc.value = desc;
  }

  function updateq() {
    if ( quantity.value == 1 ) {
      pshipping.value = 6.99;
      gshipping.value = 6.99;
    } else if ( quantity.value < 9 ) {
      pshipping.value = 12.99;
      gshipping.value = 12.99;
    } else {
      gshipping.value = 16.99;
      pshipping.value = 16.99;
    }
    gquantity.value = quantity.value;
    pquantity.value = quantity.value;
  }

/*
  $$('#orderForm input').addEvents({
    'mouseenter': function() {
      this.tween('opacity',.7);
    },
    'mouseleave': function() {
      this.tween('opacity',1);
    }
  });
*/
});
