function fillZero(obj) {
	if (obj.value == '') obj.value = '0';
}

function emptyAlert(obj, msg) {
	if (obj.value == '') {
		alert(msg + '\uc744(\ub97c) \uc785\ub825\ud558\uc138\uc694.');
		obj.focus();
		return true;
	}
	return false; 
}

function emptySelectAlert(obj, msg) {
	if (obj.options[obj.selectedIndex].value == '') {
		alert(msg + '\uc744(\ub97c) \uc785\ub825\ud558\uc138\uc694.');
		obj.focus();
		return true;
	}
	return false;
}
function checkLength(obj, maxLen, fieldName){
	var i, len=0;
	var s = obj.value;
	
	// String \uae38\uc774\ub97c \uad6c\ud558\ub294 \ubd80\ubd84..
	for(i=0;i < s.length; i++) (s.charCodeAt(i) > 255)? len+=2:len++;
	
	// \uae38\uc774 \ud655\uc778.	
	if (maxLen < len) {
		if(fieldName != "")
			alert(fieldName + "\uc740(\ub294) " + maxLen + "\uc790\ub97c \ub118\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4(\ud55c\uae00\uc740 \uae00\uc790\ub2f9 2\uc790\ub85c \uacc4\uc0b0\ub429\ub2c8\ub2e4.)");
		obj.focus();
		return false;
	}
	return true;
}

function leftB(str, len) {
    var l = 0;
    for (var i=0; i<str.length; i++) {
            l += (str.charCodeAt(i) > 128) ? 2 : 1;
            if (l > len) return str.substring(0,i);
    }
    return str;
}

function checkNumberAlert(obj, msg) {  
	var digitChar = obj.value;
	if (digitChar == null) return false ;
	if (digitChar.substring(0,1) == "-") digitChar = digitChar.substring(1,digitChar.length);
       
    for (var i=0;i<digitChar.length;i++) {          
		var c = digitChar.charCodeAt(i);       
		if (!((0x30 <= c && c <= 0x39) || (c == 0x2E) || (c == 0x2C))) {         
			alert(msg + "\uc5d0\ub294 \uc22b\uc790\ub97c \uc785\ub825\ud558\uc138\uc694.");
			obj.focus();
			return false ;       
		}
	}      
    return true ;
}

function checkNumber(digitChar) {  
    if (digitChar == null) return false ;
    if (digitChar.substring(0,1) == "-") digitChar = digitChar.substring(1,digitChar.length);
       
    for (var i=0;i<digitChar.length;i++) {          
		var c=digitChar.charCodeAt(i);       
		if (!((0x30 <= c && c <= 0x39) || (c == 0x2E) || (c == 0x2C))) {         
    	    return false ;       
		}
	}      
    return true ;
}

function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable) {
	na_open_window2(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable, false)
}

function na_open_window2(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable, location) {
	toolbar_str = toolbar ? 'yes' : 'no';
	menubar_str = menubar ? 'yes' : 'no';
	statusbar_str = statusbar ? 'yes' : 'no';
	scrollbar_str = scrollbar ? 'yes' : 'no';
	resizable_str = resizable ? 'yes' : 'no';
	location_str = location ? 'yes' : 'no';
	win1 = window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str+',location='+location_str);
	if (win1 != null) win1.focus();
}

function na_open_modal(url, obj, left, top, width, height, center, help, scrollbar, resizable, statusbar) {
	center_str = center ? 'yes' : 'no';
	help_str = help ? 'yes' : 'no';
	scrollbar_str = scrollbar ? 'yes' : 'no';
	resizable_str = resizable ? 'yes' : 'no';
	statusbar_str = statusbar ? 'yes' : 'no';
	
	win1 = window.showModalDialog(url, obj, 'dialogLeft:'+left+'px;,dialogTop:'+top+'px;,dialogWidth:'+width+'px;,dialogHeight:'+height+'px;,center:'+center_str+';,help:'+help_str+';,scroll:'+scrollbar_str+';,resizable:'+resizable_str+';,status:'+statusbar_str+';');
	//if (win1 != null) win1.focus();
}

function goLocation(url) {
	location.href = url;
}

function goOpenerLocation(url) {
	opener.location.href = url;
	window.close();
}

function toggleObject(obj) {
	if ( obj.style.display == "none" ) {
		obj.style.display = "";
	} else {
		obj.style.display = "none";
	}
}

function SetCookie(sName, sValue){
  document.cookie = sName + "=" + escape(sValue) ; 
} 

function setCookie( name, value, expiredays )
{
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

function getCookie( name ) 
{ 
        var nameOfCookie = name + "="; 
        var x = 0; 
        while ( x <= document.cookie.length ) 
        { 
                var y = (x+nameOfCookie.length); 
                if ( document.cookie.substring( x, y ) == nameOfCookie ) { 
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) 
                                endOfCookie = document.cookie.length; 
                        return unescape( document.cookie.substring( y, endOfCookie ) ); 
                } 
                x = document.cookie.indexOf( " ", x ) + 1; 
                if ( x == 0 ) 
                        break; 
        } 
        return ""; 
} 

function verticalWheel_event(id, Height, nSec,wdth_height){
	if(window.xwzWheelMarq == null) window.xwzWheelMarq = new Array(0);
	xwzWheelMarq[id]  = {
		install : function(id, Height, nSec){
			this.id = id;
			this.div = document.getElementById('ID_DIV_' + id);
			this.table = document.getElementById('ID_TABLE_' + id);
			if(this.div == null) return;
			this.wdth_height = (wdth_height == null) ? "width:215px;height:187px;" : wdth_height;

			this.div.style.cssText = "position:relative;cursor:pointer;"+this.wdth_height+"overflow:hidden;clip:rect(0 auto "+this.height+" 0);left:0;top:0;";
			this.div.parentNode.style.position='relative'
			this.div.parentNode.onmouseover=function(){xwzWheelMarq[id].nPause=true;}
			this.div.parentNode.onmouseout= function(){xwzWheelMarq[id].nPause=false;}	

			this.index =0;
			this.height = Height;
			this.items = new Array(0);
			this.tmID = null;
			this.nPause = false;
			this.nSec = nSec;
			var rows =this.table.tBodies[0].rows;
			for(var i = 0; i < rows.length; i++){
				this.items[i] = document.createElement("DIV");
				this.items[i].innerHTML=rows[i].innerHTML;
				this.items[i].style.padding="3";
				this.items[i].style.height=this.height;
				this.items[i].style.position="absolute";
				this.items[i].style.top = this.height * i;
				this.div.appendChild(this.items[i]);

//				rows[i].cells[0].style.cssText="padding-left:5px;border-bottom:#CACACA 1px dotted;";
				rows[i].onmouseover=function(){this.style.backgroundColor="#FDF1F0";}
				rows[i].onmouseout=function(){this.style.backgroundColor="";}
//				if(i >= rows.length -1){rows[i].cells[0].style.border="";}
			}
		},
		doClick : function(n){
			if(!n)
			{
				var nSleep = 10;
				this.nPause=false;
				this.tmID = setTimeout("xwzWheelMarq['" + this.id + "'].doWheel()", nSleep);
				return;
			}
			
			this.index = this.index+n;
			var nIndex = this.index+1 >=  this.items.length ? 0 :  this.index+1;
			if(this.index< 0 ) this.index	= this.items.length-1;
			if(this.index > this.items.length-1) this.index=0;
			var itmN = this.items[this.index];
	
			clearTimeout(this.tmID); this.tmID = null;
	
			if(parseInt(itmN.style.top) < (this.height/2)*-1){
					itmN.style.top = this.height*(this.items.length-1);
					this.index = this.index+1 >=  this.items.length ? 0 :  this.index+1;
			}
			for(var i = 0; i < this.items.length; i++){
				this.items[i].style.top =  this.height * (  (this.items.length -  this.index + i ) % this.items.length );
			}


	
			
		},
		doWheel : function(){
			var itmN = this.items[this.index];
			var nSleep= 20;
			var nIndex= this.index+1 >=  this.items.length ? 0 :  this.index+1;
			clearTimeout(this.tmID); this.tmID = null;


			if(this.nPause != true){
				for(var i = 0; i < this.items.length; i++){
					this.items[i].style.top = parseInt(this.items[i].style.top)-1;
				}
				if(parseInt(itmN.style.top) <= this.height*-1){
					itmN.style.top = this.height*(this.items.length-1);
					this.index = this.index+1 >=  this.items.length ? 0 :  this.index+1;
					nSleep= this.nSec;
				}
			}else{
				if(parseInt(itmN.style.top) < (this.height/2)*-1){
					itmN.style.top = this.height*(this.items.length-1);
					this.index = this.index+1 >=  this.items.length ? 0 :  this.index+1;
				}

				for(var i = 0; i < this.items.length; i++){
					this.items[i].style.top =  this.height * (  (this.items.length -  this.index + i ) % this.items.length );
				}
				nSleep = 10;
			}
	
			this.tmID = setTimeout("xwzWheelMarq['" + this.id + "'].doWheel()", nSleep);
		}
	}


	xwzWheelMarq[id].install(id, Height, nSec);
	xwzWheelMarq[id].tmID = setTimeout("xwzWheelMarq['" +id + "'].doWheel()", nSec);
}
function horizontalWheel(id, width, nSec,wdth_height){
	if(window.xwzWheelHoriz == null) window.xwzWheelHoriz = new Array(0);
	xwzWheelHoriz[id]  = {
		install : function(id, width, nSec){
			this.id = id;
			this.div = document.getElementById('ID_DIV_' + id);
			this.table = document.getElementById('ID_TABLE_' + id);
			if(this.div == null) return;
			this.wdth_height = (wdth_height == null) ? "width:690px;height:150px;" : wdth_height;

			this.div.style.cssText = "position:relative;cursor:pointer;"+this.wdth_height+"overflow:hidden;clip:rect(0 auto "+this.width+" 0);left:2;top:0;";
			this.div.parentNode.style.position='relative'
			//this.div.parentNode.onmouseover=function(){xwzWheelHoriz[id].nPause=true;}
			//this.div.parentNode.onmouseout= function(){xwzWheelHoriz[id].nPause=false;}	
			this.div.onmouseover=function(){xwzWheelHoriz[id].nPause=true;}
			this.div.onmouseout= function(){xwzWheelHoriz[id].nPause=false;}

			this.index =0;
			this.width = width;
			this.items = new Array(0);
			this.tmID = null;
			this.nPause = false;
			this.nSec = nSec;
			var cols =this.table.tBodies[0].rows[0].cells;
			for(var i = 0; i < cols.length; i++){
				this.items[i] = document.createElement("DIV");
				this.items[i].innerHTML=cols[i].innerHTML;
				this.items[i].style.padding="3";
				this.items[i].style.width=cols[i].width ;
				this.items[i].style.position="absolute";
				this.items[i].style.left = cols[i].width * i; //18 + cols[i].width * i;
				this.div.appendChild(this.items[i]);

//				rows[i].cells[0].style.cssText="padding-left:5px;border-bottom:#CACACA 1px dotted;";
				cols[i].onmouseover=function(){this.style.backgroundColor="#FDF1F0";}
				cols[i].onmouseout=function(){this.style.backgroundColor="";}
//				if(i >= rows.length -1){rows[i].cells[0].style.border="";}
			}
		},
		doClick : function(n){
			if(!n)
			{
				var nSleep = 10;
				this.nPause=false;
				this.tmID = setTimeout("xwzWheelHoriz['" + this.id + "'].doWheel()", nSleep);
				return;
			}
			
			this.index = this.index+n;
			var nIndex = this.index+1 >=  this.items.length ? 0 :  this.index+1;
			if(this.index< 0 ) this.index	= this.items.length-1;
			if(this.index > this.items.length-1) this.index=0;
			var itmN = this.items[this.index];
	
			clearTimeout(this.tmID); this.tmID = null;
	
			if(parseInt(itmN.style.left) < (this.width/2)*-1){
					itmN.style.left = this.width*(this.items.length-1);
					this.index = this.index+1 >=  this.items.length ? 0 :  this.index+1;
			}
			for(var i = 0; i < this.items.length; i++){
				this.items[i].style.left =  this.width * (  (this.items.length -  this.index + i ) % this.items.length );
			}


	
			
		},
		doWheel : function(){
			var itmN = this.items[this.index];
			var nSleep= 20;
			var nIndex= this.index+1 >=  this.items.length ? 0 :  this.index+1;
			clearTimeout(this.tmID); this.tmID = null;


			if(this.nPause != true){
				for(var i = 0; i < this.items.length; i++){
					this.items[i].style.left = parseInt(this.items[i].style.left)-1;
				}
				if(parseInt(itmN.style.left) <= this.width*-1){
					itmN.style.left = this.width*(this.items.length-1);
					this.index = this.index+1 >=  this.items.length ? 0 :  this.index+1;
					nSleep= this.nSec;
				}
			}else{
				if(parseInt(itmN.style.left) < (this.width/2)*-1){
					itmN.style.left = this.width*(this.items.length-1);
					this.index = this.index+1 >=  this.items.length ? 0 :  this.index+1;
				}

				for(var i = 0; i < this.items.length; i++){
					this.items[i].style.left =  this.width * (  (this.items.length -  this.index + i ) % this.items.length );
				}
				nSleep = 10;
			}
	
			this.tmID = setTimeout("xwzWheelHoriz['" + this.id + "'].doWheel()", nSleep);
		}
	}


	xwzWheelHoriz[id].install(id, width, nSec);
	xwzWheelHoriz[id].tmID = setTimeout("xwzWheelHoriz['" +id + "'].doWheel()", nSec);
}

function findCalendar(aForm,aDate,left,top) {
	//na_open_window2(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable, location)
	na_open_window2("findCalendar", "/popup/calendar.do?pTag=C" + "&pForm=" + aForm + "&pDate=" + aDate, left, top, 170, 170, false, false, true, false, true, false);
}

function findDualCalendar(aForm,aDate,aDate2,left,top) {
	//na_open_window2(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable, location)
	na_open_window2("findDualCalendar", "/popup/dualCalendar.do" + "?pForm=" + aForm + "&pDate=" + aDate + "&pDate2=" + aDate2, left, top, 340, 220, false, false, true, false, true, false);
}

function findProdOfferCalendar(aForm,aDate,aBasicDate,aOrderNo,aBundleYn,left,top) {
	//na_open_window2(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable, location)
	na_open_window2("findProdOfferCalendar", "/popup/prodOfferCalendar.do?pTag=P" + "&pForm=" + aForm + "&pDate=" + aDate + "&pBasicDate=" + aBasicDate + "&pOrderNo=" + aOrderNo + "&pBundleYn=" + aBundleYn, left, top, 170, 230, false, false, true, false, true, false);
}

function goSearch(formName) {
	var form1 = document.getElementById(formName);

	if (checkSearch(formName)) form1.submit();
}

function checkSearch(formName) {
	var form1 = document.getElementById(formName);
	if (formName == "formSearch") {
		var returnValue = !emptyAlert(form1.pProdName,"\uac80\uc0c9\uc5b4");
	} else if (formName == "formReSearch") {
		var returnValue = !emptyAlert(form1.pChildProdName,"\uac80\uc0c9\uc5b4");
	}
	
	return returnValue;
}
function setDurationTodayByOffset(objStart, objEnd, offset) {
	var startDate = new Date();
	var endDate = new Date();
	
	startDate.setDate(startDate.getDate() + offset);         
	
	objStart.value = getDateString(startDate);
	objEnd.value = getDateString(endDate);
}
function setDurationToday(objStart,objEnd) {
	var startDate = new Date();
	var endDate = new Date();
	
	objStart.value = getDateString(startDate);
	objEnd.value = getDateString(endDate);
}
function setDurationThisWeek(objStart,objEnd) {
	var date = new Date();
	var startDate = getSundayOfThisWeek(new Date());
	var endDate = new Date();
	
	objStart.value = getDateString(startDate);
	objEnd.value = getDateString(endDate);
}
function setDurationThisMonth(objStart,objEnd) {
	var startDate = getFirstDayOfThisMonth(new Date());
	var endDate = new Date();
	
	objStart.value = getDateString(startDate);
	objEnd.value = getDateString(endDate);
}
function setDurationThisYear(objStart,objEnd) {
	var startDate = getFirstDayOfThisYear(new Date());
	var endDate = new Date();
	
	objStart.value = getDateString(startDate);
	objEnd.value = getDateString(endDate);
}
function getDateString(date) {
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var day = date.getDate();
	
	if (("" + month).length == 1) month = "0" + month;
	if (("" + day).length == 1) day = "0" + day;
	
	return year + "-" + month + "-" + day;
}
function getSundayOfThisWeek(date) {
	var day = date.getDay();

    var sunDay = new Date(date.valueOf() - (day*24*60*60*1000));

	return sunDay; 
} 
function getFirstDayOfThisMonth(date) {
	return new Date(date.getFullYear(),date.getMonth(),1);
} 
function getFirstDayOfThisYear(date) {
	return new Date(date.getFullYear(),0,1);
} 
function calDateRange(val1, val2)
    {
        var FORMAT = "-";

        if (val1.length != 10 || val2.length != 10)
            return null;

        if (val1.indexOf(FORMAT) < 0 || val2.indexOf(FORMAT) < 0)
            return null;

        var start_dt = val1.split(FORMAT);
        var end_dt = val2.split(FORMAT);

        start_dt[1] = (Number(start_dt[1]) - 1) + "";
        end_dt[1] = (Number(end_dt[1]) - 1) + "";

        var from_dt = new Date(start_dt[0], start_dt[1], start_dt[2]);
        var to_dt = new Date(end_dt[0], end_dt[1], end_dt[2]);

        return (to_dt.getTime() - from_dt.getTime()) / 1000 / 60 / 60 / 24;
    }

function addCommas( strValue )
	{
		var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
		while(objRegExp.test(strValue)) {
			strValue = strValue.replace(objRegExp, '$1,$2');
		}
		return strValue;
	} 
function setReadOnly(obj) {		
	obj.style.backgroundColor = "#e5e5e5";
	obj.readOnly = true;
	obj.value = "";
}
function resetReadOnly(obj) {		
	obj.style.backgroundColor = "#ffffff";
	obj.readOnly = false;
}

function numberFormat(n) {
  var reg = /(^[+-]?\d+)(\d{3})/;   
  n += '';                          

  while (reg.test(n))
    n = n.replace(reg, '$1' + ',' + '$2');

  return n;
}

function filterNum(str)
{
    re = /^\$|,/g;
    str = String(str);
    return str.replace(re, "");
} 

function GetAbsPosition(object) {
	var position = new Object;
	position.x = 0;
	position.y = 0;
	 
	if( object ) {
		position.x = object.offsetLeft;
		position.y = object.offsetTop;
	 
		if( object.offsetParent ) {
			var parentpos = GetAbsPosition(object.offsetParent);
			position.x += parentpos.x;
			position.y += parentpos.y;
		}
	}
	 
	position.cx = object.offsetWidth;
	position.cy = object.offsetHeight;
	 
	return position;
}

function setCalendar(formName, inputName, inputValue, todayFlag) {
	var tInputValue = inputValue;
	if (tInputValue == "" && todayFlag) tInputValue = getDateString(new Date());
	var str = "";
	str += "<input type=\"text\" name=\"" + inputName + "\" size=\"10\" maxlength=\"10\" value=\"" + tInputValue + "\" onfocus=\"javascript:setCalendarInputMode(this);\" onblur=\"javascript:resetCalendarInputMode(this);\" />"
	str += "<img src=\"/images/admin/left/product_icon_07.jpg\" border=\"0\" align=\"top\" style=\"cursor:hand;\" onclick=\"javascript:findCalendar('" + formName + "','" + inputName + "', event.x, event.y)\" />";
	document.write(str);
} 

function setCalendarAutoSubmit(formName, inputName, inputValue, todayFlag, submitFlag) {
	var tInputValue = inputValue;
	if (tInputValue == "" && todayFlag) tInputValue = getDateString(new Date());
	var str = "";
	str += "<input type=\"text\" name=\"" + inputName + "\" size=\"10\" maxlength=\"10\" value=\"" + tInputValue + "\" onfocus=\"javascript:setCalendarInputMode(this);\" onblur=\"javascript:resetCalendarInputMode(this);\""
	if (submitFlag) str += " onchange=\"javascript:document." + formName + ".submit();\" "
	str += " />"
	str += "<img src=\"/images/admin/left/product_icon_07.jpg\" border=\"0\" align=\"top\" style=\"cursor:hand;\" onclick=\"javascript:findCalendar('" + formName + "','" + inputName + "', event.x, event.y)\" />";
	document.write(str);
} 

function setDualCalendar(formName, inputName1, inputValue1, inputName2, inputValue2, todayFlag, autoSelectFlag) {
	var tInputValue1 = inputValue1;
	if (tInputValue1 == "" && todayFlag) tInputValue1 = getDateString(new Date());

	var tInputValue2 = inputValue2;
	if (tInputValue2 == "" && todayFlag) tInputValue2 = getDateString(new Date());

	var str = "";
	str += "<span id=\"transparent\">"
	if (autoSelectFlag) {
	str += "<table style=\"width:240px;\"><tr>";
	} else {
		str += "<table style=\"width:180px;\"><tr>";
	}
	str += "<td>";
	str += "<input type=\"text\" name=\"" + inputName1 + "\" size=\"10\" maxlength=\"10\" value=\"" + tInputValue1 + "\" onfocus=\"javascript:setCalendarInputMode(this);\" onblur=\"javascript:resetCalendarInputMode(this);\" />"
	str += "</td><td style=\"vertical-align:bottom;font-size:4px;\">";
	str += "<table style=\"width:11px;\">";
	str += "<tr><td style=\"vertical-align:bottom;font-size:4px;\" height=\"8\">";
	str += "<a href=\"javascript:offsetDate('" + formName + "','" + inputName1 + "',1)\"><img src=\"/images/admin/left/icon1_arr01.gif\" border=\"0\" align=\"top\" /></a>";
	str += "</td></tr>";
	str += "<tr><td style=\"vertical-align:top;font-size:4px;\" height=\"8\">";
	str += "<a href=\"javascript:offsetDate('" + formName + "','" + inputName1 + "',-1)\"><img src=\"/images/admin/left/icon1_arr02.gif\" border=\"0\" align=\"top\" /></a>";
	str += "</td></tr>";
	str += "</table>";
	str += "</td><td>";
	str += "</td><td>";
	str += " ~ ";
	str += "</td><td>";
	str += "<input type=\"text\" name=\"" + inputName2 + "\" size=\"10\" maxlength=\"10\" value=\"" + tInputValue2 + "\" onfocus=\"javascript:setCalendarInputMode(this);\" onblur=\"javascript:resetCalendarInputMode(this);\" />"
	str += "</td><td style=\"vertical-align:bottom;font-size:4px;\">";
	str += "<table style=\"width:11px;\">";
	str += "<tr><td style=\"vertical-align:bottom;font-size:4px;\" height=\"8\">";
	str += "<a href=\"javascript:offsetDate('" + formName + "','" + inputName2 + "',1)\"><img src=\"/images/admin/left/icon1_arr01.gif\" border=\"0\" align=\"top\" /></a>";
	str += "</td></tr>";
	str += "<tr><td style=\"vertical-align:top;font-size:4px;\" height=\"8\">";
	str += "<a href=\"javascript:offsetDate('" + formName + "','" + inputName2 + "',-1)\"><img src=\"/images/admin/left/icon1_arr02.gif\" border=\"0\" align=\"top\" /></a>";
	str += "</td></tr>";
	str += "</table>";
	str += "</td><td>";
	str += "<img src=\"/images/admin/left/product_icon_07.jpg\" border=\"0\" align=\"top\" style=\"cursor:hand;\" onclick=\"javascript:findDualCalendar('" + formName + "','" + inputName1 + "','" + inputName2 + "', event.x, event.y)\" /></a>";
	str += "</td>";
	
	if (autoSelectFlag) {
		str += "<td>";
		str += "<select onchange=\"javascript:setDualCalendarValueAuto('" + formName + "', '" + inputName1 + "', '" + inputName2 + "', this.value);\">";
		str += "<option value=\"\">\uc120\ud0dd</option>";
		str += "<option value=\"TODAY\">\uc624\ub298</option>";
		str += "<option value=\"WEEK\">\uc774\ubc88\uc8fc</option>";
		str += "<option value=\"MONTH\">\uc774\ubc88\ub2ec</option>";
		str += "<option value=\"YEAR\">\uc62c\ud574</option>";
		str += "<option value=\"LAST7\">1\uc8fc\uc77c</option>";
		str += "<option value=\"LAST10\">\uc5f4\ud758</option>";
		str += "<option value=\"LAST30\">30\uc77c</option>";
		str += "<option value=\"LAST365\">1\ub144</option>";
		str += "</select>"
		str += "</td>";
	} else {
		//str += "<td width=50>";
		//str += "</td>";
	}

	str += "</tr></table></span>";

	document.write(str);
} 

function setDualCalendarValueAuto(formName, inputName1, inputName2, durationCode) {
	var obj1 = eval(formName + "." + inputName1);
	var obj2 = eval(formName + "." + inputName2);
	
	if (durationCode == 'TODAY') {
		setDurationToday(obj1,obj2);
	} else if (durationCode == 'WEEK') {
		setDurationThisWeek(obj1,obj2);
	} else if (durationCode == 'MONTH') {
		setDurationThisMonth(obj1,obj2);
	} else if (durationCode == 'YEAR') {
		setDurationThisYear(obj1,obj2);
	} else if (durationCode == 'LAST7') {
		setDurationTodayByOffset(obj1,obj2,-7);
	} else if (durationCode == 'LAST10') {
		setDurationTodayByOffset(obj1,obj2,-10);
	} else if (durationCode == 'LAST30') {
		setDurationTodayByOffset(obj1,obj2,-30);
	} else if (durationCode == 'LAST365') {
		setDurationTodayByOffset(obj1,obj2,-365);
	}
}	

function setCalendarInputMode(obj) {
	obj.value = obj.value.replace(/\-/gi, "");
	//obj.select(); 
}

function resetCalendarInputMode(obj) {
	var str = obj.value;
	if (str.length == 10 || str.length == 0) {
		
	} else if (str.length == 8) {
		
		obj.value = str.substring(0,4) + "-" + str.substring(4,6) + "-" + str.substring(6,8);
	} else {
		//alert("\ub0a0\uc9dc\ud615\uc2dd\uc774 \uc798 \ubabb \ub418\uc5c8\uc2b5\ub2c8\ub2e4.");
		//obj.select();
		//return false;
	}
	return true;
}

function offsetDate(formName, inputName, offset) {
	var obj = eval(formName + "." + inputName);
	var arrDate = obj.value.split("-");
	
	if (arrDate.length == 3) {
		if (arrDate[1].substring(0,1) == "0") arrDate[1] = arrDate[1].substring(1,2);
		if (arrDate[2].substring(0,1) == "0") arrDate[2] = arrDate[2].substring(1,2);
		
		var startDate = new Date(parseInt(arrDate[0]), parseInt(arrDate[1]) - 1, parseInt(arrDate[2]));
		
		startDate.setDate(startDate.getDate() + offset);         
		obj.value = getDateString(startDate);
	}
}

/**
*
* UTF-8 data encode / decode
* http://www.webtoolkit.info/
*
**/

var Utf8 = {

    // public method for url encoding
    encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // public method for url decoding
    decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

	function checkDate(obj) {
		var str = obj.value;
		if (str.length == 10) {
			str = str.replace(/\-/gi, "");
		} 
		
		if (str.length == 8) {
			var sYear = str.substring(0,4);
			var sMonth = str.substring(4,6);
			var sDay = str.substring(6,8);
			
			if (sMonth.substring(0,1) == "0") sMonth = sMonth.substring(1,2);
			if (sDay.substring(0,1) == "0") sDay = sDay.substring(1,2);
		
			var oDate = new Date(parseInt(sYear),parseInt(sMonth) - 1,parseInt(sDay));
			
			if (
				oDate.getFullYear() != parseInt(sYear)
				|| oDate.getMonth() != (parseInt(sMonth) - 1)
				|| oDate.getDate() != parseInt(sDay)
				) {
				alert(" \ub0a0\uc9dc\ud615\uc2dd\uc774 \uc798 \ubabb \ub418\uc5c8\uc2b5\ub2c8\ub2e4.");
				obj.select();
				return false;
			}
		} else {
			alert("\ub0a0\uc9dc\ud615\uc2dd\uc774 \uc798 \ubabb \ub418\uc5c8\uc2b5\ub2c8\ub2e4.");
			obj.select();
			return false;
		}
		return true;
	}		

	function checkDate(obj, objname) {
		var str = obj.value;
		if (str.length == 10) {
			str = str.replace(/\-/gi, "");
		} 
		
		if (str.length == 8) {
			var sYear = str.substring(0,4);
			var sMonth = str.substring(4,6);
			var sDay = str.substring(6,8);
			
			if (sMonth.substring(0,1) == "0") sMonth = sMonth.substring(1,2);
			if (sDay.substring(0,1) == "0") sDay = sDay.substring(1,2);
		
			var oDate = new Date(parseInt(sYear),parseInt(sMonth) - 1,parseInt(sDay));
			
			if (
				oDate.getFullYear() != parseInt(sYear)
				|| oDate.getMonth() != (parseInt(sMonth) - 1)
				|| oDate.getDate() != parseInt(sDay)
				) {
				alert(objname + " \ub0a0\uc9dc\ud615\uc2dd\uc774 \uc798 \ubabb \ub418\uc5c8\uc2b5\ub2c8\ub2e4.");
				obj.select();
				return false;
			}
		} else {
			alert(objname + " \ub0a0\uc9dc\ud615\uc2dd\uc774 \uc798 \ubabb \ub418\uc5c8\uc2b5\ub2c8\ub2e4.");
			obj.select();
			return false;
		}
		return true;
	}	
	
	/*
	  \uc0ac\uc6a9\uc790\uc758 PC\uc758 \uc6b4\uc601\uccb4\uc81c\uac00 "\ube44\uc2a4\ud0c0" \uacbd\uc6b0 true \ub9ac\ud134
	*/ 
	function isVista() 
	{ 
	    var re = new RegExp("Windows NT ([0-9]).([0-9])" ,"g"); 
	    var m = re.exec(navigator.userAgent); 
	    return (m[1] >= 6);
	} 
	
function cutString(obj, limit) {
	obj.value = leftB(obj.value,limit);
}