 $(document).ready(function(){
 
 $(".pause").addClass("hidden");
 $("#popupSignupedit").hide();
  $(".showbreaks").click( function() {
	//$(".pause").toggle("fast");
	if($(".pause").hasClass("hidden"))
	{
		$(".pause").removeClass("hidden");	
	}
	else
	{
		$(".pause").addClass("hidden");
	}
 });
            $("#popupClose").click(function () {
                //    alert("close");
                $("#popupSignupedit").slideUp("fast");
                //disablePopup("Contact", null);
            });
						
            $("#popupOkSave").click(function () {
				//alert("ok, gemmer..."+$("#plannerinput_joint").is(":checked"));        
				if($("#plannerinput_joint").is(":checked"))
				{
					$("#plannerinput_setjoint").val("1");
				}
				else
				{
					$("#plannerinput_setjoint").val("0");
				}
                $("#plannerinput_signal").val("1");
				//$("#popupSignupedit").slideUp("fast");
                $("form").submit();
                
                //disablePopup("Contact", null);
            });			
			 
			
			
            $(".popuplink").click(function (e) {
                //   alert("open");

                // If div is open, close it!
                if ($("#popupSignupedit").is(":visible")) {
					//alert("hiode");
                    $("#popupSignupedit").hide();
                }
                //else {


                    // Position the div               
                    var parentOffset = $(this).offset();
                    $("#popupSignupedit").css({
                        "position": "absolute",
                        "top": parentOffset.top,
                        "left": parentOffset.left + 100
                    });

                    var s = $(this).attr("itemid");
                    $("#editlabel").html(s);
                    
                    $("#plannerinput_fromtime").val($(this).find(".popuplink_from").val());
                    $("#plannerinput_duration").val($(this).find(".popuplink_minutes").val());
					
					var j = $(this).find(".popuplink_joint").val();
					//alert(j);
                    if(j == "True")
					{					    
					    $("#plannerinput_joint").attr("checked","checked");
					}
					else
					{
					   $("#plannerinput_joint").removeAttr("checked");
					}
                    //{
						//                        
                    //}
                    //else
                    //{
                     
                    //}                    
                    $("#plannerinput_signupid").val($(this).find(".popuplink_id").val());
                    $("#plannerinput_course").val($(this).find(".popuplink_course").val());
                    $(".popupSignupedit").slideDown("fast");
                    //Get data into popup
                    //populatePopup("popupedit", $j(this).attr("rel"), buildFormData);           
                    // Show popup
                    //loadPopup("popupedit");
                //}
            });			
			
 $(".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);	
	});
}

