	function addLoadEvent(func) {
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
	  } else {
		window.onload = function() {
		  if (oldonload) {
			oldonload();
		  }
		  func();
		}
	  }
	}
	
	function updateSet(direction){
		var totalPics = document.getElementById("galleryWrapper").getElementsByTagName("div").length;
		var currentID = "p" + currentPic;
		var twoPic = currentPic + 1;
		var threePic = currentPic + 2;
		var nextPic = currentPic + 3;
		var twoID = "p" + twoPic;
		var threeID = "p" + threePic;
		var nextID = "p" + nextPic;		
		document.getElementById("bb").style.display ="none";
		document.getElementById("nb").style.display ="none";
		if (direction != "back" ){
			if (document.getElementById(nextID)){
				if(currentPic != 0){
					Effect.Fade(currentID);
					if (document.getElementById(twoID)){
						Effect.Fade(twoID);
					}
					if (document.getElementById(threeID)){
						Effect.Fade(threeID);
					}
					currentPic += 3;
				}else{
					currentPic++;
				}
				currentID = "p" + currentPic;
				twoPic = currentPic + 1;
				threePic = currentPic + 2;
				twoID = "p" + twoPic;
				threeID = "p" + threePic;
				Effect.Appear(currentID, { delay: 1.2, duration: 1.5 });
				if (document.getElementById(twoID)){
					Effect.Appear(twoID, { delay: 1.7, duration: 1.5 });
				}
				if (document.getElementById(threeID)){
					Effect.Appear(threeID, { delay: 2.2, duration: 1.5 });
				}
			}else{
				Effect.Fade(currentID);
				if (document.getElementById(twoID)){
					Effect.Fade(twoID);
				}
				if (document.getElementById(threeID)){
					Effect.Fade(threeID);
				}
				currentPic = 1;
				currentID = "p" + currentPic;
				twoPic = currentPic + 1;
				threePic = currentPic + 2;
				twoID = "p" + twoPic;
				threeID = "p" + threePic;
				Effect.Appear(currentID, { delay: 1.2, duration: 1.5 });
				if (document.getElementById(twoID)){
					Effect.Appear(twoID, { delay: 1.7, duration: 1.5 });
				}
				if (document.getElementById(threeID)){
					Effect.Appear(threeID, { delay: 2.2, duration: 1.5 });
				}
			}
		}else{
			var backPic = currentPic - 3;
			var backID = "p" + backPic;
			if (document.getElementById(backID)){
				Effect.Fade(currentID);
				if (document.getElementById(twoID)){
					Effect.Fade(twoID);
				}
				if (document.getElementById(threeID)){
					Effect.Fade(threeID);
				}
				currentPic -= 3;
				currentID = "p" + currentPic;
				twoPic = currentPic + 1;
				threePic = currentPic + 2;
				twoID = "p" + twoPic;
				threeID = "p" + threePic;
				Effect.Appear(currentID, { delay: 1.2, duration: 1.5 });
				if (document.getElementById(twoID)){
					Effect.Appear(twoID, { delay: 1.7, duration: 1.5 });
				}
				if (document.getElementById(threeID)){
					Effect.Appear(threeID, { delay: 2.2, duration: 1.5 });
				}
			}else{
				Effect.Fade(currentID);
				if (document.getElementById(twoID)){
					Effect.Fade(twoID);
				}
				if (document.getElementById(threeID)){
					Effect.Fade(threeID);
				}
				currentPic = totalPics - 2;
				currentID = "p" + currentPic;
				twoPic = currentPic + 1;
				threePic = currentPic + 2;
				twoID = "p" + twoPic;
				threeID = "p" + threePic;
				Effect.Appear(currentID, { delay: 1.2, duration: 1.5 });
				if (document.getElementById(twoID)){
					Effect.Appear(twoID, { delay: 1.7, duration: 1.5 });
				}
				if (document.getElementById(threeID)){
					Effect.Appear(threeID, { delay: 2.2, duration: 1.5 });
				}
			}			
		}
		

		Effect.Appear("bb", { delay: 2, duration: 0.8 });
		Effect.Appear("nb", { delay: 2, duration: 0.8 });
	}
	
	
	//global variables and onload functions
	var currentPic = 0;
