function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function imageviewer(img){
	holder = img.parentNode;
	child = holder.firstChild;
	while(child.nodeName!="IMG"){
		child = child.nextSibling;
	}
	//alert(child.src);
	child.src=img.src;
}
function prepareImageviewers(){
	divs = document.getElementsByTagName("DIV");
	for(i=0;i<divs.length;i++){
		thisDiv = divs[i];
		if(thisDiv.className=="imageviewer"){
			imgs = thisDiv.getElementsByTagName("IMG");
			for(j=0;j<imgs.length;j++){
				thisImg = imgs[j];
				if(j>0){
					thisImg.onclick = function(){
						imageviewer(this);
					}
					thisImg.width="50";
				}
			}
		}
	}
}
addLoadEvent(prepareImageviewers);
