function printpage() {
	window.print();  
}

//*** Change to red dot on hover in menu
//NB! The images folder is "hardcoded"
if(document.images){
	pics = new Array();
	pics[1] = new Image();
	pics[1].src = "/images/black_dot.gif";
	pics[2] = new Image();
	pics[2].src = "/images/red_dot.gif";
}

function changer(id, img, direction) {
    if(document.images) {
    	//Change image 
    	document.images["bullet_" + id].src = pics[img].src;
    	elem = document.getElementById("link_" + id);
		// NB! We really wanted to set the className of the element, but IE refused to get the color right.
		// So these values must be kept in sync with the style sheet.
    	if (direction == "in"){
	    	elem.style.color = "red";
	    	elem.style.textDecoration = "underline";
	    }else{
	    	elem.style.color = "#333333";
	    	elem.style.textDecoration = "none";
	    }
    }
 }
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function setHeight(arr){
	
if(document.getElementById){		
	var elements = new Array();
	//Get all elements to resize
	for(i=0;i<arr.length;i++){ elements[i] = document.getElementById(arr[i]);}
		var h = 0;
		for(i=0;i<elements.length;i++){
			if(elements[i]){
				if ($(elements[i]).getHeight() > h) {
					h = $(elements[i]).getHeight();
				}
			}
		}
		    	
		for(i=0;i<elements.length;i++){
			if($(elements[i])){
				$(elements[i]).setStyle('height: ' + h + 'px;');
			}
		}
	}	
}

function wait() {
	
}

function setFontSize(size) {
    /*
	var fontsizeclass = "";
	fontsizeclass = 'fontsize-' + size;
	$('containertop').removeClassName('fontsize-smaller');
	$('containertop').removeClassName('fontsize-normal');
	$('containertop').removeClassName('fontsize-larger');
	$('containertop').addClassName(fontsizeclass);
	var topElements = new Array();
	topElements[0] = 'left_column';
	topElements[1] = 'main_column';
	topElements[2] = 'right_column';
	setHeight(topElements, size);
	var bottomElements = new Array();
	bottomElements[0] = 'bottom_left_column';
	bottomElements[1] = 'bottom_main_column';
	bottomElements[2] = 'bottom_right_column';
	setHeight(bottomElements, size);
	//Keep selected font-size on site	
	createCookie('fontSize', fontsizeclass, 1);
        */


    var elements = $$('body');
    var currentFontSize;
       
    for(i=0; i<elements.length;i++) {
        currentFontSize = $(elements[i]).getStyle('font-size');
        fontSize = 75;
        if(currentFontSize.endsWith('px')) {
            fontSize = 75;
        }
        else {
            fontSize = currentFontSize.sub('%', '');
        }

        if(size==0) {
            $(elements[i]).setStyle('font-size: 75%;');
            createCookie('fontSize', '75', 1);
        }
        else if(size>0){
            fontSize = parseFloat(fontSize)+10;
            $(elements[i]).setStyle('font-size: '+fontSize+'%;');
            createCookie('fontSize', fontSize, 1);
        }
        else {
            fontSize = parseFloat(fontSize)-10;
            $(elements[i]).setStyle('font-size: '+fontSize+'%;');
            createCookie('fontSize', fontSize, 1);
        }
        

    }
}
function createCookie(name,value,days) {
	  if (days) {
	    var date = new Date();
	    date.setTime(date.getTime()+(days*24*60*60*1000));
	    var expires = "; expires="+date.toGMTString();
	  }
	  else expires = "";
	  document.cookie = name+"="+value+expires+"; path=/";
};
function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
}
function eraseCookie(name) {
		createCookie(name,"",-1);
}

// Change the height of the specified wrapper div to that of the
// tallest content element within.
// This is to avoid "jumping" layout when switching between tabs.
function autoExpandWrapperHeight(id, extraHeight) {
    var maxHeight = 0;
    $(id).childElements().each(function(div) {
        maxHeight = Math.max(maxHeight, div.getHeight());
    });
    $(id).setStyle('height:'+(maxHeight+extraHeight)+'px;');
}
