function showPic(whichpic) {
  if (!document.getElementById("placeholder")) return true;
  var source = whichpic.getAttribute("href");
  var placeholder = document.getElementById("placeholder");
  placeholder.setAttribute("src",source);
		//Ovo je moj dodatak
		var acad = document.getElementById("acad");
		acad.setAttribute("href",source.replace(/jpg/,"dwg")); //mijenja jpg extenziju u dwg za download
						
  if (!document.getElementById("opis")) return false;
  if (whichpic.innerHTML) {
    var text = whichpic.innerHTML; //uzima tekstualnu vrijednost linka pomocu innerHTML properties
  } else {
    var text = "";
  }
  var opis = document.getElementById("opis");
  if (opis.firstChild.nodeType == 3) {
    opis.firstChild.nodeValue = text;
  }
  return false; 
}

function prepareGallery() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("MenuBar1")) return false;
  var gallery = document.getElementById("MenuBar1");
  var links = gallery.getElementsByTagName("a");
  for ( var i=0; i < links.length; i++) {
    links[i].onclick = function() {
      return showPic(this);
    }
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(prepareGallery);

