var ie6x =  (jQuery.browser.msie && jQuery.browser.version >= 6.0 && jQuery.browser.version < 7.0);
function chgQty(delta) {
    qty = parseFloat(document.productForm.count.value) + delta;
    if (isNaN(qty) || qty < 1.0) {
        qty = 1.0;
    } else if (qty >= 999.99) {
        qty = 999.99;
    }
    qty = Math.floor( (qty-3.0)/1.0 )*1.0  + 3.0;
    document.productForm.count.value = qty;
}

// dynamically grow font to fit box
$(document).ready(function() {

	// font size limitations
	var fontSize = 14;
  var	maxFontSize = 34;

	// get container dimensions
	var maxHeight = $('.jtextfill').height();
  // var maxWidth = $('.jtextfill').width();
	var maxWidth = 535;
  // alert(maxWidth);

	// define vars
	var textHeight;
	var textWidth;
	var paddingTop;

	do {
	  //increment font size by 1 till its maxed in either of 3 params
	  $('.dyntextval').css('font-size', fontSize);
     textHeight = $('.dyntextval').height();
		textWidth = $('.dyntextval').width();
		fontSize = fontSize + 1;
	} while ((textWidth < maxWidth && textHeight < maxHeight) && fontSize < maxFontSize);

   // will set center text in container with padding
   paddingTop = ((maxHeight - textHeight) / 2);
   paddingTop = Math.round(paddingTop);
   $('.jtextfill').css('padding-top', paddingTop);
 });
 
 //fade out the bottle and fade in the pumpkin if there is no quantity
 $(document).ready(function(){
   $('#the_bottle').delay(1200).fadeOut(1500, function(){
     $('#pumkin').fadeIn(1500);  
   });
 })
 
 $(document).ready(function(){
   $("#follow-box").click(function(){
     $("#follow-box").animate({
            right: '0px'    
          }, 300, function(){
            //finished
      });
   });
   $("#follow-box").mouseleave(function(){

      $("#follow-box").delay(100).animate({
              right: '-67px'    
            }, 100, function(){
              //finished
        });
   })
 })
 
 //called when like button is clicked
 function like_callback(href, widget) {
   $("#like-feedback").remove();
   $("#product-info").append('<div id="like-feedback" style="margin: 0 0 5px 5px">Thank you for liking this wine offer, we like it too!</div>');
 }
 
 
 