PICSCROLL = function () {
	this.speed = 4;
	this.pos = 0;
	this.newpos;
	this.current = 1;
	this.record = 1;
	this.playing = false;
	this.moving = false;
	this.moveMe;
	this.changeMe;
	this.imgobj;
	this.createItems = function() {
		var img = '';
		var temp;
		for(var i=1; i <= picimg.record; i++) {
			temp = picimg['item' + i];
			img += '<div class="picimg" id="picimg' + temp.id + '"><a href="' + temp.linkto + '"><img src="/images/featureditem/' + temp.img + '" width="500" height="250" alt="' + temp.title + '" /></a></div>';		}
		this.imgobj = this.getItem('picimgholder');
		if(this.pos != 0) this.setposition(this.pos);
		this.setText('picimgcontainer', img);
	}
	this.getItem = function(obj) {
		if(document.layers) {
			obj = (document.layers[obj] != undefined) ? document.layers[obj] : false;
		} else if (document.all && !document.getElementById) {
			obj = (document.all[obj] != undefined) ? document.all[obj] : false;
		} else {
			obj = (document.getElementById(obj) != undefined) ? document.getElementById(obj) : false;
		}
		if (!obj && !obj.style) obj.style = obj;
		return obj;
	}
	this.setText = function(obj, txt) {
		this.getItem(obj).innerHTML = txt;
	}
	this.play = function() {
		if(this.record > 1) {
			this.playing = true;
			if(!this.moving) this.playMe();
			return false;
		}
	}
	this.playMe = function() {
		this.changeMe = setTimeout(this.name + '.change();', 4500);
	}
	this.change = function() {
		clearTimeout(this.changeMe);
		var c = this.current + 1;
		if(c > this.record) c = 1;
		this.view(c);
	}
	this.pause = function() {
		clearTimeout(this.changeMe);
		this.playing = false;
		return false;
	}
	this.choose = function(i) {
		if(this.playing) this.pause();
		this.view(i);
		return false;
	}
	this.view = function(i) {
		this.getItem('picindicator').className = 'picindicator' + i;
		this.current = i;
		this.newpos = (i-1)*500;
		if(this.pos != this.newpos && !this.moving) this.move(i);
	}
	this.move = function() {
		this.pos += (this.newpos>this.pos) ? Math.ceil((this.newpos-this.pos)/this.speed) : Math.floor((this.newpos-this.pos)/this.speed);
		this.setposition(this.pos);
		if(this.pos != this.newpos) {
			this.moving = true;
			this.moveMe = setTimeout(this.name + '.move();', 20);
		} else {
			this.moving = false;
			if(this.playing) this.playMe();
		}
	}
	this.setposition = function(p) {
		this.imgobj.scrollLeft = p;
	}
}
picscroll = new PICSCROLL();
picscroll.name = 'picscroll';