var country = geoplugin_countryCode();
var shipping;
if(country === 'US') { shipping = 3.6 } else if (country === 'CA')  { shipping = 2; } else { shipping = 7.2; }
jQuery(document).plum('shop', { 
	shippingtype: 'function',
	shippingrate: shipping,
	shipping: function (rate) {
		if(this.price >= 60 && this.weight) {
			var country = geoplugin_countryCode();	
			if(country === 'US') { rate = rate + 4.6; } else if (country === 'CA')  { rate = rate + 3; } else { rate = rate + 5; }
			return this.quantity * parseFloat(this.weight) * rate + 2;
		} else if(this.price <= 10 && this.weight) {
			return this.quantity * parseFloat(this.weight) * rate + 2;
		} else if (this.weight) {
			return this.quantity * parseFloat(this.weight) * rate + 5;
		} else {
			return 5;
		}
	},
	paypaluser: 'katieflindall',
	paypaldomain: 'gmail.com',
	currency: 'CAD',
	returnurl: 'http://moonhouseart.com/thank-you-for-your-order/',
	cartitem: '<div class="item-title-desc"><img class="cart-thumb" src="{thumb}"/><span class="item-title">{title}</span><span class="cart-desc">{description}</span></div><div class="item-number">{quantity}</div><div class="item-price">{pricesingle}</div><div class="item-total-price">{pricetotal}</div><span class="remove">x</span>',
	additem: function () {
		// item added to cart
	},
	updatetotals: function () {
		// this runs when the cart is modified
	},
	discountcodes: {
		'ARTLOVE': '10%'
	}
});
jQuery(document).ready(function($) {

	$('select.price').change(function () {
		var menu = $(this);
		if(menu.children(':selected').val() != 'choose') {
			var option = menu.children(':selected').text();
			var price = menu.children(':selected').val();
			var weight = menu.children(':selected').attr('rel');
			menu.next().val(option);
			menu.next().next().val(price);
			menu.next().next().next().val(weight);
		}
	});
	$('.purchase').click(function() {
		if($('select.price').children(':selected').val() == 'choose') {
			alert('Please choose an option');
			return false;
		} else {
			return true;
		}
	});
});
