//function to allow more than one window.onload event
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


//OpenClose
function OpenClose(id) {
	var element = document.getElementById(id);
	if (element.style.display != 'block') {
		element.style.display = 'block';
	}
	else {
		element.style.display = 'none';
	}
}

function getElementsByClassName(classname, node) {
	if(!node) node = document.getElementsByTagName("body")[0];
	var a = [];
	var re = new RegExp('\\b' + classname + '\\b');
	var els = node.getElementsByTagName("*");
	for(var i=0,j=els.length; i<j; i++)
	if(re.test(els[i].className))a.push(els[i]);
	return a;
}

function LoadSlideshowThumbs(){
	if(!document.getElementById("thumbs")) return;
	prepareGallery();
}

function LoadFeatureButtons() {	
	if(!document.getElementById("DetailsBox")) return;
	initiatePrintLink();
	initiateMailFriend();
	initiateFavLink();
}	 
addLoadEvent(LoadSlideshowThumbs);
addLoadEvent(LoadFeatureButtons);
