/*================================================
DEFAULT util script. by sensitivefreak, delie
-------------------------------------------------
> information
	win : 새 창 관련 유틸
		open - 새 창 띄우기
			loc 경로-------------|
			wid 가로사이즈       |--(생략 불가)
			hei 세로사이즈-------|
			etc 기타 옵션        |--(생략 가)
			nam 새창 이름--------|
		close - 창 닫기
	evt : 이벤트 관련 유틸
		add - 이벤트 등록
		del - 등록 된 이벤트 삭제 (미구현)
	dom : 엘레멘트 관련 유틸
		$ - document.getElementById("element name")기능 / prototype 에서 발췌, 이와 관련한 카피라이트는 하단에 표기
		toggle - 이미지 토글 기능 / JPG, GIF and FF, IE, OP, Safari 지원
-------------------------------------------------
> example
	새 창을 띄울 때
		win.open(param1, param2, param3...
	이미지 롤오버 롤아웃
		<img src="[path]" onmouseover="dom.toggle(this);" onmouseout="dom.toggle(this);"...
-------------------------------------------------*/
/*<![CDATA[*/
try { 
	document.execCommand('BackgroundImageCache', false, true); 
} catch(me) {}

var win = {
	open : function(loc, wid, hei, etc, nam) {
		if(loc) {
			var win;
			var opt = "toolbar=no, menubars=no, left=0, top=0";
			var w = (wid) ? wid : "100";
			var h = (hei) ? hei : "100";
			var e = (etc) ? ","+etc : "";
			var n = (nam) ? nam : "";
				opt += ", width="+w+", height="+h+e;
				win = window.open(loc, nam, opt);
				win.focus();
		}
	},
	close : function(tgt) {
		var w = (tgt) ? tgt : window;
			w.close();
	},
	go : function(loc, tgt) {
		if(!loc) return;
		if(!tgt) {
			window.location.href = loc;
		} else {
			tgt.location.href = loc;
			win.close();
		}
	},
	print : function() {
		window.print();
	},
	resize : function(emt) {
		var n = navigator.userAgent, plus = 85, size = new Array(dom.$(emt).scrollWidth+10, dom.$("container").scrollHeight);
		if(n.indexOf("MSIE") != -1) {
			if(n.indexOf("7") == -1) plus = 65;
		} else {
			plus = 59;
		}
		window.resizeTo(size[0],size[1] + plus);
	}
};

var evt = {
	add : function(tgt, typ, call) {
		if(tgt.addEventListener) {
			tgt.addEventListener(typ, call, false);
		} else if(tgt.attachEvent) {
			tgt["e"+typ+call] = call;
			tgt[typ+call] = function() { tgt["e"+typ+call]( window.event ); }
			tgt.attachEvent("on"+typ, tgt[typ+call]);
		} else {
			tgt["on"+typ] = tgt["e"+typ+call];
		}
	},
	del : function(tgt, typ, call) {
		if(tgt.removeEventListener) {
			tgt.removeEventListener(typ, call, false);
		} else {
			tgt["e"+typ+call] = call;
			tgt[typ+call] = function() { tgt["e"+typ+call]( window.event ); }
			tgt.detachEvent("on"+typ, tgt[typ+call]);
		}
	},
	key : function(prt, call) {
		this.inp = dom.$$(dom.$(prt), "input");
		for(var i = 0; i < this.inp.length; i++) {
			this.inp[i].call = this;
			this.inp[i].callback = call;
			evt.add(this.inp[i], "keydown", function() { this.call.handle(this.callback) });
		}
	}
};
	evt.key.prototype = {
		handle : function(callback) {
			var keyCode = escape(event.keyCode);
			if(keyCode != "13") return;
			callback();
		}
	};

var dom = {
	$ : function(emt) {
		emt = document.getElementById(emt);
		return emt;
	},
	$$ : function(par, tag, cnm) {
		var emt = par.getElementsByTagName(tag);
		if(arguments.length == 3) {
			var arr = new Array();
				for(var i = 0; i < emt.length; i++) {
					if(emt[i].className == cnm) {
						arr.push(emt[i]);
					}
				}
			return arr;
		}
		else if(arguments.length == 2) {
			return emt;
		}
	},
	x : function(cmt, obj_id) {
		var emt = this.$(cmt);
		if(navigator.appName == "Microsoft Internet Explorer") {
			document.write(emt.text);
			emt.id = "";
		}
		if(obj_id)
			window[obj_id] = this.$(obj_id);
	},
	checkin : function(k1, k2) {
		var c = (k1.indexOf(k2) != -1) ? true : false;
		return c;
	},
	flashfunction : function(emt_id ,funcname) {
		var ie = navigator.appName.indexOf("Microsoft") != -1; 
		var emt = null;
		emt = (ie) ? dom.$(emt_id) : window.document.emt_id;
		emt[funcname]();
	}
};
	dom.x.resize_y = function(tgt, hei) { tgt.style.height = hei+"px" };
	dom.x.resize_x = function(tgt, wid) { tgt.style.width = wid+"px" };

var inf = {
	get_browser : function() {
		var n = navigator.userAgent.toLowerCase(), c = dom.checkin, b;
			if(c(n,"msie")) {
				b = "ie";
				if(c(n,"7.0")) b = "ie7";
			} else {
				b = false;
			}
			return b;
	},
	isie : this.get_browser
};

var isNav4, isIE4, isMac, isNav6;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  isStd = (navigator.appName == "Netscape") ? true : false
  isIE  = (navigator.appName.indexOf("Microsoft") != -1) ? true : false
  isMac = (navigator.platform.indexOf("Mac") != -1) ? true : false
  isPNG = (isIE && ! isMac) ? false : true
}

var ajax = function(uri, params, call, rtype) {
	this.R = this.set();				// Request Object
	this.C = call;						// Callback Func
	this.M = rtype ? rtype : "GET";		// Method
	this.P = params ? params : null;	// Parameters
	this.U = params ? uri+"?"+this.P : uri;
	this.get();
//	alert(params);
};

ajax.prototype = {
	set : function() {
		if(isIE) {
			try {
				return new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {
					return null;
				}
			}
		} else if(window.XMLHttpRequest) {
			return new window.XMLHttpRequest();
		} else {
			return null;
		}
	},
	get : function() {
		this.R.open(this.M, this.U, true);
		this.R.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.R.onreadystatechange = this.C;
		this.R.send(this.M == "POST" ? this.P : null);
	}
};