/*==================================================================

	File_name    : common.js
	Description  : put your custom js here
	Version      : 1.00 
	The date     : 2007.12.10
	
	index /////////////////////////////////////////////////////

		-- addEvent
		
		-- rollover 

	//////////////////////////////////////////////////////////

================================================================== */

/*==================================================================
addEvent
================================================================== */

function addEvent(elm, evType, func, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, func, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, func);
		return r;
	} else {
		elm['on' + evType] = func;
	}
}


/*==================================================================
rollover 
================================================================== */
function initRollovers() {
	if (!document.getElementById) return;
	
	var overPath = "_over";	
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, overPath+ftype);
			//hsrc = 'over' + hsrc;

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace(overPath+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

addEvent(window, 'load', initRollovers, false);
//window.onload = initRollovers;