﻿/*
//    NTREEV Nate icon viewer (2008.11.05)
*/

// Nate email icon viewer
// privileged method 생성방식을 이용한 객체별 아이콘 뷰어 작동 함수
 function nateIconViewer(obj) {

	var img = document.createElement('img');	// element 생성

	// style 설정
	img.style.zIndex = '50';
	img.style.position = 'absolute';
	img.style.margin = '0';
	img.src = obj.src.replace('.gif','_over.gif');
	img._alpha = 0;
	img._target = 0;
	img._timer = null;

	// opacity 값 적용함수
	img._setAlpha = function(o) {
		this.style.opacity = o/100;
		this.style.filter = 'alpha(opacity='+o+')';
	};

	// fade 작동기
	img._IconViewer = function() {
		if ( this._alpha < this._target )
			this._alpha = this._alpha + 10;
		else if ( this._alpha > this._target  )
			this._alpha = this._alpha - 10;
		else
			clearInterval(this._timer);

		this._setAlpha(this._alpha);
	};

	// 이벤트 삽입
	img.onmouseover = function() {
		clearInterval(this._timer);
		var _this = this;
		this._target = 100;
		this._timer = setInterval(function() { _this._IconViewer(); }	,15);
	};
	img.onmouseout = function() {
		clearInterval(this._timer);
		var _this = this;
		this._target = 0;
		this._timer = setInterval(function() { _this._IconViewer(); }	,15);
	};

	// 초기 opacity 값 설정 및 element 삽입
	img._setAlpha(0);
	obj.parentNode.insertBefore(img,obj);

};