function http_req(){
	this.http_request = false;
}
http_req.prototype.setroot = function(val){this.root =val;}
http_req.prototype.setarray = function(val){this.array =val;}
http_req.prototype.settable = function(val){this.table =val;}
http_req.prototype.setfunc = function(val){this.func =val;}
http_req.prototype.setistableloaded = function(val){this.istableloaded =val;}
http_req.prototype.setisfieldloaded = function(val){this.isfieldloaded =val;}
http_req.prototype.getnodeValue = function(xobj){
	return xobj[0].firstChild.nodeValue;
}
http_req.prototype.XMLWriteTable= function(){
	var xmlobj = this.http_request;
	var xml = xmlobj.responseXML;
	if(this.func)this.func(xmlobj,xml,1);
	if(this.isfieldloaded == 1){

	}else if(this.istableloaded == 1) {
		var tags = xml.getElementsByTagName( this.root );
		for( var b = 0; b < tags.length; b++ ) {
			var otable = document.getElementById(this.table).insertRow(-1);
			for( i in this.array) {
				var value= this.getnodeValue(tags[b].getElementsByTagName(this.array[i]));
				var tds = otable.insertCell( -1 );
				tds.innerHTML = value;
			}
		}
	}
}
http_req.prototype.XMLload = function(url){
	this.http_request = false;
	this.http_loading=true;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		this.http_request = new XMLHttpRequest();
		if (this.http_request.overrideMimeType) {
			this.http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			this.http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.http_request = new ActiveXObject("Microsoft.XMLHTTP");
				this.http_request.setContentType("text/xml");
			} catch (e) {}
		}
	}
	if (!this.http_request) {
		alert('Cannot create XMLHTTP instance');
		return false;
	}
	this.http_request.onreadystatechange = alertContents;
	this.http_request.open('GET', url, true);
	try {
		this.http_request.send(null);
	} catch(e) {
		alert("Don't Send");
	}
	function alertContents() {
		
		if (http_req_val.http_request.readyState == 4) {
			http_req_val.http_loading = false;
			if (http_req_val.http_request.status == 200) {
				http_req_val.XMLWriteTable();
			} else {
				if(http_req_val.func){
					http_req_val.func(null,null,0);
				}
			}
		}
	}

}

var http_req_val = new http_req();
function getXmlTagValue(xml,tagname){ 
	return xml.getElementsByTagName(tagname)[0].firstChild.nodeValue;
}
function do_xml(url,resfunction) {
	http_req_val.setfunc(resfunction);
//	http_req_val.setisloaded(0);
	http_req_val.XMLload(url);
}
function loadtable(url,root,arr,table,func) {
	http_req_val.setroot(root);
	http_req_val.setarray(arr);
	http_req_val.settable(table);
	http_req_val.setfunc(func);
	http_req_val.setistableloaded(1);
	http_req_val.XMLload(url);
}
function loadfield(url,func) {
//	http_req_val.setroot(root);
	http_req_val.setfunc(func);
	http_req_val.setisfieldloaded(1);
	http_req_val.XMLload(url);
}

function GetObjectId(sid){
	return document.getElementById(sid);
}
function SetObjectText(sid,html){
	var obj = GetObjectId(sid);
	if(obj){
		obj.innerHTML = html;
	}
}
function SetObjectValue(sid,val){
	var obj = GetObjectId(sid);
	if(obj){
		obj.value = val;
	}
}
function GetObjectValue(sid){
	var obj = GetObjectId(sid);
	if(obj){
		return obj.value;
	}
}
function visibleStyle(sid,sytle){
	var obj = GetObjectId(sid);
	if(obj){
		obj.style.display = sytle;
	}
}
//////////////////////////////////////////////////////////
function cookieVal(cookieName){
	thisCookie = document.cookie.split("; ");
	for(i=0; i<thisCookie.length; i++){
			if(cookieName == thisCookie[i].split("=")[0]){
				return unescape(thisCookie[i].split("=")[1]);
			}
	}
	return "0";
}
function setCookie(name, value, expiredays){ 
	var todayDate = new Date(); 
	todayDate.setDate(todayDate.getDate() + expiredays); 
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 
////////////////////////////////////////////////////////////
function SetImagetoElement(url,objname,w,h){
	try {
		var obj = GetObjectId(objname);
		if (obj) {
			var img = new Image;
			img.src = url;
			obj.src = img.src;
			if (w) 
				obj.width = w;
			if (h) 
				obj.height = h;
		}
		return 1;
	}catch(e){
		return 0;
	}
}
function GetImageInfo(url){
	var img = new Image;
	var arr = new Array;
	arr[0] = img.fileSize;
	arr[1] = img.width;
	arr[2] = img.height;
	return arr;
}
/////////////////////////////////////////////////////////////
var MothionTween = function(frameogjname,inobjname,stop){
	this_s = this;
	this.frmobj = document.getElementById(frameogjname);
	this.inobj = document.getElementById(inobjname);
	this.motionAct = 0.05;
	this.mvpoint = 0;
	this.svpoint = 0;
	this.manual = 0;
	this.sw = 0;
	this.motion();
	if(stop==0)	this.autoload();
}
MothionTween.prototype.motion = function(){
	if(this.action1 ==1)return;
	function act(){
		this_s.action1 = 1;
		if(this_s.manual){
			this_s.svpoint += ((this_s.mvpoint - this_s.svpoint)*0.05);
			var eenp = Math.round(this_s.svpoint);
			this_s.inobj.style.left = eenp+"px";
		}
		setTimeout(act, 10);
	}
	act();
}
MothionTween.prototype.autoload = function(){
	if(this.action2 ==1)return;
	function auto(){
		this_s.action2 = 1;
		this_s.manual --;
		var mvp= this_s.inobj.offsetLeft;
		if(this_s.manual <=0){
			this_s.manual =0;
			var wid = this_s.frmobj.offsetWidth;
			var widinn =this_s.inobj.offsetWidth;
			if(mvp <-(widinn-(wid*2)))this_s.sw =1;
			if(mvp>0) this_s.sw =0;
			if(this_s.sw == 1) mvp +=1;
			else mvp -=1;
			this_s.inobj.style.left = mvp+"px";
		}
		setTimeout(auto, 10);
	}
	auto();
}
MothionTween.prototype.go = function(rv){
	var wid = this.frmobj.offsetWidth;
	var tpage =Math.floor(this.inobj.offsetWidth/wid)-1;
	var nowpage = Math.round(Math.abs(this.inobj.offsetLeft) / wid)
	if(rv ==1) nowpage++;
	else nowpage--;
	if(nowpage<0)nowpage= 0;
	if(nowpage>=tpage) nowpage=tpage;
	this.svpoint = this.inobj.offsetLeft;
	this.mvpoint = wid*(-nowpage);
	this.manual = 200;
}

//<script>
//mt = new MothionTween("content_frame","content_part",0);
//</script>
//	mt.go(1);
//	mt.go(0);


function openPop(url,wid,hei,sname){
	if(!sname){
		sname = "popup";
	}
	var w = window.open(url,sname,"width="+wid + ",height="+hei+",toolbar=0,resizable=0");
}
function openPopOnScr(url,wid,hei,sname){
	if(!sname){
		sname = "popup";
	}
	var w = window.open(url,sname,"width="+wid + ",height="+hei+",toolbar=0,resizable=0,scrollbars=1");
}
var _loaddelgourl = "";
function _loadldprA(reqobj, xml, success){
	var chkvalue = getXmlTagValue(xml,'ret');
	if(chkvalue== "1"){
		if(_loaddelgourl) {
			document.location.href=_loaddelgourl;
			_loaddelgourl = "";
		}else{
			window.location.reload(); 
		}
	}else{
		alert('삭제할 수 없습니다.');
	}
}
function DB_DeleteItem(t,ind){
  if(confirm("삭제하시겠습니까?"))	do_xml('./ajax/runscript.php?t='+t+'&m=d&i='+ind,_loadldprA);
}
function DB_DeleteItemgoUrl(t,ind,url){
	_loaddelgourl = url;
  if(confirm("삭제하시겠습니까?"))	do_xml('./ajax/runscript.php?t='+t+'&m=d&i='+ind,_loadldprA);
}
function popImg(img){
    var Popimg;
    Popimg=window.open("","","width=100, height=100, resizable=yes,scrollbars=1");
    Popimg.document.write("<html><head>");
    Popimg.document.write("<title>::::: PIC :::::</title>");
    Popimg.document.write("</title></head>");
    Popimg.document.write("<script>");
    Popimg.document.write("function resizeWin() {");
    Popimg.document.write("var obj = document.getElementById('img');");
    Popimg.document.write("var w = obj.width;");
    Popimg.document.write("var h = obj.height;");
    Popimg.document.write("window.resizeTo(w + 30, h + 27);");
    Popimg.document.write("}");
    Popimg.document.write("<\/script>");
    Popimg.document.write("<body topmargin=0");
    Popimg.document.write(" leftmargin=0");
    Popimg.document.write(" onLoad='resizeWin();'>");
    Popimg.document.write("<img src='" + img + "'");
    Popimg.document.write(" onclick='self.close()'");
    Popimg.document.write(" style=cursor:hand id='img'>");
    Popimg.document.write("</body></html>");
    Popimg.document.close();
}