function checkThis(elem) {

	var inputElem = jQuery(elem).parent().find("input").get(0);

	if ("radio" == inputElem.type) {
		jQuery(inputElem).attr("checked", "checked");
	} else if("checkbox" == inputElem.type) {

		if(true === jQuery(inputElem).attr("checked")) {
			jQuery(inputElem).removeAttr("checked");
		} else {
			jQuery(inputElem).attr("checked", "checked");
		}
	}

	return true;
}

function recalcItems() {

	var objCart = {}
	
	// Flowers only
	if (0 < document.getElementsByName("roses").length) {
		var strFlowerItem = jQuery("#shop input[name='roses']:checked").get(0).value;
		
		var fltFlowerPrice = objPrices[strFlowerItem];
		var intFlowerAmount = jQuery("#shop select[name='roses_amount']").val();

		objCart[objNames[strFlowerItem]] = fltFlowerPrice * intFlowerAmount;
	
	// Special and Flowers
	} else {
		var strFlowerItem = jQuery("#shop input[name='special_and_flowers']:checked").get(0).value;
		
		// Flowers
		if (-1 !== strFlowerItem.indexOf("roses_")) {
		
			var fltFlowerPrice = objPrices[strFlowerItem];
			var intFlowerAmount = jQuery("#shop select[name='roses_amount']").val();			

			objCart[objNames[strFlowerItem]] = fltFlowerPrice * intFlowerAmount;
		
		// Special	
		} else {
			objCart[objNames[strFlowerItem]] = objPrices[strFlowerItem];
		}
	}

	jQuery("#shop :checkbox:checked").each(function() {

		objCart[objNames[this.name]] = objPrices[this.name];

	});

	// Add free postcard
	objCart[objNames['postcard']] = objPrices['postcard'];

	var strCartXHTML = "<table class=\"cart_list\">";
	var fltTotal = 0;

	for (var strItem in objCart) {

		if ("undefined" === typeof objCart[strItem]) {
			continue;
		}

		strCartXHTML += "<tr><td>" + strItem + "</td><td class=\"right\">" + objCart[strItem].toFixed(2) + " " + strShopCurrency + "</td></tr>";

		fltTotal += objCart[strItem];

	}

	var	fltNoDeliveryTotal 		= fltTotal;
	var strCartNoDeliveryXHTML 	= strCartXHTML + "</table>";
	
	// Delivery
	fltTotal += objPrices['delivery'];

	strCartXHTML += "<tr>\
						<td>\
							" + objNames["delivery"] + "<br />\
							<span style=\"font-size: 11px; color: #888888;\">" + objDescriptions["delivery"] + "</span>\
						</td>\
						<td class=\"right\">\
							24.00 " + strShopCurrency + "\
						</td>\
					</tr>";
	strCartXHTML += "</table>";

	fltTotal 			= fltTotal.toFixed(2);
	fltNoDeliveryTotal 	= fltNoDeliveryTotal.toFixed(2);
	
	jQuery(".cart_content").html(strCartXHTML);
	jQuery(".cart_content_no_delivery").html(strCartNoDeliveryXHTML);
	jQuery(".cart_total").text(fltTotal);
	jQuery(".cart_total_no_delivery").text(fltNoDeliveryTotal);
	jQuery("#price").val(fltTotal);

	return true;
}

jQuery(function() {

	jQuery("#shop_choose_target ul").hide();
	
	jQuery("#shop_choose_target li").click(function() { window.location.href = jQuery("a", this)[0].href; })
									.hover(function() { jQuery(this).addClass("present"); }, function() { jQuery(this).removeClass("present"); });
	
	jQuery("#shop_choose_target").hover(function() { jQuery("ul", this).show(50); }, function() { jQuery("ul", this).hide(); });
	
});
