function scrollTopBottom(optionsGrab) {
	var self = this; 
	self.topPos = 0;
	self.runGrab = false;
	self.nhayList = 4;
	self.objGrab;
	self.heightGrab = 0;
	self.widthGrab = 0;
	self.heightContent = 0;
	
	GrabContent();
	
	function GrabContent(){
		self.topPos = 0;
		self.runGrab = false;
		self.nhayList = (typeof(optionsGrab.speed) != "undefined" && optionsGrab.speed > 0)?optionsGrab.speed:2;
	//	if(typeof(optionsGrab.mainGrab) == "undefined") return;
		if(typeof(optionsGrab.objGrab) == "undefined") return;
		if(typeof(optionsGrab.contentGrab) == "undefined") return;
		
		self.objGrab = getRawObject(optionsGrab.objGrab);
		if(!self.objGrab || typeof(self.objGrab) == "undefined"){
			setTimeout(function () {	 
				GrabContent();
			}, 100);
			return;
		}
		self.heightGrab = (typeof(optionsGrab.height) != "undefined" && parseInt(optionsGrab.height) > 0)?parseInt(optionsGrab.height):self.objGrab.offsetHeight;
		self.widthGrab = (typeof(optionsGrab.width) != "undefined" && parseInt(optionsGrab.width) > 0)?parseInt(optionsGrab.width):self.objGrab.offsetWidth;
		if(!self.heightGrab || typeof(self.heightGrab) == "undefined" || self.heightGrab <= 0){
			setTimeout(function () {	 
				GrabContent();
			}, 100);
			return;
		}
		if(!self.widthGrab || typeof(self.widthGrab) == "undefined" || self.widthGrab <= 0){
			setTimeout(function () {	 
				GrabContent();
			}, 100);
			return;
		}
		self.heightContent = getRawObject(optionsGrab.contentGrab).offsetHeight;
		if(!self.heightContent || typeof(self.heightContent) == "undefined" || self.heightContent <= 0){
			setTimeout(function () {	 
				GrabContent();
			}, 100);
			return;
		}
		if(self.heightContent <= self.heightGrab) return;
		
		self.objGrab.setAttribute("style", 'width:'+self.widthGrab+'px; height:'+self.heightGrab+'px; text-align:left; cursor:-moz-grab; cursor: url('+pathToTheme()+'/themes/5.0/images/pan.cur), move !important; overflow:hidden; float:left');
		
	//	getRawObject(optionsGrab.mainGrab).setAttribute("style", 'position:absolute; height:'+self.heightGrab+'px; width:'+self.widthGrab+'px; overflow:hidden');
		addEventHandler(self.objGrab,'mousedown', function(event){self.startGrab(event);});
		addEventHandler(self.objGrab,'mousemove', function(event){self.doneGrab(event);});
		addEventHandler(self.objGrab,'mouseout', function(event){self.stopGrab2(event);});
		addEventHandler(self.objGrab,'mouseup', function(){self.stopGrab();});
		
	//	self.objGrab.onmousedown = function(event){
	//		self.startGrab(event);	
	//	};
	//	self.objGrab.onmousemove = function(event){
	//		self.doneGrab(event);	
	//	};
	//	self.objGrab.onmouseout = function(event){
	//		self.stopGrab2(event);	
	//	};
	//	self.objGrab.onmouseup = function(){
	//		self.stopGrab();	
	//	};
		
		/*
		self.scrollUp = document.createElement("div");		
		getRawObject(optionsGrab.mainGrab).appendChild(self.scrollUp);
		self.scrollUp.id = "scrollUp";
		self.scrollUp.setAttribute("style", 'background:url("'+pathToTheme()+'/themes/5.0/images/arrow-asc.png") no-repeat transparent; width:13px; height:13px; text-align:center; cursor:pointer; position:relative; z-index:200; margin-top:-25px; margin-right:100px; float:right');
		
		if (self.scrollUp.filters) {
			try {
				self.scrollUp.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 15;
			} catch (e) {
				// If it is not set initially, the browser will throw an error.  self will set it if it is not set yet.
				self.scrollUp.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 15 + ')';
			}
		} else {
			self.scrollUp.style.opacity = 15 / 100;
		} */
	}
	self.startGrab = function(event) {
		self.objGrab.setAttribute("style", 'width:'+self.widthGrab+'px; height:'+self.heightGrab+'px; text-align:left; cursor:-moz-grabbing; cursor: url('+pathToTheme()+'/themes/5.0/images/pandown.cur), move !important; overflow:hidden; float:left');
		var e = event;
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
		
		self.topPos = e.clientY + st - findPosTop(self.objGrab);
		if(self.topPos < 0) self.topPos = 0;
		self.runGrab = true;
	//	alert(2);
	};
	self.stopGrab2 = function(event) {
		var e = event;
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
	
		var topPos2 = e.clientY + st - findPosTop(self.objGrab);
		if(topPos2 <= 0 || topPos2 >= self.heightGrab){
			self.stopGrab();
			return;
		}
		var leftPos2 = e.clientX - findPosLeft(self.objGrab);
		if(leftPos2 <= 0 || leftPos2 >= self.widthGrab){
			self.stopGrab();
		}
	};
	self.stopGrab = function() {
		self.runGrab = false;
		self.objGrab.setAttribute("style", 'width:'+self.widthGrab+'px; height:'+self.heightGrab+'px; text-align:left; cursor:-moz-grab; cursor: url('+pathToTheme()+'/themes/5.0/images/pan.cur), move !important; overflow:hidden; float:left');
	};
	self.doneGrab = function(event) {
		if(self.runGrab){
			var e = event;
			var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
			if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
		
			var topPos2 = e.clientY + st - findPosTop(self.objGrab);
			if(topPos2 < 0) topPos2 = 0;
					
			if(topPos2 > self.topPos){
				self.nhayList = topPos2 - self.topPos;
				if(self.nhayList > 0) self.nhayList += 1;
				self.move_objList('top');
			}
			else if(topPos2 < self.topPos){
				self.nhayList = self.topPos - topPos2;
				if(self.nhayList > 0) self.nhayList += 1;
				self.move_objList('bottom');
			}
			self.topPos = topPos2;
		}
	};
	self.move_objList = function(ty) {
		if(ty == 'bottom'){	
			var len_2 = self.heightContent - self.heightGrab - self.objGrab.scrollTop;
			if(len_2 > 0){
				self.move_bottom();
			}
		}else if(ty == 'top'){
			self.move_top();
		}
	};
	self.move_bottom = function() {
		var len = self.heightContent - self.heightGrab;
		var scrollTop = self.objGrab.scrollTop;
		if(scrollTop < len){
			self.objGrab.scrollTop = scrollTop + self.nhayList;
		}
	};	
	self.move_top = function() {
		var scrollTop = self.objGrab.scrollTop;
		if (scrollTop > 0){
			self.objGrab.scrollTop = scrollTop - self.nhayList;
			if(self.objGrab.scrollTop < 0) self.objGrab.scrollTop = 0;
		}
	};	
}
function getRawObject(obj) {
	var isCSS = (document.body && document.body.style) ? true : false;
	var isW3C = (isCSS && document.getElementById) ? true : false;
	var isIE4 = (isCSS && document.all) ? true : false;
	var isNN4 = (document.layers) ? true : false;
	var isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	var theObj;
	if (typeof obj == "string") {
		if (isW3C) {
			theObj = document.getElementById(obj);
		} else if (isIE4) {
			theObj = document.all(obj);
		} else if (isNN4) {
			theObj = seekLayer(document, obj);
		}
	} else {
		// pass through object reference
		theObj = obj;
	}
	return theObj;
}
function pathToTheme() {
	var path = "";
	var url = window.location.href;
	var last = url.lastIndexOf("/");
	if(last != -1){
		path = url.substring(0, last);	
	}else path = url;
	return path;
}
function findPosLeft(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (1) {
			curleft+=obj.offsetLeft;
			if (!obj.offsetParent) {
				break;
			}
			obj=obj.offsetParent;
		}
	} else if (obj.x) {
		curleft+=obj.x;
	}
	return curleft;
}
function findPosTop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (1) {
			curtop+=obj.offsetTop;
			if (!obj.offsetParent) {
				break;
			}
			obj=obj.offsetParent;
		}
	} else if (obj.y) {
		curtop+=obj.y;
	}
	return curtop;
}
function addEventHandler(element, type, func) { //unfortunate hack to deal with Internet Explorer's horrible DOM event model <iehack>
	if(element.addEventListener) {
		element.addEventListener(type,func,false);
	}
	else if (element.attachEvent) {
		element.attachEvent('on'+type,func);
	}
}
//-----------------------------------------------------------------------------
function removeEventHandler(element, type, func) { //unfortunate hack to deal with Internet Explorer's horrible DOM event model <iehack>
	if(element.removeEventListener) {
		element.removeEventListener(type,func,false);
	}
	else if (element.attachEvent) {
		element.detachEvent('on'+type,func);
	}
}
