
function Common(){
}

//Update stock info
Common.updateStockInfo = function(){
	$(".StockVal").parent().each(function(){
						 var stockNode = $(this).children(".StockVal");
						 var stock = parseInt(stockNode.html());
						 var delivery = $(this).children(".Delivery").html().match(/[\d]/);					
						 if(stock > 9){
							 //If the stock is larger than 9, 10+ is shown instead
							 var info = "10+ ";
						 } else if(stock <= 0){
							 //If the stock is 0 or less the info will be removed
							 if(delivery <= 3){
								 //If delivery is three days or less, info is given on stock on remote warehouse
								 $(this).empty();
								 $(this).append(stockNode);
								 stockNode.html('<img src="/Images/Design/Da/ProductList/IconStock2.gif"> På fjernlager - levering 3 hverdage');
							 } else{
								 var info = "";
							 }
						 } else{
							 // Else the stock is shown
							 info = stock + " ";
						 }
						 stockNode.html(info);
	})
}

//Replace DKK with kr
Common.changeCurrency = function(c){
	$(c).each(function(){
							   var str = $(this).html();
							   str = str.replace("DKK", "kr");
								$(this).html(str);
							   });
}

Common.removeDecimals = function(c){
	$(c).each(function(){
							   var str = $(this).html();
							   str = str.replace(",00", "");
								$(this).html(str);
							   });
}

