var PUrl="";

function isIE() {
	return navigator.userAgent.search(/MSIE/) >= 0;
}

function npopup(id, pic, picfull, picpng, picfullpng, cornerpic, cornerpicfull, stdsize, minanisize, maxanisize, fullsizewidth, fullsizeheight, cornerpicwidth, cornerpicheight, target, wpopup, hpopup, iecke) {
var brows=navigator.userAgent;
var erg=brows.search(/iPhone.+/);
if(erg!=-1 && iecke!=2) return;
if(target!="http://www.haus-jonathan.de"){
	var frameset_geladen = "okay";
	PUrl=target;
	if(iecke!=2) NewWindow(target,'__LANGEOOGNEWS__',wpopup,hpopup,'custom','back', iecke);
//	this.blur();
//	self.focus();

	if(iecke>0){

		pic = picpng;
		picfull = picfullpng;

    document.write("<div onmouseout=\"ppMouseOut(this);\" onmouseover=\"ppMouseOver(this);\" id=\"pp_"+id+"\" style=\"display:none\"><a target=\"_blank\" href=\""+target+"\"><div style=\"position:absolute;top:0px;left:0px;width:100%;height:100%;overflow:hidden;\"><img id=\"pp_"+id+"_cpic\" src=\""+cornerpic+"\" border=\"0\" style=\"position:absolute;top:0px;right:0px\" /></div><img id=\"pp_"+id+"_pic\" src=\""+pic+"\" border=\"0\" style=\"position:absolute;left:0px;top:0px;width:100%;height:100%;\" /></a></div>");
    st_func="starte(\""+id+"\", \""+pic+"\", \""+picfull+"\", \""+picpng+"\", \""+picfullpng+"\", \""+cornerpic+"\", \""+cornerpicfull+"\", \""+stdsize+"\", \""+minanisize+"\", \""+maxanisize+"\", \""+fullsizewidth+"\", \""+fullsizeheight+"\", \""+cornerpicwidth+"\", \""+cornerpicheight+"\", \""+target+"\", \""+wpopup+"\", \""+hpopup+"\")";
    setTimeout(st_func,2000);
	var div = document.getElementById("pp_"+id);
	div.ishtmlpp = false;
	div.raise2 = (maxanisize-minanisize) / (125-110);
	div.raise1 = 2*div.raise2;
	div.picname = pic;
	div.picfullname = picfull;
	div.style.zIndex = 20;
	div.cornerpic = cornerpic;
	div.cornerpicfull = cornerpicfull;
	div.style.position = "absolute";
	div.size = stdsize;
	div.minanisize = minanisize;
	div.maxanisize = maxanisize;
	div.ratio = fullsizewidth/fullsizeheight;
	div.fullsize = fullsizewidth;
	div.cornerpicwidth = cornerpicwidth;
	div.cornerpicheight = cornerpicheight;
	div.currentFull = true;
    }
}
}
function starte(id, pic, picfull, picpng, picfullpng, cornerpic, cornerpicfull, stdsize, minanisize, maxanisize, fullsizewidth, fullsizeheight, cornerpicwidth, cornerpicheight, target, wpopup, hpopup){
   var div = document.getElementById("pp_"+id);
   setPosition(div);
   div.style.display = "block";
   div.timer = null;
   div.motion = 0;
   ppMouseOut(div);   
}
function n_popup(id, pic, picfull, picpng, picfullpng, cornerpic, cornerpicfull, stdsize, minanisize, maxanisize, fullsizewidth, fullsizeheight, cornerpicwidth, cornerpicheight, target, wpopup, hpopup, i_ecke) {
	var frameset_geladen = "okay";
	PUrl=target;
	if(i_ecke){
		pic = picpng;
		picfull = picfullpng;

    document.write("<div onmouseout=\"ppMouseOut(this);\" onmouseover=\"ppMouseOver(this);\" id=\"pp_"+id+"\" style=\"display:none\"><a target=\"_blank\" href=\""+target+"\"><div style=\"position:absolute;top:0px;left:0px;width:100%;height:100%;overflow:hidden;\"><img id=\"pp_"+id+"_cpic\" src=\""+cornerpic+"\" border=\"0\" style=\"position:absolute;top:0px;right:0px\" /></div><img id=\"pp_"+id+"_pic\" src=\""+pic+"\" border=\"0\" style=\"position:absolute;left:0px;top:0px;width:100%;height:100%;\" /></a></div>");
    st_func="starte(\""+id+"\", \""+pic+"\", \""+picfull+"\", \""+picpng+"\", \""+picfullpng+"\", \""+cornerpic+"\", \""+cornerpicfull+"\", \""+stdsize+"\", \""+minanisize+"\", \""+maxanisize+"\", \""+fullsizewidth+"\", \""+fullsizeheight+"\", \""+cornerpicwidth+"\", \""+cornerpicheight+"\", \""+target+"\", \""+wpopup+"\", \""+hpopup+"\")";
    setTimeout(st_func,2000);

}
}function ppMouseOut(div) {
    div.motion = 1;
	box = document.getElementById(div.id+"_contentbox");
	if (box != null) {
		box.style.zIndex = 2;
	}
	if (div.timer == null) {
        div.timer = window.setInterval("doPPTimer(\""+div.id+"\");", 50);
    }
}

function ppMouseOver(div) {
    div.motion = 2;
    var img = document.getElementById(div.id+"_pic");
    img.src = div.picfullname;
	if (!div.ishtmlpp) {
    	img = document.getElementById(div.id+"_cpic");
    	img.src = div.cornerpicfull;
    }
	div.currentFull = true;
	if (div.timer == null) {
        div.timer = window.setInterval("doPPTimer(\""+div.id+"\");", 50);
    }
}

function doPPTimer(id) {
    div = document.getElementById(id);
    switch(div.motion) {
        //wird bis 200 gross.
        case 0: {
            if (div.size < div.maxanisize) {
                div.size += div.raise1;
                setPosition(div);
                break;
            }
            else {
                div.motion++;
            }
        }
        case 1: {
           //wird bis 100 klein.
            if (div.size > div.maxanisize+div.raise1) {
                div.size *= 0.9;
                setPosition(div);
                break;
            }
            else if (div.size > div.minanisize) {
                var img = document.getElementById(div.id+"_pic");
				if (div.currentFull) {
                	img.src = div.picname;
					if (!div.ishtmlpp) {
	                	img = document.getElementById(div.id+"_cpic");
                		img.src = div.cornerpic;
					}
					div.currentFull = false;
				}
                div.size -= div.raise2;
                setPosition(div);
                break;
            }
            else {
                div.motion--;
                break;
            }
        }
        case 2: {
            //auf fullsize erweitern:
            if (div.size < div.fullsize) {
                div.size *= 1.2;
                if (div.size > div.fullsize) div.size = div.fullsize;
                setPosition(div);
                break;
            }
            if (div.timer != null) {
                window.clearInterval(div.timer);
                div.timer = null;
                div.motion = 0;
				box = document.getElementById(div.id+"_contentbox");
				if (box != null) {
					box.style.zIndex = 5;
				}
            }
        }
    }
}

function setPosition(div) {
	var si = Math.round(div.size);
    div.style.top = "0px";
    div.style.right = "0px";
    div.style.width = si+"px";
    div.style.height = (si/div.ratio)+"px";
	img =  document.getElementById(div.id+"_cpic");
	box = document.getElementById(div.id+"_contentbox");
	img.style.left = (si-div.cornerpicwidth)+"px";
	if (box != null) box.style.left = (si-box.offsetWidth)+"px";
	var perc = (si / div.fullsize);
	if (perc < 1) {
		var pw = perc * div.cornerpicwidth-1;
		var ph = perc * div.cornerpicheight-1;
	} else {
		var pw = perc * div.cornerpicwidth;
		var ph = perc * div.cornerpicheight;
	}
	img.style.clip = "rect(0px, "+(div.cornerpicwidth)+"px, "+(ph)+"px, "+(div.cornerpicwidth-pw)+"px)";
	if (box != null) {
		var bw = box.offsetWidth;
		var bh = box.offsetHeight;
		box.style.clip = "rect(0px, "+(bw)+"px, "+(ph)+"px, "+(bw-pw)+"px)";
	}
}

// Popup öffnen

function NewWindow(mypage,myname,w,h,pos,infocus,iecke){
	if(GetCookie("sid") == "999"){return;}
	document.cookie="sid=999; Path=/; Expires= " + getFuture(30);
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=yes,toolbar=yes,resizable=yes";
//	win=window.open(mypage,myname,settings);
// -- ist Popup geblockt?? 
//	functi="start("+w+","+h+")";
//	if(win==null) {if(iecke==0) start(w,h);}
//	else win.blur();
	start(w,h);
}

// Popup als div öffnen

function start(w,h){
		create_div(w,h);
		if(PUrl!="") {
		status=PUrl;
	   PopUp.location.href=PUrl;
	   document.getElementById("popup").style.visibility = "visible"; }
}

// Popup-div schließen

function stop(){
		PopUp.location.href="http://www.langeoognews.de/aktuell/leer.htm";
		document.getElementById("popup").style.visibility = "hidden";
}

// Popup-div anzeigen

function pshow(){
		   PopUp.location.href=PUrl;
		document.getElementById("popup").style.visibility = "visible";
}

function getFuture(f){
var d = new Date();
d.setTime(d.getTime() + (60000 * f));
return d;
}

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg)
  return getCookieVal (j);
  i = document.cookie.indexOf(" ", i) + 1;
  if (i == 0) break; 
  }
  return null;
  }

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function create_div(w,h) {
	document.write("<div id=\"popup\" style=\"position: absolute; left: 50px; top: 440px; width: "+w+"px; height: "+h+"px; visibility: hidden\">");
	document.write("<table style=\"border-collapse:collapse; margin:0; padding:0; border-spacing:0; border:10px; margin-bottom : 0; margin-top : 0;\">");
	document.write("<tr><td height=\"39\" background=\"/fileadmin/scripts/bnr/p/ol.png\"><img width=\"40\" height=\"39\" border=\"0\" hspace=\"0\" vspace=\"0\" src=\"/fileadmin/scripts/bnr/p/transp.gif\" onClick=\"stop()\" style=\"cursor:pointer;\"></td><td background=\"/fileadmin/scripts/bnr/p/o.png\"></td>");
	document.write("<td width=\"47\" background=\"/fileadmin/scripts/bnr/p/or.png\"><img width=\"47\" height=\"39\" hspace=\"0\" vspace=\"0\" border=\"0\" src=\"/fileadmin/scripts/bnr/p/transp.gif\" onClick=\"stop()\" style=\"cursor:pointer;\"></td></tr>");
	document.write("<tr><td background=\"/fileadmin/scripts/bnr/p/l.png\"></td>");
	document.write("<td bgcolor=\"#ffffff\"><iframe name=\"PopUp\" src=\"http://www.langeoognews.de/fileadmin/scripts/bnr/leer.htm\" marginwidth=\"0\" marginheight=\"0\" width=\""+w+"\" height=\""+h+"\" target=\"Hauptframe\">Ihr Browser untersttzt Inlineframes nicht oder zeigt sie in der derzeitigen Konfiguration nicht an.</iframe></td>");
	document.write("<td background=\"/fileadmin/scripts/bnr/p/r.png\"></td></tr>");
	document.write("<tr><td background=\"/fileadmin/scripts/bnr/p/ul.png\"><img border=\"0\" hspace=\"0\" vspace=\"0\" src=\"/fileadmin/scripts/bnr/p/transp.gif\"></td><td background=\"/fileadmin/scripts/bnr/p/u.png\"></td><td background=\"/fileadmin/scripts/bnr/p/ur.png\"><img border=\"0\" hspace=\"0\" vspace=\"0\"  src=\"/fileadmin/scripts/bnr/p/transp.gif\"></td></tr>");
	document.write("</table>");
	document.write("</div>");
}

