﻿/* ====================================================
    Ntreevsoft / Script by Park.
   ================================================== */

// 툴팁 스킨 [ 치환테그 :: <!--msg--> ]
var chkMessagePath = ''; // 스킨 이미지 파일 경로
var chkMessageSkin = new Array;
chkMessageSkin[0] =
	'<div style="background:url('+chkMessagePath+'bg_alert0.gif) no-repeat 0 bottom;width:241px;padding-bottom:6px;"><div style="background:url('+chkMessagePath+'bg_alert0.gif) no-repeat 0 top;padding:8px 0 0 25px;text-align:left;line-height:15px;color:#756a36;">'+
	'<!--msg-->'+
	'</div></div>';
chkMessageSkin[1] =
	'<div style="background:url('+chkMessagePath+'bg_alert1.gif) no-repeat 0 bottom;width:241px;padding-bottom:6px;"><div style="background:url('+chkMessagePath+'bg_alert1.gif) no-repeat 0 top;padding:8px 0 0 25px;text-align:left;line-height:15px;color:#756a36;">'+
	'<!--msg-->'+
	'</div></div>';



// input status tooltip
function chkMessage(obj) {
	if(!obj) return false
	// obj type 식별 및 객채 보유 툴팁 div 생성
	var _obj = (typeof(obj) == 'object') ? obj : document.getElementById(obj)
	if(!_obj.obj) {
		_obj.target = 'chkMessageDiv'+parseInt(Math.random() *100000)
		var _Div = document.createElement('div');
		_Div.setAttribute('id', _obj.target);
		with(_Div.style) {
			display = "none";
			position = "absolute";
			top = left = "0";
			zindex = "900";
		}
		document.body.appendChild(_Div)
	}
	_obj.obj = document.getElementById(_obj.target)

	// 툴팁 뷰어
	_obj.view = function(msg,type,color) {
		this.skin = type ? chkMessageSkin[type] : chkMessageSkin[0];
		this.skin = !color ? this.skin : this.skin.replace(/#756a36/ig,color);
		this.obj.style.top = getPosition(this).y;
		this.obj.style.left = getPosition(this).x + this.scrollWidth + 10 + 'px';
		this.obj.style.display = "block";
		this.obj.innerHTML = this.skin.replace(/<!--msg-->/,msg)
	}
	// 툴팁 제거
	_obj.clear = function() { this.obj.style.display = "none"; 	}
	return _obj
}

// object position return
function getPosition(obj) {
	var position = new Object;
	position.x = position.y = 0 ;
	if( obj ) {
		position.x = obj.offsetLeft;
		position.y = obj.offsetTop;
		if( obj.offsetParent ) {
			var parentpos = getPosition(obj.offsetParent);
			position.x += parentpos.x;
			position.y += parentpos.y;
		}
	}
	return position;
 }