
// Reagiert auf alle <img> tags mit class="preview"
function addEvent(obj, eventType, funktion, useCaption)
{
  if (obj.addEventListener) {
    obj.addEventListener(eventType, funktion, useCaption);
    return true;
  } else if (obj.attachEvent) {
    var retVal = object.attachEvent("on"+eventType, funktion);
    return retVal;
  } else {
    return false;
  }
}


function init_popups() {
	var imgs = document.images;
	for(var i = 0; i < imgs.length; i++) {
		if(imgs[i].className == "preview") {
// 			imgs[i].setAttribute("onclick", "return popup(this)");
			addEvent(imgs[i], "click", "return popup_dyn(this)", false);

		}
	}
}

function popup_dyn(target) {
	var img_url = target.src.split(".");
	var url = "";

	for(var i = 0; i < (img_url.length)-1; i++) {
		if ( url ) url += ".";
		url += img_url[i];
	}
	url += "_gross." + img_url[img_url.length-1];
	var pop = window.open(url, '', 'width=800,height=525,resizable');
	return (pop) ? false : true;
}

function popup(target) {
	var pop = window.open(target, '', 'width=800,height=525,resizable');
	return (pop) ? false : true;
}

function init() {
	if(document.getElementsByTagName("body")[0]) {
		init_popups();
	} else {
		window.setTimeout("init()", 1000);
	}
}
// window.setTimeout("init()", 1000); 
