// ingen konflikter med andre js-frameworks
jQuery.noConflict();

// ved load af siden
jQuery(document).ready(function(){
 
	// ie 7 hacks
	if(jQuery.browser.msie) {
		if(jQuery.browser.version < 8) {
		 jQuery('#top_hoejre ul li ul').css('margin-left','-100px');
		} 
	}
	
	// mouseover farver paa topmenu
	jQuery('#top_hoejre > ul >li').eq(0).hover( function () { jQuery(this).css('background-color','#8CB28D'); }, function () { jQuery(this).css('background-color','transparent'); });
	jQuery('#top_hoejre > ul >li').eq(1).hover( function () { jQuery(this).css('background-color','#E7E6AE'); }, function () { jQuery(this).css('background-color','transparent'); });
	// jQuery('#top_hoejre > ul >li').eq(2).hover( function () { jQuery(this).css('background-color','#9BC8E9'); }, function () { jQuery(this).css('background-color','transparent'); });
	jQuery('#top_hoejre > ul >li').eq(2).hover( function () { jQuery(this).css('background-color','#C8C8C8'); }, function () { jQuery(this).css('background-color','transparent'); });
	jQuery('#top_hoejre > ul >li').eq(3).hover( function () { jQuery(this).css('background-color','#9BC8E9'); }, function () { jQuery(this).css('background-color','transparent'); });
	
	// smider klasser paa dropdowns
	jQuery('#top_hoejre>ul>li>ul:eq(0)').addClass('dropdown_1');
	jQuery('#top_hoejre>ul>li>ul:eq(1)').addClass('dropdown_2');
	jQuery('#top_hoejre>ul>li>ul:eq(2)').addClass('dropdown_3');
	jQuery('#top_hoejre>ul>li>ul:eq(3)').addClass('dropdown_4');
	
	// dropdown menuen
 jQuery('#top_hoejre>ul').superfish({ 
  delay:200,
  animation:{opacity:'show',height:'show'},
  speed:250,
  autoArrows:false,
  dropShadows:false 
 });
	
	// viser evt. topnyheden	
	if((sideid == '606' && gup('M') != 'NewsV2' && jQuery('#topnyhed_test').length > 0) || (sideid == '607' && gup('M') != 'NewsV2' && jQuery('#topnyhed_test').length > 0)){
		jQuery('#side_venstre, #side_midt').css('margin-top','343px'); // jQuery('#side_venstre, #side_midt').css('margin-top','243px');
		jQuery('#topnyhed').show();
	}
	
	// hvis vi har links med klassen 'medlem' paa, saa skal der laves modals
	if(jQuery('a.medlem').length > 0){
	 jQuery('a.medlem').each(function(){
		 jQuery(this).click(function(){
		  jQuery('#modal').modal();
			 return false;
		 });
		});
	}
	
	// blagodariya, bratko mi
 jQuery('#side').EqualHeightColumns(jQuery('.kolonne'));
	
	// fast placering
	// jQuery('#adresselinie').constantfooter({'opacity':'1.0'});
	
	// saetter aktivt topmenupunkt
	aktiver_menupunkt(sidetopid); 
	
	// hvis vi ser paa accordions
	if(jQuery('.accordions').length > 0){
	 jQuery('#side_midt>table').css('width','100%');
	}

	// hovers paa de 4 topmenupunkter
	jQuery('.top_hoejre_blok_knap img[rel!="aktiv"]').hover(
 	function () {
		 var billede1 = jQuery(this).attr('src');
		 var billede2 = billede1.replace('_up','_over');
		 jQuery(this).attr('src',billede2);
		}, 
		function () {
		 var billede1 = jQuery(this).attr('src');
		 var billede2 = billede1.replace('_over','_up');
		 jQuery(this).attr('src',billede2);
	 }
 );
	
	// flytter dropdownmenuen ud, saa vi kan faa absolute position paa.. i ie
	/* if(jQuery.browser.msie) {
	 var menu = jQuery('#top_hoejre').appendTo('body').addClass('ie-menu');
	} */
	
	// skjuler flashkortet i ie ved hover paa dropdown
	if(jQuery.browser.msie) {	 
		// jQuery('#top_hoejre > ul > li').has('ul').hover(
		jQuery('#top_hoejre > ul > li').eq(3).hover(
 	 function () { jQuery('#kortholder #kort').hide(); }, 
		 function () { jQuery('#kortholder #kort').show(); }		
  );
	}
	
});

// funktion til at deaktivere hoejrespalten med
function fjernhoejrespalte(){
 jQuery(document).ready(function(){
	 jQuery('#side_midt').css('width','714px');
  jQuery('#side_hoejre').remove();
		jQuery('#side').EqualHeightColumns(jQuery('.kolonne'));
	});
}

// funktion til at vise det aktive menupunkt
function aktiver_menupunkt(id){
	switch(sidetopid){
  case '606':
   jQuery('#side_venstre_titel').html('Dit syn');
   break;
		case '607':
   jQuery('#top_hoejre_blok1 .top_hoejre_blok_knap img').attr('src','/Files/System/do11/grafik/topknap_branchen_over.jpg').attr('rel','aktiv');
			jQuery('#side_venstre_titel').html('Branchen');
   break;
		case '608':
   jQuery('#top_hoejre_blok2 .top_hoejre_blok_knap img').attr('src','/Files/System/do11/grafik/topknap_fagligt_over.jpg').attr('rel','aktiv');
			jQuery('#side_venstre_titel').html('Fagligt');
   break;
		case '609':
   jQuery('#top_hoejre_blok3 .top_hoejre_blok_knap img').attr('src','/Files/System/do11/grafik/topknap_optikeren_over.jpg').attr('rel','aktiv');
			jQuery('#side_venstre_titel').html('Optikeren');
   break;
		case '610':
   jQuery('#top_hoejre_blok4 .top_hoejre_blok_knap img').attr('src','/Files/System/do11/grafik/topknap_omos_over.jpg').attr('rel','aktiv');
			jQuery('#side_venstre_titel').html('Om os');
   break;
 }
}

// funktion til at toggle accordions
function toggle_accordion(id){
 var status = jQuery('#accordions_accordion_' + id + '_tekst').is(":visible");
	jQuery('.accordions_accordion_tekst').slideUp(250);
 jQuery('.accordions_accordion_titel').css('font-size','10px');	
	if(status != true){
	 jQuery('#accordions_accordion_' + id + '_tekst').show(300);
	 jQuery('#accordions_accordion_' + id + '_titel').css('font-size','12px');
	}
}

// funktion til at toggle leksikon med
function leksikon_toggle(id){
 jQuery('.leksikon_element').slideUp(100);
 jQuery('#leksikon_element' + id).slideDown(350);
}

// funktion til at hente url parametre med
function gup(name){
 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
 var regexS = "[\\?&]"+name+"=([^&#]*)";
 var regex = new RegExp( regexS );
 var results = regex.exec( window.location.href );
 if( results == null )
 return "";
 else
 return results[1];
}
