function change_decoration(number, numbertwo)
{
    
    Effect.Fade('decoration_' + number, { duration: 1.3 }); 
    Effect.Appear('decoration_' + numbertwo, { duration: 1.3 , queue: 'end'});
    setTimeout("switch_top()", 9000);
}

function load_menu(number)
{
    $$('a.cover').each(function(div){
        if(div.id != 'menu_hover_' + number)
        {
            div.hide();
        }
    }); 
        
    $('menu_hover_' + number).show();
}

function unload_menu(number)
{
    $('menu_hover_' + number).hide();
}

function switch_top()
{
		mark_menu();
   number = parseInt($('decoration').className);
   numbertwo = number + 1;
   if(numbertwo > 3)
   {
       numbertwo = 1;
   }
   $('decoration').className = numbertwo;
   change_decoration(number, numbertwo);
}



// This looks what page is loaded and marks the corresponding menu items.
function mark_menu()
{
 loc = window.location.href;
 if(loc.match("vara_program.html") || loc.match("program") || loc.match("ebd.html") || loc.match("kommunikation") || loc.match("mf.html"))
 {
		mark_top_menu('menu_hover_1');
 } 

 if(loc.match("om_vaxjo.html"))
 {
	 mark_top_menu("menu_hover_4");
 }

 if(loc.match("snart_linneuniversitetet.html"))
{
	mark_top_menu("menu_hover_5");
}

 if(loc.match("tavling.html"))
 {
	mark_top_menu("menu_hover_6");
}

 if(loc.match('studenter_tycker_till.html'))
 {
	 mark_top_menu('menu_hover_2');
 }

 if(loc.match('om_campus_och_universitetet.html'))
 {
	 mark_top_menu('menu_hover_3');
 }



	if(loc.match("jag_vill_ha_mer_information.html"))
	{
		$('right_menu_1').addClassName('selected');
	}
	
	if(loc.match("anmalningar.html"))
	{
	
		$('right_menu_2').addClassName('selected');
	}
	
	if(loc.match("vara_studievagledare.html"))
	{
	
		$('right_menu_3').addClassName('selected');
	}
	
	if(loc.match("fragor_om_antagningen.html"))
	{
		$('right_menu_4').addClassName('selected');
	}
	

	if(loc.match("campus.html"))
	{
		$('right_menu_yellow_1').addClassName('selected');
		mark_top_menu('menu_hover_3');
	 
	}
	if(loc.match("boende.html"))
	{
		$('right_menu_yellow_2').addClassName('selected');
		mark_top_menu('menu_hover_3');
	 
	}
	if(loc.match("studentliv.html"))
	{
		$('right_menu_yellow_3').addClassName('selected');
		mark_top_menu('menu_hover_3');
	 
	}
	if(loc.match("utomlands.html"))
	{
		$('right_menu_yellow_4').addClassName('selected');
		mark_top_menu('menu_hover_3');
	 
	}

	

}


function mark_top_menu(div_id)
{
	$(div_id).show();
	$(div_id).firstDescendant().src = $(div_id).firstDescendant().src.replace("hover", "cover");
	$$('a.cover').each(function(div){
      if(div.id != div_id)
      {
					//alert("div:" + div.id + " - " + div_id);
          div.hide();
      } else {
				//alert("div:" + div.id + " == " + div_id);
}
  });
}
