/**
 *
 * @author Steffen Bensch (s.bensch@hisobe.de)
 *
 * @date 2009-12-04
 * 
 * Achtung: diese Datei wird aus dem php-common Projekt heraus 
 * regelmäßig aktualisiert. Für projektbezogene Anpassungen bitte die 
 * starter.js benutzen...   
 *
 */

/**
 * 
 * @param id
 * @return
 */
function showElement(id, hideId) {

	if (hideId)
		$('#' + hideId).hide();

	if (!id)
		return false;

	$('#' + id).show();

	return true;
}

function enableTooltips() {

	$(".tooltip_p").tooltip();
}

function openPopup(id) {

	if (!id)
		return;

	var popupid = "#popup_" + id;
	var detailsid = "#details_" + id;

	$(detailsid).colorbox({
		opacity : "0.8",
		scrolling : false,
		inline : true,
		href : popupid
	});
}

/**
 * 
 */
function slideSwitch() {

	var active = $('#slideshow img.active');

	if (active.length == 0)
		active = $('#slideshow img:last');

	var next = active.next().length ? active.next() : $('#slideshow img:first');

	active.addClass('last-active');

	next.css({
		opacity : 0.0
	}).addClass('active').animate({
		opacity : 1.0
	}, 1000, function() {

		active.removeClass('active last-active');
	});
}

/**
 * Ersetzt im String text alle Newlines (\r, \n, \r\n) durch &lt;br /&gt;
 * @param text
 * @returns
 */
function replaceNewlineWithBr(text) {

	if (text)
		return text.replace(/(\r\n|\n|\r)/gm, "<br />");

	return "";
}
