var SmartAlt = {
	alt: false,
	
	show: 0,
	hide: 0,
	
	showIdx: 0,
	hideIdx: 0,
	
	
	InitEvents: function(child){
		var div = child.getElementsByTagName('div');
		
		if( div ){
			if( child.childNodes[0].nodeType == 1 )
				child = child.childNodes[0];
			child.__smartalt = div[0];
			
			addListener(child, 'onmouseover', this.ShowAlt);
			addListener(child, 'onmouseout', this.HideAlt);
			
			addListener(document.body, 'onmousemove', this.Move);
		}
	}, // InitEvents();
	
	
	Move: function(e){
		if( typeof SmartAlt == 'undefined' ) return;
		
		if( SmartAlt.alt ){
			SmartAlt.alt.style.left = (e.X || e.clientX)+10;
			SmartAlt.alt.style.top = (e.Y || e.clientY)+10 + document.body.scrollTop;
		}
	}, // Move();
	
	
	Find: function(elm){
		do{
			if( elm.__smartalt )
				return elm
		} while( elm = elm.parentNode );
		
		return false;
	}, // Find()
	
	
	ShowAlt: function(e){
		var elm = SmartAlt.Find(e.target || e.srcElement);
		
		clearTimeout(SmartAlt.timeIdx);
		if( elm.__smartalt ){
			SmartAlt.alt = elm.__smartalt;
			SmartAlt.Move(e);
			SmartAlt.showIdx = setTimeout("SmartAlt.alt.style.display = 'block';", SmartAlt.show);
		}
	}, // ShowAlt();
	
	
	HideAlt: function(e){
		clearTimeout(SmartAlt.showIdx);
		clearTimeout(SmartAlt.hideIdx);

		if( SmartAlt.alt ){
			SmartAlt.alt.style.display = '';
			SmartAlt.alt = false;
		}
	}, // ShowAlt();
	
	
	Init: function(show, hide){
		var childs = document.getElementsByClassName('SmartAlt');
		
		this.show = show > 0 ? show : 0;
		this.hide = hide;

		for(var i = 0; i < childs.length; i++){
			this.InitEvents(childs[i]);
		}
	} // Init();
	
	
	
} // END: SmartAlt();


//js_isLoaded('smartalt.js');
