//alert('mouseover.js');

var main = top.main;

var loaded = false;

var p_whoswho="";


//***Start Define Selector() and methods

function _add_image(imgname) {
	if (typeof(imgname) == "undefined") return;
	this[imgname] = new Object();
	this[imgname].on = new Image();
	this[imgname].off = new Image();
	this[imgname].over = new Image();
	this[imgname].status = "";
	
	this.names[this.names.length] = imgname; //reverse index
	this[imgname].rIdx = this.names.length;
}

function _reset_images() {
	for (var i=0;i<this.names.length;i++) {
		document.images[this.names[i]].src = this[this.names[i]].off.src
	}	
}

function imgObj(im)
{
	if (document.layers)
		return document.layers['body'].document.images[im]
	return eval("document."+im);
}

function _image_over(imgname) {
	if (typeof(imgname) == "undefined") return;
	if (imgname == this.selected) return;
	if (typeof(imgObj(imgname)) == "undefined") {
		alert("1 no img defined with this name:" + imgname)
	} else {
		imgObj(imgname).src = this[imgname].over.src
	}
}

function _image_out(imgname) {
	if (typeof(imgname) == "undefined") return;
	if (imgname == this.selected) return;
	if (typeof(imgObj(imgname)) == "undefined") {
		alert("2 no img defined with this name:" + imgname)
	} else {
		imgObj(imgname).src = this[imgname].off.src
	}
}

function _image_select(imgname) {
	if (typeof(imgname) == "undefined") return;
	if (imgname == this.selected) return;
	if (typeof(document.images[imgname]) == "undefined") {
		alert("no img defined with this name:" + imgname)
	} else {
		if (this.selected != "") document.images[this.selected].src = this[this.selected].off.src
		document.images[imgname].src = this[imgname].on.src
	}
	this.selected = imgname;
	this.selectedIdx = this[imgname].rIdx;
}


function Selector() {
	this.names = new Array();
	this.status="";
	this.selected = "";
	this.selectedIdx = -1;
}
new Selector();
Selector.prototype.AddImage = _add_image;
Selector.prototype.ResetImages = _reset_images;
Selector.prototype.ImageOut = _image_out;
Selector.prototype.ImageOver = _image_over;
Selector.prototype.ImageSelect = _image_select;
//***End Define Selector() and methods


var navs = new Selector();
with (navs) {

	AddImage("about");
	about.on.src="icns/about_on.gif";
	about.off.src="icns/about_off.gif";
	about.over.src="icns/about_on.gif";
	about.status="About Melville Design";
	
	AddImage("public");
	public.on.src="icns/public_on.gif";
	public.off.src="icns/public_off.gif";
	public.over.src="icns/public_on.gif";
	public.status="Public Information";
	
	AddImage("private");
	private.on.src="icns/private_on.gif";
	private.off.src="icns/private_off.gif";
	private.over.src="icns/private_on.gif";
	private.status="Private Sector";
	
	AddImage("housing");
	housing.on.src="icns/housing_on.gif";
	housing.off.src="icns/housing_off.gif";
	housing.over.src="icns/housing_on.gif";
	housing.status="Housing Associations";
	
	AddImage("charity");
	charity.on.src="icns/charity_on.gif";
	charity.off.src="icns/charity_off.gif";
	charity.over.src="icns/charity_on.gif";
	charity.status="Charity Sector";
	
	AddImage("web");
	web.on.src="icns/web_on.gif";
	web.off.src="icns/web_off.gif";
	web.over.src="icns/web_on.gif";
	web.status="Web Design";
	
	AddImage("contact");
	contact.on.src="icns/contact_on.gif";
	contact.off.src="icns/contact_off.gif";
	contact.over.src="icns/contact_on.gif";
	contact.status="Contact Us";

}

function loadMain(page,imgname) {
	navs.ImageSelect(imgname);
	if (loaded==true) main.document.location.href=page;
}


var tempNav = null;
var tempSrc = null;

function keepOn(nav)
{
	if (tempNav != nav)
	{
		var swapper = eval("navs." + nav + ".off.src")
		eval ("navs." + nav + ".off.src = navs." + nav + ".on.src")
		if (tempNav != null)
		{
			eval ("navs." + tempNav + ".off.src = '" + tempSrc + "'")
			eval ("navs.ImageOut('" + tempNav + "')")
		}
		tempNav = nav
		tempSrc = swapper
	}
}

