var currentItem = subTimeout = projects = [], lastProject = null, proSwap = 0, wait = 8000, fadeAmount = 10, bgPanels = [], myZIndex = 1, doFade = true, rewriteOn = false; var mozWin = (window.navigator.userAgent.match(/Windows(.+)Firefox/)); function setupSub() { var sub = $("submenu"); if (sub) { Event.add(sub, "mouseover", subMouseover, false); Event.add(sub, "mousemove", subMouseover, false); Event.add(sub, "mouseout", subMouseout, false); } } function subMouseover() { clearTimeout(subTimeout); $("submenu").style.marginRight = 0; } function subMouseout() { subTimeout = setTimeout(function() { $("submenu").style.marginRight = "-180px"; }, 150); } function changeHomeImage(id, e) { if (id == lastProject) { return false; } if (doFade) { if (mozWin) { var outP = (lastProject != null) ? $("bgPane_" + lastProject) : false; var inP = $("bgPane_" + id); for (var q = 0, l = bgPanels.length; q < l; q ++) { if (bgPanels[q] != outP && bgPanels[q] != inP) { bgPanels[q].style.zIndex = 0; bgPanels[q].style.visibility = "visible"; } } setOpacity(inP, 100); inP.style.zIndex = 1; inP.style.visibility = "visible"; inP.style.position = "relative"; if (outP) { outP.style.zIndex = 2; outP.style.position = "absolute"; fade(outP, "out"); } } else { var d = byTag("DIV", $("background")); var outP = d[currentItem ? 1 : 0]; outP.style.zIndex = 1; var inP = d[currentItem ? 0 : 1]; setOpacity(inP, 0); inP.style.zIndex = 2; //byTag("h1", inP)[0].style.backgroundImage = "url(images/projects/" + id + "/logo.gif)"; if (rewriteOn) { byTag("a", inP)[0].href = "projects/" + id + "/" + $("smenu_" + id).innerHTML.replace(/ /g, "+"); } else { byTag("a", inP)[0].href = "index.php?page=projects&id=" + id + "&name=" + $("smenu_" + id).innerHTML.replace(/ /g, "+"); } byTag("img", inP)[0].src = "images/projects/" + id + "/home980.jpg"; byTag("img", inP)[0].alt = byTag("img", inP)[0].title = $("smenu_" + id).innerHTML; fade(inP, "in"); } } else { // moz fix if (mozWin) { var outP = (lastProject != null && $("bgPane_" + lastProject)) ? $("bgPane_" + lastProject) : false; } else { var outP = byTag("DIV", $("background"))[currentItem ? 1 : 0]; } if (outP) { outP.style.zIndex = 1; } var inP = byTag("DIV", $("background"))[0]; setOpacity(inP, 100); inP.style.position = "absolute"; if (rewriteOn) { byTag("a", inP)[0].href = "projects/" + id + "/" + $("smenu_" + id).innerHTML.replace(/ /g, "+"); } else { byTag("a", inP)[0].href = "index.php?page=projects&id=" + id + "&name=" + $("smenu_" + id).innerHTML.replace(/ /g, "+"); } byTag("img", inP)[0].src = "images/projects/" + id + "/home980.jpg"; byTag("img", inP)[0].alt = byTag("img", inP)[0].title = $("smenu_" + id).innerHTML; inP.style.zIndex = 2; } lastProject = id; currentItem = (currentItem) ? 0 : 1; myZIndex ++; //proSwap = setTimeout(autoUpdateImage, wait); } function preloadImages() { var bg = $("background"); if (bg) { if (byTag("DIV", bg)[0]) { var bgClone = byTag("DIV", bg)[0].cloneNode(true); var x = $("submenu"); if (x) { var k = 0; var a = x.getElementsByTagName("A"); for (var s = 0, l = a.length; s < l; s ++) { var m = String(a[s].onclick).match(/changeHomeImage\(([0-9]+), Event\)/); if (m) { if (mozWin && doFade) { if (! k) { // id top panel var d = byTag("DIV", bg)[0]; d.id = "bgPane_" + m[1]; d.style.zIndex = 1; lastProject = m[1]; } else { // create clone var d = bgClone.cloneNode(true); //byTag("h1", d)[0].style.backgroundImage = "url(images/projects/" + m[1] + "/logo.gif)"; if (rewriteOn) { byTag("a", d)[0].href = "projects/" + m[1] + "/" + $("smenu_" + m[1]).innerHTML.replace(/ /g, "+"); } else { byTag("a", d)[0].href = "index.php?page=projects&id=" + m[1] + "&name=" + $("smenu_" + m[1]).innerHTML.replace(/ /g, "+"); } byTag("img", d)[0].src = "images/projects/" + m[1] + "/home980.jpg"; byTag("img", d)[0].alt = byTag("img", d)[0].title = $("smenu_" + m[1]).innerHTML; d.id = "bgPane_" + m[1]; d.style.zIndex = 0; d.style.visibility = "hidden"; bg.appendChild(d); } bgPanels.push(d); k ++; } else { var i = new Image(); i.src = "images/projects/" + m[1] + "/home980.jpg"; } projects.push(m[1]); } } // clone first div if (! mozWin && doFade) { bg.appendChild(bgClone); } proSwap = setTimeout(autoUpdateImage, wait); } } } } function preloadProjectImages() { var s = $("strip"); if (s) { var i = byTag("IMG", s); for (var q = 0, l = i.length; q < l; q ++) { var img = new Image(); img.src = i[q].src.replace(/\/thumbs/, ""); i[q].onclick = function() { $("major").src = this.src.replace(/\/thumbs/, ""); $("major").alt = $("major").title = this.alt; $("blurro").src = this.src.replace(/\/thumbs\/([^.]+)/, "/$1-blur"); $("blurro").onload = function() { this.style.height = (this.offsetHeight < 862) ? "862px" : this.offsetHeight + "px"; } $("major").onload = function() { $('infoText').style.display = 'none'; $('major').parentNode.style.display = ''; } eval("var s = imageSizes.x" + this.id.replace(/th_/, "") + ";"); $("major").style.width = s.width + "px"; $("major").style.height = s.height + "px"; } } } } function autoUpdateImage() { do { var x = Math.getRandom(0, (projects.length - 1)); } while (projects[x] == lastProject); changeHomeImage(projects[x]); proSwap = setTimeout(autoUpdateImage, wait); } function fade(obj, dir) { var steps = 1.75; clearTimeout(obj.fadeTimeout); if (typeof(obj.fadePercent) == "undefined" || obj.fadePercent == null) { obj.fadePercent = (dir == "in") ? 0 : 100; } var amount = (dir == "in") ? fadeAmount : -fadeAmount; obj.fadePercent += amount; setOpacity(obj, obj.fadePercent); if (dir == "in" && obj.fadePercent == 100 || dir == "out" && obj.fadePercent == 0) { obj.fadePercent = null; } else { obj.fadeTimeout = setTimeout(function() { fade(obj, dir) }, 5); } } function setOpacity(obj, value) { if (document.all) { obj.style.filter = "alpha(opacity=" + value + ")"; } else { obj.style.opacity = (value / 100).toFixed(2); } // if (value == 0) { obj.style.visibility = "hidden"; } else { obj.style.visibility = "visible"; } } Event.add(window, "load", setupSub, false); Event.add(window, "load", preloadImages, false); Event.add(window, "load", preloadProjectImages, false);