function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function')  { 
		window.onload = func;
	}
	else { 		
		window.onload = function() {
			oldonload(); 
			func();
		}
	}
}

function epostlenke(navn, domene) {	
	if (domene == null || domene == "")
		domene = String.fromCharCode(99,97,112,112,101,108,101,110,46,110,111)
	window.location = String.fromCharCode(109,97,105,108,116,111) + String.fromCharCode(58) + navn + String.fromCharCode(64) + domene
	return false
}


/*
Kampanjefelthendelser
*/
$(document).ready(function(){
	var occupied = false;
	$('div.eyecatcher li > a').click(function(event){
		event.preventDefault();
		if(!occupied){
			occupied = true;
			/* henter ut posisjonen til pilen som vises. Det varierer fra IE til Mozilla */
			var slideTo = $('div.eyecatcher li.selected div.arrow').css('left');
			
			/* skjuler kampanjefeltet som det er klikket på*/
			$(this).parent().children('div.banner').hide();
			
			/* flytter feltet øverst i stakken */
			$(this).parent().children('div.banner').css('z-index','1');
			
			/* fader in bildet */
			$(this).parent().children('div.banner').fadeIn('fast');
			
			/* legger på pilen */
			$(this).parent().addClass('active');
			
			/* skyver den forrige pilen inn */
			$('div.eyecatcher li.selected div.arrow').animate(
				{
					left:'209px'
				},
				'fast',
				function(){
					/* når animasjonen er ferdig fjernes klassene og laget nullstilles */
					$(this).parent().removeClass('selected');
					$(this).parent().removeClass('active');
				}
			);
			
			/* skyver den nye pilen ut */
			$(this).parent().children('div.arrow').animate(
				{
					left:slideTo
				},
				'fast',
				function(){
					/* når animasjonen er ferdig settes laget til aktivt og stil nullstilles */
					$(this).parent().addClass('selected');
					$(this).parent().children('div.banner').css('z-index','');
					occupied = false;
				}
			);
		}
	});
});

