// JavaScript Document
	// Preload Images
	var myimages = new Array();
	var imagedir = "images/";
	function preloadimgs(){
		if (document.images)
		{
			var arrlen = myimages.length;
			for (var x=0; x<arguments.length; x++){
				myimages[x + arrlen] = new Image();
				myimages[x + arrlen].src = imagedir + arguments[x];
			}
		}
	}
	//preloadimgs("main-buttonover-tile.gif","main-button-tile.gif");
	
	function menuclass() {
		for (var x=0; x<arguments.length; x++){
			ele = document.getElementById(arguments[x]);
			ele.className += (ele.className ? " " : "") + "currentmenu";
			for (var i=0; i<ele.childNodes.length; i++) {
				aele = ele.childNodes[i];
				if (aele.nodeName == "A") 
					aele.className += (aele.className ? " " : "") + "currentmenu";
			}
		}
	}
	
	function evtObserve(element, name, observer, useCapture) {
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (element.addEventListener) {
			element.addEventListener(name, observer, useCapture);
		} else if (element.attachEvent) {
			element.attachEvent('on' + name, observer);
		}
	}


SlideShow = {
	currentimg:1,
	timer:null,
	imgcnt:2,
	idPrefix:"pict",
	isRndm:false,
	timeout:5000,
	next: function() {
		this.stoptimer();
		next=this.currentimg + 1;
		if (next > this.imgcnt) next = 1;
		this.display(next, this.currentimg);
	},
	prev: function() {
		this.stoptimer();
		next=this.currentimg - 1;
		if (next < 1) next = this.imgcnt;
		this.display(next, this.currentimg);
	},
	stoptimer: function() {
		if (this.timer != null) {
			clearTimeout(this.timer);
			this.timer = null;
		}
	},
	start: function(prefix, timeout, rndm) {
		this.idPrefix = prefix;
		this.timeout = timeout;
		this.imgcnt = 0;
		this.timer="start";
		while (document.getElementById(this.idPrefix + (this.imgcnt + 1))) this.imgcnt++;
		if (rndm) {
			this.isRndm = true;
			disp = rndm(0);
			this.display(rndm(disp), disp);
		} else {
			this.isRndm = false;
			this.display(1, 2);
		}
	},
	rndm: function(ignore) {
		rnd = ignore;
		while (rnd == ignore) {
			rnd = Math.ceil(Math.random() * this.imgcnt);
		}
		return rnd;
	},
	display: function(on, off) {
		this.currentimg = on;
		var pon = document.getElementById(this.idPrefix + on);
		pon.style.left = "0px"
		var poff = document.getElementById(this.idPrefix + off);
		poff.style.left = "-5000px"
		if (this.isRndm) {
			next = rndm(on);
		} else {
			next = on + 1;
			if (next > this.imgcnt) next = 1;
		}
		if (this.timer != null)
			this.timer = setTimeout('SlideShow.display('+next+','+on+');', this.timeout);
	}
};
