google.load("jquery", "1");
google.setOnLoadCallback(function(){
	/* Easing Functions */
	jQuery.easing['jswing'] = jQuery.easing['swing']; jQuery.extend( jQuery.easing,{ def: 'easeInOutQuad', swing: function (x, t, b, c, d) { return jQuery.easing[jQuery.easing.def](x, t, b, c, d); }, easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; }, easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; }, easeInOutQuad: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; } });

	var orderFormTabs = $('#orderform .tabs a');
	$(orderFormTabs).click(function(){
		$(orderFormTabs).removeClass('active');
		$(this).addClass('active');
		$('#orderform form').hide();
		$( $(this).attr('href') ).show();
		return false;
	});
	$('#orderform .tabs a:first').click();

	calculatePrintCost();
	$('#printform input[type="radio"]').bind($.browser.msie ? 'propertychange': 'change', function(e){
		calculatePrintCost();
	});

	function calculatePrintCost(){
		var mediaAdjust, sizePrice, price;
		$('#printform input[name="media"]:checked').each(function(){
			mediaAdjust = parseFloat($(this).attr('data-priceadjust'));
			if( $(this).parent().text() == ' Lustre') {
				$('#printform li.lustre-only').show();
			} else {
				$('#printform li.lustre-only').hide();
				if( $('#printform input[name="size"]:checked:hidden').length ) {
					$('#printform input[name="size"]:visible:first').attr('checked', true);
				}
			}
		});
		$('#printform input[name="size"]:checked').each(function(){
			sizePrice = parseFloat($(this).attr('data-price'));
		});
		$('#printprice').text('$'+formatCurrency(sizePrice*mediaAdjust));
	}
	
	calculateDigitalCost();
	$('#digitalform input[type="radio"]').bind($.browser.msie ? 'propertychange': 'change', function(e){
		calculateDigitalCost();
	});

	function calculateDigitalCost(){
		var optionPrice;
		$('#digitalform input:checked').each(function(){
			optionPrice = parseFloat($(this).attr('data-price'));
		});
		$('#digitalprice').text('$'+formatCurrency(optionPrice));
	}
	
	function formatCurrency(amount) {
		var i = parseFloat(amount);
		if(isNaN(i)) { i = 0.00; }
		var minus = '';
		if(i < 0) { minus = '-'; }
		i = Math.abs(i);
		i = parseInt((i + .005) * 100);
		i = i / 100;
		s = new String(i);
		if(s.indexOf('.') < 0) { s += '.00'; }
		if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
		s = minus + s;
		return s;
	}
	
});
