// 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);
		}
	}


oldSlideShow = {
	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);
	}
};

// SlideShow Class used to rotate thru banners.
SlideShow = {
	currentimg:1,
	timer:null,
	imgcnt:2,
	idPrefix:"pict",
	isRndm:false,
	timeout:5000,
	menuItems:null,
	linkid:null,
	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);
	},
	showPic: function(picnum) {
		this.stoptimer();
		next=picnum;
		if (next < 1) next = this.imgcnt;
		if (next > this.imgcnt) next = 1;
		if (next == this.currentimg) return;
		this.display(next, this.currentimg);
	},
	stoptimer: function() {
		if (this.timer != null) {
			clearTimeout(this.timer);
			this.timer = null;
		}
	},
	start: function(prefix, timeout, rndm, linkid) {
		this.idPrefix = prefix;
		this.timeout = timeout;
		this.imgcnt = 0;
		this.timer="start";
		this.menuItems = new Array();
		if (linkid != "undefined") this.linkid = document.getElementById(linkid);
		while (document.getElementById(this.idPrefix + (this.imgcnt + 1))) {
			var picDiv = document.getElementById(this.idPrefix + (this.imgcnt + 1));
			/* Initialize the object
			for (var i=0; i<picDiv.childNodes.length; i++) {
				var aTag = picDiv.childNodes[i];
				if (aTag.nodeName == "A") {
					for (var j=0; j<aTag.childNodes.length; j++) {
						var ele = aTag.childNodes[j];
						if (ele.nodeName == "IMG") {
							for (var k=0; k<ele.attributes.length; k++) {
								var attr = ele.attributes[k];
								if (attr.nodeName == "alt") this.menuItems.push(attr.nodeValue);
							}
						}
					}
				}
			}*/
			this.imgcnt++;
		}
		if (rndm) {
			this.isRndm = true;
			disp = this.rndm(0);
			this.display(this.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;
	},
	showMenu: function() {
		if (this.linkid != null) {
			// First Clear the menu
			for (var i=this.linkid.childNodes.length-1; i>=0; i--) {
				this.linkid.removeChild(this.linkid.childNodes[i]);
			}
			// Now Add them
			for (i = 0; i < this.menuItems.length; i++) {
				li_ele = document.createElement("li");
				a_ele = document.createElement("a");
				a_ele.setAttribute("href", "javascript:SlideShow.showPic("+(i+1)+")");
				if (i == this.currentimg - 1) a_ele.className="current";
				a_ele.appendChild(document.createTextNode(this.menuItems[i]));
				li_ele.appendChild(a_ele);
				this.linkid.appendChild(li_ele);
			}
		}
	},
	display: function(on, off) {
		this.currentimg = on;
		this.showMenu();
		var pon = document.getElementById(this.idPrefix + on);
		//pon.style.right = "0px"
		pon.style.opacity = 100;
		//if (pon.style.filter) 
		pon.style.filter = 'alpha(opacity=100)';
		var poff = document.getElementById(this.idPrefix + off);
		//poff.style.right = "6000px"
		poff.style.opacity = 0;
		//if (poff.style.filter) 
		poff.style.filter = 'alpha(opacity=0)';
		if (this.isRndm) {
			next = this.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);
	}
	
};


var fadeEffect=function(){
    return{
        init:function(id, flag, target){
            this.elem = document.getElementById(id);
            clearInterval(this.elem.si);
            this.target = target ? target : flag ? 100 : 0;
            this.flag = flag || -1;
            this.alpha = this.elem.style.opacity ? parseFloat(this.elem.style.opacity) * 100 : 0;
            this.si = setInterval(function(){fadeEffect.tween()}, 20);
        },
        tween:function(){
            if(this.alpha == this.target){
                clearInterval(this.elem.si);
            }else{
                var value = Math.round(this.alpha + ((this.target - this.alpha) * .05)) + (1 * this.flag);
                this.elem.style.opacity = value / 100;
                this.elem.style.filter = 'alpha(opacity=' + value + ')';
                this.alpha = value
            }
        }
    }
}();
//fadeEffect.init('fade', 1)
