// Delade funktioner
		var isNetscape = (!document.all && document.getElementById) ? true : false;

//---------------PopUp------------------
		var lastInfoDiv;
		var infoDivName = 'listdiv';
		var showEmptyStrings = true;
		
		
		// Hide element
		function HideDiv(divId){
			if(divId && document.getElementById){
				document.getElementById(divId).style.visibility = "hidden";
			}else if(lastInfoDiv && document.layers){
				document.layers[divId].visibility = "hidden";
			}
		}
		// Get height of div
		function GetDivH(divId){
			if(document.getElementById){
				return document.getElementById(divId).offsetHeight;
			}else if(document.layers){
				return document.layers[divId].offsetHeight;
			}
		}
		function GetDivTop(divId){
			if(document.getElementById){
				return document.getElementById(divId).style.top;
			}else if(document.layers){
				return document.layers[divId].style.top;
			}
		}
		// Get width of div
		function GetDivW(divId){
			if(document.getElementById){
				return document.getElementById(divId).offsetWidth;
			}else if(document.layers){
				return document.layers[divId].offsetWidth;
			}
		}
		// fill object with new HTML code
		function WriteHTML(objid, newcode){
			if(document.getElementById){ // !!!!!!!!				
				document.getElementById(objid).innerHTML = newcode;
			}else if(document.layers){ // !!!!!!
				document.layers[objid].document.write(newcode);
				document.layers[objid].document.close();
			}
		}
		// Get X & Y coords from pointer. Use this to position a div
		function getDivXYPosition(e, divH, divW){
			if (!document.all && document.getElementById){ // NS6
			
				nyX = e.pageX + 10;
				nyY = e.pageY + 10;
				if(e.clientY + divH > window.innerHeight){ 
					nyY = nyY - ((e.clientY + divH)- window.innerHeight) - 25;
				}
				if(e.clientX + divW + 20 > window.innerWidth){ 
					nyX = e.pageX - divW - 10;
				}
			}else if(document.documentElement && document.documentElement.scrollTop){ // IE 6.0
			
				var scrVal = document.documentElement.scrollTop;
				nyX = e.clientX + document.documentElement.scrollLeft + 10;
				nyY = e.clientY + scrVal + 10;
				if(e.clientY + divH > document.documentElement.clientHeight){ //IE 6.0 only
					nyY = nyY - ((e.clientY + divH)- document.documentElement.clientHeight) - 10;
				}
				if(e.clientX + divW > document.documentElement.clientWidth){ //IE 6.0 only
					nyX = (e.clientX + document.documentElement.scrollLeft) - divW;
				}
			}else if(document.layers){ // !!!!!!
				nyX = e.pageX + 10;
				nyY = e.pageY + 10;
				if(e.clientY + divH > window.innerHeight){ 
					nyY = nyY - ((e.clientY + divH)- window.innerHeight) - 25;
				}
				if(e.clientX + divW + 20 > window.innerWidth){ 
					nyX = e.pageX - divW - 10;
				}
			}else{ // IE+rest
			
				nyX = e.clientX + window.document.body.scrollLeft + 10;
				
				nyY = e.clientY + window.document.body.scrollTop + 10;
				if(e.clientY + divH > document.body.clientHeight){ //IE only
					nyY = nyY - ((e.clientY + divH)- document.body.clientHeight) - 10;
				}
				if(e.clientX + divW > document.body.clientWidth){ //IE only
					//nyX = (e.clientX + window.document.body.scrollLeft) - divW;
				}
			}
			var retarr = new Array(nyX, nyY);
			return retarr;
		}
		
		function get2DivXYPosition(divH, divW, xco, yco){
			var xtrapix;
			var ytrapix;
			if (!document.all && document.getElementById){
				xtrapix = 10;
				ytrapix = 55;
			}else{ // Bla IE6
				xtrapix = 10;
				ytrapix = 50;
			}
			yco = yco + pushy + ytrapix;
			xco = xco + pushx + xtrapix;
			var retarr = new Array(xco, yco);
			return retarr;
		}
		
		
		
		// Move div
		function MoveDiv(divId, xc, yc){
			if(document.getElementById){ // !!!!!!!!				
				document.getElementById(divId).style.top= yc + "px";
				document.getElementById(divId).style.left= xc + "px";
			}else if(document.layers){ // !!!!!!
				document.layers[divId].top= yc;
				document.layers[divId].left= xc;
			}
		}
		// turn on div
		function LightDiv(divId){
			if(document.getElementById){
				document.getElementById(divId).style.visibility = "visible";
			}else if(document.layers){
				document.layers[divId].visibility = "visible";
			}
		}
		
		// Show div with number of customers in map
		function sList(omrId, e){
			omrNamn= areaarray[omrId][0];
			oplan= areaarray[omrId][1];
			plan= areaarray[omrId][2];
			HideDiv(lastInfoDiv);

			if(showEmptyStrings == true || (showEmptyStrings == false && omrNamn.length > 1)){
				var listObject;
				listObject = infoDivName;
				var nyText;
				nyText = '<TABLE border="0"><TR><TD colspan="2" class="dl_bg_header_div"><b>' + omrNamn + '</b></TD></TR>' +
							'<TR><TD>Oplanerade:</TD><TD><b>'+ oplan + '</b></TD></TR>' +
							'<TR><TD>Planerade:</TD><TD>'+ plan + '</TD></TR>' +
							'</TABLE>';
				WriteHTML(listObject, nyText);
				var divH = GetDivH(listObject);			
				var divW = GetDivW(listObject);
				var tmpCoords = getDivXYPosition(e, divH, divW);
				var nyX = tmpCoords[0];
				var nyY = tmpCoords[1];
				
				
				
				MoveDiv(listObject, nyX, nyY);
				LightDiv(listObject);
				lastInfoDiv = listObject;
			}
		}
		function cList(){
			HideDiv(infoDivName);
		}

		function mList(e, adjY){
			
			var listObject;
			listObject = infoDivName;
			var nyX;
			var plusY;
			if(adjY){
				plusY = adjY;
			}else{
				plusY = 0;
			}
			var nyY;
			if (isNetscape){
				nyX = e.pageX + 15;
				nyY = e.pageY + plusY;
				
			}else if(document.documentElement && document.documentElement.scrollTop){ // IE 6.0
			
				var scrVal = document.documentElement.scrollTop;
				nyX = e.clientX;
				nyY = e.clientY + scrVal;
			}else{
			
				nyX = e.clientX + 5;
				nyY = e.clientY + window.document.body.scrollTop + 5;
			}
			if(document.getElementById){ // !!!!!!!
				
				document.getElementById(listObject).style.top= nyY + "px";
				document.getElementById(listObject).style.left= nyX + "px";
			}else if(document.layers){
				var tyu;
			}
		}

		// Manage details for plotted locations.
		// Show div with number of customers in map
		function ShowPInfo(arrindex, e){
			var starttime = plotarray[arrindex][2];
			var stoptime = plotarray[arrindex][3];
			if(!stoptime || stoptime == '-'){
				stoptime = "Ingen prognos";
			}
			var plantxt = (!plotarray[arrindex][6]) ? "Strömavbrott" : "Planerat arbete";
			var customers = (plotarray[arrindex][6] == 0)? plotarray[arrindex][4] : plotarray[arrindex][5];
			HideDiv("plotinfo");
			var nyText = '<TABLE border="0"><TR><TD colspan="2" class="dl_bg_header_div"><b>' + plantxt + '</b></TD></TR>' +'<TR><TD>Startade:</TD><TD>'+ starttime + '</TD></TR>' +
							'<TR><TD>Beräknas klar:</TD><TD>'+ stoptime + '</TD></TR>' +
							'<TR><TD>Berörda kundanl.:</TD><TD>'+ customers + '</TD></TR>' +
							'</TABLE>';
			WriteHTML("plotinfo", nyText);
			var divH = GetDivH("plotinfo");	
			
			var divW = GetDivW("plotinfo");
			var tmpCoords = getDivXYPosition(e, divH, divW);
			var nyX = tmpCoords[0];
			var nyY = tmpCoords[1];
			MoveDiv("plotinfo", nyX, nyY);
			LightDiv("plotinfo");
		}
		
		
		function ShowPInfo2(arrindex, xco, yco){
			var starttime = plotarray[arrindex][2];
			var stoptime = plotarray[arrindex][3];
			if(!stoptime || stoptime == '-'){
				stoptime = "Ingen prognos";
			}
			var plantxt = (!plotarray[arrindex][6]) ? "Strömavbrott" : "Planerat arbete";
			var customers = (plotarray[arrindex][6] == 0)? plotarray[arrindex][4] : plotarray[arrindex][5];
			HideDiv("plotinfo");
			var nyText = '<TABLE border="0"><TR><TD colspan="2" class="dl_bg_header_div"><b>' + plantxt + '</b></TD></TR>' +'<TR><TD>Startade:</TD><TD>'+ starttime + '</TD></TR>' +
							'<TR><TD>Beräknas klar:</TD><TD>'+ stoptime + '</TD></TR>' +
							'<TR><TD>Berörda kundanl.:</TD><TD>'+ customers + '</TD></TR>' +
							'</TABLE>';
			WriteHTML("plotinfo", nyText);
			var divH = GetDivH("plotinfo");			
			var divW = GetDivW("plotinfo");
			var divTop = GetDivTop("plotdiv");
			
			var tmpCoords = get2DivXYPosition(divH, divW, xco, yco);
			var nyX = tmpCoords[0];
			
			//var nyY = tmpCoords[1];
			var nyX = xco+10;
			var nyY = yco+10;
			MoveDiv("plotinfo", nyX, nyY);
			LightDiv("plotinfo");
		}
		
		
		
		function HidePInfo(){
			HideDiv("plotinfo");
		}

		
		function sListHist(antal, e){
			
			if(lastInfoDiv && document.getElementById){
				document.getElementById(lastInfoDiv).style.visibility = "hidden";
			}else if(lastInfoDiv && document.layers){
				document.layers[lastInfoDiv].visibility = "hidden";
			}

			if(showEmptyStrings == true || (showEmptyStrings == false && omrNamn.length > 1)){
				var listObject;
				listObject = infoDivName;
				var nyText;
				nyText = '<TABLE border="0"><TR><TD colspan="2"><b>' + antal + '</b></TD></TR>' +
							'</TABLE>';
				var divH;			
				var divW;
				var nyX;
				var nyY;

				if(document.getElementById){ // !!!!!!!!				
					document.getElementById(listObject).innerHTML = nyText;
					divH = document.getElementById(listObject).offsetHeight;
					divW = document.getElementById(listObject).offsetWidth;
				}else if(document.layers){ // !!!!!!
					document.layers[listObject].document.write(nyText);
					document.layers[listObject].document.close();
					divH = document.layers[listObject].offsetHeight;
					divW = document.layers[listObject].offsetWidth;
				}
				
				
				if (!document.all && document.getElementById){ // NS6
				
					nyX = e.pageX + 30;
					nyY = e.pageY + 10;
					if(e.clientY + divH > window.innerHeight){ 
						nyY = nyY - ((e.clientY + divH)- window.innerHeight) - 25;
					}
					if(e.clientX + divW + 20 > window.innerWidth){ 
						nyX = e.pageX - divW - 0;
					}
					
				}else if(document.documentElement && document.documentElement.scrollTop){ // IE 6.0
					var scrVal = document.documentElement.scrollTop;
					nyX = e.clientX + document.documentElement.scrollLeft + 10;
					nyY = e.clientY + scrVal + 10;
					if(e.clientY + divH > document.documentElement.clientHeight){ //IE 6.0 only
						nyY = nyY - ((e.clientY + divH)- document.documentElement.clientHeight) - 10;
					}
					if(e.clientX + divW > document.documentElement.clientWidth){ //IE 6.0 only
						nyX = (e.clientX + document.documentElement.scrollLeft) - divW + 10;
					}
				}else if(document.layers){ // !!!!!!
					nyX = e.pageX + 15;
					nyY = e.pageY + 10;
					if(e.clientY + divH > window.innerHeight){ 
						nyY = nyY - ((e.clientY + divH)- window.innerHeight) - 25;
					}
					if(e.clientX + divW + 20 > window.innerWidth){ 
						nyX = e.pageX - divW - 0;
					}
				}else{ // IE+rest
					nyX = e.clientX + window.document.body.scrollLeft + 20;
					nyY = e.clientY + window.document.body.scrollTop + 10;
					if(e.clientY + divH > document.body.clientHeight){ //IE only
						nyY = nyY - ((e.clientY + divH)- document.body.clientHeight) - 10;
					}
					if(e.clientX + divW > document.body.clientWidth){ //IE only
						nyX = (e.clientX + window.document.body.scrollLeft) - divW + 10;
					}
					
				}
				if(document.getElementById){ // !!!!!!!!				
					document.getElementById(listObject).style.top= nyY + "px";
					document.getElementById(listObject).style.left= nyX + "px";
					document.getElementById(listObject).style.visibility = "visible";
					lastInfoDiv = listObject;
				}else if(document.layers){ // !!!!!!
					document.layers[listObject].top= nyY;
					document.layers[listObject].left= nyX;
					//document.layers[listObject].layerbackgroundcolor = "FFFFFF";
					document.layers[listObject].visibility = "visible";
					lastInfoDiv = listObject;
				}
			}
		}
		function cListHist(){
			var listObject;
			listObject = infoDivName;
			if(document.getElementById){ // !!!!!!!!				
				document.getElementById(listObject).style.visibility = "hidden";
			}else if(document.layers){ // !!!!!!
				document.layers[listObject].visibility = "hidden";
			}
		}

		function mListHist(e, adjY){
			
			var listObject;
			listObject = infoDivName;
			var nyX;
			var plusY;
			if(adjY){
				plusY = adjY;
			}else{
				plusY = 0;
			}
			var nyY;
			if (isNetscape){
				nyX = e.pageX + 5;
				nyY = e.pageY + plusY - 25;
			}else if(document.documentElement && document.documentElement.scrollTop){ // IE 6.0
				var scrVal = document.documentElement.scrollTop;
				nyX = e.clientX + 10;
				nyY = e.clientY + scrVal;
			}else{
				nyX = e.clientX + 10;
				nyY = e.clientY + window.document.body.scrollTop;
			}
			if(document.getElementById){ // !!!!!!!
				document.getElementById(listObject).style.top= nyY + "px";
				document.getElementById(listObject).style.left= nyX + "px";
			}else if(document.layers){
				var tyu;
			}
		}




//---------------------------------------


//--------------------------------
	function loadText(frameObj){
		var nyText;
		nyText = '<div id="loadDiv" STYLE="position: absolute;top: 55px;left: 100px;>' + fText + '</div>';
		frameObj.document.open();
		frameObj.document.write(nyText);
		frameObj.document.close();
	}


function showUppgift(e){

	var docHeight = window.innerHeight;
	var docWidth = window.innerWidth;
	alert('FrameH=' + docHeight + ' DivH=' + document.getElementById('asd2').offsetHeight);
}

// Placering
function posWin() {
	this.focus();
	window.moveTo(100,100);
	//window.resizeTo(550,500);
}

// Open new window for history.
function openWindow2(url) {
	window.open(url, "new_window", "height=550,width=600,scrollbars=yes");
}
// Open new window
function openWindow(url){
	window.open(url, "new_window", "height=500,width=600,scrollbars=yes");
}
// Another open window
function openWindowAdmin(url){
	window.open(url, "new_window", "height=500,width=780,scrollbars=yes,resizable=yes");
}
//--------------------------------------------------------------------------