﻿// open popup window
// OpenSubWindow('../open/a.aspx', 'id', 100, 100, 'no');
function OpenSubWindow(url, id, width, height, scroll) {
    var top = (screen.availHeight - height) / 2;
    var left = (screen.availWidth - width) / 2; 
    var size = 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left;
	var etc = size + ',resizable=no,scrollbars=' + scroll + ',status=no';	
	reval = window.top.open(url,id,etc);
	if (reval == null) {
	    alert('팝업 차단을 허용해 주세요');
	} else {
	    reval.focus();
	}
}
function SetCookie(name, value, expiredays) {
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + "; domain=" + "estsoft.co.jp";
}
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 OnlyNumericCheck(thisone) { 
    var tempnum = thisone.value;
    for (i = 0; i <= tempnum.length; i++) { 
        if (tempnum.charCodeAt(i) < 48 || tempnum.charCodeAt(i) > 57) {
            thisone.value = tempnum.substring(0,i);
            break ;
        }
    }
}
function DateCheck(thisone) {
    var obj = thisone.value.split("-");	
    if (obj.length == 1 && thisone.value.length == 8) {
        var yyyy = thisone.value.substring(0,4);
        var mm = thisone.value.substring(4,6);
        var dd = thisone.value.substring(6,8);
        
        if (mm > 0 && mm < 13 && dd > 0 && dd < 32) {
        	if (dd > get_Day(yyyy, mm)) {
        	    thisone.value = "";
        	    return;
            }
            thisone.value = yyyy + "-" + mm + "-" + dd;
        } else {
            thisone.value = "";
            return;
        }
    }
    else if (obj.length == 3) {
        if (obj[0] >= 0 && obj[0] < 10000 && obj[0].length == 4 && obj[1] > 0 && obj[1] < 13 && obj[1].length == 2 && obj[2] > 0 && obj[2] < 32 && obj[2].length == 2) {
            if (obj[2] > get_Day( obj[0], obj[1] )) {
                thisone.value = "";
                return;
            }
        } else {
            thisone.value ="";
        }
    } else {
        thisone.value = "";
    }
}
function get_Day(year, month) {
    var Last_Mon = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    var Mon2;    
    if ( year % 4 == 0 ) { Mon2 = true; }
    else {Mon2 = false; }
    Last_Mon[1] = (Mon2) ? 29 : 28;
    return Last_Mon[month-1];
}