/**
* ºê¶ó¿ìÁ®ÀÇ Å¸ÀÔÀ» ¼³Á¤
*/
var ns = (document.layers)? true:false;
var ie = (document.all)? true:false;
var doc = (ie)? document.all : document;

/**
 * ÀÔ·Â °ªÀÌ Object ÀÎÁö¸¦ ¹ÝÈ¯.
 * returns true if a is an object, and array, or a function.
 * It returns false if a is a string, a number, a boolean, or null, or undefined.
 */
function isObject(input) {
	return (input && typeof input == 'object') || isFunction(input);
}

/**
 * ÀÔ·Â °ªÀÌ Function ÀÎÁö¸¦ ¹ÝÈ¯.
 */
function isFunction(input) {
	return typeof input == 'function';
}

function rtnFalse() {
	return false;
}

function disableFocus(obj) {
	obj.readOnly=true;
	obj.ondragstart=rtnFalse;
	obj.onselectstart=rtnFalse;
}

function enableFocus(obj) {
	obj.readOnly=false;
	obj.ondragstart=null;
	obj.onselectstart=null;
}

function checkAll(frmIndex){	//Æû¿¡ÀÖ´Â chkID Ã¼Å©¹Ú½º ÀüÃ¼ ¼±ÅÃ ÇÔ¼ö - ¹Ýµå½Ã ÀÌ¸§ÀÌ chkID ¿©¾ßÇÔ
	var totalCount=document.forms[frmIndex].chkID.length;	
	if(totalCount>1){
		if(document.forms[frmIndex].chkID[0].checked){
			for(i=0;i<totalCount;i++){
				document.forms[frmIndex].chkID[i].checked=false;
			}
		}else{
			for(i=0;i<totalCount;i++){
				document.forms[frmIndex].chkID[i].checked=true;
			}
		}
	}else{
		if(document.forms[frmIndex].chkID.checked)
			document.forms[frmIndex].chkID.checked=false;
		else
			document.forms[frmIndex].chkID.checked=true;
	}
	return;
}

/**
 * ÁÖ¾îÁø ±æÀÌ°¡ Ã¤¿öÁö¸é ´ÙÀ½ form field ·Î ÀÚµ¿ ÀÌµ¿ 
 * - ½Å¿ëÄ«µå¹øÈ£ ÀÔ·Â, ÀüÈ­¹øÈ£ ÀÔ·Â µî 
 */
function autoShift(fromFld, nextFld, satisfyFldLen){
	if(fromFld.value.length==satisfyFldLen){
		nextFld.focus();
		return;
	}
}

/**
 * µ¿ÀÏÇÑ ÀÌ¸§À» °®´Â checkbox ¿¡¼­ check µÈ count ¸¦ return 
 */
function getCheckedCount(checkBoxObject){
	var checkedCount = 0;

	if(checkBoxObject && checkBoxObject.length){
		for(i=0; checkBoxObject.length > i; i++){
			if (checkBoxObject[i].checked == true){
				checkedCount++;
			}
		}
	}
	else if(checkBoxObject){
		if(checkBoxObject.checked==true) checkedCount++;
	}
	return checkedCount;
}

/**
 * check box selection À» ¹ÝÀü½ÃÅ´ - µ¿ÀÏÇÑ ÀÌ¸§À» °°´Â checkbox ÀüÃ¼  
 */
function checkreverse(checkObject) {
	if(checkObject.length){ // 2°³ÀÌ»ó 
		for(i=0; i<checkObject.length; i++){
			checkObject[i].checked = !checkObject[i].checked;
		}
	}
	else if(checkObject){
		checkObject.checked = !checkObject.checked;
	}
}

/**
 * check box selection ÀüÃ¼ ¼±ÅÃ
 */
function checkBoxAll(checkObject1,checkObject2) {
	if(!checkObject1|| !checkObject2) return;
	if(!isObject(checkObject2))
	{
		return;
	}
	if(checkObject2.length){ // 2°³ÀÌ»ó 
		for(i=0; i<checkObject2.length; i++){
			if(checkObject1.checked)
			{

				checkObject2[i].checked=true;
			}
			else
			{
				checkObject2[i].checked=false;
			}
		}
	}
	else
	{
		if(checkObject1.checked)
		{
			checkObject2.checked=true;
		}
		else
		{
			checkObject2.checked=false;
		}
	}
}

/**
 * ¼±ÅÃµÈ ¶óµð¿À¹öÆ°ÀÌ ÀÖ´ÂÁö Ã¼Å©
 */
function hasCheckedRadio(input) {
	if (input.length > 1) {
		for (var inx = 0; inx < input.length; inx++) {
			if (input[inx].checked) return true;
		}
	} else {
		if (input.checked) return true;
	}
	return false;
}

/**
 * ¼±ÅÃµÈ Ã¼Å©¹Ú½º°¡ ÀÖ´ÂÁö Ã¼Å©
 */
function hasCheckedBox(input) {
	return hasCheckedRadio(input);
}

function openWin(oURL,wwidth,wheight){	//½ºÅ©·Ñ¹Ù Æ÷ÇÔ »õÃ¢
	window.open(oURL,"openWindow","left=0,top=0,width="+wwidth+",height="+wheight+",scrollbars=yes,resizable=yes,menubar=no,status=no,toolbar=no,location=no");
}

function openWin(oURL,wwidth,wheight,name){	//½ºÅ©·Ñ¹Ù Æ÷ÇÔ »õÃ¢
	window.open(oURL,name,"left=0,top=0,width="+wwidth+",height="+wheight+",scrollbars=yes,resizable=yes,menubar=no,status=no,toolbar=no,location=no");
}

function openWinS(oURL,wwidth,wheight){	//½ºÅ©·Ñ¹Ù ºñÆ÷ÇÔ »õÃ¢
	window.open(oURL,"openWindow","width="+wwidth+",height="+wheight+",scrollbars=no,resizable=yes,menubar=no,status=no,toolbar=no,location=no");
}
function openWinS(oURL,wwidth,wheight,name){	//½ºÅ©·Ñ¹Ù ºñÆ÷ÇÔ »õÃ¢
	window.open(oURL,name,"width="+wwidth+",height="+wheight+",scrollbars=no,resizable=yes,menubar=no,status=no,toolbar=no,location=no");
}

function movePage(mPage,sURL){
	setValue();
	document.actFrm.action=sURL;
	document.actFrm.nowPage.value=mPage;
	document.actFrm.submit();
}

function viewMember(id){
	openWin("http://www.i-base.co.kr/backoffice/user/user_inpt_frm.jsp?userID="+id,400,520,"member");
}

function imgMgt(){
	openWin("http://www.i-base.co.kr/backoffice/common/image_view.jsp",800,600,"imgMgt");
}
function help(){
	openWin("http://www.i-base.co.kr/backoffice/common/help.jsp",637,600,"help");
}
/**
 * POPUP Resize
 */
function resize_pop() {
	var obj = navigator.appVersion;
	var hei = 29;
	var oBody = document.body;
	if (navigator.appVersion.indexOf("NT") != -1) {
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") {
			if(obj.indexOf("SV1")!=-1){
				hei = 45;
			}
			else{
				hei = 31;
			}
		}
	}
	wid = oBody.scrollWidth + (oBody.offsetWidth-oBody.clientWidth) + 5;
	hei = oBody.scrollHeight + (oBody.offsetHeight-oBody.clientHeight) + hei;
	self.resizeTo(wid,hei);
	this.focus();
}
function resize_pop_h() {
	var obj = navigator.appVersion;
	var hei = 29;
	var oBody = document.body;
	if (navigator.appVersion.indexOf("NT") != -1) {
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") {
			if(obj.indexOf("SV1")!=-1){
				hei = 47;
			}
			else{
				hei = 31;
			}
		}
	}
	wid = oBody.scrollWidth + (oBody.offsetWidth-oBody.clientWidth) + 8;
	hei = oBody.scrollHeight + (oBody.offsetHeight-oBody.clientHeight) + hei;
	if(hei>700){
		hei=700;
	}
	self.resizeTo(wid,hei);
	this.focus();
}
function resize_pop_wh() {
	var obj = navigator.appVersion;
	var hei = 29;
	var oBody = document.body;
	if (navigator.appVersion.indexOf("NT") != -1) {
		os = obj.substr(obj.indexOf("NT"),6);
		if (os > "NT 5.0") {
			if(obj.indexOf("SV1")!=-1){
				hei = 51;
			}
			else{
				hei = 35;
			}
		}
	}
	wid = oBody.scrollWidth + (oBody.offsetWidth-oBody.clientWidth) + 28;
	hei = oBody.scrollHeight + (oBody.offsetHeight-oBody.clientHeight) + hei;
	if(wid>860){
		wid=800;
	}
	if(hei>700){
		hei=700;
	}
	self.resizeTo(wid,hei);
	this.focus();
}
/*
 * iFrame Resize
 * obj			: iFrame ÀÌ¸§
 * minHeight	: iFrameÀÇ ÃÖ¼Ò ³ôÀÌ
 */
function resizeIfr(obj, minHeight, bufferHeight) {

	minHeight = minHeight || 10;

	try {
	
		var doc = obj.contentDocument || obj.contentWindow.document;
		if (doc.location.href == 'about:blank') {
			obj.style.height = minHeight+'px';
			return;
		}
		
		if (/MSIE/.test(navigator.userAgent)) {
			var h = doc.body.scrollHeight;
		} else {
			var s = doc.body.appendChild(document.createElement('DIV'))
			s.style.clear = 'both';

			var h = s.offsetTop;
			s.parentNode.removeChild(s);
		}

		
		if (h < minHeight) h = minHeight;
	
		if(bufferHeight)
			obj.style.height = h + parseInt(bufferHeight, 10) + 'px';
		else
			obj.style.height = h + 'px';

		if (typeof resizeIfr.check == 'undefined') resizeIfr.check = 0;
		

		setTimeout(function(){ resizeIfr(obj,minHeight) }, 3000); // check 5 times for IE bug

	} catch (e) { 

	}
}

/**
* ´Þ·Â ¼±ÅÃ ÆË¾÷Ã¢À» Ãâ·ÂÇÏ±â À§ÇÑ ½ºÅ©¸³Æ® (³¯Â¥¸¸:datetime='date')
*/
function callCalendar(datetime,field){
	    dateField = field;
		    __showCalendarPanel(datetime,'::');
}

/**
 * ½ÇÁ¦ ´Þ·Â ÆË¾÷Ã¢À» Ãâ·ÂÇÑ´Ù.
 */
function __showCalendarPanel(type, param, title, x, y)
{
	if(param == null){
		alert("Javascript:__showCalendarPanel: You must specify the parameter");
		return;
	}
	var separator = ":";
	var pa = param.split(separator);

	if(pa.length != 3)  //<= 1 || (pa[0].length <= 0 && pa[1].length <= 0)) 
	{
		alert("Javascript:__showCalendarPanel: You must specify INPUT objects name to be set to local datetime or GMT one");
		return;
	}

	var left = 100;
	var top = 200;
	if(x != null) left = x;
	if(y != null) top = y;

	var url = "common/calendar47d9.html?type=" + type + "&objLocalDate=" + pa[0] + "&objGMTDate=" + pa[1] + "&initDateTime=" + pa[2] + ( title != null ? "&title=" + title : "");
	var width  = (ie) ? "230":"240";
	if( type == "date" )
		var height = (ie) ? "288":"293";
	else
		var height = (ie) ? "318":"323";
	var ws  = "left=" + left + ",top=" + top + ",menubar = no,width=" + width + ",height=" + height + ",resizable=no,scrollbars=no";
	window.open(url, "__newWin", ws);
}


/**
 * ½ÇÁ¦ ´Þ·Â ÆË¾÷Ã¢¿¡¼­ ¼±ÅÃÇÑ ³»¿ëÀ» ÀÔ·ÂÇÏ°íÀÚ ÇÏ´Â Æû¿¡ Àü´ÞÇÑ´Ù.
 */
function setDateTime(local, gmt, type){
	if(type=='date'){
		dateField.value = local.substring(0, 4)
			+ "-" + local.substring(4, 6)
			+ "-" + local.substring(6, 8);
	}
	else{
		dateField.value = local.substring(0, 4)
			+ "-" + local.substring(4, 6)
			+ "-" + local.substring(6, 8)
			+ " " + local.substring(8, 10)
			+ ":" + local.substring(10, 12);
	}

}

/**
 * ¿ìÆí¹øÈ£ °Ë»ö Ã¢À» ¶ç¿î´Ù.
 */
function callZipSearch(frm, zip1, zip2, addr, focus){
	openWinS('common/zip_search1b83.html?formNm='+frm+'&zip1Nm='+zip1+'&zip2Nm='+zip2+'&addrNm='+addr+"&focus="+focus,100,100);
}

/**
 * °Ô½ÃÆÇ ¾÷·Îµå ÀÌ¹ÎÁöÀÇ ¿øº»ÀÌ¹ÌÁö Ãâ·Â
 */
function board_image(url){
	openWin('common/show_imagec461.html?url='+url,100,100);
}

/**
 * Editor ¿¡¼­ ÀÛ¼ºÇÑ ³»¿ëÀÇ ¸µÅ© TargetÀ» º¯°æÇÑ´Ù.
 */
function changeLinkTarget()
{
	var bodys = document.all.THE_TEXT;
	var anchors;

	if(!isObject(bodys)) return;

	if(bodys.length == undefined)
	{
		anchors = bodys.getElementsByTagName("A");

		for(j=0; j< anchors.length; j++)
		{
			if(isEmpty(anchors[j].target))
			{
				anchors[j].target = "_blank";
			}
		}
	}
	else
	{
		for(i=0; i<bodys.length; i++)
		{
			anchors = bodys[i].getElementsByTagName("A");

			for(j=0; j< anchors.length; j++)
			{
				if(isEmpty(anchors[j].target))
				{
					anchors[j].target = "_blank";
				}
			}
		}
	}
}


function wrongPath(){
	alert("ºñÁ¤»óÀûÀÎ °æ·Î·Î Á¢±ÙÇÏ¼Ì½À´Ï´Ù");
	
	window.opener = window.location.href;
	self.close();
}
