var W3CDOM = (document.createElement && document.getElementsByTagName);

var mouseOver = new Array();
var mouseOut = new Array();

var z = 0;

function init() {
	if (!W3CDOM) return;
	attachjs('menu');
	checkheight();
}

function attachjs(element) {
	var menu = document.getElementById(element);
	var img = menu.getElementsByTagName('img');
	
	/*for (i=0; i<img.length; i++) {
		if (!img[i].src.match("_over") && !img[i].src.match("seperator")) {
			img[i].onmouseover = swapon;
			img[i].onmouseout = swapoff;
			
			var suffix = img[i].src.substring(img[i].src.lastIndexOf('.'));
			mouseOut[z] = new Image();
			mouseOut[z].src = img[i].src;
			mouseOver[z] = new Image();
			mouseOver[z].src = img[i].src.substring(0,img[i].src.lastIndexOf('.')) + "_over" + suffix;
			img[i].number = z;
			z++;
		}
	}*/
}

function swapon() {
	this.src = mouseOver[this.number].src;
}

function swapoff() {
	this.src = mouseOut[this.number].src;
}

var loop;

function checkheight() {
	var maxheight = '250';
	
	var full = document.getElementById('fullcontent');
	var scroll = document.getElementById('scroll');

	scroll.style.visibility = 'hidden';
	return;
	if (full.offsetHeight > maxheight) {
		scroll.style.visibility = 'visible';
		loop = new TextScroll('loop','content','up','down');
	} else
		scroll.style.visibility = 'hidden';
}

function TextScroll(scrollname, div_name, up_name, down_name) {
	this.div_name = div_name;
	this.name = scrollname;
	this.scrollCursor = 0;
	this.speed = 8;
	this.timeoutID = 0;
	this.div_obj = null;
	this.up_name = up_name;
	this.dn_name = down_name;
	
	{
		if (document.getElementById) {
			div_obj = document.getElementById(this.div_name);
			if (div_obj) {
				this.div_obj = div_obj;
				this.div_obj.style.overflow = 'hidden';
			}
			div_up_obj = document.getElementById(this.up_name);
			div_dn_obj = document.getElementById(this.dn_name);
			if (div_up_obj && div_dn_obj) {
				div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") };
				div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
				
				div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") };
				div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
         }
     }
	}

	this.stopScroll = function() {
		clearTimeout(this.timeoutID);
	}

	this.scrollUp = function() {
		if (this.div_obj) {
			this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
			this.div_obj.scrollTop = this.scrollCursor;
			this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
		}
	}

	this.scrollDown = function() {
		if (this.div_obj) {
			this.scrollCursor += this.speed;
			this.div_obj.scrollTop = this.scrollCursor;
			if (this.div_obj.scrollTop == this.scrollCursor)
				this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
			else
				this.scrollCursor = this.div_obj.scrollTop;
		}
	}

	this.resetScroll = function() {
		if (this.div_obj) {
			this.div_obj.scrollTop = 0;
			this.scrollCursor = 0;
		}
	}
}
