/********************************************************
NiceAlt by flep (based on "HoverHelp" script)
Date: 08/09/2005
Bug iE fixed in 26/10/2005
Auto Resolution Position add in 26/10/2005

Music: Blaze feat Barbara Tucker - Most Precious Love (Dennis Ferrer's Future 3000 Mix)

flep comments:
Is it no good?
Ok, i'm just a designer, not a programmer! >P

Ah, if accidentally altContets has a word for line in iE, u need to place altContents out of div's.
iE bug >P
********************************************************/
document.getElementsByClassName = function (needle){
	var my_array = document.getElementsByTagName("*");
	var retvalue = new Array();
	var i;
	var j;
	for (i = 0, j = 0; i < my_array.length; i++){
		var c = " " + my_array[i].className + " ";
		if (c.indexOf(" " + needle + " ") != -1)
      	retvalue[j++] = my_array[i];
	}
	return retvalue;
}
function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}
function viewAlt(){
	this._mousePosX = 0;
	this._mousePosY = 0;
	this._hoverItem = null;
	this._hoverContents = null;
}
viewAlt.prototype.init = function(){
	var af = this;
	var altItems = document.getElementsByClassName('altFloat');
	for (var i=0; i<altItems.length; i++){
		altItems[i].onmousemove = function(e){
			if (!e) var e = window.event;
			if (e.pageX || e.pageY){
				af.mousePosX = e.pageX;
				af.mousePosY = e.pageY;
			} else if (e.clientX || e.clientY){
				af.mousePosX = e.clientX + document.documentElement.scrollLeft;
				af.mousePosY = e.clientY + document.documentElement.scrollTop;
			}
			af._hoverItem = this;
			af._hoverContents = document.getElementById(this.id+'alt');
			af.move();
		}
		altItems[i].onmouseout = function (e){
			af.out();
		}
	}
}
viewAlt.prototype.out = function(){
	this._hoverContents.style.display = "none";
	this._hoverItem = null;
	this._hoverContents = null;
}
viewAlt.prototype.move = function(){
	this._hoverContents.style.display = "inline";
	//alert(document.documentElement.scrollTop+"-"+this.mousePosY);
	if (this.mousePosX + this._hoverContents.offsetWidth > document.body.offsetWidth - 10){
		this._hoverContents.style.left = this.mousePosX - this._hoverContents.offsetWidth +'px';			
	} else {
		this._hoverContents.style.left = this.mousePosX +10 +'px';
	}
	if (this.mousePosY + this._hoverContents.offsetHeight > document.body.offsetHeight - 20){
		this._hoverContents.style.top = this.mousePosY - this._hoverContents.offsetHeight +'px';
	} else {
		this._hoverContents.style.top = this.mousePosY+20+'px';
	}
}
addEvent(window, 'load', function(){
	var af = new viewAlt();
	af.init();
});
