// $Id: img.js,v 1.1.1.1 2005/11/17 16:06:11 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 = '';
	}
}

var home_current_id;
var home_current_click_id;
home_current_id = 0;
home_current_click_id = 0;

function home_over(id) {
	if ( (home_current_id != 0) && (home_current_id != id) ) {
		home_out();
	}
	if ( (home_current_click_id != 0) && (home_current_click_id != id) ) {
		home_click_out();
	}
	document.getElementById("homebox" + id).style.display = "block";
	document.getElementById("homeimg" + id).style.visibility = "visible";
	home_current_id = id;
}

function home_click(id) {
	document.getElementById("homebox" + id).style.display = "block";
	document.getElementById("homeimg" + id).style.visibility = "visible";
	home_current_click_id = id;
}

function home_out() {
	if (document.getElementById("homebox" + home_current_id) && (home_current_click_id != home_current_id)) {
		document.getElementById("homebox" + home_current_id).style.display = "none";
		document.getElementById("homeimg" + home_current_id).style.visibility = "hidden";
		home_current_id = 0;
	}
	if (home_current_click_id != 0) {
		home_click(home_current_click_id);
	}
}

function home_click_out() {
	if (document.getElementById("homebox" + home_current_click_id)) {
		document.getElementById("homebox" + home_current_click_id).style.display = "none";
		document.getElementById("homeimg" + home_current_click_id).style.visibility = "hidden";
		//home_current_click_id = 0;
	}
}