var ssAbout, ssWork, ssServices; function boot() { var as = document.getElementsByTagName("a"), m; for (var i = 0; i < as.length; i++) { if (as[i].href && (m = /#(\w+)$/.exec(as[i].href))) { as[i].onclick = new Function("scroll('" + m[1] + "'); return false;"); } } as = document.getElementById('menu').getElementsByTagName('img'); for (var i = 0; i < as.length; i++) { var bits = as[i].src.split('.'); bits[bits.length-2] += '_h'; as[i].onmouseover = new Function("this.src = '" + bits.join('.') + "';"); as[i].onmouseout = new Function("this.src = '" + as[i].src + "';"); } } function scroll(id) { new Scroller(id); } function submitContact() { var fields = [ "name_text", "email_text", "message_text" ], i = 0; for (i = 0; i < fields.length; i++) { if ($(fields[i]).value.length == 0) { $('send-notification').innerHTML = "Please complete all fields and resend it one more time"; $('send-notification').style.display = 'block'; return; } } new Ajax.Request( 'contact.php', { parameters: Form.serialize($('contact_form'), true), onSuccess: function() { new Blip('blip'); $('send-notification').innerHTML = "Your message has been sent"; $('send-notification').style.display = 'block'; for (i = 0; i < fields.length; i++) { Form.Element.clear($(fields[i])); } } } ); } function Slideshow(id, root, size) { var container = $(id); this.main = document.createElement("div"); this.main.className = "item-1"; this.main.innerHTML = container.innerHTML; this.off = document.createElement("div"); this.off.className = "item-2"; container.innerHTML = ""; container.appendChild(this.main); container.appendChild(this.off); this.width = this.main.offsetWidth; this.height = this.main.offsetHeight; this.root = root; this.size = size; this.curr = 1; this.busy = false; } Slideshow.prototype.prev = function() { if (this.busy) return; this.curr -= 1; if (this.curr < 1) this.curr = this.size; this.start = -this.width; this.fire(); } Slideshow.prototype.next = function() { if (this.busy) return; this.curr += 1; if (this.curr > this.size) this.curr = 1; this.start = this.width; this.fire(); } Slideshow.prototype.fire = function() { this.busy = true; this.off.style.left = "" + this.start + "px"; this.off.style.display = 'block'; this.progress = 0; me = this; new Ajax.Updater(this.off, this.root + this.curr, {onComplete: function() { me.timer = window.setInterval(function(){me.tick();}, 40); }}); } Slideshow.prototype.tick = function() { this.progress += 0.05; if (this.progress > 1) this.progress = 1; var progress = this.progress * this.progress; this.off.style.left = "" + (this.start + (progress * -this.start)) + "px"; this.main.style.left = "" + (progress * -this.start) + "px"; if (this.progress >= 1) { var tmp = this.main; this.main = this.off; this.off = tmp; this.off.style.display = 'none'; window.clearInterval(this.timer); this.busy = false; } } function Scroller(id, options) { var me = this; this.start = this.getCurrentScrollPos(); this.end = this.getElementPos(id); this.end[1] = Math.max(0, this.end[1] - 100); this.delta = [this.end[0]-this.start[0], this.end[1]-this.start[1]]; this.progress = 0; this.timer = window.setInterval(function(){me.tick();}, 20); } Scroller.prototype.tick = function() { this.progress += 0.02; var progress = this.ease(this.progress); if (this.progress > 1) this.progress = 1; window.scrollTo(this.start[0] + this.delta[0] * progress, this.start[1] + this.delta[1] * progress); if (this.progress >= 1) window.clearInterval(this.timer); } Scroller.prototype.getElementPos = function(id) { var ele = document.getElementById(id); var out = [ ele.offsetLeft, ele.offsetTop]; while (ele = ele.offsetParent) { out[0] += ele.offsetLeft; out[1] += ele.offsetTop; } return out; } Scroller.prototype.getCurrentScrollPos = function() { return [window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0, window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0]; } Scroller.prototype.ease = function(c) { if (c < 1/2.75) { return (7.5625*c*c); } else if (c < 2/2.75) { return (7.5625*(c-=(1.5/2.75))*c+.75); } else if (c < (2.5/2.75)) { return (7.5625*(c-=(2.25/2.75))*c + 0.9375); } else { return (7.5625*(c-=(2.625/2.75))*c + 0.984375); } }