isOP = (navigator.userAgent.indexOf('Opera') > 0)?true:false;
isIE = (navigator.appName=='Microsoft Internet Explorer' && !isOP)?true:false;

if (!document.getElementById){
	document.getElementById = function(){return null;}
	document.getElementsByTagName = function(){return null;}
}

// Load functions
onLoadList = new Array();
function addOnLoad(func){
	onLoadList[onLoadList.length] = func;
}

function runOnLoad(){
	for(i in onLoadList){
		var addPar = "";
		if (onLoadList[i].indexOf("(") == -1) addPar = "()";
		eval(onLoadList[i]+addPar);
	}
}
if(isIE){addOnLoad('emulateHoverPseudoClass')};
if(isOP)addOnLoad('operaCompat');

if(location.href.indexOf('WBCMODE=AuthoringReedit') != -1 || location.href.indexOf('WBCMODE=AuthoringNew') != -1 || location.href.indexOf('wbc_purpose=Authoring') != -1){
	addOnLoad('initToggle');
	addOnLoad('showAnchors');
}
if(location.href.indexOf('www.de-info.dk') == -1){
	window.onresize = setPageMode;
}
if(location.href.indexOf('www.kreds') == -1){
	addOnLoad('setSearchSuggestions');
}
addOnLoad('setArticleListHeight');
addOnLoad('styleCustomLayoutTables');
addOnLoad('setFooterEmail');

window.onload = runOnLoad;




// Functions
function setFooterEmail(){
	if(document.getElementById('footerEmail')){
		document.getElementById('footerEmail').innerHTML += '<a href="mailto:de@de.dk">de@de.dk</a>';
	}
}


function operaCompat(){
	document.getElementById('service').getElementsByTagName('UL')[0].style.width = '450px';
	document.getElementById('ElementTop_showFlash').style.display = 'none';
}

function setArticleListHeight(){
	if(document.getElementById('articleList') && document.getElementById('articleShow')){
		setHeight = 0;
		curHeight = 300;
		newHeight = document.getElementById('articleShow').offsetHeight;
		if(newHeight > curHeight){
			setHeight = newHeight;
			if(document.getElementById('searchResult')){
				setHeight -= 48;
			}
		}
		else{
			setHeight = curHeight;
		}
		document.getElementById('articleList').style.height = (setHeight - 44) + 'px';
	}
}
function styleCustomLayoutTables(){
	tableCount=document.getElementsByTagName('table');
	for(var i=0;i<tableCount.length;i++){
		if(tableCount[i].className.indexOf('customLayout') != -1){
			setRowClass(tableCount[i]);			
		}
	}
}

function setRowClass(obj){
	rowCount = obj.getElementsByTagName('tr')
	if(rowCount.length >= 1)
	{
		rowCount[0].className='th';
		for(var i=2;i<rowCount.length;i+=2)
		{
			rowCount[i].className = ((rowCount[i].className=='wait')?'wait':'odd');
		}
	}
}

function setPageMode(){
	if(document.body.className != 'wide' && document.body.clientWidth > 970){
		document.body.className = 'wide';
	}
	else if(document.body.className != '' && document.body.clientWidth <= 970){
		document.body.className = '';
	}
}

function emulateHoverPseudoClass() {
	navRoot = document.getElementById('nav').getElementsByTagName('UL')[0];
	if(navRoot){
		for (i=0; i < navRoot.childNodes.length; i++){
			node = navRoot.childNodes[i];
			if (node.nodeName=='LI') {
				node.onmouseover=function() {
					this.className+='over';
		  		}
		  		node.onmouseout=function() {
		  			this.className=this.className.replace('over', '');
				}
			}
		}
	}
}

// Gosearch on Enter
function setSearchSuggestions(){
	var oTextbox = new AutoSuggestControl(document.getElementById("TextBox_search"), new StateSuggestions());
}

function goSearch(){
	searchStr = document.getElementById('TextBox_search').value;
	if(searchStr != ''){
		searchUrl = document.getElementById('searchUrl').value;
		location.href = searchUrl + searchStr;
	}
}

// CreunaMCMSLib functions
function initToggle(){
	elems = getCheckBoxesByParentNodeClassName('mcmsLibToggle');
	for(i=0;i<elems.length;i++){
		
		//Show already active on onLoad
		if(elems[i].checked){
			elems[i].parentNode.parentNode.className = 'on';
		}
		
		//Attatch functions
		elems[i].onmousedown = setToggle;
		elems[i].onmouseout = maxCompat;
	}
}

function setToggle(){
	this.parentNode.parentNode.className = (this.checked)?'':'on';
}

function maxCompat(){
	this.checked = (this.parentNode.parentNode.className == 'on')?true:false;
}

function getCheckBoxesByParentNodeClassName(clName){
	checkBoxCollection = new Array();
	inputs = document.getElementsByTagName('input');
	for(i=0;i<inputs.length;i++){
		if(inputs[i].type == 'checkbox' && inputs[i].parentNode.className == clName){
			checkBoxCollection.push(inputs[i]);
		}
	}
	return checkBoxCollection;
}
function showMap(elemToShow){
	elemsToHide = new Array;
	elemsContainer = document.getElementById('dealerMaps');
	elemsToHide = elemsContainer.getElementsByTagName('IMG');
	if(isIE){
		elemsContainer.filters[0].Apply();
		elemsContainer.filters[0].Play();
	}
	for(i=0;i<elemsToHide.length;i++){
		elemsToHide[i].style.display = 'none';
	}
	document.getElementById(elemToShow).style.display = 'block';
}
function popArticle(){
	window.open('/Pages/Infosys/pop.htm','','width=650, height=500,scrollbars,resizable',false);
}

function popPrintArticles(url){
	x = window.open(url,'X','width=650, height=500,scrollbars,resizable',false);
	x.focus();
}

function showAnchors(){
	edits = document.getElementsByTagName('iframe');
	if(edits.length > 0 && isIE){
		mainEdit = document.frames[edits.length -1].window.document.body;
		parseLinks(mainEdit);
	}
	
}
function parseLinks(obj) {
	var a = obj.getElementsByTagName('a');
	for (var i=a.length;i!=0;i--) {
		var c = a[i-1];
		if (!c.href) c.className = 'isAnchor';
	}
}
function toggleFaq(obj){
	if(document.getElementById('content').getElementsByTagName('iframe').length == 0){
		obj.className = (obj.className == 'faq')? 'faqOn' : 'faq';
	}
}