
//
// Created on: 2010-03-22
// Author: M
//
// Main script for Hebest Pflege & Betreuung.
//
// ***
//
// LAST MODIFICATION:
//
// 2010-03-12: M
// 	Added the functionality for the slideshow containers.
//

DHTML = (document.getElementById || document.all || document.layers);
if (DHTML) {


/* Adds an event to window.onload without overwriting currently
 * assigned onload functions.
 * Function found at Simon Willison's weblog - 
 *	  http://simon.incutio.com/ */
function
addLoadEvent (func)
{
	var old_onload  = window.onload;

	if (typeof window.onload != 'function') {
		window.onload   = func;
	} 
	else {
		window.onload   = function () {
			old_onload ();
			func ();
		}
	}
}
function add_load_event(init_ss) {
	addLoadEvent(init_ss);
}



/* Initialisiert Links (öffnen in neuem Fenster, öffnen des Mehl-Clients, 
 * usw.). */
function
init_links ()
{
	var anchors = document.getElementsByTagName("a");

	// Loop through all anchor tags
	for(var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];

		// Oeffnen von neuen Browserfenstern:
		if (anchor.getAttribute("href")  &&
		   anchor.getAttribute("rel")   == "newwin")
		{
			anchor.href = "javascript:newwin('"+
				anchor.getAttribute("href")+"');";
			anchor.className = anchor.className + " newwin";
		} else if (anchor.getAttribute("href")   &&
			  anchor.getAttribute("rel")	== "mehl")
		{
			var mailad	= anchor.innerHTML;
			mailad		= mailad.replace(/, /, "@");
			mailad		= mailad.replace(/ /g, ".");
			anchor.href	= "mailto:" + mailad;
			anchor.innerHTML= mailad;
			anchor.className= anchor.className+" mehl";
		} else if(anchor.getAttribute("href")   &&
				  anchor.getAttribute("rel")	== "galerie")
		{
			// Link zu einem Fotos soll sich in einem Popup oeffen:
			anchor.href = "javascript:popupPic('" +
				anchor.getAttribute("href") 
				+ "', '" + anchor.getAttribute("title") + "');";
		} else ;
	}
}



function
newwin(url) {
	window.open(url);
}

addLoadEvent(init_links);

} /* if DHTML */
