function InitializeMenu()
{
	var navRoot = document.getElementById("MainMenu").getElementsByTagName("LI");     
	for (var i=0; i<navRoot.length; i++) 
	{         
		navRoot[i].onmouseover=function() 
		{             
			this.className+="over";         
		}         
		navRoot[i].onmouseout=function() 
		{             
			this.className=this.className.replace(new RegExp("over\\b"), "");
		}     
	}
}


function setActiveStyleSheet(title) {
    var i, a, main;
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
            a.disabled = true;
            if (a.getAttribute("title") == title) a.disabled = false;
        }
    }

    var myLanguage = 'nl';

    if (document.URL.indexOf('\/en\/') != -1) {
        myLanguage = 'en';
    }

    var StockQuotes;
    StockQuotes = document.getElementById("StockQuotes");
    if (StockQuotes != null) {
        StockQuotes.setAttribute("src", "http://services.eurobench.com/Kendrion/Details.aspx?l=" + myLanguage + "&size=" + getActiveStyleSheet());
    }

    var MiniStockQuotes;
    MiniStockQuotes = document.getElementById("MiniStockQuotes");
    if (MiniStockQuotes != null) {
        MiniStockQuotes.setAttribute("src", "http://services.eurobench.com/Kendrion/MiniKoers.aspx?l=" + myLanguage + "&size=" + getActiveStyleSheet());
    }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return "medium";
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return "medium";
}

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;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

function initNewsTicker()
{
	var newsScroller = document.getElementById("NewsScroller");	
	newsScroller.style.left = 0;	
	
	if (RetrieveComputedStyle(newsScroller, "position") == "relative")
	{
		var relativeWidth = newsScroller.offsetWidth;
		
		newsScroller.style.position = "absolute";
		newsScroller.calculatedWidth = newsScroller.offsetWidth;
		
		if (relativeWidth > newsScroller.calculatedWidth)
		{
			newsScroller.calculatedWidth = relativeWidth;
		}		
		newsScroller.style.position = "relative";
	}
	else
	{
		newsScroller.calculatedWidth = newsScroller.clientWidth;
	}
	MoveNewsScroller();
	
	return true;
}

function MoveNewsScroller()
{
	var increment = 2;
	var newsScroller = document.getElementById("NewsScroller");	
	var currLeft  = parseInt(newsScroller.style.left);
	
	if (currLeft < newsScroller.calculatedWidth * -1)
	{
		newsScroller.style.left = newsScroller.parentNode.offsetWidth + "px";
	}
	else
	{
		newsScroller.style.left = (parseInt(newsScroller.style.left) - increment) + "px";
	}
	setTimeout("MoveNewsScroller()", 50);
	
	return true;
}

function RetrieveComputedStyle(element, styleProperty)
{
	var computedStyle = null;
	if (typeof element.currentStyle != "undefined")
	{
		computedStyle = element.currentStyle;
	}
	else
	{
		computedStyle = document.defaultView.getComputedStyle(element , null);
	}
	return computedStyle[styleProperty];
}

var hasBeenLoaded = false;

function ShowContentBlock(theId)
{
	if (hasBeenLoaded)
	{
		HideContentBlocks();
		document.getElementById('myContent' + theId).style.display = 'block';

	}
}

function HideContentBlocks()
{
	if (hasBeenLoaded)
	{
		for (i = 0; i < 5; i++)
		{
			document.getElementById('myContent' + i).style.display = 'none';
		}
	}
}