// JavaScript Document

$(document).ready(function() {
	
	if (location.href.indexOf('.dk/shop') != -1){
	
		// Fjerner efterkrav ved GLS i step 2
		if (location.href.indexOf('shop/order2.html') != -1){

//		if (location.href.indexOf('&ma') != -1){alert(	$('#ShopMainLayOutTable #ShippingMethodID72').length	);}

			if ($('#ShopMainLayOutTable #ShippingMethodID72').length > 0){
				$('#ShippingMethod_73').remove();
			}
			
			if ($('#ShopMainLayOutTable #ShippingMethodID65:checked').length == 1 || $('#ShopMainLayOutTable #ShippingMethodID66:checked').length == 1){
				$('#PaymethodID_63').parent().parent().hide();
			}
		
			$('#ShippingMethodsContainer input').click(function() {
				if ($(this).attr('id').indexOf('ShippingMethodID65') == -1 && $(this).attr('id').indexOf('ShippingMethodID66') == -1){
					$('#PaymethodID_63').parent().parent().show();
				}else{
					setTimeout("$('#PaymethodID_63').parent().parent().hide();",200);
				}
			});
		}
	
	}

	if (location.href.indexOf('.de/shop') != -1){

		if (location.href.indexOf('showbasket.html') != -1){
		
			BasketAmount1=0;
			BasketAmount=0;
			BasketTotalPrice=0.00;

			$('#ShopMainLayOutTable .ShowBasket_ChildProduct_SPAN').each(function() {
				if ($(this).text().toLowerCase().indexOf('gema') != -1){
					BasketAmount = BasketAmount + parseInt($(this).parent().parent().find('.ShowBasket_ProductLineFeeProduct_Amount_TD').text())
					BasketTotalPrice = BasketTotalPrice + parseFloat($(this).parent().parent().find('.ShowBasket_ProductLineFeeProduct_TotalPrice_TD').text().replace(',','.'))
					$(this).parent().parent().hide();
				}
			});
						
			$('#ShopMainLayOutTable .Fees_ShowBasket').eq(1).prepend('Gema ('+ BasketAmount +' Stck.)<br>')
			$('#ShopMainLayOutTable .Fees_ShowBasket').eq(3).prepend(BasketTotalPrice.toFixed(2).replace('.',',') +'<br>')

		}


		if (location.href.indexOf('shop/order3.html') != -1){
		
			BasketAmount1=0;
			BasketAmount=0;
			BasketTotalPrice=0.00;

			$('#ShopMainLayOutTable .TableLines_OrderStep3 table table table table table tr').each(function() {
				if ($(this).find('td:eq(1)').text().toLowerCase().indexOf('gema') != -1){
					BasketAmount = BasketAmount + parseInt($(this).find('td:eq(0)').text())
					BasketTotalPrice = BasketTotalPrice + parseFloat($(this).find('td:eq(3)').text().replace(',','.'))
					$(this).hide();
				}
			});
			
			$('#ShopMainLayOutTable .BackGroundColor1_OrderStep3 center div table table table').before('<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td>Gema ('+ BasketAmount +' Stck.)<br></td><td align="right">'+ BasketTotalPrice.toFixed(2).replace('.',',') +'<br></td></tr></table>')
			
		}



		if (location.href.indexOf('shop/order4.html') != -1){
		
			BasketAmount1=0;
			BasketAmount=0;
			BasketTotalPrice=0.00;

			$('#ShopMainLayOutTable .TableLines_OrderStep4 table table table tr').each(function() {
				if ($(this).find('td:eq(4)').text().toLowerCase().indexOf('gema') != -1){
					BasketAmount = BasketAmount + parseInt($(this).find('td:eq(0)').text())
					BasketTotalPrice = BasketTotalPrice + parseFloat($(this).find('td:eq(6)').text().replace(',','.'))
					$(this).hide();
				}
			});
			
			$('#ShopMainLayOutTable #GemaStep4').html('<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td>Gema ('+ BasketAmount +' Stck.)<br></td><td width="80" align="right">&nbsp;</td><td width="80" align="right">'+ BasketTotalPrice.toFixed(2).replace('.',',') +'<br></td></tr></table>')
			
		}









		 $('body').append('<div id="BasketTemp" style="display:none;"></div>');
		 $('#BasketTemp').load('/shop/showbasket.html .TableLines_ShowBasket', function() {
		
//		alert($('#BasketTemp .ShowBasket_ProductLine_Amount_TD').text());

		  
		  ProdNr1 = 0;
		  ProdNr2 = 0;
		  $('#BasketTemp .ShowBasket_ProductLine_Amount_TD').each(function() {
			  ProdNr1 = ProdNr1+ parseInt($(this).text());
		  });

		  $('#BasketTemp .ShowBasket_ProductLineFeeProduct_Amount_TD').each(function() {
			  ProdNr2 = ProdNr2+ parseInt($(this).text());
		  });

		$('#ShopMainLayOutTable #DivClickBasket .NumberProduct_Basket').html($('#ShopMainLayOutTable #DivClickBasket .NumberProduct_Basket').html().replace(ProdNr1 + ProdNr2,ProdNr1));

		 });
		
	}

});
