 $(document).ready(function(){

 $(".expander").mouseover(function(){this.style.textDecoration='underline';});
 $(".expander").mouseout(function(){this.style.textDecoration='none';});
 $(".expandee").addClass("collapsed");

 // These two will now JUST be the actual triggers. The id of the area to hide/show must be passed in the "rel"
 $(".expandit").toggle(function(){toggleiton(this);}, function(){toggleitoff(this);}); 
 $(".collapseit").toggle(function(){toggleitoff(this);}, function(){toggleiton(this);});
 $(".expandit").mouseover(function(){this.style.textDecoration='underline';});
 $(".expandit").mouseout(function(){this.style.textDecoration='none';});
 $(".expandittarget").hide();
 
 $(".expandable").toggle(function(){toggleon(this);}, function(){toggleoff(this);});
 $(".collapsable").toggle(function(){toggleoff(this);}, function(){toggleon(this);});

  // Set top nav sub menu show and hide:  IE fix
 $(".navband li").hover(function(){$(this).addClass("scripthover");},function(){$(this).removeClass("scripthover");});
 $("#showold").click(function() { hideoldoff(); return false;});
 $("#hideold").click(function() { hideoldon(); return false;}); 
});

function hideoldon()
{
$(".gl_begivenhed").slideUp('normal');
$("#showold").fadeIn('fast');
$("#hideold").fadeOut('fast');
}
function hideoldoff()
{
$(".gl_begivenhed").slideDown('slow');
$("#showold").fadeOut('fast');
$("#hideold").fadeIn('fast');
}

function toggleon(expandableobject)
{
  $(expandableobject).find(".expandee").removeClass("collapsed"); 
  $(expandableobject).find(".expander").addClass("collapser").removeClass("expander");
}

function toggleoff(expandableobject)
{
  $(expandableobject).find(".expandee").addClass("collapsed");
  $(expandableobject).find(".collapser").addClass("expander").removeClass("collapser"); 
}

function toggleiton(expander)
{  
  $("#"+$(expander).attr('rel')).show("fast");
  $(expander).css('background-position','0px -15px');
}

function toggleitoff(expander)
{
  $("#"+$(expander).attr('rel')).hide("fast");
  $(expander).css('background-position','0px 0px');
}

//catch and disable firebug debug calls for other browsers than firefox
if (!window.console || !console.firebug) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",  "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i < names.length; ++i){
        window.console[names[i]] = function() {}
	}
}

//fix background image flicker for IE 6 
try {document.execCommand("BackgroundImageCache", false, true);} catch(err) {}

//run on DOM ready
/*
$(function(){
	
	// CHANGE: TRANSLATION: In line below: Added translatable global labels. Set in the Arn-lib.xslt file taken from the dictionary. /TORK: alert(transprev+' * '+transnext); 
	//init slideshow	
	var transprev = "Forrige";
	var transnext = "N&aelig;ste";
	$('#slideshow').after('<div id="slideshowNav"><div class="prevnext"><a href="#" id="slideshowPrev">&laquo; '+transprev+'</a><a href="#" id="slideshowNext">'+transnext+' &raquo;</a></div><div id="slideshowPager"></div>').cycle({ 
	    fx:     'fade', 
	    speed:  'slow', 
	    timeout: 8000, //set to 0 for full manual
		pause:  1, //pauses slideshow on mouseover
	    pager:  '#slideshowPager',
		next: 	'#slideshowNext', 
		prev:   '#slideshowPrev',
		before: setCaption
	});
	
	$('#introphotos').cycle({
	    random: true,
	    timeout: 8000
	});
	
});
*/

//updating the slide description
function setCaption(){
	var slide  = this;
	$("#slideshowCaption").fadeOut(500, function(){
		var img = $("img",slide);
		var desc = $(".description",slide).html() || img.attr("title") || '';
		$("#slideshowCaption").html(desc).fadeIn(500);	
	});
}

