/*
 * Modify Date: 20030728 by JSB
 * °øÅëÀûÀÎ ºÎºÐÀ» ´Þ·ÂÀ» Æ÷½ÃÇÏ´Â ymd.js¿Í ymd_vb.js¸¦ °øÅëÆÄÀÏ·Î µÎ°í 
 * °¢ ¸ðµâ¸¶´Ù Â÷ÀÌ°¡ ³ª´Â MiniCal()°ú doClick()¸¸ °¢ È£ÃâµÇ´Â ¸ðµâ¿¡ ÀÛ¼ºÇÑ´Ù.
 */

var target;
var stime;
function doClick() {
	cal_Day = window.event.srcElement.title;
	window.event.srcElement.style.borderColor = "red";
	dateCheck(cal_Day);
}

function doOver() {
	var el = window.event.srcElement;
	cal_Day = el.title;

	if (cal_Day.length > 7) {
		el.style.borderTopColor = el.style.borderLeftColor = "buttonhighlight";
		el.style.borderRightColor = el.style.borderBottomColor = "buttonshadow";
	}
	window.clearTimeout(stime);
}

function doOut() {
	var el = window.event.fromElement;
	cal_Day = el.title;

	if (cal_Day.length > 7) {
		el.style.borderColor = "white";
	}
	stime = window.setTimeout("minical.style.display='none';", 200);
}

function doDelete() { target.value = ""; }

function doToday() {
	var date = new Date();
    toYear  = date.getFullYear();
    toMonth = date.getMonth()+1;
    toDay   = date.getDate();
	if(toMonth<10) toMonth = "0" + toMonth;
	if(toDay<10)   toDay = "0" + toDay; 
    target.value = toYear+"-"+toMonth+"-"+toDay;
}


function dateCheck(cal_Day){

    var pos, base, ymd, mm, dd, data;

	if (cal_Day.length > 7) {
        base = cal_Day.indexOf("-");
        pos  = cal_Day.indexOf("-", base + 1);
        ymd  = cal_Day;

        cal_Day = ymd.substring(0, base);	//³âµµ ºÐ¸®
       
        //¿ùÀ» ºÐ¸®ÇÏ¿© ÇÑÀÚ¸® ÀÏ°æ¿ì '0À» ºÙ¿©ÁØ´Ù.'
        mm = ymd.substring(base + 1, pos);
        if (mm.length == 1) cal_Day += "0" + mm;
        else cal_Day += mm;
        base = pos + 1;

        //ÀÏÀ» ºÐ¸®ÇÏ¿© ÇÑÀÚ¸® ÀÏ°æ¿ì '0À» ºÙ¿©ÁØ´Ù.'
        dd = ymd.substring(base, ymd.length);
        if (dd.length == 1){ cal_Day += "0" + dd; }
        else { cal_Day += dd; }
        data = cal_Day.substring(0,4)+"-"+cal_Day.substring(4,6)+"-"+cal_Day.substring(6,8);
        target.value = data;
    }
}
