// JavaScript Document
var tempObj = null;
var tempChild1 = null;
var tempSpace = null;
var tempScroll = null;
var tempTimer = null;
var tempDir = 'left';
var Fn = function(){}
Fn.prototype={
	init:function(parentElem,space,interval){
		this.parentElem = parentElem;
		this.space = space;
		this.interval = interval;
		this.obj = document.getElementById(this.parentElem);
		this.innerDiv = this.obj.getElementsByTagName("div")[0];
		this.childObj1 = this.obj.getElementsByTagName("ul")[0];
		this.childObj2 = document.createElement("ul");
		tempObj = this.obj;
		tempChild1 = this.childObj1;
		tempSpace = this.space;
		tempScroll = this.scroll;
		this.innerDiv.appendChild(this.childObj2);
		if(this.childObj1.offsetWidth>=this.obj.offsetWidth){
			this.childObj2.innerHTML = this.childObj1.innerHTML;
			tempTimer  = setInterval(tempScroll,this.interval);
		}
	},
	scroll:function(){
		if(tempDir=='left'){
			if(tempObj.scrollLeft>=tempChild1.offsetWidth){
					tempObj.scrollLeft -= tempChild1.offsetWidth;
				}else{
					tempObj.scrollLeft += tempSpace;
				}
		}
		else{
			if(tempObj.scrollLeft<=0){
					tempObj.scrollLeft += tempChild1.offsetWidth;
				}else{
					tempObj.scrollLeft -= tempSpace;
				}
		}
	},
	stop:function(){
		clearInterval(tempTimer);
        tempTimer=null;
	},
	start:function(){
		if(tempTimer != null){clearInterval(tempTimer);tempTimer = null;}
		if(tempTimer == null)
			tempTimer = setInterval(tempScroll,this.interval);
	}
}

var scrollImg = new Fn();
scrollImg.init("picshow",1,20);
/*document.getElementById('scrollLeftBtn').onmousedown = function()
{
	tempDir='left';
	this.style.marginTop = "1px";
			this.style.marginLeft = "1px";
			this.style.marginBottom = "";
			this.style.marginRight = "";
}
document.getElementById('scrollLeftBtn').onmouseout = document.getElementById('scrollLeftBtn').onmouseup = function(){
	this.style.marginTop = "";
			this.style.marginLeft = "";
			this.style.marginBottom = "1px";
			this.style.marginRight = "1px";
	}

document.getElementById('scrollRightBtn').onmousedown = function()
{
	tempDir='right';
	this.style.marginTop = "1px";
			this.style.marginLeft = "1px";
			this.style.marginBottom = "";
			this.style.marginRight = "";
}
document.getElementById('scrollRightBtn').onmouseout = document.getElementById('scrollRightBtn').onmouseup = function(){
	this.style.marginTop = "";
			this.style.marginLeft = "";
			this.style.marginBottom = "1px";
			this.style.marginRight = "1px";
	}*/

scrollImg.obj.onmouseover = function(){
				clearInterval(tempTimer);
				tempTimer=null;
			};
scrollImg.obj.onmouseout = function(){
	if(tempTimer != null){clearInterval(tempTimer);tempTimer=null;}
	if(tempTimer==null)
		tempTimer = setInterval(tempScroll,scrollImg.interval);
};
