var pop = null;

// Popup schliessen
function popdown() {
  if (pop && !pop.closed) pop.close();
}

// starres Popup
function openPopup(obj, Website, WindowTop, WindowLeft, WindowWidth, WindowHeight) 
{
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
	
	if (WindowTop==0 && WindowLeft==0)
	{
		WindowLeft=(screen.width-WindowWidth)/2; 
		WindowTop=(screen.height-WindowHeight)/2;
	}	
	
	Fensteroptionen='top='+WindowTop+', left='+WindowLeft+', toolbar=0, scrollbars=0, location=0, statusbar=0, menubar=0, resizable=1, width='+WindowWidth+', height='+WindowHeight;

   
  pop = window.open(url,Website, Fensteroptionen);
	pop.focus();
  return (pop) ? false : true;
}


// flexibles Popup
function openScrollPopup(obj, Website, WindowTop, WindowLeft, WindowWidth, WindowHeight) 
{
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
	
	if (WindowTop==0 && WindowLeft==0)
	{
		WindowLeft=(screen.width-WindowWidth)/2; 
		WindowTop=(screen.height-WindowHeight)/2;
	}	
	
	Fensteroptionen='top='+WindowTop+', left='+WindowLeft+', toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0, resizable=1, width='+WindowWidth+', height='+WindowHeight;

   
  pop = window.open(url,Website, Fensteroptionen);
	pop.focus();
  return (pop) ? false : true;
}



// Init Popupcheck
function init() {
	if (!checkParent())
	{
		document.getElementById("homepage").style.display= 'block';
		document.getElementById("closelink").style.display= 'none';
	}
}

// Wenn das Fenster kein Popup ist, Link zur Homepage aktivieren
function checkParent() {
try { 
    window.opener.document.title = window.opener.document.title; 
    return true;
}
catch(e) { 
    return false;
 }
}


// Popdown schliessen
//window.onunload = popdown;

