// file:              mouseover.js
// author:            Gabriel MacIsaac
// last modified:     Friday, April 14, 2000
// version:           1.4

var able,focused;
function onImageError(){
	this.error=true;
}
function loadImages(){
	if(!able)for(c=0;c<document.images.length;c++)if(document.images[c].name.charAt(0)=='!'){
		var file=document.images[c].src;
		var end=file.lastIndexOf('.');
		var ext=file.substring(end,file.length);
		var pre=file.substring(0,end);
		document.images[c].out=new Image();
		document.images[c].out.src=file;
		document.images[c].over=new Image();
		document.images[c].over.error=false;
		document.images[c].over.onerror=onImageError;
		document.images[c].over.onabort=onImageError;
		document.images[c].over.src=pre+'_over'+ext;
		document.images[c].click=new Image();
		document.images[c].click.error=false;
		document.images[c].click.onerror=onImageError;
		document.images[c].click.onabort=onImageError;
		document.images[c].click.src=pre+'_click'+ext;
	}
	able=1;
      if(self.onLoad)onLoad();
}self.onload=loadImages;
function over(a,imageName,statusText,windowInfo){
	//Create New Link Properies image and windowInfo
	if(!a.image)a.image=document[imageName];
	if(!a.windowInfo&&windowInfo)a.windowInfo=windowInfo;
	//Create onMouseOut and onClick Event Handlers
	if(!a.onmouseout)a.onmouseout=onMouseOut;
	if(!a.onclick)a.onclick=onClick;
	//Swap Image if the images have been loaded and this image is complete loading without error
	if(able&&a.image.over.complete&&!a.image.over.error)a.image.src=a.image.over.src;
	if(statusText){
		//Show Status Message
		self.status=statusText;
		//Create New Link Property Called status
		if(!a.status)a.status=true;
		return true;
	} else return false;
}
//out Function
function out(a){
	self.focused=null;
	//Swap Image if images have been loaded
	if(able)a.image.src=a.image.out.src;
	//Clear Status Message if one exists
	if(a.status)self.status='';
}
//onMouseOut Event Handler
function onMouseOut(){
	out(this);
}
//mouseclick Function
function mouseclick(a,windowInfo){
	//Remove focus from this link to get rid of dotted outline in IE
	if(a.blur)a.blur();
	//Swap Image if images have been loaded, image exists, and is complete loading without errors
	if(able&&a.image&&a.image.click.complete&&!a.image.click.error){
		a.image.src=a.image.click.src;
		self.focused=a.image;
		setTimeout('if(focused)focused.src=(able&&focused.over.complete&&!focused.over.error)?focused.over.src:focused.out.src;',250);
	}
	var follow=(a.href!='#');
	if(windowInfo&&windowInfo.indexOf('=')==-1){
		if(a.target&&a.target!='_top'&&a.target!='_parent'&&a.target!='_self'&&a.target!='_blank'){
			var targetFrame=windowInfo+'.'+a.target;
			//either focus across frames,
			if(eval(targetFrame))setTimeout(targetFrame+'.focus();',0);
			//or give error message in status bar
			else self.status='Error: Frame "'+targetFrame+'" doesn`t exist. Check your code.';
		}
	} else {
		if(a.target=='_blank'&&windowInfo){
			//create blank window with special window options (toolbars=no,etc...)
			if(follow)window.open(a.href,'_blank',windowInfo);
			follow=false;
		}
		else if(a.target&&a.target!='top'&&a.target!='_parent'&&a.target!='_self'&&a.target!='_blank'){
			//create a window where window reference is the same as the window name
			eval('self.'+a.target+'=window.open("",a.target'+((windowInfo)?',windowInfo)':')'));
			setTimeout(a.target+'.focus();',0);
		}
	}
	return follow;
}
//onClick Event Handler
function onClick(){
	return mouseclick(this,this.windowInfo);
}