window.onload = function() { // Requires delay or slide width wrongly computed on first load! setTimeout((function(){slideShow.init('makers')}),100); // Customer types task('.types_choice a').click( function (sourceElement) { customerType(sourceElement); } ); task('.expand').firstChild().click( function (sourceElement) { var featuresPanel = task(sourceElement).parentNode().ofClass('.expand_this').obj(); task(featuresPanel).show(); showFeatures(featuresPanel); } ); task('.close_this').click( function (sourceElement) { task(sourceElement).parentNode().hide(); } ); } var slideShow = { frame : 0, speed : 10, roller_delay : 2400, slides: 0, slides_Cont : 0, slide_width : 0, slide_focus : 0, init : function (el) { this.slides_Cont = document.getElementById(el); this.slides = this.slides_Cont.children; this.slides_Cont.style.width = (this.slides.length * 508) + "px"; this.slide_width = this.slides_Cont.offsetWidth / this.slides.length; this.markers(); setTimeout(this.cycle.bind(this), 500); }, markers :function (){ var markers_Con = document.getElementById('slide_markers'); for (i=0; i < this.slides.length; i++) { var marker_Sel = "slide_marker_Sel"; if ( i < this.slides.length - 1 ) marker_Sel = ""; var div = document.createElement("div"); div.className = "slide_marker " + marker_Sel; markers_Con.appendChild(div); } this.markers = markers_Con.children; }, cycle : function () { // If slides at anchor point if ( ( this.frame > this.slide_width / this.speed ) ) { this.frame = 0; this.slide_focus++; if ( this.slide_focus >= this.slides.length ) this.slide_focus = 0; // Set marker for (i=0; i < this.markers.length; i++) { this.markers[i].className = "slide_marker"; } this.markers[this.slides.length - this.slide_focus - 1].className = "slide_marker slide_marker_Sel"; // Send first position slide to last position to maintain a loop this.slides[0].parentNode.appendChild(this.slides[0]); setTimeout(this.slidesMotion.bind(this), this.roller_delay); } else { setTimeout(this.slidesMotion.bind(this), 1); } }, slidesMotion : function () { // Prevent slide container going to far left if ( this.slides_Cont.offsetLeft < ( (this.slide_width * -1) + this.speed ) ) { this.slides_Cont.style.left = '0px'; } else { this.slides_Cont.style.left = this.slides_Cont.offsetLeft - this.speed + 'px'; } this.frame++; this.cycle(); } }; // Customer type function customerType(obj) { data = obj.dataset; task('.types').hide(); task('#' + data.type + '_section').show(); task('.types_choice a').className('types_choice_deSel'); task('#' + data.type + '_linkType').obj().className = "types_choice_sel"; } // Show features var showFeatures = (function () { var timer, start, rate; return function (target) { rate = 5; frame_count = 190; function frame() { frame_count++; if ( target.getBoundingClientRect().top < 90 ) { clearTimeout(timer); } else if ( target.getBoundingClientRect().top > 90 ) { move = frame_count / rate; window.scrollBy(0, Math.floor(move)); } } timer = setTimeout(frame, 1); }; }());