// DiBa javascript
/* Changes the process icon for the loan calculators, to make IE work properly */

function change_processicon(){
	var icon = document.getElementById('calculating'); 
	icon.style.visibility = "visible";
	icon.src = document.getElementById("calculating").src;
}

function NewWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random")	{
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="center")	{
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	else if((pos!="center" && pos!="random") || pos==null)	{
		LeftPosition=0;TopPosition=0
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	myname1 = myname + Math.round(1099999999*Math.random());
	win=window.open(mypage,myname1,settings);
}

window.onresize = function(){
	centerMenu();
/*	setHeightOfContent(0);*/
}

window.onload = function(){
/*	setHeightOfContent(0);
	centerMenu();
	activateMenu();*/
}

function init(){
	setHeightOfContent(0);
	centerMenu();
	activateMenu();
}

function init_resize(){
	//centerMenu();
}


function centerMenu(){
	var oMenu = document.getElementById("s1_menu_container");
	if (oMenu) {
		oMenu.style.display = "none";
		oMenu.style.left = (document.body.clientWidth/2)-(767/2)+"px";
		oMenu.style.display = "block";
	}
}

function showPrint()
{
	NewWindow("/printPopup.asp","new","500","500","yes","center");
}

function showSelect() {
	k = document.getElementsByTagName('select');
	for(i in k) 
		if(k[i].type) {
			k[i].style.visibility = "visible";
		}
}

function hideSelect() {
	k = document.getElementsByTagName('select');
	for(i in k)
		if(k[i].type)
			k[i].style.visibility = "hidden";
			
}

function activateMenu(){
	if (document.all&&document.getElementById) {
		var oRoot = document.getElementById("dibamenu");
		for (var i=0; i<oRoot.childNodes.length; i++) {
			node = oRoot.childNodes[i];
			if (node.nodeName=="LI") {
				if(node.getElementsByTagName("UL")[0]){
					node.onmousemove=function() {
						hideSelect();
					}
					node.onmouseover=function() {
						setTimeout("hideSelect()", 300);
						this.getElementsByTagName("UL")[0].style.display = "block";
						this.getElementsByTagName("UL")[0].style.visibility = "visible";
					}
					node.onmouseout=function() {
						this.getElementsByTagName("UL")[0].style.display = "none";
						this.getElementsByTagName("UL")[0].style.visibility = "hidden";
						setTimeout("showSelect()", 300); 
					}
				}
			}
		}
	}
}

function setHeightOfContent(iColHeight) {
	var oColContainer1 = document.getElementById("c1_container");
	var oColContainer2 = document.getElementById("c2_container");
	var oFooter = document.getElementById("s1_footer");
	var iHeight = 0;
	if (oFooter){
		oFooter.style.display = "none";
	}
	if (oColContainer1){
		var oCol1_1 = document.getElementById("c1_column1");
		var oCol1_2 = document.getElementById("c1_column2");
		var oCol1_3 = document.getElementById("c1_column3");
		iHeight = Math.max(Math.max(oCol1_1.clientHeight,oCol1_2.clientHeight),oCol1_3.clientHeight);
		if (iHeight < 380){ iHeight = 380 }
		if (iHeight < iColHeight){ iHeight = iColHeight}
		oColContainer1.style.height = iHeight + "px";
		oCol1_1.style.height = iHeight + "px";
		oCol1_2.style.height = iHeight + "px";
		oCol1_3.style.height = iHeight + "px";
	} else { 
		if (oColContainer2){
			var oCol2_1 = document.getElementById("c2_column1");
			var oCol2_2 = document.getElementById("c2_column2");
			var oCol2_2_loanCalc = document.getElementById("loanCalcBox");
			
			if (oCol2_2_loanCalc && (oCol2_2_loanCalc.clientHeight > oCol2_2.clientHeight)) {
				iHeight = Math.max(oCol2_2_loanCalc.clientHeight+40,oCol2_1.clientHeight);
			}
			else {
				iHeight = Math.max(oCol2_1.clientHeight,oCol2_2.clientHeight);
			}
			if (iHeight < 380){ iHeight = 380 }
			if (iHeight < iColHeight){ iHeight = iColHeight}
			
			oColContainer2.style.height = iHeight + "px";
			oCol2_1.style.height = iHeight + "px";
			oCol2_2.style.height = iHeight + "px";
		}
	}
	if (oFooter){
		oFooter.style.display = "block";
	}
}


// font size thingie

var iNormalSize = 10;
var iNormalLine = 14;
var iLargeSize = 11;
var iLargeLine = 18;

function setFontSize(iAction){
	if(arguments.length>1) {
		if(((iInitSize < 3) && (iInitSize >= 0)) && (iAction)) {
			//var imgs = document.getElementById(arguments[1]);
			//imgs.src = '/script/fsize.asp?action=1&t=' + new Date().getMilliseconds();
			iInitSize++;
		} else if(((iInitSize <= 3) && (iInitSize > 0)) && (!iAction)) {
			//var imgs = document.getElementById(arguments[1]);
			//imgs.src = '/script/fsize.asp?action=0&t=' + new Date().getMilliseconds();
			iInitSize--;
		} else
			return;
	} 
		
	var oC1_container = document.getElementById("c1_container");
	var oC2_container = document.getElementById("c2_container");

	var oC1_column1 = document.getElementById("c1_column1");
	var oC1_column2 = document.getElementById("c1_column2");
	var oC1_column3 = document.getElementById("c1_column3");
	
	var oC2_column1 = document.getElementById("c2_column1");
	var oC2_column2 = document.getElementById("c2_column2");
	
	var par, c, it, arr = new Array();
	c = 0;
	var k = 10;
	/*var ps = document.getElementsByTagName("P");
	alert(ps.length);
	alert(ps[0].parentNode().id);
	alert(ps[1].parentNode().id);
	alert(ps[2].parentNode().id);*/
	/*for(it in document.all) {
		k--;
		if(!k)
			break;
		alert(it);
		
		
		if(par = document.all[it].parent) {
			alert('hti');
			if(par.id == 'c2_column1')
				c++;
		}
	}
	alert(c);			
	*/
	var iHeight = 0;
	
	switch (iAction) {
		// go larger
		case 1:
			iNormalSize += 1;
			iNormalLine += 1;
			iLargeSize += 1;
			iLargeLine += 1;
			
			if (oC2_column2) {
				oC2_column2.style.fontSize = iNormalSize + "px";
				oC2_column2.style.lineHeight = iNormalLine + "px";
				
				var aEl = oC2_column2.getElementsByTagName("*");
				
				for(var i=0; i<aEl.length; i++){
					
					switch (aEl[i].nodeName) {
						case "B":
						case "LABEL":
						case "STRONG":
						case "I":
						case "P":
						case "TD":
						case "LI":
						case "A":
						
							aEl[i].style.fontSize = iNormalSize + "px";
							aEl[i].style.lineHeight = iNormalLine + "px";
						break;
						
						case "H1":
							aEl[i].getElementsByTagName("SPAN")[0].style.fontSize = iLargeSize + "px";
							aEl[i].style.lineHeight = iNormalLine + "px";
						break;
						
						case "H2":
						case "H3":
						case "TH":	
							aEl[i].style.fontSize = iLargeSize + "px";
							aEl[i].style.lineHeight = iLargeLine + "px";
						break;
						
						
					}
				}
				
				setHeightOfContent(oC2_column2.clientHeight + 100);
			}
			
			if (oC1_column2) {
				oC1_column2.style.fontSize = iNormalSize + "px";
				oC1_column2.style.lineHeight = iNormalLine + "px";
			
				var aEl = oC1_column2.getElementsByTagName("*");
				
				var retval = "";
				for(var i=0; i<aEl.length; i++){
					retval += aEl[i].nodeName + "\t\t";
					switch (aEl[i].nodeName) {
						case "B":
						case "LABEL":
						case "STRONG":
						case "I":
						case "P":
						case "TD":
						case "LI":
						case "A":
						
							aEl[i].style.fontSize = iNormalSize + "px";
							aEl[i].style.lineHeight = iNormalLine + "px";
						break;
						
						case "H1":
							aEl[i].getElementsByTagName("SPAN")[0].style.fontSize = iLargeSize + "px";
							aEl[i].style.lineHeight = iNormalLine + "px";
						break;
						
						case "H2":
						case "H3":
						case "TH":	
							aEl[i].style.fontSize = iLargeSize + "px";
							aEl[i].style.lineHeight = iLargeLine + "px";
						break;
						default:
					}
					
				}
				setHeightOfContent(oC1_column2.clientHeight + 100);
			}
			

			
		break;
		
		// go smaller
		case 0:
			iNormalSize -= 1;
			iNormalLine -= 1;
			iLargeSize -= 1;
			iLargeLine -= 1;
			
			if (oC2_column2) {	
				var aEl = oC2_column2.getElementsByTagName("*");
				for(var i=0; i<aEl.length; i++){
					
					switch (aEl[i].nodeName) {
						case "B":
						case "LABEL":
						case "STRONG":
						case "I":
						case "P":
						case "TD":
						case "LI":
						case "A":
						
							aEl[i].style.fontSize = iNormalSize + "px";
							aEl[i].style.lineHeight = iNormalLine + "px";
						break;
						
						case "H1":
							aEl[i].getElementsByTagName("SPAN")[0].style.fontSize = iLargeSize + "px";
							aEl[i].style.lineHeight = iNormalLine + "px";
						break;
						
						case "H2":
						case "H3":
						case "TH":	
							aEl[i].style.fontSize = iLargeSize + "px";
							aEl[i].style.lineHeight = iLargeLine + "px";
						break;
					}
				}
			}
			
			
			if (oC1_column2) {
				var aEl = oC1_column2.getElementsByTagName("*");
				for(var i=0; i<aEl.length; i++){
					
					switch (aEl[i].nodeName) {
						case "B":
						case "LABEL":
						case "STRONG":
						case "I":
						case "P":
						case "TD":
						case "LI":
						case "A":
						
							aEl[i].style.fontSize = iNormalSize + "px";
							aEl[i].style.lineHeight = iNormalLine + "px";
						break;
						
						case "H1":
							aEl[i].getElementsByTagName("SPAN")[0].style.fontSize = iLargeSize + "px";
							aEl[i].style.lineHeight = iNormalLine + "px";
						break;
						
						case "H2":
						case "H3":
						case "TH":	
							aEl[i].style.fontSize = iLargeSize + "px";
							aEl[i].style.lineHeight = iLargeLine + "px";
						break;
					}
				}
			}
		break;
	}
	return false
}

function switchImage(sImageName, iNumber){
	if ( document.images ) {
		eval('document.images.' + sImageName + '.src = ' + sImageName + '_' + iNumber + '.src');
	}
}

function switchMap(iMap, aPictures, sTarget){
	var oTarget = document.getElementById(sTarget);
	if (oTarget && aPictures){
		oTarget.src = aPictures[iMap].src
	}
}

var iCurrentArea = 0;
function populateAreaBox(sTarget,iRegion){
	var aZips = getRegions(iRegion)
	var oTarget = document.getElementById(sTarget);
	
	if (oTarget && aZips){
		//oTarget.options.length = 0;
		iCurrentArea = iRegion;
		for(i=0; i<aZips.length; i++){
			sNewOption = document.createElement("OPTION");
        		oNewText = document.createTextNode(aZips[i].n);
			sNewOption.setAttribute("value", aZips[i].p);
        		sNewOption.appendChild(oNewText);
		   	oTarget.appendChild(sNewOption);
		}
	}
}


function resetSelectedAreas(sTarget){
	oTarget = document.getElementById(sTarget);
	if (oTarget) {
		oTarget.options.length = 0;
		if (iCurrentArea != 0){
			populateAreaBox('selectedAreas',iCurrentArea);
		}
	}
}

function setAllAreas(sTarget){
	var aZips;
	var aNames;
	aNames = new Array("Region hovedstad nord","Region hovedstad syd","Solrød & Greve","Roskilde","Lejre","Holbæk","Odsherred","Køge","Ringsted","Sorø","Kalundborg","Stevns","Faxe","Næstved","Slagelse","Vordingborg","Guldborgsund","Bornholm","Lolland");
	aZips = new Array(20,15,25,265,350,316,306,259,329,340,326,336,320,370,330,390,376,400,360);
	oTarget = document.getElementById(sTarget);
	if (oTarget) {
		oTarget.options.length = 0;
		for(i=0; i<aZips.length; i++){
			sNewOption = document.createElement("OPTION");
        		oNewText = document.createTextNode(aNames[i]);
        		sNewOption.setAttribute("value", aZips[i]);
        		sNewOption.appendChild(oNewText);
		   	oTarget.appendChild(sNewOption);
		}
	}
}

function selectArea(oThis, sTarget){
	oTarget = document.getElementById(sTarget);
	if (oThis && oTarget) {
		/*var opt = new Option(oThis.options[oThis.selectedIndex].text, oThis.options[oThis.selectedIndex].value, false, false);
		oTarget.options[oTarget.length] = opt;
		*/
		sNewOption = document.createElement("OPTION");
	        oNewText = document.createTextNode(oThis.options[oThis.selectedIndex].text);
	        sNewOption.setAttribute("value", oThis.options[oThis.selectedIndex].value);
	        sNewOption.appendChild(oNewText);
	        oTarget.appendChild(sNewOption);
		oThis.removeChild(oThis.options[oThis.selectedIndex]);
	}
}

// advanced switchMap function to show advisor areas
function switchMiniMap(iMap, aPictures, sTarget,oEvent){
	var oTarget = document.getElementById(sTarget);

	if (oTarget && aPictures && aAdvisors){
		oTarget.src = aPictures[iMap].src

		if (!oEvent)
			var oEvent = window.event; // IE event fixer
		
		if (oEvent.type == "click"){
			removeWriteJSToMe()
			// region Advisor popup box
			var sBox = "<div id=\"regionAdvisorBox\" class=\"regionAdvisorBox\" style=\" visibility: hidden; z-index: 5000;\">" +
				"	<h3><img src=\"/img/bn_slet.gif\" onclick=\"removeWriteJSToMe()\" alt=\"Luk\" title=\"Luk\"><span>" + aAdvisors[iMap].region + "</span></h3>" +
				"	<div class=\"regionAdvisorBoxContent\">" +
				"		<img src=\"/img/advisors/" + aAdvisors[iMap].image + "\" alt=\"\">" +
				"		<div>" +
				"			<h4>DiBa Direkte</h4>" +
				"			<p>" + aAdvisors[iMap].name + "<br>" + aAdvisors[iMap].title + "</p>" +
				"			<h4>Kontakt mig</h4>" +
				"			<p>- på tlf. " + aAdvisors[iMap].tlf + "<br>- via e-mail <a href=\"mailto:" + aAdvisors[iMap].email + "\" title=\"\">" + aAdvisors[iMap].email + "</a>" +
//				"<br>- eller kontakt <a href=\"#\" title=\"\">mine kolleger</a>" +
				"</p>" +
				"		</div>" +
				"		<div class=\"clr\"></div>" +
				"	</div>" +
				"</div>";

			// insert the box into writeJSToMe, so it will be placed outside the container of the website.
			document.getElementById('writeJSToMe').innerHTML = sBox;
			
			// place the box according to the mouse coords and finally show the box to the user
			var oBox = document.getElementById('regionAdvisorBox');
			var scrollFromTop = document.getElementsByTagName("html")[0].scrollTop
			var x = getMouseX(oEvent)-(oBox.offsetWidth/2);
			var y = getMouseY(oEvent)-(oBox.offsetHeight+20)+scrollFromTop;

			
			oBox.style.top = y + "px";
			oBox.style.left = x + "px";
			oBox.style.visibility = "visible";
		}
	}
}

function switchMiniDKmap(mapId,area) {
	var map = document.getElementById(mapId),
	mapSrc = "/img/advisors/dk_map";
	
	if (area) map.src = mapSrc + "_" + area + ".gif";
	else map.src = mapSrc + ".gif";
	
}

			
function switchMinimapVersion(mapId){
	if (mapId == 0){
		document.getElementById('mapDenmark').style.display = "none";
		document.getElementById('mapSjaelland').style.display = "block";
	}
	else if (mapId == 1){
		document.getElementById('mapSjaelland').style.display = "none";
		document.getElementById('mapDenmark').style.display = "block";
	}
	removeWriteJSToMe();
}

function removeWriteJSToMe(){
	document.getElementById('writeJSToMe').innerHTML = '';
}

function fbolig() {
	var fs = document.getElementById('regsub');
	var ele = fs.value.split(";");
	var it;
	for(it in ele) {
		addAreaItem(ele[it].split(","), 'regionSelectedAreas');
	}
}

function addAreaItem(oItem, sTarget) {
	oTarget = document.getElementById(sTarget);
	if(oTarget && oItem && (oItem.length > 1) ) {
		sNewOption = document.createElement("OPTION");
		oNewText = document.createTextNode(oItem[1]);
		sNewOption.setAttribute("value", oItem[0]);
		
		sNewOption.appendChild(oNewText);
		oTarget.appendChild(sNewOption);
	}
}

function removeArea(oThis, sTarget) {
	oTarget = document.getElementById(sTarget);
	if (oThis && oTarget) {
		oThis.removeChild(oThis.options[oThis.selectedIndex]);
	}
}

function switchImage(oThis, sImageName){
	if ( document.images && imgmap) {
		document.images[sImageName].src = imgmap[oThis.id].src;
		document.images[sImageName].alt = imgmap[oThis.id].alt;
		document.images[sImageName].title = imgmap[oThis.id].title;
	}
	
	if ( arguments.length==4 ) {
		document.getElementById(arguments[2]).href=arguments[3];
	}
}

if(!iCurrentPicture)
	var iCurrentPicture = 0;
function switchLargePicture(oThis, sTargetId) {
	oPicture = document.getElementById(sTargetId);
	if (oPicture && aPicturesLarge) {
		iCurrentPicture = oThis.position
		oPicture.src = aPicturesLarge[oThis.position].oPic.src; //oThis.src
		oPicture.alt = aPicturesLarge[oThis.position].oPic.alt; //oThis.alt
		oPicture.title = aPicturesLarge[oThis.position].oPic.title;
	}
}

function movePicture(iDirection, aPictures, sTarget){
	var oTarget = document.getElementById(sTarget);
	
	if (oTarget){
		switch(iDirection){
			case 0:
				if (iCurrentPicture > 0 && iCurrentPicture < aPictures.length){
					iCurrentPicture = iCurrentPicture - 1
					oTarget.src = aPictures[iCurrentPicture].oPic.src;
					oTarget.alt = aPictures[iCurrentPicture].sAlt;
					oTarget.title = aPictures[iCurrentPicture].oPic.title;
				}
			break;
		
			case 1:
				if (iCurrentPicture >= 0 && iCurrentPicture < aPictures.length - 1 ){
					iCurrentPicture = iCurrentPicture + 1
					oTarget.src = aPictures[iCurrentPicture].oPic.src;
					oTarget.alt = aPictures[iCurrentPicture].sAlt;
					oTarget.title = aPictures[iCurrentPicture].oPic.title;
				}
			break;
		}
	}
}

function showThumbnails(aPictures, sTargetId){
	
	var oTarget = document.getElementById(sTargetId);
	if (oTarget && aPictures){
		for (var i=0; i<aPictures.length; i++){
			oImg = document.createElement("IMG");
			oImg.src = aPictures[i].oPic.src;
			oImg.alt = aPictures[i].sAlt;
			oImg.title = aPictures[i].oPic.title;
			oImg.position = i;
			oImg.onclick = function(){switchLargePicture(this, 'largePicture');};
			oTarget.appendChild(oImg);
		}
	}
	
	var thumbHeight = oTarget.clientHeight;
	var c2_c = document.getElementById('c2_container');
	var c2_1 = document.getElementById('c2_column1');
	var c2_2 = document.getElementById('c2_column2');
	
	c2_c.style.height = parseInt(c2_c.style.height.replace('px','')) + thumbHeight + 'px';
	c2_1.style.height = parseInt(c2_1.style.height.replace('px','')) + thumbHeight + 'px';
	c2_2.style.height = parseInt(c2_2.style.height.replace('px','')) + thumbHeight + 'px';
}

function getSelectedAreas(sAreas, sTarget){
	oAreas = document.getElementById(sAreas);
	if (oAreas){
		var retval = "";
		for(i=0; i<oAreas.length; i++){
			oAreas[i].selected = true;
			retval += oAreas[i].value + "," + oAreas[i].text;
			if(i<oAreas.length-1)
				retval+=";";
		}
		var ele;
		if(ele = document.getElementById('regsub')) {
			ele.value = retval;
		}

		
		if(oAreas.length) {
			return true;
		} else {
			alert("Venligt vælg kommune");
			return false;
		}	
	} else {
		return false;
	}
}

function Set_Cookie(name,value,expires,path,domain,secure) { 
    var cookieString = name + "=" +escape(value) + 
       ( (expires) ? ";expires=" + expires.toGMTString() : "") + 
       ( (path) ? ";path=" + path : "") + 
       ( (domain) ? ";domain=" + domain : "") + 
       ( (secure) ? ";secure" : ""); 
    document.cookie = cookieString; 
} 

function Delete_Cookie(name,path,domain) { 
   if (Get_Cookie(name)) document.cookie = name + "=" + 
      ( (path) ? ";path=" + path : "") + 
      ( (domain) ? ";domain=" + domain : "") + 
      ";expires=Thu, 01-Jan-70 00:00:01 GMT"; 
} 

// Shows extra information on different options
function display_pant(iNum) {
	var oPant = document.getElementById("pant_text");
	if(oPant){
		if (iNum == 1) {
			oPant.style.visibility = "visible";
		}	else {
			oPant.style.visibility = "hidden";
		}
	
		setHeightOfContent(0);
	}
}

function displaybox(oThis,iBox){
	box = document.getElementById("info" + iBox).style;
	if (box.display == "block"){
		box.display = "none";
		oThis.getElementsByTagName("img")[0].src = "/img/laaneberegner/bn_aabn.gif";
	} else {
		box.display = "block";
		oThis.getElementsByTagName("img")[0].src = "/img/laaneberegner/bn_luk.gif";
	}
	setHeightOfContent(0);
}

function displayboxes(iBox1,iBox2){
	box1 = document.getElementById("info" + iBox1);
	box2 = document.getElementById("info" + iBox2);
	
	box1.style.display = "none";
	box1.parentNode.getElementsByTagName("img")[0].src = "/img/laaneberegner/bn_aabn.gif";
	
	box2.style.display = "block";
	box2.parentNode.getElementsByTagName("img")[0].src = "/img/laaneberegner/bn_luk.gif";
	
	setHeightOfContent(0);
}

function popuphelp(num){
	
}

function show_info(mus_x,mus_y,num,display) {
	if(display)
		hideSelect();
		
	box = document.getElementById("inf_"+num).style;
	if (box.display == "none" || box.display == "" || display==1){
		if (num == 1){
			box.top = (mus_y+getScrollWindowHeight()-40)+"px";
			box.left = (mus_x-260)+"px";
		} else {
			box.top = (mus_y+getScrollWindowHeight()-40)+"px";
			box.left = (mus_x+20)+"px";
		}
		box.display = "block";
	}
	else{
		box.display = "none";
	}
	
	if(!display)
		showSelect();
	
}

// Returns x coordinate of mousepointer
function getMouseX(oEvent){
	var x = oEvent.clientX;
	if (!x){x = 0}
	return x;
}

// Returns y coordinate of mousepointer
function getMouseY(oEvent){
	var y = oEvent.clientY;
	if (!y){y = 0}
	return y;
}

// Opens a popup - <a href="http://dwarf.dk/ onclick="return setPopup(this, 300, 300)">
function setPopup(oThis, sHeight, sWidth, bResize, bScroll, bMenu, bLocation, bToolbar){
	var sUrl;
	if(typeof(oThis) == "string"){sUrl = oThis}else{sUrl=oThis.href}
	if(bResize){bResize="resizable"}else{bResize="resizable=0"}
	if(bScroll){bScroll="scrollbars"}else{bScroll="scrollbars=0"}
	if(bMenu){bMenu="menubar"}else{bMenu="menubar=0"}
	if(bLocation){bLocation="location"}else{bLocation="location=0"}
	if(bToolbar){bToolbar="toolbar"}else{bToolbar="toolbar=0"}
	var dwarfPopup = window.open(sUrl, "dwarfPopup", "width=" + sWidth + ", height=" + sHeight + ", " + bResize + ", " + bScroll + ", " + bMenu + ", " + bLocation + ", " + bToolbar + "");

	return false;
}

// Returns browser name
function getBrowserData(){
	var sBrowserData = navigator.userAgent + " " + navigator.appVersion
	if (sBrowserData.indexOf("MSIE") != -1 && sBrowserData.indexOf("Macintosh") != -1) { return "MSIE_MAC" }
	else if (sBrowserData.indexOf("MSIE 5.0") != -1 && sBrowserData.indexOf("Windows") != -1) {	return "MSIE_50" }
	else if (sBrowserData.indexOf("MSIE 5.5") != -1 && sBrowserData.indexOf("Windows") != -1) { return "MSIE_55" } 
	else if (sBrowserData.indexOf("MSIE 6.0") != -1 && sBrowserData.indexOf("Windows") != -1) { return "MSIE_60" } 
	else if (sBrowserData.indexOf("Firefox") != -1) { return "Firefox" } 
	else if (sBrowserData.indexOf("Safari") != -1) { return "Safari" } 
	else { return "Unknown Browser"	}
}

function getScrollWindowHeight(){
	var oBody = document.getElementsByTagName("BODY")[0];
	var oHtml = document.getElementsByTagName("HTML")[0];
	if (oBody && oHtml) {
		switch(getBrowserData()){
			case "Firefox":
			case "MSIE_60":
				return oHtml.scrollTop;
			break;
			
			default:
				return oBody.scrollTop;
		}
	}
}


/* checks if there is only numbers in an input field - insert like this: onkeydown="return check_for_numbers(this,event)" */
function check_for_numbers(oThis,oEvt){
	var charCode = (oEvt.which) ? oEvt.which : event.keyCode;
	if (charCode >=48 && charCode <=57 || charCode >= 96 && charCode <= 105 || charCode >= 37 && charCode <= 40 || charCode == 8 || charCode == 13 || charCode == 46 || charCode == 9 || charCode == 18 || charCode == 17 || charCode == 27){
		return true
	}	else {
		return false
	}
}


/* changes focus after x amount of chars entered in field */
function focus_shift(oThis,iAmount,oNext){
	if (oThis.value.length >= iAmount) {
		document.getElementById(oNext).focus();
	}
}


/* reload all flash elements for IE, so it doesn't need activation */
/* this function is not a very good solution as IE has tendensies to fuckup */
/* function reloadFlash(){
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++){
		objects[i].outerHTML = objects[i].outerHTML;
	}
} */


/* reload all flash elements for IE, so it doesn't need activation */
var bo_ns_id = 0;

function startIeFix(){
  if(isIE()){
    document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
  }
}

function endIeFix(){
  if(isIE()){
    document.write('</div>');
    var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
    var theCode = theObject.innerHTML;
    theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
    document.write(theCode);
  }
}

function isIE(){
  // only for Win IE 6+
  // But not in Windows 98, Me, NT 4.0, 2000
  var strBrwsr= navigator.userAgent.toLowerCase();
  if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){
    if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6){
      return false;
    }
    if(strBrwsr.indexOf("win98") > -1 ||
       strBrwsr.indexOf("win 9x 4.90") > -1 ||
       strBrwsr.indexOf("winnt4.0") > -1 ||
       strBrwsr.indexOf("windows nt 5.0") > -1)
    {
      return false;
    }
    return true;
  }else{
    return false;
  }
}

// Scripts til flashloads - load flash uden om IE's sikkerhedsmodel.

function Flashees(){}

// returnerer browserens flashversion
Flashees.prototype.flashVersion = function(){
	var intMaxFlashVersion = 20;
	var intFlashVersion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		for (var i = 0; i < navigator.plugins.length; i++) {
			if (navigator.plugins[i].name.indexOf('Shockwave Flash') != -1) {
				intFlashVersion = navigator.plugins[i].description.split('Shockwave Flash ')[1].charAt(0);
				break;
			}
		}
	} else if (window.ActiveXObject){
		for (var i = 2; i <= intMaxFlashVersion; i++){
			try {
				objFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + i + "');");
				if (objFlash) {
					intFlashVersion = i;
				}
			}
			catch(e) {}
		}
	}
	return intFlashVersion;
}

// loader flash object uden om explorers sikkerhedsblokering
Flashees.prototype.loadFlash = function(intVersion, strMovieUrl, intWidth, intHeight, blnClickable, strAlternativeImage, strTitle, strAlternativeUrl, strname, strid){
	var strReturn = "";
	if(this.flashVersion() >= intVersion || intVersion == 0){
		strReturn += "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" name=\"" + strname + "\" id=\"" + strid + "\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + intVersion + ",0,0,0\" width=\"" + intWidth + "\" height=\"" + intHeight + "\" id=\"flashloader\" align=\"middle\">\n";
		strReturn += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n";
		strReturn += "<param name=\"movie\" value=\"" + strMovieUrl + "\" />\n";
		strReturn += "<param name=\"quality\" value=\"high\" />\n";
		strReturn += "<param name=\"wmode\" value=\"transparent\" />\n";
		if (this.flashVars != "") strReturn += "<param name=\"FlashVars\" value=\"" + this.flashVars + "\" />\n";
		strReturn += "<embed src=\"" + strMovieUrl + "\" wmode=\"transparent\" quality=\"high\" width=\"" + intWidth + "\" height=\"" + intHeight + "\" name=\"" + strname + "\" id=\"" + strid + "\" align=\"middle\" allowscriptaccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" ";
		if (this.flashVars != "") strReturn += " FlashVars=\"" + this.flashVars + "\"";
		strReturn += " />\n";
		strReturn += "</object>\n";
		document.write(strReturn);
	} else {
		if (strAlternativeImage != ""){
			if (blnClickable) {
				strReturn += "<a href=\"" + strAlternativeUrl + "\" title=\"" + strTitle + "\">\n";
				strReturn += "<img src=\"" + strAlternativeImage + "\" alt=\"" + strTitle + "\" title=\"" + strTitle + "\" />\n";
				strReturn += "</a>\n";
			}	else {
				strReturn += "<img src=\"" + strAlternativeImage + "\" alt=\"" + strTitle + "\" title=\"" + strTitle + "\" />\n";	
			}
			document.write(strReturn);
		} else if (strAlternativeUrl && strAlternativeUrl != ""){
			document.location.href = strAlternativeUrl;
		}
	}
}

var disclaimerCount = 0;




function checkSignup(obj){
	
	if (obj.checked){
		disclaimerCount++;
	}else{
		disclaimerCount--;
	}
	if (disclaimerCount>0){
		document.getElementById('disclaimerBox').style.visibility='visible';	
		
	}else{
		document.getElementById('disclaimerError').style.visibility='hidden';
		document.getElementById('disclaimerBox').style.visibility='hidden';
	}
	
	
}

function checkLoebetid(){
	
	var arrTimes = {	10:'10 år',
				9:'9 år',
				8:'8 år',
				7:'7 år',
				6:'6 år',
				5:'5 år',
				4:'4 år',
				3:'3 år',
				2:'2 år',
				1:'1 år'
			};

	var currentMonth = new Date().getMonth();
	
	var objThis = document.getElementById('OutAargangNew');
	var obj = document.getElementById('loebetid');
	if(obj)
	{
		
		var x,c=0,i=0,intOffset = 0,intSelectedOffset=0;
		
		if ((objThis.selectedIndex<3 && currentMonth<7) || (objThis.selectedIndex<2 && currentMonth>=7))
		{
			intSelectedOffset=2;
		}
		else if ((objThis.selectedIndex<6 && currentMonth<7) || (objThis.selectedIndex<5 && currentMonth>=7))
		{
			intOffset = 2;
			intSelectedOffset=3;
		}
		else
		{
			intOffset = 5;
			intSelectedOffset=5;
		}
		
		for(x in arrTimes)
		{
			if(c>=intOffset)
			{
				obj.options[i] = new Option(arrTimes[x],x*12);
				i++
			}
			else
			{
				obj.options[i] = null;
			}
			
			c++;
		}
		obj.selectedIndex=intSelectedOffset-intOffset;
		
		
	}
}


function CheckPayout(sDestinationId,sSourceId){
	return;
	var oDestination = document.getElementById(sDestinationId);
	var oSource = document.getElementById(sSourceId);
	if (oDestination && oSource){
		var iPayoutMin = parseInt(oSource.value,10)*0.3||0;
		var bOk = false;
		if (oDestination.value.length>0 && !isNaN(oDestination.value)){
			var iPayout = parseInt(oDestination.value,10);
			if (iPayout>=iPayoutMin){
			 	bOk = true;
			}
		}
		if (!bOk){
			oDestination.value = iPayoutMin;
		}
	}	
}

function validTextField(aThis,aFocus){
  var newvalue="";
  newvalue=removeChar(aThis.value,"'\"");
  aThis.value = newvalue
  if (aFocus) { aThis.select(); }
  return newvalue;  
}

function removeChar(aStr,aRemoveChars) {
  var newvalue = "";
  var temp;
  if (aStr==null) { aStr=""; }
  for (var i=0; i<aStr.length; i++) {
  temp = "" + aStr.substring(i, i+1);
  if (aRemoveChars.indexOf(temp) == "-1") { newvalue+=temp;}
  } 
  return newvalue;
}
 
var tKeepAlive;
var iKeepAliveCount = 0;
function keepAlive(bFirst){
	if (!bFirst){
		var keepalive_img = document.createElement('img');
		keepalive_img.setAttribute('alt','tracking');
		keepalive_img.style.visibility = 'hidden';
		keepalive_img.style.width = '1px';
		keepalive_img.style.height = '1px';
		keepalive_img.style.position = 'absolute';
		keepalive_img.style.bottom = '0';
		keepalive_img.setAttribute('src','/services/keepAlive.asp');
		document.body.appendChild(keepalive_img);
	}
	
	iKeepAliveCount++;
	tKeepAlive = setTimeout("keepAlive(false);",20000);
	
	
	
}

function validateDisclaimer(){
		if (disclaimerCount>0 && !document.getElementById('disclaimerConfirm').checked){
				document.getElementById('disclaimerError').style.visibility='visible';
				setHeightOfContent(0);
				return false;
		}
		else{
				return true;
		}
		
}

Flashees.prototype.flashVars = "";

var flashees = new Flashees();

function changeState(sElm){
	oElm = document.getElementById(sElm);
	
	if (oElm.style.display == "none") oElm.style.display = "block";
	else oElm.style.display = "none";
}
