// image rollover, based on togglebutton class from javascript the definitive guide 3rd edition.
// (C) john pye 2002.

function Rollover(document,w,h,active,normal,url,onmouseover,onmouseout,imgattribs,adjtext){

	if(document==null)return;

	if(!url)url="";
	if(!adjtext)adjtext="";
	if(!imgattribs)imgattribs="";
	
	this.width=parseInt(w);
	this.height=parseInt(h);
	
	this.over=Rollover_over;
	this.out=Rollover_out;
	
	if(onmouseover){
		this.onmouseover=onmouseover;
		if(typeof this.onmouseover=="string")
			this.onmouseover=new Function("state",this.onmouseover);
	}
	//this.onmouseover("1");
	
	if(onmouseout){
		this.onmouseout=onmouseout;
		if(typeof this.onmouseout=="string")
			this.onmouseout=new Function("state",this.onmouseout);
	}
	
	this.images=new Array();
	this.imagenames=new Array();
	
	this.loadimage=Rollover_loadimage;
	
	this.loadimage(0,normal);
	this.loadimage(1,active);
	
	this.document=document;
	
	this.highlighted=false;
		
	var index=document.images.length;
	
	document.write('<a href="'+url+'" '+' onmouseover="document.images['+index+']._Rollover.over();return true;" onmouseout="document.images['+index+']._Rollover.out();return true;">');
	
	document.write('<img src="'+this.imagenames[0] +'"');
	
	if(this.width)document.write(' width='+this.width);
	if(this.height)document.write(' height='+this.height);
	
	if(imgattribs)document.write(' '+imgattribs);
	
	document.write('>');
	
	document.write(adjtext+"</a>");
	
	this.image=document.images[index];
	
	if(!this.image)alert("Netscape 6 error: rollover can not be first image on page");
	
	this.image._Rollover=this;
}

function Rollover_over(){
	this.image.src=this.imagenames[1];
	this.highlighted=true;
	if(this.onmouseover){
		this.onmouseover(this.highlighted);
	}
}

function Rollover_out(){
	this.image.src=this.imagenames[0];
	this.highlighted=false;
	if(this.onmouseout){
		this.onmouseout(this.highlighted);
	}
}

function Rollover_loadimage(index,url){
	this.imagenames[index]=url;
	this.images[index]=new Image(this.width,this.height);
	this.images[index].src=url;
}