var request = null;

function init() {
	doPopups();
	ds('http://www.ekkw.de/ebz/')
}

function doPopups() {
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var i=0; i < links.length; i++) {
		if (links[i].className.match("popup")) {
			links[i].onclick = function() {
				var wnd, doc;
				wnd = window.open("", 'Popup', 'height=450,width=640,left=50,location=no,menubar=no,status=no,top=50,scrollbars=yes,resizable=yes');
				wnd.document.open;
				doc = wnd.document;
				
				doc.write('<html><body onload="javascript:window.resizeTo(document.image.width+50,document.image.height+140)"><p align="center"><img name="image" src="' + this.href+ '"></p>');
				doc.write('<p>[<a href="javascript:self.close()">Fenster schlie&szlig;en</a>]</p></body></html>');
				doc.close();
				wnd.focus();
				
				return false;
			}
		}
	}
}

function ds(redirect) {
	var d, dom, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op, l, fs;
	
	d = document;
	n = navigator;
	na = n.appVersion;
	nua = n.userAgent;
	win = ( na.indexOf( 'Win' ) != -1 );
	mac = ( na.indexOf( 'Mac' ) != -1 );
	lin = ( nua.indexOf( 'Linux' ) != -1 );
	fs = false;
	
	if ( !d.layers ){
		dom = ( d.getElementById );
		op = ( nua.indexOf( 'Opera' ) != -1 );
		konq = ( nua.indexOf( 'Konqueror' ) != -1 );
		saf = ( nua.indexOf( 'Safari' ) != -1 );
		moz = ( nua.indexOf( 'Gecko' ) != -1 && !saf && !konq);
		ie = ( d.all && !op );
		ie4 = ( ie && !dom );
		ie5x = ( d.all && dom );
		ie5mac = ( mac && ie5x );
		ie5xwin = ( win && ie5x );
	}
	
	if (saf) {
		try {
			l = top.location.href;
			if (l.indexOf("ekkw.de") == -1)
				fs = true;
		}
		catch (e) {
			top.location.href = redirect;
		}
		if (fs) {
			top.location.href = redirect;
		}
	} // if (saf)
}

//function getEvents() {
//	// request = null;
//	if (window.XMLHttpRequest) {
//		request = new XMLHttpRequest(); // Mozilla, Safari, Opera
//	} 
//	else if (window.ActiveXObject) {
//		try {
//			request = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
//		} catch (e) {
//			try {
//				request = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
//			} catch (e) {}
//		}
//	}
//
//	if (request) {
//		document.getElementById('ajaxEvents').innerHTML = '<p style="text-align:center;"><img src="img/layout/loading.gif" width="32" height="32" alt="" border="0" style="border:none;float:none;" /><br />Aktuelle Veranstaltungen werden geladen.</p>';
//		request.open('get', 'ajax.vk_startseite.php', true);
//		request.onreadystatechange = handle_getEvents;
//		request.send(null);
//	}
//	else
//		return;
//}
//
//function handle_getEvents() {
//	var line = /–/gi;
//	
//	if (request.readyState != 4)
//		return;
//						
//	if (request.status == 200) {
//		document.getElementById('ajaxEvents').innerHTML = request.responseText.replace(line, "+");
//		// document.getElementById('ajaxEvents').innerHTML = request.responseText
//	}
//	else {
//		document.getElementById('ajaxEvents').innerHTML = '<p><a href="programm/jahresprogramm.php">Unsere aktuellen Veranstaltungen finden Sie hier.</a></p>';
//	}
//}

window.onload = init;