function formatDttm(dttm)
{
	return dttm.substr(0, 4)+"/"+dttm.substr(4, 2)+"/"+dttm.substr(6, 2)+" "+dttm.substr(8, 2)+":"+dttm.substr(10, 2);
}

function isIE()
{
	var agent = navigator.userAgent.toLowerCase(); 
	this.ie = (agent.indexOf("msie") != -1); 

	return ie;
}

function openWindow(url, width, height, is_scroll)
{
	//var features="toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=500,height=600";

	today = new Date();

	//var winName="cmc";
	var winName=today.getTime();

	var v_toolbar	= "no";
	var v_location	= "no";
	//var v_status	= "no";
	var v_status	= "yes";
	var v_menubar	= "no";
	var v_scrollbars= "yes";
	var v_resizable	= "no";

	if(is_scroll == false)
	{
		v_scrollbars= "no";
	}

	var features="toolbar="+v_toolbar+",location="+v_location+",status="+v_status+",menubar="+v_menubar+",scrollbars="+v_scrollbars+",resizable="+v_resizable+",width="+width+",height="+height;

	window.open(url, winName,features);
}

function redirect(url, target)
{
	if(!target)
	{
		location.href = url;
	}
	else
	{
		target.location.href = url;
	}
}

function isNull(name, ment)
{
	if(!name.value)
	{
		if(ment != undefined)
		{
			alert(ment);
		}
		
		try
		{
			name.focus(); 
		}
		catch(e)
		{
		}

		return false; 
	}
}

//url: http://www.phpschool.com/bbs2/inc_view.html?id=10435&code=tnt2&start=0&mode=&field=&search_name=&operator=&period=&category_id=&s_que=
//usr: 혀니 
function getParam(str)
{
	try
	{
		QueryString = location.search.split("?");
		Query = QueryString[1].split("&")
		
		for(i = 0; i <= Query.length-1; i++)
		{
			if(Query[i].indexOf(str) == 0)
			{
				GetQuery = Query[i].split("=");
				return GetQuery[1];
			}
		}
	}
	catch (e)
	{
		return null;
	}
}

function getPathInfo()
{
	str = document.URL.substring(0, (document.URL).indexOf("?"));
	str = str.replace("http://" + document.domain, "");
	return str;
}

function autolink(id) {
        var container = document.getElementById(id);
        var doc = container.innerHTML;
        var regURL = new RegExp("(http|https|ftp|telnet|news|irc)://([-/.a-zA-Z0-9_~#%$?&=:200-377()]+)","gi");
        var regEmail = new RegExp("([xA1-xFEa-z0-9_-]+@[xA1-xFEa-z0-9-]+\.[a-z0-9-]+)","gi");
        container.innerHTML = doc.replace(regURL,"<a href='$1://$2' target='_blank'>$1://$2</a>").replace(regEmail,"<a href='mailto:$1'>$1</a>");
}

function getRand(len)
{
	var sum = 1;

	while (len > 0)
	{
		sum = sum * 10;

		len--;
	}

	return	Math.round(Math.random() * sum);
}




var g_PopupIFrame;

function IsIE()
{

	return ( navigator.appName=="Microsoft Internet Explorer" );

}

function HidePopupDiv(divID)
{

	var divPopup;
	divPopup=document.getElementById(divID);
	divPopup.style.visibility = "hidden";

	if (IsIE())
	{

		document.body.removeChild(g_PopupIFrame);
		g_PopupIFrame=null;

	}

}

function ShowPopupDiv(divID)
{

	var divPopup=document.getElementById(divID);

	if (!IsIE())
	{

		//Just display the div
		divPopup.style.visibility ="visible";
		return;

	}

	//Increase default zIndex of div by 1, so that DIV appears before IFrame
	divPopup.style.zIndex=divPopup.style.zIndex+1;

	var iFrame = document.createElement("IFRAME");
	iFrame.setAttribute("src", "");

	//Match IFrame position with divPopup
	iFrame.style.position="absolute";
	iFrame.style.left =divPopup.offsetLeft + 'px';
	iFrame.style.top =divPopup.offsetTop + 'px';
	iFrame.style.width =divPopup.offsetWidth + 'px';
	iFrame.style.height =divPopup.offsetHeight + 'px';

	document.body.appendChild(iFrame);

	//Store iFrame in global variable, so it can get removed when divPopup is hidden g_PopupIFrame=iFrame;
	g_PopupIFrame=iFrame;
	divPopup.style.visibility ="visible";

}

function print_r(Obj) { // debuging Mode
    
  var igear = 'igear array_view \r\n\r\n';

  if(Obj.constructor == Array || Obj.constructor == Object) { // 배열체크

    for(var p in Obj) // 루프 시작
      if(Obj[p].constructor == Array|| Obj[p].constructor == Object) { // 이중배열 체크
        igear += "● [" + p + "] => "+ typeof(Obj[p]) + " \r\n";
        print_r(theObj[p]);

        } else igear += "● [" + p +  "] => "+ Obj[p] + " \r\n";
        

      alert(igear);    
  }

}

function getScrollHeight()
{
	var y;

	// all except Explorer
	if (self.pageYOffset)
		y = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop)   
		y = document.documentElement.scrollTop;
	else if (document.body) // all other Explorers
		y = document.body.scrollTop;
	
	return parseInt(y);
}

document.write("<div id='commonMsgDiv'></div>");

var show_common_msg;

function showCommonMsg(str, sec)
{
	if(typeof(show_common_msg) != 'undefined')
		clearTimeout(show_common_msg);

	if(sec != -1 && !sec)
		sec = 2;

	var msg_div = document.getElementById('commonMsgDiv');
	msg_div.style.top = getScrollHeight() + 'px';

	if(str)
		msg_div.style.display = 'block';
	else
		msg_div.style.display = 'none';

	msg_div.innerHTML = str;

	if(sec != -1)
		show_common_msg = setTimeout(hideCommonMsg, sec * 1000);
}

function hideCommonMsg()
{
	var msg_div = document.getElementById('commonMsgDiv');
	msg_div.style.display = 'none';
}




Array.prototype.unique = function()
{
	var mark = [];

	for(var i in this)
	{
		// var indx = this[i]; --> if type does not matter
		// create a unique index if type does matter
		var indx = this[i] + "_" + typeof(this[i]);

		if(mark[indx])
			delete this[i];
		else
		mark[indx] = this[i];
	}

	this.sort();

	// empty indexed entries are at the end of the array
	// shorten it [delete does not reduce array]

	while(!this[this.length-1]) this.length--;
}


//document.write('<script type="text/javascript" src="/com/js/cookie.js"></script>');


function numToCurrency(num) 
{
	num = num.toString().replace(/\$|\,/g,'');
	
	if(isNaN(num))
		num = "0";
	
	sign = (num == (num = Math.abs(num)));
	
	num = Math.floor(num*100+0.50000000001);
	
	cents = num%100;
	
	num = Math.floor(num/100).toString();
	
	if(cents<10)
		cents = "0" + cents;

	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+	num.substring(num.length-(4*i+3));

	return (((sign)?'':'-') + '$' + num + '.' + cents);
}