	var selectedDiv = '';
	function isdefined(object, variable)
	{
		return (typeof(eval(object)[variable]) == 'undefined')? false: true;
	}
	
	window.onload = function()
	{
		var f = function(e)
	{
	
	if(!e) e = window.event;
	var txt = '';
	for(var a in e) if(typeof e[a] != 'function')  txt += a + '=' + e[a] + '\n';
		if(selectedDiv != ''){
			if(isdefined(e,'wheelDelta')){
				if(e['wheelDelta'] < 0){
					eval(selectedDiv + '.scrollDown();')
					eval(selectedDiv + '.stopScroll();')
				}else{
					eval(selectedDiv + '.scrollUp();')
					eval(selectedDiv + '.stopScroll();')
				}
			}else if(isdefined(e,'detail')){
				if(e['detail'] > 0){
					eval(selectedDiv + '.scrollDown();')
					eval(selectedDiv + '.stopScroll();')
				}else{
					eval(selectedDiv + '.scrollUp();')
					eval(selectedDiv + '.stopScroll();')
				}
			}else{
			}
		}
		//alert(txt);
	}
	if( window.addEventListener) window.addEventListener('DOMMouseScroll', f, false)
	else window.document.onmousewheel = f
	}
	
	// gives up and down scroll buttons to images, spans, ... named up_name, down_name, respectively.
	// will keep the default scroll_box's style overflow if it encounters errors (so make overflow: auto;)
	
	// usage: put this after the scrollbox div:  var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box');
	function TextScroll(scrollname, div_name, up_name, down_name, direction, action){
	    this.div_name = div_name;
	    this.name = scrollname;
	    this.scrollCursor = 0;
	    this.speed = 10;
	    this.timeoutID = 0;
	    this.div_obj = null;
	    this.up_name = up_name;
	    this.dn_name = down_name;
			this.direction = direction;
			this.action = action;
	{
	        if (document.getElementById) {
	            div_obj = document.getElementById(this.div_name);
	            if (div_obj) {
	                this.div_obj = div_obj;
	                this.div_obj.style.overflow = 'hidden';
	            }
	            div_up_obj = document.getElementById(this.up_name);
	            div_dn_obj = document.getElementById(this.dn_name);
							
							
							
							
							
							
							if(this.action == 'klick'){
								if(this.direction == 'vertical'){
			            if (div_up_obj && div_dn_obj) {
										div_up_obj.onmousedown = function() { eval(scrollname + '.scrollUp();') };
										div_up_obj.onmouseup = function() { eval(scrollname + '.stopScroll();') };
										
										div_dn_obj.onmousedown = function() { eval(scrollname + '.scrollDown();') };
										div_dn_obj.onmouseup = function() { eval(scrollname + '.stopScroll();') };
			            }
								}else if(this.direction == 'horizontal'){
									div_up_obj.onmousedown = function() { eval(scrollname + '.scrollLeft();') };
									div_up_obj.onmouseup = function() { eval(scrollname + '.stopScroll();') };
									
									div_dn_obj.onmousedown = function() { eval(scrollname + '.scrollRight();') };
									div_dn_obj.onmouseup = function() { eval(scrollname + '.stopScroll();') };
								}
							}else if(this.action == 'mouseover'){
								if(this.direction == 'vertical'){
			            if (div_up_obj && div_dn_obj) {
										div_up_obj.onmouseover = function() {div_up_obj.src=div_up_obj.src.replace('.gif','_mo.gif'); eval(scrollname + '.scrollUp();') };
										div_up_obj.onmouseout = function() {div_up_obj.src=div_up_obj.src.replace('_mo.gif','.gif'); eval(scrollname + '.stopScroll();') };
										
										div_dn_obj.onmouseover = function() {div_dn_obj.src=div_dn_obj.src.replace('.gif','_mo.gif'); eval(scrollname + '.scrollDown();') };
										div_dn_obj.onmouseout = function() {div_dn_obj.src=div_dn_obj.src.replace('_mo.gif','.gif'); eval(scrollname + '.stopScroll();') };
			            }
								}else if(this.direction == 'horizontal'){
									div_up_obj.onmouseover = function() {div_up_obj.src=div_up_obj.src.replace('.gif','_mo.gif'); eval(scrollname + '.scrollLeft();') };
									div_up_obj.onmouseout = function() {div_up_obj.src=div_up_obj.src.replace('_mo.gif','.gif'); eval(scrollname + '.stopScroll();') };
									
									div_dn_obj.onmouseover = function() {div_dn_obj.src=div_dn_obj.src.replace('.gif','_mo.gif'); eval(scrollname + '.scrollRight();') };
									div_dn_obj.onmouseout = function() {div_dn_obj.src=div_dn_obj.src.replace('_mo.gif','.gif'); eval(scrollname + '.stopScroll();') };
								}
							}
							
							
							
							
							
							
	        }
	    }
	
	this.stopScroll = function() {
       clearTimeout(this.timeoutID);
   }

	this.scrollUp = function() {
       if (this.div_obj) {
           this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
           this.div_obj.scrollTop = this.scrollCursor;
           this.timeoutID = setTimeout(this.name + '.scrollUp()', 20);
       }
   }
	
	this.scrollDown = function() {
		if (this.div_obj) {
			this.scrollCursor += this.speed;
			this.div_obj.scrollTop = this.scrollCursor;
			if (this.div_obj.scrollTop == this.scrollCursor) {
				this.timeoutID = setTimeout(this.name + '.scrollDown()', 20);
			} else {
				this.scrollCursor = this.div_obj.scrollTop;
			}
		}
	}

	 this.scrollLeft = function() {
       if (this.div_obj) {
           this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
           this.div_obj.scrollLeft = this.scrollCursor;
           this.timeoutID = setTimeout(this.name + '.scrollLeft()', 20);
       }
   }
	  this.scrollRight = function() {
			if (this.div_obj) {
				this.scrollCursor += this.speed;
				this.div_obj.scrollLeft = this.scrollCursor;
				if (this.div_obj.scrollLeft == this.scrollCursor) {
					this.timeoutID = setTimeout(this.name + '.scrollRight()', 20);
				} else {
					this.scrollCursor = this.div_obj.scrollLeft;
				}
			}
		}

	
	
	this.resetScroll = function() {
	  if (this.div_obj) {
	      this.div_obj.scrollTop = 0;
				this.div_obj.scrollLeft = 0;
	      this.scrollCursor = 0;
	  }
	}
}
