var ie = document.all;
var nn6 = document.getElementById &&! document.all;

var title_url = "news/popup/popup_title.jpg";
var body_url = "news/popup/popup_body.jpg";
var close_url = "news/popup/popup_close.gif";

var isdrag = false;
var x, y;
var dobj;

function movemouse( e ) {
  if( isdrag ) {
    dobj.style.left = (tx + (nn6 ? e.clientX : event.clientX) - x) + "px";
    dobj.style.top  = (ty + (nn6 ? e.clientY : event.clientY) - y) + "px";
    return false;
  }
}

function selectmouse( e ) {
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  while (fobj.tagName != topelement && fobj.className != "dragme") {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }

  if (fobj.className=="dragme") {
    isdrag = true;
    dobj = document.getElementById("styled_popup");
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
    return false;
  }
}

// Browser safe opacity handling function

function setOpacity( value ) {
	document.getElementById("styled_popup").style.opacity = value / 10;
	document.getElementById("styled_popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() {
	for( var i = 0 ; i <= 100 ; i++ )
		setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
}

function fadeOutMyPopup() {
	for( var i = 0 ; i <= 100 ; i++ ) {
		setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
	}

	setTimeout('styledPopupClose()', 800 );
}

function fireMyPopupLoad() {
	setTimeout("fireMyPopup()", 500);
}

function fireMyPopup() {
	setOpacity( 0 );
	document.getElementById("styled_popup").style.display = "block";
	fadeInMyPopup();
}

function styledPopupClose() {
  document.getElementById("styled_popup").style.display = "none";
}

function setDragFalse() {
	isdrag=false;
}

if (window.addEventListener) window.addEventListener("load",fireMyPopupLoad,false);
else if (window.attachEvent) window.attachEvent("onload",fireMyPopupLoad);

document.onmousedown=selectmouse;
document.onmouseup=setDragFalse;
// window.onload=new Function('setTimeout("fireMyPopup()", 500)');

document.write("<div id='styled_popup' name='styled_popup' style='width: 425px; height: 628x; display:none; z-index:9999; position: absolute; top: 150px; left: 50px;'>");
document.write("<table width='425' cellpadding='0' cellspacing='0' border='0'>");
document.write("<tr>");
document.write("<td><img height='23' width='401' src='"+title_url+"' class='dragme' style='cursor: move; z-index:9999;'></td>");
document.write("<td><a href='javascript:fadeOutMyPopup();'><img height='23' width='24' src='"+close_url+"' border='0'></a></td>");
document.write("</tr>");
document.write("<tr><td colspan='2' style='background: url(\""+body_url+"\") no-repeat top left; width: 425px; height: 600px; z-index:9999; cursor: pointer' onclick=\"window.location.href='http://www.schwanenplatz.de/news.html'\">&nbsp;</td></tr>");
document.write("</table>");
document.write("</div>");
