$(document).ready(function() {
	$('#head a').eq(0).html('<img src="/img/logo.gif" alt="" width="214" height="49" />');
	$('div.gallery a').each(function() {
		$(this).fancybox();
	});
});

/**
 * Toggles visibility of staff member's CV and publications
 * @param {Object} Target element (the one to be toggled), can also be ID
 * @param {Object} Calling <a> element
 * @return Always returns false
 * @type {Boolean}
 * @author CB
 * @required jQuery
 */
function toggleElement(targetID, linkElement) {
	$('#' + targetID).toggle();
	lang = $('html').eq(0).attr('lang');
	cnt = $(linkElement).html();
	if (cnt.indexOf('einblenden') != -1 ||
	    cnt.indexOf('Show') != -1) {
		if ('en' == lang) {
			cnt = cnt.replace(/Show/, 'Hide');
		} else {
			cnt = cnt.replace(/einblenden/, 'ausblenden');
		}
	} else {
		if ('en' == lang) {
			cnt = cnt.replace(/Hide/, 'Show');
		} else {
			cnt = cnt.replace(/ausblenden/, 'einblenden');
		}	
	}
	$(linkElement).html(cnt);
	return false;
}

/**
 * Displays a centered popup window
 *
 * @param {String} path URL or path to display, or <a> element
 * @param {Number} width Popup window's width
 * @param {Number} height Popup window's height
 * @param {Boolean} fixed If set to true, the window will neither have a
                          statusbar or scrollbars nor will it be resizable,
                          otherwise both will be available
 * @return Returns the window object that was created
 * @type Object
 * @author CB
 * @version 2007-06-22
 */
function popup(path, width, height, fixed) {

	if (!height || !width) {
		// Width and/or height missing, set window width to
		// default value and set fixed to false
		width = 350;
		height = 250;
		fixed = false;
	}

	if (screen.availWidth) {
		position = 'left=' + (Math.floor(screen.availWidth / 2 - width / 2)) +
		           ',top=' + (Math.floor(screen.availHeight / 2 - height / 2));
	} else if (window.screenX) {
		position = 'screenX=' + (window.screenX + 50) + ',screenY=' + (window.screenY + 50);
	} else {
		position = 'left=120,top=120';
	}

	if (fixed) {
		attrs = 'status=no,resizable=no,scrollbars=no';
	} else {
		attrs = 'status=yes,resizable=yes,scrollbars=yes';
	}

	pp = window.open(
		path, 
		'_blank',
		'width=' + width + ',height=' + height + ',' + position + attrs
	);

	pp.focus();
	
	return pp;

} // function popup(path, width, height, fixed, forcenew)


