
function showpopup(){
     document.getElementById('PopUp').style.display = 'inline';
	 scroll(0,0);
}
function closepopup(){
     document.getElementById('PopUp').style.display = 'none';
}
function showminipopup(){
     document.getElementById('PopUp_mini').style.display = 'inline';
	 scroll(0,0);
}
function closeminipopup(){
     document.getElementById('PopUp_mini').style.display = 'none';
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	
	//document.location = document.location;
}
//createCookie('popup','http://sosuaarhus.net.dynamicweb.dk/Nyheder-239.aspx?Action=1&NewsId=7&M=NewsV2&PID=6&news=true',10);
//createCookie('popup',' ',10);

var popuplink;
var popupxpos;
var popupypos;
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
var is_safari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);{
			//alert(c.substring(nameEQ.length,c.length));
			//alert(ca[i]);
			//alert(c.substring(0,5));
			if(c.substring(0,6)=='popupx'){
				popupxpos = c.substring(nameEQ.length,c.length);
				//alert(popupxpos);			
				setTimeout("document.getElementById('PopUp_mini').style.left = popupxpos",500);
			}
			else if(c.substring(0,6)=='popupy'){
				popupypos = c.substring(nameEQ.length,c.length);
				//alert(popupypos);			
				setTimeout("document.getElementById('PopUp_mini').style.top = popupypos",500);
			}
			else if(c.substring(0,5)=='popup'){
				popuplink = c.substring(nameEQ.length,c.length);
				if(popuplink.length > 9){
					setTimeout("showminipopup();",100);
					//alert(is_chrome);
					if(is_chrome==true){
						//alert(is_chrome);
						setTimeout("document.getElementById('PopUp_mini_frame').src = popuplink",500);
					}
					else if(is_safari==true){
						setTimeout("document.getElementById('PopUp_mini_frame').src = 'D'+popuplink",500);
					}
					else{
						setTimeout("document.getElementById('PopUp_mini_frame').src = 'D'+popuplink",500);
					}	
				}
			};					
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}
readCookie('popup');
readCookie('popupx');
readCookie('popupy');

isIE=document.all;
isNN =! document.all && document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.PopUp_mini : document.getElementById("PopUp_mini");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar" && hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
	offsetx=isIE ? event.clientX : e.clientX;
	offsety=isIE ? event.clientY : e.clientY;
	nowX=parseInt(whichDog.style.left);
	nowY=parseInt(whichDog.style.top);
	ddEnabled=true;
	document.onmousemove=dd;
	//document.title = 'X='+nowX+' Y='+nowY;
	createCookie('popupx',nowX,10);
	createCookie('popupy',nowY,10);
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false; 
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE); 
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.PopUp_mini.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.PopUp_mini.visibility="show";
}
document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false"); 

function setXY(){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  	//document.title = 'X='+nowX+' Y='+nowY;
	createCookie('popupx',nowX,10);
	createCookie('popupy',nowY,10);
	}
