
//
// Created on: 2009-12-04
// Author: M
//
// Startup-Script for the Referenz Immobilien website.
//
// ***
//
// LAST MODIFICATION:
//
// YYYY-MM-DD: Author
//      Description
// 2009-12-10: M
// 	Added new function: close().
//

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 ();
        }
    }
}


/* Initialisiert Links (öffnen in neuem Fenster, öffnen des Mehl-Clients, 
 * usw.). */
function
init_links ()
{
    if(!document.getElementsByTagName) {
        return ;
    }

    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")+"');";
        } 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;
        } else if(anchor.getAttribute("href")   &&
                  anchor.getAttribute("rel")    == "picture")
        {
            // 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);
}


function init_lexicon()
{
	if (document.body.className == "lexicon") {
		var links	= document.getElementsByTagName("div");
		var len		= links.length - 1;
		while (len) {
			if (links[len].className == "links") {
				links[len].innerHTML =
					links[len].innerHTML +
					"<a href='#' onclick='window.close();'"+
					"><span class='bullet'><img src='"+
					"images/bullets.png' alt='' class='"+
					"close' /></span>Fenster "+
					"schlie&szlig;en</a>";
			}
			--len;
		}
	}
}


addLoadEvent(init_links);
addLoadEvent(init_lexicon);



} /* if DHTML */

