//   w3cdom image swapper
//
//   2002 by andreas hucks (post@andreashucks.de)
//   modified for cdu-dortmund.de 2004



function ImageSwapper() {
	
	this.images = new Array();

}



ImageSwapper.instance = null;
	
	
	
ImageSwapper.getInstance = function() {

	if (ImageSwapper.instance != null) {
		return ImageSwapper.instance;
	} else {
		return new ImageSwapper();
	}

}



ImageSwapper.prototype.addImage = function(id) {
	
	var tmpImg = document.getElementById(id);
	var allLinks = document.getElementsByTagName("A");
	
	var fileName = tmpImg.src;
	var fileExt = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
	fileBase = fileName.substring(0, fileName.lastIndexOf("_"));

	this.images[id] = new Array();
	this.images[id]["on"] = new Image();
	this.images[id]["on"].src = fileBase + "_on." + fileExt;
	this.images[id]["off"] = new Image();
	this.images[id]["off"].src = fileName;
	//tmpImg.parentNode.onmouseover = function() { ImageSwapper.getInstance().on(this.firstChild.id) };
	//tmpImg.parentNode.onmouseout = function() { ImageSwapper.getInstance().off(this.firstChild.id) };
	for (var j = 0; j < allLinks.length; j++) {
		if (allLinks[j].id == id) {
			allLinks[j].onmouseover = function() { ImageSwapper.getInstance().on(this.id) };
			allLinks[j].onmouseout = function() { ImageSwapper.getInstance().off(this.id) };
		}
	}
	
	ImageSwapper.instance = this;

}



ImageSwapper.prototype.autoInit = function() {

	var allImages = document.getElementsByTagName("IMG");
	
	for (var i = 0; i < allImages.length; i++) {
		var tmpID = allImages[i].id;
		if (tmpID.substring(0, tmpID.indexOf("_")) == "swap") {
			this.addImage(tmpID);
		}
	}

}



ImageSwapper.prototype.on = function(id) {

	document.getElementById(id).src = this.images[id]["on"].src;
	return true;

}



ImageSwapper.prototype.off = function(id) {

	document.getElementById(id).src = this.images[id]["off"].src;
	return true;

}



// -----------------------------------------------------------



function doJump(url, selectElement) {

	if (selectElement.value != -1) {
		document.location = url + selectElement.value;
	}

}

