function prepareGallery(){
  if( document.getElementById &&
      document.getElementsByTagName ){
    if( document.getElementById( 'thumbs' ) ){
      var gallery = document.getElementById( 'thumbs' );
      var links = gallery.getElementsByTagName( 'a' );
      for( var i=0; i < links.length; i++ ){
        links[i].onclick = function(){
			showPic(this);
  return false;
        };
      }
    }
  }
}

function showPic(whichpic) {
  var source = whichpic.getElementsByTagName( 'img' )[0].getAttribute("src");
  /*source=source.substring(0,source.length-4)+"_p.jpg";*/
  ext=source.substring(source.length-3);
  source=source.substring(0,source.length-5)+"."+ext;
  var placeholder = document.getElementById("placeholder");
  placeholder.setAttribute("src",source);
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(prepareGallery);