jQuery(document).ready(function(){
	
	// tabs i shoppen
	// jQuery('shoptabs').tabs().find(".ui-tabs-nav").sortable({axis:'x'});
	// jQuery('#shoptabs').tabs();
	
	// aktiverer elementer i højrespalten
	if(sideid == 767){
	 jQuery('#hoejre_spalte_shop').slideDown(250);
	} else {
	 jQuery('#hoejre_spalte_helsenyt').slideDown(250);
	 jQuery('#hoejre_spalte_artikler').slideDown(250);
	}
	
	// mouseover og mouseout effekter på boxe i naturli viden
	jQuery('#naturlividen_boxe img')
 .mouseover(function(){
	 src = jQuery(this).attr('src');
		src = src.replace(/_up/,'_over')
		jQuery(this).attr('src',src);
	})
	.mouseout(function(){
	 src = jQuery(this).attr('src');
		src = src.replace(/_over/,'_up')
		jQuery(this).attr('src',src);
	})

	// tjek på bannere 
	if(sideid == 790 || sideid == 767) {
		jQuery('#midt_banner3_top_forside_internt').slideDown(500); 
		jQuery('#midt_banner_top_forside_internt:has("img"), #midt_banner_top_forside_internt:has("object")').slideDown(500); // internt topbillede
		jQuery('#midt_banner_top_forside:has("img"), #midt_banner_top_forside:has("object")').slideDown(500); // midt - top
		jQuery('#midt_banner_bund_forside:has("img"), #midt_banner_bund_forside:has("object")').slideDown(500); // midt - bund
		jQuery('#hoejre_banner_stor:has("img"), #hoejre_banner_stor:has("object")').slideDown(500); // midt - top
	 jQuery('#hoejre_banner_lille:has("img"), #hoejre_banner_lille:has("object")').slideDown(500); // midt - top
		jQuery('#venstre_banner_stor:has("img"), #venstre_banner_stor:has("object")').slideDown(500); // venstre - stor
		jQuery('#midt_banner_bund_forside_interne').slideDown(500); // forside - bund - interne
	} else {
  if(sideid != 771){
		 jQuery('#midt_banner_bund_underside:has("img"), #midt_banner_bund_underside:has("object")').slideDown(500); // midt - bund
			jQuery('#hoejre_banner_stor:has("img"), #hoejre_banner_stor:has("object")').slideDown(500); // midt - top
	  jQuery('#hoejre_banner_lille:has("img"), #hoejre_banner_lille:has("object")').slideDown(500); // midt - top
			jQuery('#venstre_banner_stor:has("img"), #venstre_banner_stor:has("object")').slideDown(500); // venstre - stor
		} 		
	}
	
	// loader knapper i menu 2
	jQuery('#menu_top_2 div').show(500,function(){
	 jQuery('#soegebox').slideDown(250,function(){
		 jQuery('#logo').fadeIn(500);
		});
	});
	
	// grafiske overskrifter
	jQuery("h1.h1").show(function(){
		 jQuery(this).replaceWith("<div class='headline' style='background-image:url(\"http://www.mediegruppen.net/overskrifter/overskrift.asp?type=31&tekst=" + jQuery(this).text() + " \");'><br /><br /><br /><br /><h1>" + jQuery(this).text() + "</h1></div>");
	});
	
	// sørger for at menupunktet med LÆS ONLINE åbner i nyt vindue
	jQuery('#venstre_menu a[href="http://www.epaper.nu/naturli/magasin/"]').attr('target','_blank');
			
	// sætter mouseover på logo
	/*
	jQuery('#logo')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.3}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	*/
	
 // sætter mouseover på topbannere på forsiden samt konkurrencebanneret i højrespalten
	jQuery('#midt_banner3_top_forside_internt div, #hoejre_banner_lille')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.7}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})

	// sætter mouseover på knapper i top menu 2
	jQuery('#menu_top_2 div')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.3}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// sætter mouseover på knapper i bunden
	jQuery('.bund_knapper_knap')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.3}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// sætter mouseover på banner for nyeste nummer
	jQuery('#venstre_nyestenummer')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.8}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// sætter mouseover på banner for naturli shop
	jQuery('#venstre_naturlishop')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.8}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})	
	
	// sætter mouseover på banner for bogtip
	jQuery('#venstre_bogtip')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.8}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// sætter mouseover på banner for kontakt
	jQuery('#venstre_kontakt')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.8}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// sætter mouseover på banner for forum
	jQuery('#venstre_forum')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.8}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// sætter mouseover på forside bund bannere
	jQuery('#forside_bannere_bund img')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.8}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// sætter mouseover på produkter
	jQuery('.produktliste_produkt')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.7}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
 
 // sætter mouseover på venstrespalte bannere
	jQuery('.venstre_banner')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.7}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// sætter mouseover på produkt blokke i højrespalten
	jQuery('.produktliste_produkt_hoejrespalte, .produktliste_produkt_midt')
	.mouseover(function(){
	 jQuery(this).stop().animate({opacity:0.7}, {duration:200})
	})
	.mouseout(function(){
	 jQuery(this).stop().animate({opacity:1.0}, {duration:200})
	})
	
	// tilføjelse til dropdownmenuen i toppen
	/*
	jQuery('#menu_top_1 a')
	.mouseover(function(){
	 jQuery('#logo').stop().animate({opacity:0.0}, {duration:200})
	})
	.mouseout(function(){
	 jQuery('#logo').stop().animate({opacity:1.0}, {duration:200})
	})
	*/
	
	// fix til at lave stipler UNDER aktive menupunkt i venstremenuen
 jQuery('ul[class="M2"]').parent().after('<li style="width:142px;margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;;background-image:url(/Files/System/naturli_2009/grafik/stipler_vandret_graa.gif);background-repeat:repeat-x;min-height:1px;line-height:1px;height:1px;"><img src="/Files/Nothing.gif" width="1" height="1" alt="" /></li>');
	
	// spoergeskemaet
	/*
	if(hent_cookie('spoergeskema') != 'nej'){
	 jQuery('#overlay').show(500,function(){
		 jQuery('#brugerundersoegelse').show(500);
		});
	}
	*/
		
});

// funktion til at tjekke tilmeldinger til nyhedsbrev i venstrespalten
function venstre_nyhedsbrev_formular_check() {
 if(document.venstre_nyhedsbrev_formular.DWNewsletterReceiptNameFieldTextTextbox.value != '' && document.venstre_nyhedsbrev_formular.DWNewsletterReceiptNameFieldTextTextbox.value != 'Indtast navn' && document.venstre_nyhedsbrev_formular.DWNewsletterReceiptEmailFieldTextTextbox.value != '' && document.venstre_nyhedsbrev_formular.DWNewsletterReceiptEmailFieldTextTextbox.value != 'Indtast email'){
  document.venstre_nyhedsbrev_formular.submit();	
	} else {
	 alert('Du skal angive dit navn og din emailadresse!');
	}
}

// funktion til at skifte tabs på forsiden 
function forside_tabskift(id,hastighed){
 if(id==1){
	 jQuery('#forside_tabdata1').slideUp(hastighed,function(){
	 jQuery('#forside_tabdata2').slideUp(hastighed,function(){
		 jQuery('#forside_tabdata3').slideUp(hastighed,function(){
			 jQuery('#forside_tabdata1').slideDown(hastighed);
			});
		});
	});
	jQuery('#forside_tab1 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab1_aktiv.jpg');
	jQuery('#forside_tab2 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab2_inaktiv.jpg');
	jQuery('#forside_tab3 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab3_inaktiv.jpg');
	}
	if(id==2){
	 jQuery('#forside_tabdata1').slideUp(hastighed,function(){
	 jQuery('#forside_tabdata2').slideUp(hastighed,function(){
		 jQuery('#forside_tabdata3').slideUp(hastighed,function(){
			 jQuery('#forside_tabdata2').slideDown(hastighed);
			});
		});
	});
	jQuery('#forside_tab1 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab1_inaktiv.jpg');
	jQuery('#forside_tab2 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab2_aktiv.jpg');
	jQuery('#forside_tab3 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab3_inaktiv.jpg');
	}	
	if(id==3){
	 jQuery('#forside_tabdata1').slideUp(hastighed,function(){
	 jQuery('#forside_tabdata2').slideUp(hastighed,function(){
		 jQuery('#forside_tabdata3').slideUp(hastighed,function(){
			 jQuery('#forside_tabdata3').slideDown(hastighed);
			});
		});
	});
	jQuery('#forside_tab1 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab1_inaktiv.jpg');
	jQuery('#forside_tab2 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab2_inaktiv.jpg');
	jQuery('#forside_tab3 img').attr('src','/Files/System/naturli_2009/grafik/forside_tabbar_tab3_aktiv.jpg');
	}
}

// funktion til at skifte tabs på forsiden 
function shop_tabskift(id,hastighed){
 if(id==1){
	 jQuery('#shop_tabdata1').slideUp(hastighed,function(){
	  jQuery('#shop_tabdata2').slideUp(hastighed,function(){
		  jQuery('#shop_tabdata3').slideUp(hastighed,function(){
			  jQuery('#shop_tabdata4').slideUp(hastighed,function(){
				  jQuery('#shop_tabdata5').slideUp(hastighed,function(){
					  jQuery('#shop_tabdata1').slideDown(hastighed);	
					 });
				 });			
			 });
		 });
	 });
	 jQuery('#shop_tab1 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab1_aktiv.jpg');
	 jQuery('#shop_tab2 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab2_inaktiv.jpg');
	 jQuery('#shop_tab3 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab3_inaktiv.jpg');
	 jQuery('#shop_tab4 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab4_inaktiv.jpg');
	 jQuery('#shop_tab5 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab5_inaktiv.jpg');
	}
 if(id==2){
	 jQuery('#shop_tabdata1').slideUp(hastighed,function(){
	  jQuery('#shop_tabdata2').slideUp(hastighed,function(){
		  jQuery('#shop_tabdata3').slideUp(hastighed,function(){
			  jQuery('#shop_tabdata4').slideUp(hastighed,function(){
				  jQuery('#shop_tabdata5').slideUp(hastighed,function(){
					  jQuery('#shop_tabdata2').slideDown(hastighed);	
					 });
				 });			
			 });
		 });
	 });
	 jQuery('#shop_tab1 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab1_inaktiv.jpg');
	 jQuery('#shop_tab2 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab2_aktiv.jpg');
	 jQuery('#shop_tab3 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab3_inaktiv.jpg');
	 jQuery('#shop_tab4 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab4_inaktiv.jpg');
	 jQuery('#shop_tab5 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab5_inaktiv.jpg');
	}
 if(id==3){
	 jQuery('#shop_tabdata1').slideUp(hastighed,function(){
	  jQuery('#shop_tabdata2').slideUp(hastighed,function(){
		  jQuery('#shop_tabdata3').slideUp(hastighed,function(){
			  jQuery('#shop_tabdata4').slideUp(hastighed,function(){
				  jQuery('#shop_tabdata5').slideUp(hastighed,function(){
					  jQuery('#shop_tabdata3').slideDown(hastighed);	
					 });
				 });			
			 });
		 });
	 });
	 jQuery('#shop_tab1 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab1_inaktiv.jpg');
	 jQuery('#shop_tab2 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab2_inaktiv.jpg');
	 jQuery('#shop_tab3 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab3_aktiv.jpg');
	 jQuery('#shop_tab4 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab4_inaktiv.jpg');
	 jQuery('#shop_tab5 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab5_inaktiv.jpg');
	}
	if(id==4){
	 jQuery('#shop_tabdata1').slideUp(hastighed,function(){
	  jQuery('#shop_tabdata2').slideUp(hastighed,function(){
		  jQuery('#shop_tabdata3').slideUp(hastighed,function(){
			  jQuery('#shop_tabdata4').slideUp(hastighed,function(){
				  jQuery('#shop_tabdata5').slideUp(hastighed,function(){
					  jQuery('#shop_tabdata4').slideDown(hastighed);	
					 });
				 });			
			 });
		 });
	 });
	 jQuery('#shop_tab1 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab1_inaktiv.jpg');
	 jQuery('#shop_tab2 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab2_inaktiv.jpg');
	 jQuery('#shop_tab3 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab3_inaktiv.jpg');
	 jQuery('#shop_tab4 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab4_aktiv.jpg');
	 jQuery('#shop_tab5 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab5_inaktiv.jpg');
	}
	if(id==5){
	 jQuery('#shop_tabdata1').slideUp(hastighed,function(){
	  jQuery('#shop_tabdata2').slideUp(hastighed,function(){
		  jQuery('#shop_tabdata3').slideUp(hastighed,function(){
			  jQuery('#shop_tabdata4').slideUp(hastighed,function(){
				  jQuery('#shop_tabdata5').slideUp(hastighed,function(){
					  jQuery('#shop_tabdata5').slideDown(hastighed);	
					 });
				 });			
			 });
		 });
	 });
	 jQuery('#shop_tab1 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab1_inaktiv.jpg');
	 jQuery('#shop_tab2 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab2_inaktiv.jpg');
	 jQuery('#shop_tab3 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab3_inaktiv.jpg');
	 jQuery('#shop_tab4 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab4_inaktiv.jpg');
	 jQuery('#shop_tab5 img').attr('src','/Files/System/naturli_2009/grafik/shop_tabbar_tab5_aktiv.jpg');
	}
	
}

// tip en ven funktioner
function tipenven_aaben(){
 jQuery('#overlay').css('display','block');
 jQuery('#tip_en_ven').fadeIn(300);
 jQuery('#soegebox').fadeOut(300);
}
function tipenven_luk(){
 jQuery('#overlay').css('display','none');
 jQuery('#tip_en_ven').fadeOut(300);
 jQuery('#soegebox').fadeIn(300);
}

function hent_cookie(name){
 var cname = name + "=";               
 var dc = document.cookie;             
 if (dc.length > 0) {              
  begin = dc.indexOf(cname);       
  if (begin != -1) {           
   begin += cname.length;       
  end = dc.indexOf(";", begin);
  if (end == -1) end = dc.length;1
   return unescape(dc.substring(begin, end));
  } 
 }
 return null;
}

function saet_cookie(name, value, expires, path, domain, secure) {
 document.cookie = name + "=" + escape(value) + 
 ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
 ((path == null) ? "" : "; path=" + path) +
 ((domain == null) ? "" : "; domain=" + domain) +
 ((secure == null) ? "" : "; secure");
}

function slet_cookie (name,path,domain) {
 if (hent_cookie(name)) {
 document.cookie = name + "=" +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  "; expires=Thu, 01-Jan-70 00:00:01 GMT";
 }
}

function fixDate(date) {
 var base = new Date(0)
 var skew = base.getTime()
 if (skew > 0) date.setTime(date.getTime() - skew)
}

// funktion til at vise spoergeskema
function spoergeskema_ja(){
 var now = new Date()
 fixDate(now)
 now.setTime(now.getTime() + 365 * 31 * 24 * 60 * 60 * 1000); // 31 dag
 saet_cookie('spoergeskema', 'nej', now); 
	jQuery('#overlay').hide(500,function(){
		jQuery('#brugerundersoegelse').hide(500);
	});	
}

// funktion til at vise spoergeskema senere
function spoergeskema_ikkenu(){
 saet_cookie('spoergeskema', 'nej');
	jQuery('#overlay').hide(500,function(){
		jQuery('#brugerundersoegelse').hide(500);
	});
}

// funktion til at skjule spoergeskema
function spoergeskema_nej(){
 var now = new Date()
 fixDate(now)
 now.setTime(now.getTime() + 365 * 31 * 24 * 60 * 60 * 1000); // 31 dag
 saet_cookie('spoergeskema', 'nej', now); 
	jQuery('#overlay').hide(500,function(){
		jQuery('#brugerundersoegelse').hide(500);
	});
}
