
////////////////////////////////////
// HiliteImage
//
//   Example Usage:  (see cdma/leftPane.jsp)

/**
 * Create an image with a mouse over change
 */
function HiliteImage(img,hiliteSrc,onclick)
{
	var id;
	if(typeof(img) == 'string') {
		// Assume img is an id
		id = img;
		this.image = document.getElementById(id);
	} else {
		// img is an Image
		this.image = img;
		id = img.id;
	}
	
	this.id = id;
	this.image.onmouseover=function() { HiliteImage.all[id].onmouseover(); };
	this.image.onmouseout=function() { HiliteImage.all[id].onmouseout(); };
	
	if(typeof(onclick) == "function") {
		this.onclick_callback=onclick;
		this.image.onclick=function() { HiliteImage.all[id].onclick(); };
	}

	this.img1 = new Image();
	this.img1.src = this.image.src;
	
	this.img2 = new Image();
	this.img2.src = hiliteSrc;
	
	HiliteImage.all[id]=this;
}

HiliteImage.all = new Array();

HiliteImage.createImages=function(divTagId,onclick,extension) {
	var images = new Array();
	var imgsInDiv = document.getElementById(divTagId).getElementsByTagName('IMG');
	for(var i = 0; i < imgsInDiv.length;i++) {
		var img = imgsInDiv[i];
		if(typeof(img.id) == "undefined" || isBlank(img.id) )
			continue;
		var index = img.src.lastIndexOf(".");
		var srcOn = img.src.substr(0,index) + extension + img.src.substr(index);
		
		images[images.length]=new HiliteImage(img,srcOn,onclick);
	}
	return images;
}

HiliteImage.prototype.hilite=function()
{
	this.image.src = this.img2.src;
	this.img1 = null;
	this.img2 = null;
}

HiliteImage.prototype.onmouseover=function()
{
	if(this.img1 == null)
		return;
		
	this.image.src = this.img2.src;
	if(typeof(this.image.alt) != "undefined")
		window.status = this.image.alt;
}

HiliteImage.prototype.onmouseout=function()
{
	if(this.img1 == null)
		return;
		
	this.image.src = this.img1.src;
	window.status = "";
}

HiliteImage.prototype.onclick=function()
{
	this.onclick_callback(this);
}



