
window.onload = initIndicator;

function setIndicator(id) {
	try {
      document.getElementById("indicator"+id).style.backgroundColor = "#ffffff";
    } catch (e) {
      
    }
		
}

function clearIndicator(id) {
	var storedId = getCookie("neMenuIndicator");

	if (id != storedId) {
		document.getElementById("indicator"+id).style.backgroundColor = "transparent";
	}

}

function storeIndicator(id) {
	setCookie("neMenuIndicator", id);
}

function initIndicator() {

	try
	{	
		
		/****** 12-10-2009 kald af function clientSideInclude ændret til jQuery .load pga. IE8 *****/
		$("#neMenuTbl").load("/cgi-files/external/menu/menu_include.htm");
		//clientSideInclude("neMenuTbl", "/cgi-files/external/menu/menu_include.htm");
		
		
		var id = getCookie("neMenuIndicator");
		//alert(id);
		if (id) {
			setIndicator(id);
			
			var bottomIndicator = document.getElementById("neBottomIndicator");
	
			/*switch(id) {
				case "1":
					bottomIndicator.style.backgroundColor = "#ffe102";
					break;
				case "2":
					bottomIndicator.style.backgroundColor = "#5bd900";
					break;
				case "3":
					bottomIndicator.style.backgroundColor = "#ff5fd6";
					break;
				case "4":
					bottomIndicator.style.backgroundColor = "#639de9";
					break;
				case "5":
					bottomIndicator.style.backgroundColor = "#d84edd";
					break;
				case "6":
					bottomIndicator.style.backgroundColor = "#00d9d7";
					break;
				default:
					bottomIndicator.style.backgroundColor = "#ffffff";
					break;
			}
	*/
		}
	}
	catch(e)
	{
		
	}
}


function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate);
}

function getCookie(c_name) {
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=")
	  if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	  }
	return null
}


function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  //alert("Bad id " + id + 
  // "passed to clientSideInclude." +
  // "You need a div or span element " +
  // "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

