// JavaScript Document


function popwin(){

window.open('/farver/skab.html','newwin','toolbar=no,location=no,scrollbars=no,width=550,height=600');

}



function EditConfigurator(StringAmount){
	$('#ShopMainLayOutTable .ProductInfo_TD INPUT').eq(3).val(StringAmount);
}

domReady(function(){
				  
		
		if ($('#ShopMainLayOutTable #ProductConfigurator3 #Total').length == 1){
		
			$('#ShopMainLayOutTable #ProductConfigurator3 #BaseProdAmount').parent().html('<INPUT SIZE="2" TYPE="TEXT" ID="BaseProdAmountNew" STYLE="text-align:center;" VALUE="1" class="TextInputField_ProductInfo">')
			$('#ShopMainLayOutTable #ProductConfigurator3 #BaseProdAmountNew').change(function() {$('#ShopMainLayOutTable .ProductInfo_TD INPUT').eq(3).val($('#ShopMainLayOutTable #ProductConfigurator3 #BaseProdAmountNew').val());}); 
//			$('#ShopMainLayOutTable #ProductConfigurator3 #BaseProdAmount').val('10')
		
		}
				  
				  
//		alert($('#ShopMainLayOutTable .ProductInfo_TD INPUT[name=AMOUNT]').attr('TYPE'));
		
		
		
//		alert(		)


		if	(location.href.indexOf('455p.html') != -1){
//			$('#ShopMainLayOutTable #BaseProdPrice').val('3');
		}



//	$('#ContentContainer_TBL').attr('style','')
//	$('#ContentContainer_TBL').attr('width','100%')


//VIRKER
/*		if	(location.href.indexOf('frontpage.html') != -1){
			$('#Main_TD').height(430)
		}else{
			$('#Main_TD').height($('#ContentContainer_TBL').height())
		}
*/		


		$('.ProductMenuCol_TD, .TopMenu_TR').hide();


		$('img').each(function(){
			if ($(this).attr('src').indexOf('btn_farvevalg_DK.png') != -1){
				$(this).wrap('<a href="javascript:popwin()" title="Klik her for at se farvevarrianter"></a>')
			}
		});


//		$('.CMProductImage')

		$('.CMProductImage').each(function(){
			$(this).find('table td img').wrap('<div class="CMProductImage"><table border="0" cellpadding="0" cellspacing="0" width="160" height="180"><tr><td valign="bottom" align="center"><a href="'+ $(this).find('a').eq(0).attr('href') +'"></a></td></tr></table></div>')
		});

/*
			$('#ShopMainLayOutTable #Main_TD').attr('height','430');
			$('#ShopMainLayOutTable #Table12').attr('style','width:100%;');
	*/	
//			$('#ShopMainLayOutTable #ContentContainer_DIV').before('<img src="/images/sjat/space.gif" width="1" height="430" align="left" style="float:left;">')
//			  $('#ShopMainLayOutTable #ContentContainer_DIV').height(430)
//		alert($('#ShopMainLayOutTable #ContentContainer_DIV').css('height'))
		
		
//		if ($('#ShopMainLayOutTable #Main_TD').height() <= 600){
//		}
		
		
		
		

		$('#ShopMainLayOutTable #Table20 tr td').eq(0).hide();
//		$('#ShopMainLayOutTable #Table18 tr').eq(0).remo();

		$('#ShopLayOut_SpaceBottomAndTop_TD table').eq(0).css('height','auto')

		var sprog = '';
		
		if	(location.href.indexOf('.co.uk') != -1 || location.href.indexOf('/Eng/') != -1){
			sprog = '-en';
		}else if (location.href.indexOf('.de') != -1 || location.href.indexOf('/Tys/') != -1){
			sprog = '-de';
		}

		$('table').each(function(){
			$(this).attr('border','0')
			$(this).attr('cellspacing','0')
			$(this).attr('cellpadding','0')
		});

		if ($('#ShowBasket_TD').html() != null){
			$('#ShowBasket_TD h1').css('display', 'none')
			$('#ShowBasket_TD').prepend('&nbsp;<div style="width:100%;" align="center"><img src="/images/sjat/step0'+ sprog +'.png"></div>&nbsp;<br>&nbsp;<br>')
//			$('#ShowBasket_TD').prepend('<h1>'+ $('#OrderStep1_TD h1').text() +'</h1>')
		}

		if ($('#OrderStep1_TD').html() != null){
			$('#OrderStep1_TD h1').css('display', 'none')
			$('#OrderStep1_TD').prepend('&nbsp;<div style="width:100%;" align="center"><img src="/images/sjat/step1'+ sprog +'.png"></div>')
//			$('#OrderStep1_TD').prepend('<h1>'+ $('#OrderStep1_TD h1').text() +'</h1>')
		}

		if ($('#OrderStep2_TD').html() != null){
			$('#OrderStep2_TD h1').css('display', 'none')
			$('#OrderStep2_TD').prepend('&nbsp;<div style="width:100%;" align="center"><img src="/images/sjat/step2'+ sprog +'.png"></div>')
//			$('#OrderStep2_TD').prepend('<h1>'+ $('#OrderStep2_TD h1').text() +'</h1>')
		}

		if ($('#OrderStep3_TD').html() != null){
			$('#OrderStep3_TD h1').css('display', 'none')
			$('#OrderStep3_TD').prepend('&nbsp;<div style="width:100%;" align="center"><img src="/images/sjat/step3'+ sprog +'.png"></div>')
//			$('#OrderStep3_TD').prepend('<h1>'+ $('#OrderStep3_TD h1').text() +'</h1>')
		}
		if ($('#OrderStep4_TD').html() != null){
			$('#OrderStep4_TD h1').css('display', 'none')
			$('#OrderStep4_TD').prepend('&nbsp;<div style="width:100%;" align="center"><img src="/images/sjat/step4'+ sprog +'.png"></div>')
//			$('#OrderStep4_TD').prepend('<h1>'+ $('#OrderStep4_TD h1').text() +'</h1>')
		}

		var i = 1;
		$('#ShopLayOut_Topmenu_TD a').each(
			function() {
				if (this.className != 'TopMenuSpace') $(this).attr('id', 'menu'+i++);
			}
		)
		
		var lastmenu = i-1
		$('#menu1').before('');
		$('#menu'+ lastmenu).after('');

		$('.ProductList').each(function(){
			$(this).html($(this).html().toLowerCase().replace('</strike>8<strike>','8'))
			$(this).html($(this).html().toLowerCase().replace('</strike>&nbsp;</strike>','</strike>&nbsp;'))
		});

		$('p').each(function(){
			if ($(this).text()  == ''){
				$(this).css('display','none');
			}
		})

		if	(location.href.indexOf('news-ALL-1.html') != -1){
			$('#ProductList_TD h1').text('Alle nyheder');
		}

		if	(location.href.indexOf('specialoffer-ALL-1.html') != -1){
			$('#ProductList_TD h1').text('Nye tilbud');
		}

		// Overskrift til søgning
		if	(Keyword  != ''){
			if	(location.href.indexOf('/shop/Tys/') != -1){
				$('#ProductList_TD h1').text('Suche...');
			}else if (location.href.indexOf('/shop/Eng/') != -1){
				$('#ProductList_TD h1').text('Search...');
			}else{
				$('#ProductList_TD h1').text('Søgning...');
			}
		}

		if	(location.href.indexOf('pay.dandomain.dk') != -1){
			$('#CreditCardPayment_TD').prepend('<h1 align="left">Betaling med kort</h1>')
		}

		if ($('#ShopMainLayOutTable #Canvas').html()  == ''){
			$('#ShopMainLayOutTable #Canvas').css('display','none');
		}

		if ($('#ShopMainLayOutTable #Selector').html()  == ''){
			$('#ShopMainLayOutTable #Selector').css('display','none');
		}

//Custom SJAT
//.eq(4).eq(7).eq(10)
//		$('#Selector img').eq(1).each(function() {
//			$(this).attr('class','PicMargin')
//		})

		$('#Mediasundefined1, #Mediasundefined4, #Mediasundefined7, #Mediasundefined10').css('margin-left','25px').css('margin-right','26px');

		$('#Table19').parent().parent().hide();
		$('#ShopLayOut_SpaceTop_TD #PositionRelative').prepend('<span id="Basket">'+ $('#Basket').html() +'</span>');



		$('#ProductmenuContainer_DIV tr#3').find('a').each(function(){
			if($(this).text() == 'Borde'){$('.CellMenu1').append('<br>');}
			if($(this).text() != ''){$('.CellMenu1').append('<a class="SJATmenupunktSite" href="'+ $(this).attr('href') +'" title="'+ $(this).text() +'">'+ $(this).text() +'</a><br>')}
		})

		$('#ProductmenuContainer_DIV tr#4').find('a').each(function(){
			if($(this).text() != ''){$('.CellMenu2').append('<a class="SJATmenupunktSite" href="'+ $(this).attr('href') +'" title="'+ $(this).text() +'">'+ $(this).text() +'</a><br>')}
		})

		$('#ProductmenuContainer_DIV tr#5').find('a').each(function(){
			if($(this).text() != ''){$('.CellMenu3').append('<a class="SJATmenupunktSite" href="'+ $(this).attr('href') +'" title="'+ $(this).text() +'">'+ $(this).text() +'</a><br>')}
		})

		$('#ProductmenuContainer_DIV tr#6').find('a').each(function(){
			if($(this).text() == 'Til Hende'){$('.CellMenu4').append('<br>');}
			if($(this).text() != ''){$('.CellMenu4').append('<a class="SJATmenupunktSite" href="'+ $(this).attr('href') +'" title="'+ $(this).text() +'">'+ $(this).text() +'</a><br>')}
		})




		if ($('#ShopMainLayOutTable #CMPrices .Prices').text() != ''){
			$('#ShopMainLayOutTable #CMPrices').text($('#ShopMainLayOutTable #CMPrices span.Price_Productinfo').text())
		}else{
			$('#ShopMainLayOutTable #CMPrices').text($('#ShopMainLayOutTable #Total').val() +' '+ $('#ShopMainLayOutTable #CMPrices .Currency').text())
		}
		
//		alert(	$('#ShopMainLayOutTable #Total').val()	)
//		alert(	$('#ShopMainLayOutTable .Prices_Custom_TBL td').text().replace('.','')	)
		
//		$('#CMPrices').after('<span class="CMPriceBefore">&nbsp;&nbsp;Før:&nbsp;'+ $('#ShopMainLayOutTable .Prices_Custom_TBL td').text() +' - SPAR: '+ parseInt( $('#ShopMainLayOutTable .Prices_Custom_TBL td').text().replace('.','')) - parseInt( $('#ShopMainLayOutTable #Total').val() ) +'</span>')
		$('#ShopMainLayOutTable #CMPrices').after('<span class="CMPriceBefore">&nbsp;&nbsp;Før:&nbsp;'+ $('#ShopMainLayOutTable .Prices_Custom_TBL td').text() +'</span>')
		if ($('#ShopMainLayOutTable .Prices_Custom_TBL td').text() == ''){$('.CMPriceBefore').hide()}
		$('.Prices_Custom_TBL').hide()
		
		if ($('#ShopMainLayOutTable .MovePrice').length != 0){
			$('#CMPrices').after('<span class="CMPriceBefore">&nbsp;&nbsp;-&nbsp;'+ $('#ShopMainLayOutTable .MovePrice').text() +'</span>')
		}

		$('#ShopMainLayOutTable #ProductConfigurator3 table tr:last input:first').css({'position':'relative','top':'4px'})
		
		if ($('#ShopMainLayOutTable .VariantGroupPosition').length == 0){
		$('#ShopMainLayOutTable #ProductConfigurator3 table tbody').prepend($('#ShopMainLayOutTable #ProductConfigurator3 table tr').eq(($('#ShopMainLayOutTable #ProductConfigurator3 table tr').length)-3))
		}

//		$('#ShopMainLayOutTable #ProductConfigurator3').html($('#ShopMainLayOutTable #ProductConfigurator3').html().replace('Antal','').replace('Stk. Pris','').replace('Pris',''))
		$('#ShopMainLayOutTable #ProductConfigurator3 table tr').eq(1).find('td').eq(1).html('');
		$('#ShopMainLayOutTable #ProductConfigurator3 table tr').eq(1).find('td').eq(3).html('');
		$('#ShopMainLayOutTable #ProductConfigurator3 table tr').eq(1).find('td').eq(5).html('');

		
		if ($('#BUYSECTION').html() == ''){
		
			$('#ShopMainLayOutTable #ProductConfigurator3 table tbody').prepend('<TR><TD COLSPAN="4" height="20"></TD><TD COLSPAN="1" align="center" valign="top"><span style="font-weight:bold">Antal</span></TD><TD COLSPAN="1" align="center" valign="top"></TD><TD COLSPAN="1" align="center" valign="top"><span style="font-weight:bold">Stk. Pris</span></TD><TD COLSPAN="1" align="center" valign="top"></TD><TD COLSPAN="1" align="center" valign="top"><span style="font-weight:bold">Pris</span></TD></TR>')
		
		}



		$("#Menu .punkt").hover(
		  function () {

			$('#MenuContent').html('');
			
			_LeftPos = $(this).position().left + 0;

			$('#MenuContent').css('left',_LeftPos+'px')
			
//			alert($(this).attr('id'))
			
			_getSub = $(this).attr('id').replace('sub','');
			
			if (_getSub == 3){

				$('#ProductmenuContainer_DIV tr#'+_getSub).find('a').each(function(){
					var spaceer = '';
					if($(this).text().indexOf('»') != -1){spaceer = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
					if($(this).text() != ''){$('#MenuContent').append('<a class="SJATmenupunkt" href="'+ $(this).attr('href') +'" title="'+ $(this).text() +'">'+ spaceer + $(this).text() +'</a>')}
				})

			}else if (_getSub == 4){

				$('#ProductmenuContainer_DIV tr#'+_getSub).find('a').each(function(){
					var spaceer = '';
					if($(this).text().indexOf('»') != -1){spaceer = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
					if($(this).text() != ''){$('#MenuContent').append('<a class="SJATmenupunkt" href="'+ $(this).attr('href') +'" title="'+ $(this).text() +'">'+ spaceer + $(this).text() +'</a>')}
				})

			}else if (_getSub == 5){

				$('#ProductmenuContainer_DIV tr#'+_getSub).find('a').each(function(){
					var spaceer = '';
					if($(this).text().indexOf('»') != -1){spaceer = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
					if($(this).text() != ''){$('#MenuContent').append('<a class="SJATmenupunkt" href="'+ $(this).attr('href') +'" title="'+ $(this).text() +'">'+ spaceer + $(this).text() +'</a>')}
				})

			}else if (_getSub == 6){

				$('#ProductmenuContainer_DIV tr#6').find('.SubCategory1_Productmenu a').each(function(){
					var spaceer = '';
					if($(this).text().indexOf('»') != -1){spaceer = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
					if($(this).text() != ''){$('#MenuContent').append('<a class="SJATmenupunkt" href="'+ $(this).attr('href') +'" title="'+ $(this).text() +'">'+ spaceer + $(this).text() +'</a>')}
				})

			}

			if ($('#MenuContent').text() == '')$('#MenuContent').html('<a class="SJATmenupunkt" href="/">(Der er ingen gupper)</a>');

			$('#MenuContent').show('fast')
		  }, 
		  function () {

			

			$("#MenuContent").hover(
			  function () {}, 
			  function () {$('#MenuContent').hide('fast');}
			);

			$("#MenuUnderlay, .punkt1, #ShopLayOut_SpaceLeft_TD, #ShopLayOut_SpaceRight_TD").hover(
			  function () {$('#MenuContent').hide('fast');}, 
			  function () {}
			);

		  }
		);

		
/*
		$('.TableLines_ShowBasket').css('border-left','1px solid #c8bdaf').css('border-right','1px solid #c8bdaf');
		$('.Heading_ShowBasket').css('border-top','1px solid #c8bdaf').css('border-bottom','1px solid #c8bdaf').css('height','30px').css('font-weight','bold').css('background','#e3dcd3');
		$('.ShowBasket_ProductLineConfParentProduct_Amount_TD').css('text-align','center');
		$('.BackgroundColor1_ShowBasket td').attr('valign','center').css('padding-top','10px').css('padding-bottom','10px');
		$('.ProductImage_ShowBasket').css('vertical-align','middle');
*/
		$('.Heading_ShowBasket').css('color','#755a36').css('height','30px').css('font-weight','bold').css('border-bottom','1px solid #d5cdc2');
		$('.BackgroundColor1_ShowBasket td, .BackgroundColor2_ShowBasket td').css('border-bottom','1px solid #d5cdc2').css('padding-bottom','10px').css('padding-top','10px');
		$('.Heading_ShowBasket').css('color','#755a36').css('height','30px').css('font-weight','bold').css('border-bottom','1px solid #d5cdc2');
		$("#ShowBasket_TD a[href=javascript:history.go(-1);]").css('margin-left','321px').css('margin-right','15px');
		$("#ShowBasket_TD a[href=/shop/basket.asp?caller=showbasket&removeall=1]").css('margin-right','15px');
		$("#ShowBasket_TD a[href=/shop/order1.html]").after('<br>&nbsp;');

		$(".ShowBasket_ProductLineConfParentProduct_ActionButtons_TD img, .ShowBasket_ProductLine_ActionButtons_TD img").css('margin-left','2px').css('margin-right','2px');

		

		
		
		
		

});


$(document).ready(function(){



		if	(location.href.indexOf('p.html') != -1){
			$('#ShopMainLayOutTable #ProductConfigurator3 tr:last input').eq(0).click(function() {
			var StopSubmit = false;
				$('#ShopMainLayOutTable #ProductConfigurator3 select').each(function(){
					if (($(this).text().indexOf('Levering') != -1 || $(this).text().indexOf('Lieferung') != -1 || $(this).text().indexOf('Delivery') != -1) && $(this).val() == 0){
						if (location.href.indexOf('/shop/Eng/') != -1){
							alert('Please choose delivery');
						}else if (location.href.indexOf('/shop/Tys/') != -1){
							alert('Bitte Lieferung wählen');
						}else{
							alert('Du mangler at vælge en leveringsform');
						}
						StopSubmit = true;
					}
				})
			if (StopSubmit){return false;}
			});
		}





		if ($('#ContentContainer_TBL').height() <= 430){
		
			$('#ContentContainer_TBL').height(430)

		}


		var Count1 = 0;
		$('#ShopMainLayOutTable .Related_Custom_TBL .Each').each(function(){+Count1++})
		var Count2 = 0;
		$('#ShopMainLayOutTable .CustomersAlsoBought_Custom_TBL .Each').each(function(){+Count2++})

		if (Count1 == 1){$('#ShopMainLayOutTable .Related_Custom_TBL').attr('width', '25%');}
		if (Count1 == 2){$('#ShopMainLayOutTable .Related_Custom_TBL').attr('width', '50%');}
		if (Count1 == 3){$('#ShopMainLayOutTable .Related_Custom_TBL').attr('width', '75%');}
	
		if (Count2 == 1){$('#ShopMainLayOutTable .CustomersAlsoBought_Custom_TBL').attr('width', '25%');}
		if (Count2 == 2){$('#ShopMainLayOutTable .CustomersAlsoBought_Custom_TBL').attr('width', '50%');}
		if (Count2 == 3){$('#ShopMainLayOutTable .CustomersAlsoBought_Custom_TBL').attr('width', '75%');}

});
