
//
// Urheberrecht (c) 2008 Asklepios - www.asklepios.at
// Alle Rechte vorbehalten
// Erstellt am: 29.12.2008
// Autor: M
//
// Main-Skript für die Lehner-Trompeter Website.
//
// ***
//
// LETZTE ÄNDERUNG: TT.MM.JJJJ, Beschreibung
//

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
add_load_event (func)
{
	var old_onload  = window.onload;

	if (typeof window.onload != 'function') {
		window.onload   = func;
	} 
	else {
		window.onload   = function () {
			old_onload ();
			func ();
		}
	}
}



/* Initialisiert Links (öffnen in neuem Fenster, öffnen des Mehl-Clients, 
 * usw.). */
function
init_links ()
{
	var anchors	= document.getElementsByTagName("a");
	var i		= anchors.length-1;

	// Loop through all anchor tags
	while (i >= 0) {
		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 ("rel") == "opener") {
			anchor.href = "javascript:load_into_opener('"+
				anchor.getAttribute("href")+"');";
		}
		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")
		{
			anchor.href = "javascript:popupPic('"	+
				anchor.getAttribute("href")	+
				"', '" + anchor.getAttribute("title") + "');";
		} else ;

		--i;
	}
}



function
newwin(url) {
	var w = window.open(url);
	w.focus ();
}



add_load_event (init_links);



} /* if DHTML */


