// +++++++++++ Initialization code +++++++++++ // var scroll_offset = 258; var scroll_holder_height = 1000; var scroll_height = 280; if (window.addEventListener) { window.addEventListener('DOMMouseScroll', wheel, false); } window.onmousewheel = document.onmousewheel = wheel; var IE = document.all?true:false; var tempX = 0; var tempY = 0; var flag = "off"; // +++++++++++ Listener code +++++++++++ // function wheel(event) { var delta = 0; if(!event) { event = window.event; } if(event.wheelDelta) { delta = event.wheelDelta / 120; if(window.opera) { delta = (delta * -1); } } else if(event.detail) { delta = (event.detail / -3); } if(delta) { handle(delta); } } // +++++++++++ Mousewheel Scroll code +++++++++++ // function handle(delta) { var scroll_amount = delta; if(scroll_amount < 0) { scroll_dir = "down"; scroll_amount = (scroll_amount * -1); } else { scroll_dir = "up"; } scroll((scroll_amount * 14), scroll_dir); } // +++++++++++ Scroll Content +++++++++++ // function scroll(amount, dir) { var content_height = document.getElementById('scroll_content').offsetHeight; if(dir == 'down') { amount = amount * (-1); } var pos = document.getElementById('scroll_content').style.top; pos = parseInt(pos.substring(0, (pos.length - 2))) + amount; if(pos > -0.5) { pos = -0.5; } if(pos < ((scroll_holder_height - 12) * -1)) { pos = ((scroll_holder_height - 12) * -1); } document.getElementById('scroll_content').style.top = pos + "px"; //document.getElementById('scroll_bar').style.top = ((pos / content_height * (350 - (71 * 2)) * (-1)) + 2) + "px"; //document.getElementById('scroll_bar').style.top = ((pos/content_height) * (-1) * scroll_height) + "px"; var copy_pos = ((pos + 2) / (scroll_height - 39)) * scroll_holder_height; //document.getElementById('pos').innerHTML = (scroll_height - (((scroll_holder_height + pos) / scroll_holder_height) * scroll_height)) + "px"; new_pos = (scroll_height - (((scroll_holder_height + pos) / scroll_holder_height) * scroll_height)); if(new_pos < 2) { new_pos = 2; } if(new_pos > scroll_height - 39) { new_pos = scroll_height - 39; } document.getElementById('scroll_bar').style.top = new_pos + "px"; } // +++++++++++ Jump to Content +++++++++++ // function jump(pos) { var content_height = document.getElementById('scroll_content').offsetHeight; document.getElementById('scroll_content').style.top = pos + "px"; //document.getElementById('scroll_bar').style.top = ((pos / content_height * (350 - (71 * 2)) * (-1)) + 2) + "px"; document.getElementById('scroll_bar').style.top = (pos / content_height * (scroll_height - 11) * (-1)) + 2 + "px"; } // +++++++++++ Scroll Bar code +++++++++++ // document.onmousemove = getMousePosition; var start = 0; function nullfunction() { return false; } function getMousePosition(e) { if(IE) { //tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } else { //tempX = e.pageX; tempY = e.pageY; } //if (tempX < 0){tempX = 0} if(tempY < 0) { tempY = 0 } if(flag != "off") { //document.getElementById(flag).style.left = tempX - 5; var curr = document.getElementById('scroll_bar').style.top; curr = curr.substring(0, (curr.length - 2)); //new_Y = parseInt(start) + parseInt(tempY) - 150; new_Y = parseInt(tempY) - scroll_offset; if(parseInt(new_Y) < 2) { new_Y = 2; } if(parseInt(new_Y) > (scroll_height - 39)) { new_Y = (scroll_height - 39); } var copy_pos = ((new_Y + 2) / (scroll_height - 39)) * scroll_holder_height; document.getElementById(flag).style.top = new_Y + "px"; document.getElementById('scroll_content').style.top = (copy_pos * -1) + "px"; } } function drag() { start = document.getElementById('scroll_bar').style.top; start = start.substring(0, (start.length - 2)); var holder = document.getElementById('scroll_bar_holder').offsetHeight; holder = parseInt(holder); //alert(holder); flag = 'scroll_bar'; //obj.style.width = 138; //obj.style.height = 96; //obj.style.left = tempX - 69; //obj.style.top = tempY - 48; return false; } function release(obj) { //var XposObj = findPosX(obj); //var YposObj = findPosY(obj); flag = "off"; return false; } function move_bar() { if(move == 'on') { scroll(1, 'down'); } }