//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	
	$('#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
	});
	$(".expander").mouseover(function(){this.style.textDecoration='underline';});
	$(".expander").mouseout(function(){this.style.textDecoration='none';});
	$(".expandee").addClass("collapsed");

	$(".expandable").toggle(function(){toggleon(this);}, function(){toggleoff(this);});
	$(".collapsable").toggle(function(){toggleoff(this);}, function(){toggleon(this);});

});


//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);	
	});
}

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 setactionfieldvalue(actionvalue)
{
    var actionfield = document.getElementById("action");
	actionfield.value = actionvalue;
}
