// requires Prototype 1.6+

var Mouseover = {
	init: function() {
		var preloadList = new Array();
		
		var oThis = this;
		Element.descendants(document.body).each( function(elem) {
			if(elem.readAttribute('mosrc') != null) {

				elem.Cmosrc = elem.readAttribute('mosrc');
				elem.Csrc = elem.readAttribute('src');
				
				Event.observe(elem,'mouseover', oThis.handleMOver.bind(elem));
				Event.observe(elem,'mouseout', oThis.handleMOut.bind(elem));
				
				preloadList.push(elem.Cmosrc);
				
			}
		})
		
		preloadList.each(this.preloadImage);
		
	},
	handleMOver: function() {
		this.src = this.Cmosrc;
	},
	handleMOut: function() {
		this.src = this.Csrc;
	},
	preloadImage: function(imgsrc) {
		
		(function() {
		
			var img = new Element('IMG',{'src': imgsrc, 'width' : 1, 'height': 1});
			
			img.setOpacity(0);
			
			img.setStyle({ position: 'absolute', top: '0px', left: '0px', 'z-index': '0' });
	
			document.body.insert(img, {position: 'bottom'});
			
		}).defer();
	}
}


Event.observe(document,'dom:loaded',function() {

	Mouseover.init();

});
