



$(document).ready(function(){
	var expand = function(e){ return hs.expand(this, config1); };
	$('a.highslide').each(function()
	{
		this.onclick = expand;
		_gaq.push(['_trackEvent', 'Pictures', 'Expand', $('img', this).attr('alt')]);
	});

	$('.tabs').tabs({fx: {opacity: 'toggle'}});
	$('#bottomhalf').fadeOut(0).fadeIn('slow');
	$('#visualsbox').fadeOut(0).fadeIn('slow');
	$('#highslidebox').fadeOut(0).fadeIn('slow');
	$('#bouquet').fadeOut(0).fadeIn('slow');
	$('#bouquets').fadeOut(0).fadeIn('slow');
	
	if(window.simpleCart)
	{
  	updateTotal();
	  $('input[data-price]').change(updateTotal);
    $('.simpleCart_shelfItem .buy').click(addItem);
  }
});


function updateTotal()
{
    var radios = $('.simpleCart_shelfItem input[data-price]').filter('*[checked]'),
        item = 0;
    
    radios.each(function()
    {
        item += parseFloat($(this).attr('data-price'));
    });
    
    $('#total .item').text(item.toFixed(2));
    
    radios = $('#shipping input[data-price]').filter('*[checked]');
    
    var shipping = 0;
    
    radios.each(function()
    {
        shipping += parseFloat($(this).attr('data-price'));
    });
    
    $('#total .shipping').text(shipping.toFixed(2));
    
    var total = shipping + item;
    
    $('#total .total').text(total.toFixed(2));
}


  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19213664-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  
if(window.simpleCart)
{
  simpleCart.PayPal;
  simpleCart.email = 'enquiries@jaynecopperwaiteflowers.com';
  simpleCart.currency = GBP;
  simpleCart.cartHeaders = [ "name", "thumb_image" , "size", "vase", "Quantity_input" , "increment",  "decrement", "Total" ];

  simpleCart.shipping = function(){ return 0; };
    
  function addItem(e)
  {
      e.preventDefault();
      var item = $(e.target).closest('.simpleCart_shelfItem');
      var name = $('.item_name', item).text(), sku = $('.item_sku', item).text(),
          size = $('input[name="size"]', item).filter('*[checked]').val(),
          vase = $('input[name="vase"]', item).filter('*[checked]').val(),
          shipping = $('#shipping input[name="shipping"]').filter('*[checked]').val(),
          thumb = $('.item_thumb', item).text(),
          message = $('.item_message', item).val(),
          total = parseFloat($('input[name="shipping"]').filter('*[checked]').attr('data-price'));
      
      var prices = $('*[data-price]', item).filter('*[checked]');
      prices.each(function()
      {
          total += parseFloat($(this).attr('data-price'));

      });
      
      $('.item_message').val('');
      
      //sku += '-' + size + '-' + vase + '-' + shipping;
      
      simpleCart.add('name=' + name, 'size='+size, 'vase='+vase+' Vase', 'shipping='+shipping, 'price='+total, 'thumb='+thumb, 'message='+message);
  }
}


