/*
function getFile(filename){ 
oxmlhttp = null;
    try
      { oxmlhttp = new XMLHttpRequest();
        oxmlhttp.overrideMimeType("text/xml");
      }
    catch(e)
      { try
          { oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch(e)
          { return null;
          }
      }
    if(!oxmlhttp) return null;
    try
      { oxmlhttp.open("GET",filename,false);
        oxmlhttp.send(null);
      }
    catch(e)
      { return null;
      }
    return oxmlhttp.responseText;
}
*/

function getWindowPosition(dim){
  var myWidth = 0, myHeight = 0;
// a little check cos IE doens't support window innerWidth

  if(typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
 
    theTop = document.documentElement.scrollTop;
    theHeight = window.innerHeight/2;
  
	theLeft = document.documentElement.scrollLeft;
    theWidth  = window.innerWidth/2;
    
    myWidth = theLeft+theWidth;
    myHeight = theTop+theHeight;

  }
  else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight )) {
    //IE 6+ in 'standards compliant mode'
    theTop = document.documentElement.scrollTop;
    theHeight = document.documentElement.clientHeight/2;
  
	theLeft = document.documentElement.scrollLeft;
    theWidth  = document.documentElement.clientWidth/2;
       
    myWidth = theLeft+theWidth;
    myHeight = theHeight+theTop;

  } else if( document.body && (document.body.clientWidth || document.body.clientHeight )) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  if(dim == 'width'){
	return myWidth;
  }
  else{
	return myHeight;
  }

}

function openWin(src){

	var l= getWindowPosition("width")-250;
	var t= getWindowPosition("height")-150;
	
	var imagefolder="/images/btnClose_en.gif";
		
		if(src.search(".dk") != -1){
		imagefolder= "/images/btnClose_dk.gif";
		}
		else if(src.search("niras.pl") != -1){
		imagefolder = "/images/btnClose_pl.gif";
		}
		else if(src.search("niras.sv") != -1){
		imagefolder  = "/images/btnClose_se.gif";
		}

	
	html ='<img src="' + imagefolder + '" onclick="closePopUp();" style=" float:right;cursor:pointer; padding:10px; padding-right:20px;"/><br/>';
	html += '<iframe src="'+src+'?lg=PopUp" name="popUp" id="popUp" width="480" height="280" marginheight="0" marginwidth="0" frameborder="0" scrolling="yes"></iframe>';
	
	document.getElementById("infoPopUp").style.left = l+"px";
	document.getElementById("infoPopUp").style.top = t+"px";
	document.getElementById("infoPopUp").innerHTML = html;
	document.getElementById("infoPopUp").style.display = "block";
	document.getElementById("infoPopUp").style.zIndex=100;
	if(document.all){
	// hack for hiding Select Box, ActiveX Object, etc. on IE
		var activeXHack = '<iframe src="javascript:false;" scrolling="no" width="480" height="320" frameborder="0"></iframe>';
		document.getElementById("infoPopUpHolder").style.left = l+"px";
		document.getElementById("infoPopUpHolder").style.top = t+"px";
		document.getElementById("infoPopUpHolder").innerHTML = activeXHack;
		document.getElementById("infoPopUpHolder").style.display = "block";
		document.getElementById("infoPopUpHolder").style.zIndex=99;
		document.getElementById("infoPopUpHolder").style.borderTopWidth=0;
	}
	//alert(html);
	
}


function closePopUp(){
	document.getElementById("infoPopUp").innerHTML = '';
	document.getElementById("infoPopUp").style.display = "none";
	document.getElementById("infoPopUpHolder").style.display = "none";
}


// Walk all elements - Recursive Standards-based
function doLoad() {

getElementHeight(); // called from global.js 

if (! document.getElementsByTagName){return false};
if (! document.getElementById){return false};

links = document.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++) {
		targetName = links[i].getAttribute("target");
	 
		if (targetName == "popup") {
		var src = links[i].attributes['href'].value;
		if(document.all){
			 links[i].attachEvent('onclick', new Function('openWin("' + src + '"); return false'));
		}
		else{
			links[i].setAttribute("onclick", "openWin('"+src+"'); return false");
		}
	}
}
}
window.onload = doLoad