var gradientshadow = {};
gradientshadow.depth = 6; //Depth of shadow in pixels
gradientshadow.containers = [];
var timer = null;

gradientshadow.create = function() {
	var a = document.all ? document.all : document.getElementsByTagName('*');
	for(var i = 0; i < a.length;i++) {
		if(a[i].className == "shadow") {
			for(var x = 0; x < gradientshadow.depth; x++) {
				var newSd = document.createElement("DIV");
				newSd.className = "shadow_inner";
				newSd.id = "shadow" + gradientshadow.containers.length + "_" + x; //Each shadow DIV has an id of "shadowL_X" (L=index of target element, X=index of shadow (depth)
				if(a[i].getAttribute("rel")) {
					newSd.style.background = a[i].getAttribute("rel");
				} else {
					newSd.style.background = "black"; //default shadow color if none specified
				}
				document.body.appendChild(newSd)
			}
			gradientshadow.containers[gradientshadow.containers.length] = a[i];
		}
	}
	gradientshadow.position();
	window.onresize = function() {
		gradientshadow.position();
	}
}

gradientshadow.position = function() {
	if(gradientshadow.containers.length > 0) {
		for(var i = 0; i < gradientshadow.containers.length; i++) {
			for(var x = 0; x < gradientshadow.depth; x++) {
  				var shadowdiv = document.getElementById("shadow" + i + "_" + x);
				shadowdiv.style.width = gradientshadow.containers[i].offsetWidth + "px";
				shadowdiv.style.height = gradientshadow.containers[i].offsetHeight + "px";
				shadowdiv.style.left = gradientshadow.containers[i].offsetLeft + x + "px";
				shadowdiv.style.top = gradientshadow.containers[i].offsetTop + x + "px";
			}
		}
	}
}

if (window.addEventListener) {
	window.addEventListener("load", gradientshadow.create, false);
} else if (window.attachEvent) {
	window.attachEvent("onload", gradientshadow.create);
} else if (document.getElementById) {
	window.onload=gradientshadow.create;
}

var scrolling = null;

function scroll_up() {
	var d = document.getElementById("portfolio_container");
	if(d != null) {
		d.scrollTop = d.scrollTop - 3;
		scrolling = window.setTimeout(function() { scroll_up(); }, 35);
	}
}

function scroll_down() {
	var d = document.getElementById("portfolio_container");
	if(d != null) {
		d.scrollTop = d.scrollTop + 3;
		scrolling = window.setTimeout(function() { scroll_down(); }, 35);
	}
}

function stop_scroll() {
	window.clearTimeout(scrolling);
}

function showTip(elName) {
	var tipText = "";
	switch(elName) {
		case "internet":
					tipText = "<div style='padding:8px;text-align:justify;width:400px;'>" +
						"<p><span class=parahdr>Invention of the Internet</span><br>" +
						"Many people think that the Internet is a recent innovation, when in fact " +
						"the fundamental ideas behind the Internet have been around for over a quarter " +
						"century.</p>" +
						"<p>The development of what we now call the Internet started in 1957 when the " +
						"Soviet Union launched Sputnik 1, the first satellite, beating the United States " +
						"into space. The powers behind the American military at the time became highly " +
						"alarmed as this meant that the USSR could theoretically launch bombs into space, " +
						"and then drop them anywhere on earth. In 1958 the concerns of people in the US " +
						"military triggered the creation of the Defence Advanced Research Projects Agency " +
						"(DARPA).</p>" +
						"<p>Click to read more about the history of the Internet.</div>";
					break;

	}
	Tip(tipText, BALLOON, true, ABOVE, true);
}
