

domReady(function(){
	
// VIS KURV

	// Sletter den sidste linie i vis kurv + laver nbsp i tomme felter
	_COuntProdLines = $('#ShopMainLayOutTable .ProdLine').length -1
	$('#ShopMainLayOutTable .ProdLine').eq(_COuntProdLines).css('border-bottom','none');
	
	
	
	

if	(location.href.indexOf('?marcus') != -1){

$('#ShopMainLayOutTable #kraklookupbtn').click(function(){
															
		var GetFalseValue = $('#ShopMainLayOutTable .KraklookupNotFound').html();
		$('#ShopMainLayOutTable .KraklookupNotFound').html('');

		$.ajax({
			type: 'GET',
			dataType: 'html',
			url: '/shop/order1.html?loadprofile=1&profileid='+ $('#ShopMainLayOutTable #invoicephone').val(),
			success: function(data) {

				if ($(data).text().indexOf('i sommerhuset') != -1){location.href = "/shop/order1.html#loginOK";}else{$('#ShopMainLayOutTable .KraklookupNotFound').html(GetFalseValue);}
				
			}
		});

	});

//	alert($('#kraklookupbtn').attr('onclick'))
	
//	GetAttr = $('#kraklookupbtn').attr('onclick')
	
//	$('#kraklookupbtn').attr('onclick',GetAttr)
	
//	$('#kraklookupbtn').attr('onclick','alert("tester")')


};


//		/shop/order1.html?loadprofile=1&profileid=22593359



	
	
	
	
	



$('#ShopMainLayOutTable .ActionButtons a').eq(0).attr('title','Tilføje en vare');
$('#ShopMainLayOutTable .ActionButtons a').eq(1).attr('title','Fjerne en vare');
$('#ShopMainLayOutTable .ActionButtons a').eq(2).attr('title','Fjerne varelinie');

	
	

	
	// Loader productmenu
	cn_init_menu(document.getElementById('ProductMenu_Table'),1);

	$('.RootCategory_Productmenu br').each(function(){
		$(this).remove();
	})




	// Indhold der flytter posison
	if ($('#MoveFrom').html()  != null){
		if ($('#MoveTo').html()  == ''){
			$('#MoveTo').html($('#MoveFrom').html())
			$('#MoveFrom').remove();
		}
	}

	if ($('.SecondPart').html()  != null){
		if ($('#MoveTo').html()  == ''){
			$('#MoveTo').html($('.SecondPart').html())
			$('.SecondPart').remove();
		}
	}






// Midlertifigt links



//if	(location.href.indexOf('shop/blaekpatroner-test-maerke-3837s.html') != -1 || location.href.indexOf('shop/blaekpatroner-skal-bruges-3782s.html') != -1){
		//	browser.version

//	}



// Rette fejl på vareliste i IE 7.0

/*
if	(location.href.indexOf('rother-dcp-375cw-3655c1.html') != -1){
//alert()
}
*/



// Fjerner ord i simpellist
function ReplaceInSimpellist(sString) {
	$('#ProductList_TD #SIMPLELIST a.SubCats_Prodlink').each(function() {
		$(this).text($(this).text().replace(sString,''));
	})
}

if	(location.href.indexOf('shop/blaekpatroner-skal-bruges-3782s.html') != -1)ReplaceInSimpellist('Blækpatroner')
	

















/*
if	(location.href.indexOf('?marcus') != -1){
*/

















// Kategoriliste

	var _CountSubs = $('#ShopMainLayOutTable .SubCats_Prodlink').length;

	var _1Cell = Math.ceil(_CountSubs/3);
	var _2Cell = Math.ceil((_CountSubs-_1Cell)/2);
	var _3Cell = Math.ceil(_CountSubs-(_1Cell+_2Cell));

	var i = 1;
	var iDIV = 1;
	var SavedText = '';
	var SavedValue = '';

	$('#ShopMainLayOutTable .SubCats_Prodlink').each(function() {
		SavedText = SavedText + '<a class="SubCats_Prodlink" href="'+ $(this).attr('href') +'">'+ $(this).text() +'</a>';
		if ((i == _1Cell && iDIV==1) || (i == _2Cell && iDIV==2) || (i == _3Cell && iDIV==3)){SavedValue = SavedValue + '<td valign="top" class="Cell'+ iDIV +'">'+ SavedText +'</td>';SavedText = '';iDIV++;i=1;}else{i++}
	})







	$('#SIMPLELIST').html('<table border="0" cellpadding="0" cellspacing="0"><tr>'+ SavedValue +'</tr></table>')

	var _CountSubs = $('#ShopMainLayOutTable #ExtraList a').length;

	var _1Cell = Math.ceil(_CountSubs/3);
	var _2Cell = Math.ceil((_CountSubs-_1Cell)/2);
	var _3Cell = Math.ceil(_CountSubs-(_1Cell+_2Cell));

	var i = 1;
	var iDIV = 1;
	var SavedText = '';
	var SavedValue = '';

	$('#ShopMainLayOutTable #ExtraList a').each(function() {
		SavedText = SavedText + '<a class="SubCats_Prodlink" href="'+ $(this).attr('href') +'">'+ $(this).text() +'</a>';
		if ((i == _1Cell && iDIV==1) || (i == _2Cell && iDIV==2) || (i == _3Cell && iDIV==3)){SavedValue = SavedValue + '<td valign="top" class="Cell'+ iDIV +'">'+ SavedText +'</td>';SavedText = '';iDIV++;i=1;}else{i++}
	})
	
	$('#ExtraList').after('<table border="0" cellpadding="0" cellspacing="0" id="ExtraList"><tr>'+ SavedValue +'</tr></table>')

	$('#ExtraList').eq(0).remove();




















/*
}else{























// Kategoriliste

	var _CountSubs = $('#ShopMainLayOutTable .SubCats_Prodlink').length;

	var _1Cell = Math.ceil(_CountSubs/3);
	var _2Cell = ((_CountSubs-_1Cell)/2)+_1Cell

	var i = 1;
	var iDIV = 1;
	var SavedText = '';
	var SavedValue = '';








	$('#ShopMainLayOutTable .SubCats_Prodlink').each(function() {
		SavedText = SavedText + '<a class="SubCats_Prodlink" href="'+ $(this).attr('href') +'">'+ $(this).text() +'</a>';
		if (i == _1Cell || i == _2Cell || i == _CountSubs){ SavedValue = SavedValue + '<td valign="top" class="Cell'+ iDIV +'">'+ SavedText +'</td>';SavedText = '';iDIV++; }
		i++
	})

	$('#SIMPLELIST').html('<table border="0" cellpadding="0" cellspacing="0"><tr>'+ SavedValue +'</tr></table>')

	var _CountSubs = $('#ShopMainLayOutTable #ExtraList a').length;

	var _1Cell = Math.ceil(_CountSubs/3);
	var _2Cell = ((_CountSubs-_1Cell)/2)+_1Cell

	var i = 1;
	var iDIV = 1;
	var SavedText = '';
	var SavedValue = '';

	$('#ShopMainLayOutTable #ExtraList a').each(function() {
		SavedText = SavedText + '<a class="SubCats_Prodlink" href="'+ $(this).attr('href') +'">'+ $(this).text() +'</a>';
		if (i == _1Cell || i == _2Cell || i == _CountSubs){ SavedValue = SavedValue + '<td valign="top" class="Cell'+ iDIV +'">'+ SavedText +'</td>';SavedText = '';iDIV++; }
		i++
	})
	
	$('#ExtraList').after('<table border="0" cellpadding="0" cellspacing="0" id="ExtraList"><tr>'+ SavedValue +'</tr></table>')

	$('#ExtraList').eq(0).remove();



















}
*/




















// Kategoriliste

// Vareliste



if	($('#ShopMainLayOutTable').html().indexOf('CmsPageStyleTest') != -1){

	_MaerkeText = $('#ShopMainLayOutTable #BREADCRUMB a').eq(1).text();
	_MaerkeLink = $('#ShopMainLayOutTable #BREADCRUMB a').eq(0).attr('href');

	_ModelText = $('#ShopMainLayOutTable #BREADCRUMB a').eq(2).text();
	_ModelLink = $('#ShopMainLayOutTable #BREADCRUMB a').eq(1).attr('href');

	_PatronText = $('#ShopMainLayOutTable .ProductInfo_TD h1').text();
	_PatronLink = $('#ShopMainLayOutTable #BREADCRUMB a').eq(2).attr('href');

	_MaerkeText = _MaerkeText.replace('Blækpatroner til ','')
	
	if (location.href.indexOf(_MaerkeLink) != -1){var CurrentTextL = 'Genindlæs ';}else{var CurrentTextL = 'Gå tilbage til ';}
	$('#maerke').html(''+ _MaerkeText +'<br><a href="'+ _MaerkeLink +'" title="'+ CurrentTextL + _MaerkeText.toLowerCase() +'" class="change">Skift mærke</a>');
//	$('#maerke').html('Brother<br><a href="/shop/blaekpatroner-3256s.html" class="change" title="Skift mærke">Skift mærke</a>');

	if (location.href.indexOf(_ModelLink) != -1){var CurrentTextL = 'Genindlæs ';}else{var CurrentTextL = 'Gå tilbage til ';}
	$('#model').html(''+ _ModelText +'<br><a href="'+ _ModelLink +'" title="'+ CurrentTextL + _ModelText.toLowerCase() +'" class="change">Skift model</a>');
//	$('#model').html(''+ _ModelText +'<br><a href="/shop/blaekpatroner-til-brother-3260c1.html" class="change" title="Skift model">Skift model</a>');
	
//	if	(location.href.indexOf('farvebaand-sort-brother-2293p.html') != -1){
//		alert(_PatronLink)
	$('#patronid').html('<div class="hiddenheight_patronid">'+ _PatronText +'</div><a href="'+ _PatronLink +'" title="'+ CurrentTextL + _PatronText.toLowerCase() +'" class="change">Skift bl&aelig;kpatron</a>');
//	$('#patronid').html(''+ _PatronText +'<br><a href="/shop/blaekpatroner-til-brother-3260c1.html" class="change" title="Skift model">Skift model</a>');
//	}
	
	$('.OtherModel').attr('href',_MaerkeLink).attr('title',_MaerkeText);
	
	$('#BREADCRUMB').hide();

}





_HeadUnit = '';

//if	((location.href.indexOf('shop/test-model-1-3838c1.html') != -1) || (location.href.indexOf('shop/brother-dcp-375cw-3655c1.html') != -1)) {

	$('#ShopMainLayOutTable .CmsPageStyleTest #BUYSECTION .BuyButton_ProductInfo input').attr('src','/images/template/koeb-big.png')

	$('#ProductList_TD .CmsPageStyleTest a, #ShopMainLayOutTable .CmsPageStyleTest #Related_Custom_TBL a').css({'color':'#13579e','text-decoration':'underline'})
	$('#ProductList_TD .CmsPageStyleTest a, #ShopMainLayOutTable .CmsPageStyleTest #Related_Custom_TBL a').hover(function(){$(this).css({'color':'#666666'})},function(){$(this).css({'color':'#13579e'})})

	if (jQuery.browser.version == '7.0'){$('.CmsPageStyleTest .TextInputField_Productlist').css('top','-1px')}
	
	var CountRelatedHeaders = 0;
	
	$('#ShopMainLayOutTable .CmsPageStyleTest .Product').each(function() {
													 
		$(this).find('.BuyButton_ProductList').attr('src','/images/template/koeb.png')
		$(this).find('.Related_BuyButton_IMG').attr('src','/images/template/koeb.png')

		_ThisUnit = $(this).find('.HeadUnit').text();
		
		if (_HeadUnit != _ThisUnit){
			if (_ThisUnit.indexOf('Kompatible') != -1){var _Erstat = 'Erstatter';}else{var _Erstat = 'Mærke';};



		_ThisTable = '\
		<table class="ProductHeader" border="0" cellspacing="0" cellpadding="0" width="100%"> \
			<tr> \
				<td>\
					<div class="ProductNumber">Varenr.</div>\
					<div class="ProductMaerke">'+ _Erstat +'</div>\
					<div class="ProductName">Beskrivelse</div>\
					<div class="ProductMaengde">Mængde</div>\
					<div class="ProductPricer">Pris</div>\
					<div class="ProductBuyS"></div> \
				</td> \
			</tr> \
		</table> '
		
			if	(location.href.indexOf('p.html') != -1){
			$(this).before('<div class="Header">Relaterede varer</div>'+ _ThisTable)
			}else{
			$(this).before('<div class="Header Header'+ _ThisUnit.substring(0,1) +'">'+ _ThisUnit +'</div>'+ _ThisTable)
			}
			
		}

		_HeadUnit = _ThisUnit;
		
		var _ProdName = $(this).find('.ProductName a').text().split(" - ")
		if (_ProdName.length == 3){
			$(this).find('.ProductName a').text(_ProdName[0]);
			$(this).find('.ProductMaerke').text(_ProdName[1]);
			$(this).find('.ProductMaengde').text(_ProdName[2]);
		}

	})

	$('.CmsPageStyleTest .HeadUnit').hide();

	$('.CmsPageStyleTest .Product .ProductImage img').wrap('<span style="position:absolute;display:none;"><div style="position:relative"></div></span>');
	$('.CmsPageStyleTest .Product .ProductImage div img').css({'position':'absolute','left':'25px','bottom':'15px','border':'1px solid #C5C5C5'});

	$('.CmsPageStyleTest .Product .ProductImage').append('<img src="/images/template/picture.png" class="ProductImageHover" style="margin-left:7px;margin-top:4px;">');

	$('.CmsPageStyleTest .ProductImageHover').hover(
		function(){
			$(this).parent().find('a span').show();
		},
		function(){
			$(this).parent().find('a span').hide();
		}		
	)


//}



// Vareliste

		// Skjul variantstreg hvis ingen variant er der...
		$('.Variants').each(function(){
			if ($(this).html() == ''){
				$('.VariantsLine').css('display', 'none');
			}
		})


// Special span i PRODUKTMENU

	$('.gray1').each(function() {

		$(this).parent().parent().attr('class','gray1')
//		$(this).parent().attr('class','font-weight:normal !important;')
		$(this).attr('class','')

	})
	
	$('.SubMenu_Productmenu_Table').parent().parent().remove();

// Special span i PRODUKTMENU










	$('#ShopMainLayOutTable .ProductInfo_TD .CmsPageStyleTest h1').html($('#ShopMainLayOutTable .ProductInfo_TD .CmsPageStyleTest h1').text());












//};




	if ($('#ShippingFee').html()  != null){
		if	($('#ShippingFee').html() == ''){
				$('#ShippingFee').text('0,00 DKK')
		}
	}



});


