// (c) 2002-2006 Thomas Holder

/*
 * no_frame=true bedeutet, die Seite darf grundsätzlich nicht im Frame geladen werden
 * (entspricht der PHP-Variable $site_no_frame)
 *
 * Das Cookie noframe=1 bedeutet lediglich, das die Warnung wegen Frameset nicht ein zweites
 * Mal angetzeigt wird (also bei Seiten, die sonst im Frameset erscheinen)
 *
 */

if ((typeof no_frame) == 'undefined')
	var no_frame = false;

function get_cookie(cookie_name) {
	var results = document.cookie.match(cookie_name + '=(.*?)(;|$)');
	if (results)
		return (unescape(results[1]));
	return null;
}

function th_check_loc(host,mainframe){
	var sloc = self.location.href;

	if (no_frame) {
		if (top.location.href != sloc)
			top.location.href = sloc;
		return;
	}

	if (sloc.indexOf(host) == 0 && top.location.href == sloc) {
		var noframe = get_cookie('noframe');
		if (noframe != '1' &&
				confirm('Diese Seite ist Teil eines Framesets.\nSoll das Frameset jetzt geladen werden?')) {
			sloc = sloc.substring(host.length,sloc.length);
			sloc = sloc.replace(/\&/,'%26');
			top.location.href = host+'?'+mainframe+'='+sloc;
		} else {
			document.cookie = "noframe=1; path=/";
		}
	}
}

th_check_loc('http://www.impactev.de/','main');

function th_mailto(x,y){
	if (y == undefined) {
		var y = 'impactev.de';
	}
	if (x == "webmaster") {
		var x = "webmaster001";
	}
	window.open('mailto:'+x+'@'+y,'_self');
	return undefined;
}

/*
 * Media-Popups
 * usage: <a href="javascript:mediaPopup(Breite, Höhe, Bild- oder Video-Url, Text)">Link</a>
 */

function mediaPopup(width, height, data, text) {
	var options = "width=" + width + ",height=" + height + ",resizable=1";
	var target = "mp" + width + "x" + height;
	var win = window.open("about:blank", target, options);
	var suffix = "unknown";
	if (data.match(/\.(\w+)$/)) {
		suffix = RegExp.$1.toLowerCase();
	}
	with (win.document) {
		open();
		write("<html><head><title>Popup</title>");
		write("<style type='text/css'>body * { font:normal 10px sans-serif; }</style>");
		write("</head><body onload='self.focus()'>");
	}
	switch (suffix) {
		case "png": case "jpg": case "jpeg": case "gif":
			win.document.write("<p><img src='" + data + "' alt='Bild'></p>");
			break;
		case "avi": case "mpg": case "mpeg":
			win.document.write("<p><object data='" + data + "'></object></p>");
			break;
		default:
			win.document.write("<p>error: unknown file format</p>");
	}
	if (text) {
		win.document.write("<p>" + text + "</p>");
	}
	with (win.document) {
		write("<hr><center><a href='javascript:window.close()'>Fenster schließen</a></center>");
		write("</body></html>");
		close();
	}
	win.focus();
}

/*
 * News-Popup
 * usage: <a href="javascript:newsPopup(Breite, Höhe, Url)">Link</a>
 */

function newsPopup(width, height, url) {
	var options = "width=" + width + ",height=" + height + ",resizable=1,scrollbars=1";
	var target = "np" + width + "x" + height;
	var win = window.open(url, target, options);
	win.focus();
}

