addLoadEvent(detailfotoInit);

var global_width=600;
var global_height=600;
function detailfotoInit() {
	if (document.getElementById) {
		allLinks=document.getElementsByTagName('a');
		for (var i=0; i<allLinks.length; i++) {
			if(allLinks[i].target=='detailfoto') {
				var popuplink = new PopupLink(allLinks[i],global_width, global_height);
				//preloadPic = eval("preloadPic" + i);
				document["preloadPic" + i] = new Image();
				document["preloadPic" + i].src = allLinks[i].href;
				document["preloadPic" + i].refLink = allLinks[i];
				//alert(document['preloadPic' + i] + " : " + document['preloadPic' + i].height + " : " + document['preloadPic' + i].getAttribute('height'));
				//alert(preloadPic + " : " + preloadPic.width + " : " + preloadPic.getAttribute('width'));
				document["preloadPic" + i].id = i;
				document["preloadPic" + i].onload= function(){
					//alert(this);
					var picHeight = (this.height > 0 ) ? this.height +140 : global_height;
					var picWidth =  (this.width > 0 ) ? this.width +40 : global_width;
					var popuplink = new PopupLink(this.refLink,picWidth, picHeight);
				}
			}
		}
	}
};



var PopupLink = function(item, this_width, this_height) {
	//alert(this_height);
	this._link = item;
	this._target = item.target;
	this._title = item.title;
	this._href = item.href;
	this._width = this_width;
	this._height = this_height;
	this._link._obj = this;
	this._link.onclick = this._open;
	
};
var fenster = null;
PopupLink.prototype._open = function() {
		//eigenschaften="left="+x+",top="+y+",screenX="+x+",screenY="+y+",width="+b+",height="+h+",menubar=no,toolbar=no,statusbar=0";
	eigenschaften="width=" + this._obj._width+ ",height=" + this._obj._height + ",location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no";
	//alert(eigenschaften);
	//fenster = window.open(this._obj._href, this._obj._target, 'width='+this._obj._width+',height='+this._obj._height+',location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no');
	fenster=window.open(this._obj._href,this._obj._target,eigenschaften);
	fenster.focus();
	fenster.document.open();
	
	with (fenster) {
		document.write("<html><head>");
		document.write("<meta http-equiv='imagetoolbar' content='no'>");
		document.write("<link type='text/css' rel='stylesheet' href='css/global.css' media='projection,screen' />");
		// geändert 2004 für Mozilla
		document.write('<scr' + 'ipt type="text/javascr' + 'ipt" language="JavaScr' + 'ipt">');
		// bei click  schliessen , on click close
		document.write("function click() { window.close(); } ");
		//document.write("document.onmousedown=click ");
		// geändert 2004 für Mozilla
		document.write('</scr' + 'ipt>');
		document.write("<title>Zum Schließen, bitte das Bild anklicken</title></head>");
		// bei Focusverlust schliessen, close if window looses focus
		// Zeile geändert Aug 2003 (Dreamweaver machte Probleme)
		document.write("<" + "body class='popup' onblur='window.close()'>");
		document.write("<img onclick='window.close()' src='"+ this._obj._href +"' border='0'>");
		document.write("<div class='caption' id='caption'>"+ this._obj._title +"</div>");
		document.write("</body></html>");
		fenster.document.close();
	}
	
	
	return false;
};


/*
	--------------------------------------------------------------------------
	Version: 1.01
	Release date: 13/05/2006
	Last update: 13/07/2006

	(c) 2006 SpamSpan (www.spamspan.com)

	This program is distributed under the terms of the GNU General Public
	Licence version 2, available at http://www.gnu.org/licenses/gpl.txt
	--------------------------------------------------------------------------
*/

var spamSpanMainClass		= 'spamspan';
var spamSpanUserClass		= 'u';
var spamSpanDomainClass		= 'd';
var spamSpanAnchorTextClass = 't';

/*
	--------------------------------------------------------------------------
	Do not edit past this point (unless you know what you are doing).
	--------------------------------------------------------------------------
*/

// load SpamSpan
addLoadEvent(spamSpan);

function spamSpan() {
	var allSpamSpans = getElementsByClass(spamSpanMainClass, document, 'span');
	for (var i=0; i<allSpamSpans.length; i++) {
		// get data
		var user = getSpanValue(spamSpanUserClass, allSpamSpans[i]);
		var domain = getSpanValue(spamSpanDomainClass, allSpamSpans[i]);
		var anchorText = getSpanValue(spamSpanAnchorTextClass, allSpamSpans[i]);
		// create new anchor tag
		var email = cleanSpan(user) + String.fromCharCode(32*2) + cleanSpan(domain);
		var anchorTagText = document.createTextNode(anchorText ? anchorText : email);
		var anchorTag = document.createElement('a');
			anchorTag.className = spamSpanMainClass;
			anchorTag.setAttribute('href', String.fromCharCode(109,97,105,108,116,111,58) + email);
			anchorTag.appendChild(anchorTagText);
		// replace the span with anchor
		allSpamSpans[i].parentNode.replaceChild(anchorTag, allSpamSpans[i]);
	}
}

function getElementsByClass(searchClass, scope, tag) {
	var classElements = new Array();
	if (scope == null) node = document;
	if (tag == null) tag = '*';
	var els = scope.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (var i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function getSpanValue(searchClass, scope) {
	var span = getElementsByClass(searchClass, scope, 'span');
	if (span[0]) return span[0].firstChild.nodeValue;
	else return false;
}

function cleanSpan(string) {
	// string = string.replace(//g, '');
	// replace variations of [dot] with .
	string = string.replace(/[\[\(\{]?[dD][oO0][tT][\}\)\]]?/g, '.');
	// replace spaces with nothing
	string = string.replace(/\s+/g, '');
	return string;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function FotoWindow(bildurl,b,h)
{
var eigenschaften,sbreite,shoehe,fenster,b,h;

// stellt die Bildschirmabmessungen fest
// find window size
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);

if(ns6||ns4) {
sbreite = innerWidth;
shoehe = innerHeight;
}
else if(ie4) {
sbreite = document.body.clientWidth;
shoehe = document.body.clientHeight;
}

x = (sbreite-b)/2;
y = (shoehe-h)/2;

eigenschaften="left="+x+",top="+y+",screenX="+x+",screenY="+y+",width="+b+",height="+h+",menubar=no,toolbar=no,statusbar=0";

fenster=window.open("","",eigenschaften);
fenster.focus();
fenster.document.open();
with (fenster) {
  document.write("<html><head>");
  // geändert 2004 für Mozilla
  document.write('<scr' + 'ipt type="text/javascr' + 'ipt" language="JavaScr' + 'ipt">');
  // bei click  schliessen , on click close
  document.write("function click() { window.close(); } ");
  document.write("document.onmousedown=click ");
  // geändert 2004 für Mozilla
  document.write('</scr' + 'ipt>');
  document.write("<title>klick to close</title></head>");
  // bei Focusverlust schliessen, close if window looses focus
  // Zeile geändert Aug 2003 (Dreamweaver machte Probleme)
  document.write("<" + "body onblur='window.close()';");
  document.write("marginwidth='0' marginheight='0' leftmargin='0' topmargin='0'>");
  document.write("<img src='"+ bildurl +"' border='0'>");
  document.write("</body></html>");
  fenster.document.close();
}
}
