basket.fadeOverlay = function(){
	Shadowbox.close();
};
basket.msgShow = function(message) {
	Shadowbox.open({
		//content:    "<div id='lightbox'><h1>"+theText+"</h1><img src='/typo3temp/GB/4a5e7df868.png' width='216' height='192' /><p>DKK 499,95-<em>Approximately &euro;30</em></p><span><a href='#'>Tilbage til shoppen</a></span><span><a href='#'>Gå til kassen</a></span></div>",
	    content: message,
		player:     "html",
	    height:     350,
	    width:      450
	});
	window.setTimeout('basket.fadeOverlay()',30000);	
};

basket.add = function () {
	jQuery.post(basket.url,{request: 'add', productId: jQuery(this).attr('butik:productid')} ,basket.updateT2H, "json");	
};

basket.updateT2H = function(data) {
	/*
	 * After adding something to the basket, we relaod the currently selected color.
	 * Otherwise we might accidently have added the last variant! 
	 */	
	basket.update(data);
	if(T2H.selectedColor) {
		loadColor(T2H.selectedColor);
	}	
}

basket.updateBasketAndDisplay = function(data) {
	basket.update(data);
	
	// should be handled in a similar manner, see comment in ButikBasketDisplayView
	//jQuery('.display-basket').load(butik_url.basketUrl+' .display-basket > *',function(){jQuery('.display-basket input').keyup(basket.updateQty);});
	document.location.reload(document.location.href);
},
$(function() {
	$('.unit-selector').each(function() {
		//console.log("The value is" + $(this).attr("butik:value"))
		//$(this).find('option[value='+$(this).attr("butik:value")+']').attr('selected',true);
		$(this).val($(this).attr("butik:value"));
		$(this).change(basket.updateQty);
	});

	$("div.awesome").each(function() {
		if($(this).text() == "") {
			$(this).remove();
		}

	});


});
