	// Indlæs Cygnet-moduler
    if(/WebKit/i.test(navigator.userAgent)){
        var _timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(_timer); cn_load();}},10);
    }else if(document.all){
        document.write("<script id=__ie_onload defer src=javascript:void(0)></script>");
        var script=document.getElementById("__ie_onload");
        script.onreadystatechange=function(){if(this.readyState=="complete"){cn_load();}}
    }else{
        document.addEventListener('DOMContentLoaded',cn_load,false);
    }

    function cn_load(){
        // Indlæs listen over moduler
        var modules=document.cn_modules;
        var i=modules.length; var j=i;
		
        // Indlæs modulerne
        if(i>0)do{
            modules[j-i]();
        }while(--i);

    }
    document.cn_modules=new Array();

	// kræver jquery
	function findreplace(el, find, rep) {
		try{$(el).html($(el).html().replace(find, rep))}catch(e){};
	}

	function getCookie(c_name)
	{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		}
	  }
	return "";
	}
	
	function setCookie(c_name,value,expiredays)
	{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}
	
function ShowCostumerDetails(){

	if ($('.LoadProfile_Orderstep1_TBL').css('display') == 'none'){
		$('.LoadProfile_Orderstep1_TBL').show()
	}else{
		$('.LoadProfile_Orderstep1_TBL').hide()
	}

}

	$(document).ready(function(){
							   
	
$('.subcats_cn table table').click(function() {
	location.href=$(this).find('a').eq(0).attr('href');
});

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// E værktøj


//		http://www.e-vaerktoej.dk/shop/indeks-30248s.html
/*
		if	(location.href.indexOf('/cms-index-over-vaerktoej.html') != -1){

$.get('ajax/test.html', function(data) {
  $('#ShopMainLayOutTable #load').html(data);
  alert('Load was performed.');
});


			$("#ShopMainLayOutTable #load").load("/shop/indeks-30248s.html #SELECTLIST");
		
		}
		*/
		if	(location.href.indexOf('p.html') != -1){
			$('#ProductInfo_MagixZoomPlus').attr('href',$('#ProductInfo_MagixZoomPlus').attr('href').replace('.jpg','-p.jpg'))
		}

		$('#ProductList_TD .PHP').each(function(){
			$(this).before($(this).find('td').eq(4).text());
			$(this).hide();
		})


		if	(location.href.indexOf('30248s.html') != -1){
			var _CountSubs = $('#ShopMainLayOutTable #cnINDEX 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 = '';
			var saveFirstletter = '';
		
			$('#ShopMainLayOutTable #cnINDEX a').each(function() {

				if ($(this).text().substring(0,1) != saveFirstletter){
					if (saveFirstletter != ''){SavedText = SavedText + '&nbsp;<br>'}
					SavedText = SavedText + '<b>'+ $(this).text().substring(0,1) +'</b><br>'
					saveFirstletter = $(this).text().substring(0,1)
				}

				SavedText = SavedText + '<a class="SubCats_Prodlink" href="'+ $(this).attr('href') +'">'+ $(this).text() +'</a><br>';
				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++}
			})
			
			$('#cnINDEX').after('<table border="0" cellpadding="0" cellspacing="0" id="cnINDEX"><tr>'+ SavedValue +'</tr></table>')
		
			$('#cnINDEX').eq(0).remove();
		}

		LoadProfileText = '<h5 style="float:left;padding-left:10px;margin-top:0px;padding-top:2px;">Marker her, hvis du har handlet her tidligere.</h5>';
		

		if	(location.href.indexOf('frontpage.html') != -1){
			$('#ShopLayOut_Topmenu_TD a').eq(0).attr('id','ActiveSite');
		}else if	(location.href.indexOf('cms-1-dags-levering.html') != -1){
			$('#ShopLayOut_Topmenu_TD a').eq(1).attr('id','ActiveSite');
		}else if	(location.href.indexOf('cms-fragt.html') != -1){
			$('#ShopLayOut_Topmenu_TD a').eq(2).attr('id','ActiveSite');
		}else if	(location.href.indexOf('showbasket.html') != -1){
			$('#ShopLayOut_Topmenu_TD a').eq(3).attr('id','ActiveSite');
		}else if	(location.href.indexOf('cms-19.html') != -1 || location.href.indexOf('cms-') != -1){
			$('#ShopLayOut_Topmenu_TD a').eq(4).attr('id','ActiveSite');
		}

		if	(location.href.indexOf('/shop/order2.html') != -1){
//			$('#ShippingMethodsContainer td').html().replace('[POSTDK]','te');
//			alert($('#ShippingMethodsContainer td').text())
			$('#ShopMainLayOutTable #ShippingMethodsContainer td b').text($('#ShopMainLayOutTable #ShippingMethodsContainer td b').text().replace(/\[POSTDK\]/gi,''));
		}
		
		//
		$('.SubCats_Prodlink img').each(function(){
			$(this).after('<br>')
		});
		

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		if	(location.href.indexOf('order1.html&showForgotPswForm=1') == -1){$('.LoadProfile_Orderstep1_TBL').hide()};
		$('.LoadProfile_Orderstep1_TBL').before('<div><input onclick="ShowCostumerDetails()" style="float:left;" type="checkbox"> '+ LoadProfileText +'</div>')
		
		if ($('#ProdPrice').text() == 'Ring for pris!'){$('.ProdHidePrice').hide();$('#ProdPrice').text('Dette produkt er midlertidigt udsolgt');}

		// For at lave en billedevisning på kategorikort
		findreplace('#COLUMNLIST table','</tr><tr>','');

		$('#COLUMNLIST a').each(function(){
			$(this).html($(this).html().replace('>','><div>'))
		});

		$('#COLUMNLIST a').each(function(){
			$(this).html($(this).html().replace('</a>','</div></a>'))
		});






		$('#ProductMenu_Table img').each(function(){
			$(this).parent().remove();
		});

		$('#ProductMenu_Table a').each(function(){
			$(this).next('br').remove()
			
			
			
	//		$(this).parent().html('<a href="'+ $(this).attr('href') +'" class="'+ $(this).attr('class') +'" title="'+ $(this).attr('title') +'"></a>')
		});

		
		


		// For skjule print på kvitering
		$('.BackGroundColor1_OrderStep4 a:parent').css('display', 'none');

		// Produktliste - Float
		$('#ShopMainLayOutTable .Frontpage_Custom_TBL tr, #ShopMainLayOutTable .ProductList_Custom_TBL tr, #ShopMainLayOutTable .Related_Custom_TBL tr').each(function(){
			$(this).find('div.ProductList:first').css({'float':'left', 'display':'inline'});
			$(this).find('div.ProductList:last').css({'float':'right', 'display':'inline'});
			$(this).find('div.ProductList').css('display', 'block');
		});
		
		
		// Giv niv's en ekstra class i tilfælde af u-tag
		$('.RootCategory_Productmenu a u').each(function(){
			$(this).parent().addClass('specialniv');
		})
/*
		// Infokort bytter om på billedeposion
		if (ProductNumber  != ''){
			if (document.getElementById('Canvas').innerHTML == ''){
			if (!document.getElementById('moveimage') == 'undefined')
			{
			document.getElementById('Canvas').innerHTML = document.getElementById('moveimage').innerHTML
			document.getElementById('moveimage').innerHTML = ''
			}
			$('#Canvas div').css('display', 'none');
			}
		}
*/
		// Overskrift til nyheder
		if	(location.href.indexOf('news-ALL-1.html') != -1){
			$('#ProductList_TD h1').text('Nyheder');
		}

		// Overskrift til tilbud
		if	(location.href.indexOf('specialoffer-ALL-1.html') != -1){
			$('#ProductList_TD h1').text('Tilbud');
		}
		
		if($('#MoveThis2').length!=0){
		
			$('#MoveTo2').html($('#MoveThis2').html());
			$('#MoveThis2').remove();
		
		}
		

/*			
			// Hvis søgesting ikke er tom gemmer den, den i en cookie
			if (Keyword != ''){setCookie('seekform',Keyword,365);};
			var SeekCookie = getCookie('seekform');
			// Sætter string ind i formen på siden
			if (SeekCookie != ''){
				if (!document.getElementById('Keyword') == 'undefined')
				{
				document.getElementById('Keyword').value = SeekCookie;
				}
								
			};
			// Hvis Formen bliver sendt tom eller med standart-text sendes brugern til forsiden
			if (CurrencyReturnUrl == '/shop/search-1.html?keyword=' || CurrencyReturnUrl == '/shop/search-1.html?keyword=S&#248;g%20efter%20produkt'){alert('Du skal udfylde et søgeord');setCookie('seekform','',-1);location.href = '/';};

			// Overskrift til søgning
			if	(Keyword  != ''){
				$('#ProductList_TD h1').text('Søgning: '+Keyword);
			}
*/

	for (i=1; i<256; i++){
		var re = new RegExp('&#(' + i + ');', 'g');
		Keyword = Keyword.replace(re, String.fromCharCode(i))
	}
	
	// Sætter overskrifter
	if (Keyword  != ''){$('#ProductList_TD h1').text('Søgning: '+Keyword);}
	
	// Hvis søgestring ikke er tom gemmer den, den i en cookie
	if (Keyword != ''){setCookie('seekform',Keyword,365);};
	
	
	if	(location.href.indexOf('search-1.html') != -1){
		$('#ShopMainLayOutTable form input.SearchField_SearchPage').val(getCookie('seekform'))
	}else{
		SearchValue = "Indtast søgeord";
		$('#ShopMainLayOutTable form input.SearchField_SearchPage').val(SearchValue).click(function(){if($(this).attr('value') == SearchValue){$(this).val('')}}).blur(function(){if($(this).attr('value') == ''){$(this).val(SearchValue)}})
	}





		
if ($('.Prices_Custom_TBL').eq(1).find('td').eq(2).text() == '0,00 DKK') {
	$('.Prices_Custom_TBL').eq(1).css('display', 'none');
	$('.ProdHidePrice').eq(10).css('display', 'none');
	$('#BUYSECTION').css('display', 'none');
	$('#ProdPrice').css({'float':'left', 'color':'red'}).text('OBS: Produktet er udgået');
}


	});


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

var includeUserfly	= false;
var userflyUserID	= 36771;

if (location.href.indexOf('/shop/order') != -1 || getCookie('includeuserfly')) {
	includeUserfly = true;
	if (location.href.indexOf('/shop/order1.html') != -1) { 
		setCookie('includeuserfly', true);                                                 
	}
}
