
// $Id: img.js,v 1.1.1.1 2005/10/04 07:21:43 jss Exp $

document.img_temp = '';
document.img_active = '';


function img_load_normal(url, name, istatus) {
	img_load('img_normal', url, name, istatus);
}

function img_load_over(url, name, istatus) {
	img_load('img_over', url, name, istatus);
}

function img_load_click(url, name, istatus) {
	img_load('img_click', url, name, istatus);
}

function img_load(img_type, url, name, istatus) {
	if (document[img_type] == null)
		document[img_type] = new Array();

	if (document[img_type][name] == null) {
		document[img_type][name] = new Image();
		document[img_type][name].src = url;
		document[img_type][name].istatus = istatus;
	}
}


function img_swap_over(name) {
	if (document.images[name] != null) 
		img_load_normal(document.images[name].src, name, '');
	img_swap('img_over', name);
	document.img_temp = name;
}

function img_swap_click(name) {
	if (document.img_active != name) {
		img_swap('img_click', name);
		document.img_active = name;
	}
}

function img_swap(img_type, name) {
	if (document[img_type] && (document[img_type][name] != null) && (document.images[name] != null) ) {
		document.images[name].src = document[img_type][name].src;
		window.status = document[img_type][name].istatus;
	}
	else if (document[img_type] && (document[img_type][name] != null) ) {
		for (i = 0; i < document.forms.length; i++) {

		//alert(document.forms[i][name]);
			if (document.forms[i][name] != null) {
				alert(1);
				document.forms[i][name].src = document[img_type][name].src;
				window.status = document[img_type][name].istatus;
			}
		}
	}
}

function img_swap_out() {
	if (document.img_active == document.img_temp) {
		img_swap('img_click', document.img_temp);
	}
	else {
		img_swap('img_normal', document.img_temp);
		document.img_temp = '';
	}
}

	function verifyCompatibleBrowser(){
		this.ver = navigator.appVersion;
		this.dom = document.getElementById ? 1 : 0;
		this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom) ? 1 : 0;
		this.ie4 = (document.all && !this.dom) ? 1 : 0;
		this.ns5 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
		this.ns4 = (document.layers && !this.dom) ? 1 : 0;
		this.bw = (this.ie5 || this.ie4 || this.ns4 || this.ns5)
		return this
	}
	bw = new verifyCompatibleBrowser()
	var speed = 80
	var loop, timer
	function ConstructObject(obj, nest) {
		nest = (!nest) ? '' : 'document.' + nest + '.';
		this.el = bw.dom ? document.getElementById(obj) : bw.ie4 ? document.all[obj] : bw.ns4 ? eval(nest+'document.' + obj) : 0;
		this.css = bw.dom ? document.getElementById(obj).style : bw.ie4 ? document.all[obj].style : bw.ns4 ? eval(nest+'document.' + obj) : 0;
		this.scrollHeight = bw.ns4 ? this.css.document.height : this.el.offsetHeight;
		this.clipHeight = bw.ns4 ? this.css.clip.height : this.el.offsetHeight;
		this.up = MoveAreaUp;
		this.down = MoveAreaDown;
		this.MoveArea = MoveArea;
		this.x;
		this.y;
		this.obj = obj + "Object";
		eval(this.obj + " = this");
		return this;
	}
	function MoveArea(x,y) {
		this.x = x;
		this.y = y;
		this.css.left = this.x + 'px';
		this.css.top = this.y + 'px';
	}
	function MoveAreaDown(move) {
		if (this.y > ( (-1 * parseInt(this.scrollHeight)) + parseInt(objContainer.clipHeight) ) ) {
			this.MoveArea(0, this.y - move);
		if (loop)
			setTimeout(this.obj + ".down(" + move + ")", speed);
		}
	}
	function MoveAreaUp(move) {
		if (this.y < 0) {
			this.MoveArea(0, this.y - move);
			if (loop)
				setTimeout(this.obj + ".up(" + move + ")", speed);
		}
	}
	function PerformScroll(speed) {
		if(initialised) {
			loop = true;
			if (speed > 0)
				objScroller.down(speed);
			else
				objScroller.up(speed);
		}
	}
	function CeaseScroll() {
		loop = false;
		if (timer)
			clearTimeout(timer);
	}
	var initialised;
	function InitialiseScrollableArea() {
		objContainer = new ConstructObject('iframeContainer');
		objScroller = new ConstructObject('content','iframeContainer');
		objScroller.MoveArea(0,0);
		initialised = true;
		if (objScroller.y <= ( (-1 * parseInt(objScroller.scrollHeight)) + parseInt(objContainer.clipHeight) ) ) {
			if (bw.dom) {
				document.getElementById("iframeUp").style.visibility = 'hidden';
				document.getElementById("iframeDown").style.visibility = 'hidden';
			}
			if (bw.ie4) {
				document.all["iframeUp"].style.visibility = 'hidden';
				document.all["iframeDown"].style.visibility = 'hidden';
			}
			if (bw.ns4) {
				document.layers["iframeUp"].visibility = 'hidden';
				document.layers["iframeDown"].visibility = 'hidden';
			}
		}
		else {
			img_load_over('images/up.gif','iframe_up','');
			img_load_over('images/down.gif','iframe_down','');
		}
		objContainer.css.visibility = 'visible';
		initialised = true;
	}