function toggle (a, b) {
	document.images[a].src = eval("i" + b + ".src");
	return true;
}

var focusWindow = false;

/**
 * Makes a new popup window. This window contains a picture and the source of this picture is given
 * by <var>src</var>.
 */
function showPhotoInWindow(src, width, height) {
	windowOpen('Photo', src, width + 20, height + 20);
	var output = '<html><body bgcolor="#ffffff"><center><img src="' + src + '" width="' + width +  '" height="' + height +  '"></center><body></html>';
	focusWindow.document.write(output);
	focusWindow.document.close();
}

/** Opens a new window */
function windowOpen(name, url, width, height){
	windowOpen(name, url, width, height, 'no');
}

/** Opens a new window */
function windowOpen(name, url, width, height, scrollbars){
	windowClose();
	focusWindow = window.open(url, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=no,width=' + width + ',height=' + height + '\'');
	focusWindow.focus();
}

/**
 * Closes an opened window.
 */
function windowClose(){
	if (focusWindow != null && focusWindow.closed == false) {
		focusWindow.close();
		focusWindow = null;
	}
}

/**
 * Whether a given string is empty or not.
 */
function empty(inputStr) {
	if (inputStr == null || trim(inputStr).length == 0) {
		return true;
	}
	return false;
}

/**
 * Trims a given string.
 */
function trim(str) {
	// Do not use quotes for the regular expression
	return str.replace(/^\s*|\s*$/g,"");
}

/**
 * Whether a given string is empty or not.
 */
function isEmail(input) {
	// Do not use quotes for the regular expression
	var regExp = /.+\@.+\..+/;
	return regExp.test(input);
}

/**
 * Redirects to the given url. If the 'fenster' parameter is
 * a popup window, then closes it and redirects the main window.
 */
function redirect(fenster, url) {
	if (fenster.opener) {
		fenster.close();
		fenster = fenster.opener;
	}
	fenster.location.href=url;
}

/** Implements the blinking for Internet Explorer. */
function doBlink() {
	var blink = document.all.tags("blink");
	for (var i = 0; i < blink.length; i++) {
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "";
	}
}

/** Starts the blinking in Internet Explorer. */
function startBlink(interval) {
	// Make sure it is IE4
	if (document.all) {
		setInterval("doBlink()", interval);
	}
}
