// ved resize, skal bg-billede placeres ordentligt
window.onresize = function() {
 $('body').css('background-position','center -200px');
}

// onload
$(document).ready(function(){	
   
  
  /*H1 fix til grafiske overskrifter*/
  
  /*http://www.mediegruppen.net/overskrifter/overskrift.asp?type=20&tekst=KOMMUNIKATION SKAL*/
  

	
 // placerer bunden
	x = $(document).height();
	y = $(window).height();	
	x = x - 80;
	y = y - 15;
	if(x > y){
	 $('#bund').css('top',x + 'px');
	} else {
	 $('#bund').css('top',y + 'px');
	}
	
	// fixer elementer
	$('#menu_venster').css('padding-top','0px');
	w = $(window).width();
	x = (w - 1450) / 2;
	// $('body').css('background-image','url(/Files/System/mediegruppen/grafik_2009/baggrunde/bg.gif)');
	// $('body').css('background-position','' + x + 'px -1500px');
	
	
	// loader elementer
	$('#spsnews div').show(500,function(){ // højrespalte
	 $('#tools').slideDown(500,function(){ // tools
	  // $('body').animate({backgroundPosition: '(' + x + 'px -200px)'});			 // bg		
		}); 		
	});
				
	// TOOLS mouseover
	$('#tools a').mouseover(function(){
	 $(this).animate({ 
			opacity:0.4
	 },150);
	})
		
	// TOOLS mouseout
	$('#tools a').mouseout(function(){
	 $(this).animate({ 
			opacity:1.0
	 },150);
	})
	
	// KNAPPER HØJRESPALTE mouseover
	$('#spsnews img').mouseover(function(){
	 $(this).animate({ 
			opacity:0.4
	 },350);
	})
		
	// KNAPPER HØJRESPALTE mouseout
	$('#spsnews img').mouseout(function(){
	 $(this).animate({ 
			opacity:1.0
	 },350);
	})
	
	// LOGO mouseover
	/*
	$('#logo').mouseover(function(){
	 $('#logo').animate({ 
			opacity:0.4
	 },350);
	})
		
	// LOGO mouseout
	$('#logo').mouseout(function(){
	 $('#logo').animate({ 
			opacity:1.0
	 },350);
	})
	*/
	
	// menuload + mouseevents
	$('#menu_venster ul li').each(function(){
	 $(this).slideDown(750,function(){
		 
			// fixer det aktive menupunkt
	  $('#menupunkt_' + toppageid).animate({ 
			 backgroundColor: 'mg_orange'
	  },350);
			
		});
				
		// mouseover
		$(this).mouseover(function(){
		 $(this).animate({ 
				opacity:0.4,
				marginLeft:'5px'
		 },200);
		})
		
		// mouseout
		$(this).mouseout(function(){
		 $(this).animate({ 
				opacity:1.0,
				marginLeft:'0px'
		 },100);
		})
		
	})
	
});

// function til at toggle accordions
function toggle_accordion(id) {
 $('.nyhed_indhold').hide(250);
 $('.nyhed_overskrift').css('font-size','10px');
	$('#nyhed_' + id + '_indhold').show(300);
	$('#nyhed_' + id + '_overskrift').css('font-size','12px');
}

function skift_loginbox(){
 if(document.getElementById('loginbox').style.display == 'block'){
  document.getElementById('loginbox').style.display = 'none'
 } else {
  document.getElementById('loginbox').style.display = 'block'
 }
}

function parseQueryString() { 
 if ( !location.search || location.search=="?" )return null; 
 var aNameValuePair = 
 location.search.substring(1,location.search.length).split("&") 
 var aParam = new Array(aNameValuePair.length); 
 for ( var i=0; i<aNameValuePair.length; i++ ) { 
  param = aNameValuePair[i].split("="); 
  aParam[param[0]] = aParam[i] = { name: param[0], value:unescape(param[1].replace('+', ' ')) }; 
 } 
return aParam; 
} 

var aParameters = parseQueryString(); 
if ( aParameters!=null ) {
 if(aParameters['mode']!=null){ 
  fejl = aParameters['mode'].value;
  if(fejl!=""){
   alert('Dit brugernavn og/eller kodeord er forkert angivet!');
  }
 } 
}