// <script>
	$(function() {
		// Kontakt form som vil ligge i venstre side af siden. Slide in and out
		$('#contact').contactable({
			subject: 'Kontakt fra Odinsoft.dk'
		});
		// Så jeg kan skrive et par debug info ud under vejs
		// $('body').prepend('<div id="debug">Test</div>');
		function debug(text) { $('div#debug').html(text); };
		$('div#debug').click(function(){
			$('div#templatemo_rightcontent_section p').toggleClass('redBorder')
			$('div#templatemo_rightcontent_section div').toggleClass('gulBorder')
		});	
		
		// Load main content to the webpage
			$('div#templatemo_rightcontent_section').hide('clip',100,function() {
				$(this).load('page/' + $('div.templatemo_topmenu > ul > li.current').attr('id') + '.htm?rnd='+ String((new Date()).getTime()).replace(/\D/gi, ''),function() {
					$(this).show('scale',800);
				});
			});
		
		// Init colorbox picture popup
		ReInitColorBox();
		
		// Sætter billede behandnling op
		$('a[rel=liva]').colorbox({ // Liva billeder
			previous:	"forrige",
			next:		"næste",
			close:		"luk",
			maxWidth:	"90%",
			maxHeight:	"90%",
			slideshow:	"true"				
		});
		
		// Hovedemenu link
		$('div.templatemo_topmenu > ul > li').click(function() {
			var $self = $(this);
			if ($self.attr('class') == 'current')
				return false;
			$('div.templatemo_topmenu > ul > li').removeClass('current');
			$self.addClass('current');
			// Fade out main tekst, load det valgte link, og fade den nye side ind
			$('div#templatemo_rightcontent_section').hide('clip',800,function() {
				$(this).load('page/' + $self.attr('id') + '.htm?rnd='+ String((new Date()).getTime()).replace(/\D/gi, ''),function() {
					$(this).show('scale',800);
					ReInitColorBox();
				});
			});
		}); // Slut hovedemenu
		
		// Arkiv link
		$('div#Arkiv_Link a[href=#]').live("click", function () {
			$('div.templatemo_topmenu > ul > li').removeClass('current');
			var $self = $(this);
			$('div#templatemo_rightcontent_section').hide('explode',800,function() {
				$(this).load('page/' + $self.attr('id') + '.htm',function() {
					$(this).show('blind',800);
					ReInitColorBox();
				});
			});
			return false;
		}); // Slut Arkiv link

		// LeftMenu link
		$('div#templatemo_leftmenu_mid a[href=#]').click(function () {
			$('div.templatemo_topmenu > ul > li').removeClass('current');
			var $self = $(this);
			$('div#templatemo_rightcontent_section').hide('explode',800,function() {
				$(this).load('page/' + $self.attr('id') + '.htm?rnd='+ String((new Date()).getTime()).replace(/\D/gi, ''),function() {
					$(this).show('blind',800);
					ReInitColorBox();
				});
			});
			return false;
		}); // Slut leftmenu
		$('a.do_magic').nospam({ replaceText: true });
	}); // End $(document).ready(function......
	
	function ReInitColorBox() {
		// Open all external link in a new window
		$('a[href^=http:]').attr('target','_blank');
		
		// Assigen title text to link from image alt text if non is given
		$('a[id=lightbox]').each(function() {
			var $self = $(this);
			if ($self.attr('title') == "") {
				$self.attr('title',$self.children('img').attr('alt'));
			}
		});

		// Setup single picture link from A tag
		$('a[id^=lightbox]').colorbox({
			close:		"luk",
			maxWidth:	"90%",
			maxHeight:	"90%"
		});
		$('a[rel=rotation]').colorbox({ // Sætter en rotation om så vi kan lave et slideshow af billeder.
			previous:	"forrige",
			next:		"næste",
			close:		"luk",
			maxWidth:	"90%",
			maxHeight:	"90%",
			slideshow:	"true"				
		});

	};
// </script>

