var undefined;

var currentExpanded;

resizeItAll = function() {
    if(document.getElementById('wunSiteWidth') != undefined) {
        if(document.getElementById('wunSiteWrapper') != undefined) {
            document.getElementById('wunSiteWrapper').style.width = (document.body.offsetWidth > (document.getElementById('wunLeftWidth').offsetWidth + document.getElementById('wunSiteWidth').offsetWidth+50)) ? (document.body.offsetWidth - 40) + "px"  : document.getElementById('wunLeftWidth').offsetWidth + document.getElementById('wunSiteWidth').offsetWidth + 10 + "px";
        }/* else if(document.getElementById('wunSiteOtherWrapper') != undefined) {
            document.getElementById('wunSiteWrapper').style.width = (document.body.offsetWidth > (document.getElementById('wunLeftWidth').offsetWidth + document.getElementById('wunSiteWidth').offsetWidth+50)) ? (document.body.offsetWidth - 40) + "px"  : document.getElementById('wunLeftWidth').offsetWidth + document.getElementById('wunSiteWidth').offsetWidth + 10 + "px";
        }*/
    } else if(document.getElementById('wunForsideSiteWidth') != undefined) {
        /*document.getElementById('wunForsideSiteWidth').style.width = (document.body.offsetWidth > 1020) ? (document.body.offsetWidth - 40) + "px" : "1020px" ;*/
        if(document.getElementById('wunSiteWrapper') != undefined) {
            document.getElementById('wunSiteWrapper').style.width = document.body.offsetWidth > (document.getElementById('wunForsideSiteWidth').offsetWidth +50) ? (document.body.offsetWidth - 40) + "px"  : document.getElementById('wunForsideSiteWidth').offsetWidth + 10 + "px";
        }
    }
}

window.onload = function() {
    resizeItAll();
}

window.onresize = function() {
    resizeItAll();
}

var $ = function(elementId) {
	return document.getElementById(elementId);
}

var currentFrontpageTab = 1;
var currentFrontpageContent = 1;

var frontpageToggle = function(tab, content) {
	
	$('frontpageBigBox').style.backgroundImage = "url(images/frontpage_bigbox_"+tab+".gif)";
	
	for(i=1; i < 3; i++) {
		if(undefined != $('frontpageBigBoxTab'+i) && i != tab) {
			$('frontpageBigBoxTab'+i).className = "wunBigBoxTab";
			$('frontpageTabcontent'+i).className = "wunDnone";
		}
		else if(i == tab) {
			$('frontpageBigBoxTab'+tab).className = "wunBigBoxTabSelected";
		$('frontpageTabcontent'+tab).className = "wunBigBoxRight";	
		}
	}
	
	for(i=1; i < 10; i++) {
		if(undefined != $('section'+tab+'_'+i) && i != content) {
			$('section'+tab+'_'+i).className = "wunDnone";
			$('numberselect'+tab+'_'+i).className = "wunSelectionBoxNumber";
		}
		else if(i == content) {
			$('section'+tab+'_'+content).className = "something";
			$('numberselect'+tab+'_'+content).className = "wunSelectionBoxNumberSelected";
		}
	}
	
	currentFrontpageTab = tab;
	currentFrontpageContent = content;
}

var frontpageSectionGo = function(step) {
	
	if(undefined != $('section'+currentFrontpageTab+'_'+(currentFrontpageContent+step))) {
		
		for(i=1; i < 10; i++) {
			if(undefined != $('section'+currentFrontpageTab+'_'+i)) {
				$('section'+currentFrontpageTab+'_'+i).className = "wunDnone";
				$('numberselect'+currentFrontpageTab+'_'+i).className = "wunSelectionBoxNumber";
			}
		}
		
		currentFrontpageContent += step;
		
		$('section'+currentFrontpageTab+'_'+currentFrontpageContent).className = "";
		$('numberselect'+currentFrontpageTab+'_'+currentFrontpageContent).className = "wunSelectionBoxNumberSelected";
	}
}



var tabSelect = function(sender) {
	for(i=1; i < 5; i++) {
		if(undefined != $("tab" + i)) {
			$("tab" + i).className = "wunTab";
			$("tabcontent" + i).className = "wunDnone";
		}
	}
	sender.className = "wunTabSelected";
	$(sender.id.split("tab").join("tabcontent")).className = "wunMediumBox";
}

var expandListItemToggle = function (idNumber) {
	listItemElement = $("wunListItem" + idNumber);
	
	
	if (listItemElement.className == "wunListItem") {
		listItemElement.className = "wunListItemExpanded";
	} else {
		listItemElement.className = "wunListItem";
	}
	
}

var expandListItemToggleThis = function (domElement) {
	listItemElement = domElement.parentNode;
	if (listItemElement.className == "wunListItem") {
	    if(currentExpanded == undefined) {
	        currentExpanded = listItemElement.parentNode.childNodes[0];
	    }
	    currentExpanded.className = "wunListItem";
		listItemElement.className = "wunListItemExpanded";
		
		currentExpanded = listItemElement;
	}
	
	
}
var expandBoxToggle = function (idNumber) {
	expandBoxElement = $("wunExpandBox" + idNumber);
	
	if (expandBoxElement.className == "wunExpandBox") {
		expandBoxElement.className = "wunExpandBoxExpanded";
	} else {
		expandBoxElement.className = "wunExpandBox";
	}
}

var redirect = function() {
	if(arguments.length == 1) {
		if(arguments[0].options[arguments[0].selectedIndex].value != "")
			location.href = arguments[0].options[arguments[0].selectedIndex].value;
	}
	else if(arguments.length == 2) {
		// do nothing yet	
	}
}

var printWindowContent;

var openPrintWindow = function(elementId) {

	printWindowContent = "";
	printWindowContent += "<div class=\"wunSite\" style=\"padding: 20px;\">";
	printWindowContent += "<div class=\""+$(elementId).className+"\" style=\"width: 520px;\">";

	printWindowContent += $(elementId).innerHTML;
	
	printWindowContent += "</div>";
	printWindowContent += "<br /><a href=\"javascript:void(window.print());\">hvis udskrivning ikke starter automatisk kan du klikke her</a>";
	printWindowContent += "</div>";
	
	printWindow = window.open('/danmark/din_virksomhed/print.aspx','printerPopup');
	printWindow.focus();
}


//fix background
document.body.style.backgroundPosition= "0px "+document.getElementById('msviMasthead').offsetHeight+"px";