
domReady(function(){

//PRODUCTMENU

		// Loader productmenu
		cn_init_menu(document.getElementById('ProductMenu_Table'),1)

//PRODUCTMENU
		
		
		$('img').each(function(){
			if ($(this).attr('src').indexOf('-r.jpg') != -1){
				$(this).attr('src',$(this).attr('src').replace('-r.jpg','-t.jpg'))
			}
		})


});

isDebug = function(){
	return (location.href.indexOf('?cn') != -1);	
}


$(document).ready(function() {



		$('#ShopMainLayOutTable #ProductList form').each(function(){
			if ($(this).find('.ProductNumber_Productlist').eq(1).text().indexOf('økotex') != -1){
				$(this).wrap('<div style="position:relative;"></div>')
				$(this).find('table').eq(0).before('<img src="/images/template/label_okotex.png" style="position:absolute;top:-15px;right:10px;">');
			}else if ($(this).find('.ProductNumber_Productlist').eq(1).text().indexOf('øko') != -1){
				$(this).wrap('<div style="position:relative;"></div>')
				$(this).find('table').eq(0).before('<img src="/images/template/label_100oko.png" style="position:absolute;top:-15px;right:10px;">');
			}
			
			$(this).find('.ProductNumber_Productlist').eq(1).hide();
		})




	$('#ShopMainLayOutTable .ProductInfo_MagixZoomPlus_MainImage_TD').css('border','none');
	$('#ShopMainLayOutTable .ProductInfo_MagixZoomPlus_MainImage_TABLE').nextAll().find('img').eq(0).css('border','3px solid #b50937');

    $('#ShopMainLayOutTable .ProductInfo_MagixZoomPlus_MainImage_TABLE').nextAll().find('img').click(function () { 
	  $('#ShopMainLayOutTable .ProductInfo_MagixZoomPlus_MainImage_TABLE').nextAll().find('img').css('border','3px solid #9db820');
      $(this).css('border','3px solid #b50937');
    });
	
      $('#Text p').eq(1).css('margin-top','-18px');


});


// Denne funktion sørger for automatisk at tilpasse indholdet er en menu
function cn_init_menu(menu,level){
	// Hent indhold i menuen
	var list=menu.rows;
	var i=list.length; var j=i;

	// Gennemgå punkterne
	if(i>0)do{
		// Hent en reference til punktet
		var tmp=list[j-i].cells; tmp=tmp[tmp.length-1];

		// Tjek om det er en undermenu
		var x=tmp.getElementsByTagName('table')[0];
		if(x){
			cn_init_menu(x,level+1);
			continue;
		}

		// Tjek om det er et almindeligt punkt
		tmp=tmp.getElementsByTagName('a');
		var x=tmp[0];
		var y=tmp[1];
		
		if (tmp.length>2)
		{
			tilfoej = '';
			if (tmp[2].innerHTML.substring(0,3)=='<u>') tilfoej = 'specialniv'
			tmp[2].innerHTML='<div class="niv'+level+' '+tilfoej+'">'+tmp[2].innerHTML+'</div>';
		}
		if(y&&x&&y.parentNode==x.parentNode) 
		{
			if (tmp.length<3)
			{
				tilfoej = '';
				if (y.innerHTML.substring(0,3)=='<u>') tilfoej = 'specialniv'
				y.innerHTML='<div class="niv'+level+' '+tilfoej+'">'+y.innerHTML+'</div>';
			}
		}
		else if(x)
		{
			tilfoej = '';
			if (x.innerHTML.substring(0,3)=='<u>') tilfoej = 'specialniv'
			x.innerHTML='<div class="niv'+level+' '+tilfoej+'">'+x.innerHTML+'</div>';		
		}
	}while(--i);
}

