// new script for popups
// @date 17.11.2005
//
// usage example:
// <a href="agb.aspx" target="popup:agb" onclick="return popupLink(this)">

var popupOptions = new Array();

popupOptions['_blank'] = {
	width: 0,
	height: 0,
	top: 0,
	left: 0,
	scrollbars: 'no',
	location: 'no',
	toolbar: 'no',
	menubar: 'no',
	status: 'no',
	resizable: 'no'
}
popupOptions['service'] = {
	width: 800,
	height: 600,
	top: 50,
	left: 150,
	scrollbars: 'yes',
	location: 'no',
	toolbar: 'no',
	menubar: 'yes',
	status: 'no',
	resizable: 'yes'
}
popupOptions['ecard'] = {
    width: 560,
    height: 830,
    top: 50,
    left: 150,
    scrollbars: 'yes',
    location: 'no',
    toolbar: 'no',
    menubar: 'no',
    status: 'no',
    resizable: 'no'
}
popupOptions['shop'] = {
	width: 1010,
	height: 600,
	top: 50,
	left: 150,
	scrollbars: 'yes',
	location: 'yes',
	toolbar: 'no',
	menubar: 'yes',
	status: 'no',
	resizable: 'yes'
}
popupOptions['impressum'] = {
	width:700,
	height:450,
	top:'center',
	left:'center',
	screenX:200,
	screenY:300,
	scrollbars: 'no',
	location: 'no',
	toolbar: 'no',
	menubar: 'no',
	status: 'no',
	resizable: 'no'
}
popupOptions['nutzungsbedingungen'] = {
	width:750,
	height:300,
	top:'center',
	left:'center',
	screenX:200,
	screenY:300,
	scrollbars: 'yes',
	location: 'no',
	toolbar: 'no',
	menubar: 'no',
	status: 'no',
	resizable: 'no'
}
popupOptions['cookies'] = {
	width:750,
	height:250,
	top:'center',
	left:'center',
	screenX:200,
	screenY:300,
	scrollbars: 'no',
	location: 'no',
	toolbar: 'no',
	menubar: 'no',
	status: 'no',
	resizable: 'no'
}
popupOptions['datenschutz'] = {
	width:750,
	height:252,
	top:'center',
	left:'center',
	screenX:200,
	screenY:300,
	scrollbars: 'yes',
	location: 'no',
	toolbar: 'no',
	menubar: 'no',
	status: 'no',
	resizable: 'no'
}
popupOptions['agb'] = {
	width: 700,
	height: 480,
	top: 50,
	left: 150,
	scrollbars: 'yes',
	location: 'no',
	toolbar: 'no',
	menubar: 'yes',
	status: 'no',
	resizable: 'yes'
}
popupOptions['help'] = {
	width: 700,
	height: 480,
	top: 50,
	left: 150,
	scrollbars: 'yes',
	location: 'no',
	toolbar: 'no',
	menubar: 'yes',
	status: 'no',
	resizable: 'yes'
}
popupOptions['datenweitergabe'] = {
	width: 750,
	height: 300,
	top: 150,
	left: 0,
	scrollbars: 'yes',
	location: 'no',
	toolbar: 'no',
	menubar: 'no',
	status: 'no',
	resizable: 'yes'
}
popupOptions['pilgrim'] = {
		width: 308,
		height: 242,
		top: 150,
		left: 0,
		scrollbars: 'yes',
		location: 'no',
		toolbar: 'no',
		menubar: 'no',
		status: 'no',
		resizable: 'yes'
}


popupOptions['livecam'] = {
	width:700,
	height:700,
	top: 0,
	left: 0,	
	scrollbars: 'yes',
	location: 'no',
	toolbar: 'no',
	menubar: 'no',
	status: 'no',
	resizable: 'yes'
}
	
function initializePopups(){
	var a,i
	for(i=0;a=document.links[i];i++) {
		if (a.target && a.target.indexOf("popup:") == 0)  {
			a.onclick = popupHandler
		}
	}
}

function parsePopupTarget(t) {
	var a,s,i,o,p
	a=new Array()
	s=t.substring(6)
	if(s.indexOf(',')>=0) {
		s = s.split(',')
		for(i in s){
				p=s[i].split('=')
			a[p[0]]=p[1]
		}
		return a
	} else if(popupOptions[s]){
		o=popupOptions[s]
			if(!o.name) {
				o.name=s
			}
		return o
	} else {
		//alert("Unknown popup style: '"+s+"'")
	}
}

function serializePopupOptions(options){
	var s,sw,sh,key,v
	s=''
	sw=screen.availWidth? screen.availWidth : 800;
	sh=screen.availHeight? screen.availHeight : 600;

	for(key in options) {
		v=options[key];

		if(key=='left' && v=='center' && options['width']) {
			v=Math.round(sw/2 - options['width']/2);
		}

		if(key=='top' && v=='center' && options['height']) {
			v=Math.round(sh/2 - options['height']/2);
		}

		if(key != 'name') {
			s += key + '=' + v + ',';
		}
	}

	// alert("Options: " + s);
	return s
}

function popup(url, options) {
	var n=options['name']
	
	if(!n)n=String(new Date().getTime())
	var w=window.open(url,n,serializePopupOptions(options))
	if("focus" in w) w.focus()
	return w
}

function popupOpenerLocation(url){
	opener.location.href=url;
}

function predefinedPopup(url, style){
	return popup(url, popupOptions[style])
}

function popupLink(a) {
    if (a.rel == 'popup:_blank') open(a.href)
    else popup(a.href, parsePopupTarget(a.rel))
    return false
}