//var themecolor='0097a6';
var themecolor = new Array();

	themecolor[2]='3f00b1';
	themecolor[0]='71af00';
	themecolor[3]='000000';
	themecolor[5]='e0384e';
	themecolor[7]='00a41f';
	themecolor[6]='909223';
	themecolor[4]='0044a3';
	themecolor[1]='7f3a38';
	themecolor[8]='FF6A06';
	themecolor[9]='252728';
	themecolor[10]='0a8c22';


$(document).ready(function(){

//
// MENUER -> start
//


// Preload the images used in the hover bar

	var pre_images = new Array();
	
	pre_images[2] = new Image();
	pre_images[2].src = "/fileadmin/kunst/gfx/theme1/body_bg_x_frontpage.gif";
	pre_images[0] = new Image();
	pre_images[0].src = "/fileadmin/kunst/gfx/theme2/body_bg_x_frontpage.gif";
	pre_images[3] = new Image();
	pre_images[3].src = "/fileadmin/kunst/gfx/theme3/body_bg_x_frontpage.gif";
	pre_images[5] = new Image();
	pre_images[5].src = "/fileadmin/kunst/gfx/theme4/body_bg_x_frontpage.gif";
	pre_images[7] = new Image();
	pre_images[7].src = "/fileadmin/kunst/gfx/theme5/body_bg_x_frontpage.gif";
	pre_images[6] = new Image();
	pre_images[6].src = "/fileadmin/kunst/gfx/theme6/body_bg_x_frontpage.gif";
	pre_images[4] = new Image();
	pre_images[4].src = "/fileadmin/kunst/gfx/theme7/body_bg_x_frontpage.gif";
	pre_images[1] = new Image();
	pre_images[1].src = "/fileadmin/kunst/gfx/theme8/body_bg_x_frontpage.gif";
	pre_images[8] = new Image();
	pre_images[8].src = "/fileadmin/kunst/gfx/theme9/body_bg_x_frontpage.gif";
	pre_images[9] = new Image();
	pre_images[9].src = "/fileadmin/kunst/gfx/theme10/body_bg_x_frontpage.gif";
	pre_images[10] = new Image();
	pre_images[10].src = "/fileadmin/kunst/gfx/theme11/body_bg_x_frontpage.gif";

var disable_switch = 0;

// Finds the a tag with the selected class and disables switching

$('.jsmenu a.selected').each(function(){
	
	var thetext = $(this).text();		
	var lines = 't1';
	
	if(thetext.split(' ').length > 1) {
		lines = 't2';
	}
	thetext = thetext.substring(1);
	
	
	$('#scenes').html('<span class="'+lines+'">'+thetext+'</span>');
	
	disable_switch = 1;

});


if(disable_switch < 1){

	// Insert a mouseout behaviour for mainmenu
	$('#mainmenu').mouseout(function(){
		sceneOut();
	});


	$('.jsmenu a').each(function(i){
	
		var thetext = $(this).text();	
		var lines = 't1';
		
		if(thetext.split(' ').length > 1 && $(this).width() > 119) {
			lines = 't2';
		}		
		thetext = thetext.substring(1);
		

		$(this).mouseover(function(){
		
		//alert($(this).width());
		
			dropOutWithScene();
			//Only changes dynamically for the front page (where has_theme is not set)

			if(window.has_theme > 8) {
				//has_theme = eval(has_theme - 1);
				sceneOver(thetext,lines,themecolor[has_theme - 1],pre_images[has_theme - 1].src);
			} else {
				sceneOver(thetext,lines,themecolor[i],pre_images[i].src);
			}
		});
	
	
	});
}

// This changes the class for the pagetitle if it is more than 2 words
$('.rightcolumn span').each(function(){
	
	var thetext = $(this).text();		
	
	if(thetext.split(' ').length > 1  && thetext.length >= 20) {
		$('.rightcolumn').addClass('rightcolumntwolines');
	}
});

//
// MENUER -> stop
//

//anchor - fetching the right url    
$('.menu_top ul li:last a').each(function(){
	var siteUrl = window.location;
	var linkUrl = $(this).attr("href");
	if ( linkUrl.indexOf("#") > -1 ){
        elId = linkUrl.substr(linkUrl.indexOf("#"));
        }
	$(this).attr("href", siteUrl + elId);
});

$('.menu_bottom ul li:last a').each(function(){
	var siteUrl = window.location;
	var linkUrl = $(this).attr("href");
	if ( linkUrl.indexOf("#") > -1 ){
        elId = linkUrl.substr(linkUrl.indexOf("#"));
        }
	$(this).attr("href", siteUrl + elId);
});


$('#tilskud_form select').change(function() {
    $(this).parents("form").submit();
});


}); // Ends jquery onready

