// Alternative popup 

var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;

function movemouse(e)
{
  if (isdrag)
  {
    dobj.style.left = nn6 ? tx + e.clientX - x + "px" : tx + event.clientX - x;
    dobj.style.top  = nn6 ? ty + e.clientY - y + "px" : ty + event.clientY - y;
    return false;
  }
}

function selectmouse(e) 
{
  var fobj = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "HTML";

  while (fobj.tagName!=topelement && fobj.attributes['id'] && fobj.attributes['id'].value!='pp_widget_1')
  {
	fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }
  if (fobj.attributes['id'] && fobj.attributes['id'].value=='pp_widget_1')
  {
	isdrag = true;
	dobj = fobj;
	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;
  }
  //alert(fobj.tagName);
}
function popup_close(id, e) {
	var node = document.getElementById('pp_widget_'+id);
	document.getElementsByTagName('body')[0].removeChild(node);
}
// @params popup.open(int ID, str Title, str Source, int Width, int Height, int Top, int Left, int Scrollbars, int Shadow)
function popup_open(id, title, src, width, height, top, left, scrollbars, shadow) {
	if (!document.getElementById('pp_widget_'+id)) {
		if(ie) { 
			var div = document.createElement('div');
			var divAttrId = document.createAttribute('id');
			divAttrId.nodeValue = 'pp_widget_'+id;
			div.setAttributeNode(divAttrId);
			div.style.zIndex = '9999';
			div.style.position = 'absolute';
			div.style.width = width+'px';
			div.style.height = height+'px';
			if (top==0 && left==0) {
				// centered
				div.style.marginLeft = (width/2)-width+'px';
				div.style.marginTop = (height/2)-height+'px';
				div.style.left = Math.ceil((screen.availWidth / 2));
				div.style.top = Math.ceil((screen.availHeight / 2) - 100);
			} else {
				// positioned
				div.style.left = left+'px';
				div.style.top = top+'px';
			}
		} else {
			var div = document.createElement('div');
			div.setAttribute('id', 'pp_widget_'+id);
			if (top==0 && left==0) {
				// centered
				div.setAttribute('style', 'z-index:9999; position:absolute; margin-left:'+Math.ceil((width/2)-width)+'px; margin-top:'+Math.ceil((height/2)-height)+'px; width:'+width+'px; height:'+height+'px; left:'+parseInt(Math.ceil((screen.availWidth / 2)))+'px; top:'+parseInt(Math.ceil((screen.availHeight / 2)-100))+'px;');
			} else {
				// positioned
				div.setAttribute('style', 'z-index:9999; position:absolute; width:'+width+'px; height:'+height+'px; left:'+left+'px; top:'+top+'px;');
			}
		}
		if (scrollbars==1)  scrbar = 'yes';
		else				scrbar = 'no';
		var width_fixed = width + 3;
		if(shadow==1) {
			div.innerHTML ='<div id="pp_frame" style="position:absolute; width:'+width_fixed+'px; height:'+height+'; z-index:10005; background-color: #FFFFFF; border-bottom:1px solid #CCCCCC;"><div id="pp_handle" style="background:#CCCCCC; height:17px; border-bottom:1px solid #CCCCCC;"><div id="titlebar" style="position:absolute; display:block; float:left; background:#CCCCCC; color:#444444; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; width:'+parseInt(width-140)+'px; cursor:move;">&nbsp;'+title+'<\/div><a href="javascript:popup_close('+id+')" style="display:block; float:right; height:13px; text-decoration:none; color:#333333; padding-right:5px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; font-weight:normal; solid #333333;">Fenster schließen<\/a><\/div><iframe src="'+src+'" frameborder="0" height="'+parseInt(height-17)+'" width="100%" scrolling="'+scrbar+'"><\/iframe><\/div><div style="position:absolute; width:'+parseInt(width-7)+'px;	height:'+parseInt(height-7)+'px; z-index:10000; left: 8px; top: 8px; border:1px solid #000000; filter:alpha(opacity=50); -moz-opacity:.50; opacity:.50;"><\/div><div style="position:absolute; width:'+parseInt(width-5)+'px; height:'+parseInt(height-5)+'px; z-index:10001; left: 7px;	top: 7px; border:1px solid #000000; filter:alpha(opacity=40); -moz-opacity:.40; opacity:.40;"><\/div><div style="position:absolute; 	width:'+parseInt(width-3)+'px; height:'+parseInt(height-3)+'px; z-index:10002; left: 6px; top: 6px; border:1px solid #000000; filter:alpha(opacity=30); -moz-opacity:.30; opacity:.30;"><\/div><div style="position:absolute; width:'+parseInt(width-1)+'px; height:'+parseInt(height-1)+'px; z-index:10003; left: 5px;	top: 5px; border:1px solid #000000; filter:alpha(opacity=20); -moz-opacity:.20; opacity:.20;"><\/div><div style="position:absolute; width:'+parseInt(width+1)+'px; height:'+parseInt(height+1)+'px; z-index:10004; left: 4px; top: 4px; border:1px solid #000000; filter:alpha(opacity=10); -moz-opacity:.10; opacity:.10;"><\/div>';
			document.getElementsByTagName('body')[0].appendChild(div);
		} else {
			div.innerHTML ='<div id="pp_frame" style="position:absolute; width:'+width_fixed+'px; height:'+height+'; z-index:10005; background-color: #FFFFFF; border-bottom:1px solid #CCCCCC;"><div id="pp_handle" style="background:#CCCCCC; height:17px; border-bottom:1px solid #CCCCCC;"><div id="titlebar" style="position:absolute; display:block; float:left; background:#CCCCCC; color:#444444; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; width:'+parseInt(width-140)+'px; cursor:move;">&nbsp;'+title+'<\/div><a href="javascript:popup_close('+id+')" style="display:block; float:right; height:13px; text-decoration:none; color:#333333; padding-right:5px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; font-weight:normal; solid #333333;">Fenster schließen<\/a><\/div><iframe src="'+src+'" frameborder="0" height="'+parseInt(height-17)+'" width="100%" scrolling="'+scrbar+'"><\/iframe><\/div>';
			document.getElementsByTagName('body')[0].appendChild(div);
		}
	} else {
		popup_close(id);
	}
}
document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");


