function dvf_textDateCheck(p_date) {
		var dateValue = p_date.value;
		var dateLength = dateValue.length;

		if (dateValue == false && dateValue != "0")
			return true;

		if ( !dvf_checkDateChar(dateValue) ) {
			alert("날짜 형식에 맞지 않습니다.");
			p_date.value = "";
			p_date.focus();
			return false;
		}

		if( dateLength == 8 )
		{
			if( dvf_dateCheck(dateValue) )
			{
				dateValue = dateValue.substring(0,4)+"-"+dateValue.substring(4,6)+"-"+dateValue.substring(6,8);
				p_date.value = dateValue;
				return true;
			}
			else
			{
				alert("날짜 형식에 맞지 않습니다.");
				p_date.value = "";
				p_date.focus();
				return false;
			}
		}
		else if( dateLength == 10 )
		{
			if( dvf_dateCheck10(dateValue) )
			{
				return true;
			}
			else
			{
				alert("날짜 형식에 맞지 않습니다.");
				p_date.value = "";
				p_date.focus();
				return false;
			}
		}
		else
		{
			alert("날짜 형식에 맞지 않습니다.");
			p_date.value = "";
			p_date.focus();
			return false;
		}
}

function dvf_checkNumChar(p_checkData) {
		var numReg = /[^0-9]+/g;
		return !numReg.test(p_checkData);
}

/*
 * 숫자가 마스킹 되었는지를 판단한다.
 *
 * 작성자 : 홍재훈
 * 작성일 : 2007. 09. 17
 */
function dvf_isMaskNumber(p_maskNumber) {
	if ( p_maskNumber == null || p_maskNumber.length == 0 ) return false;

	if ( p_maskNumber.indexOf(",") > 0 )
		return true;
	return false;
}

/*
 * 숫자에 들어간 ','를 없애주는 스크립트
 *
 * 작성자 : 홍재훈
 * 작성일 : 2007. 09. 17
 */
function dvf_offMaskNumber(p_maskNumber) {
	if ( p_maskNumber == null || p_maskNumber.length == 0 ) return "";

	var maskReg = /,/g;
	return p_maskNumber.replace(maskReg, "");
}

/*
 * 날자 형식에 들어간 구분 기호를 없애주는 스크립트
 *
 * 작성자 : 홍재훈
 * 작성일 : 2007. 09. 17
 */
function dvf_offMaskDate(p_maskDate) {
	if ( p_maskDate == null || p_maskDate.length == 0 ) return "";

	var maskReg = /[0-9]+/g;
	var arrResult = p_maskDate.match(maskReg);
	var result = "";
	for (var idx = 0; idx < arrResult.length; idx++)
	{
		result += arrResult[idx];
	}

	return result;
}

/*
 * 숫자에 세자리 마다 ','를 찍어주는 스크립트
 *
 * 작성자 : 홍재훈
 * 작성일 : 2007. 09. 17
 */
function dvf_maskNumber(p_srcNumber) {
	if ( typeof(p_srcNumber) == "undefined" || p_srcNumber == "" ) {
		return "0";
	}

	var val = String(p_srcNumber);
	val = dvf_offMaskNumber(val);

	if ( val == "" ) return "0";

	if ( !dvf_checkNumberChar(val) ) {
		alert("숫자만 입력하세요.");
		return "0";
	}

	var minus = "";
	var remainder = "";
	var percent = "";

	if ( val.substring(0, 1) == "-" ) {
		minus = val.substring(0, 1);
		val = val.substring(1);
	}

	while ( val.indexOf("-") != -1 )
		val = val.replace("-", "");

	if ( val.substring(val.length-1, val.length) == "%" ) {
		percent = val.substring(val.length-1, val.length);
		val = val.substring(0, val.length-1);
	}

	while ( val.indexOf("%") != -1 )
		val = val.replace("%", "");

	if ( val.indexOf(".") > 0 ) {
		// 소수점이 있는 경우
		remainder = val.substring(val.indexOf(".")+1);
		val = val.substring(0, val.indexOf("."));

		if ( remainder.indexOf(".") != -1 ) {
			alert("실수 형식이 올바르지 않습니다.");
			return "0";
		}
	}

	var len = val.length;

	if ( len < 4 ) return minus + val + ((remainder != "") ? "." + remainder : "");

	var loop = 1;
	var count = 0;
	var retVal = "";

	while ( loop < len + 1 ) {
		if ( count == 3 ) {
			count = 1;
			retVal = "," + retVal;
		}
		else
			count++;

		retVal = val.substring(len-loop, len-loop+1) + retVal;
		loop++;
	}

	return minus + retVal + ((remainder != "") ? "." + remainder : "") + percent;
}
function dvf_checkNumberChar(check){
    var inputVal = escape(check);
	var isNum = /[^0-9\-.]+/g;
	return !isNum.test(inputVal);
}

function dvf_simpleGrid(p_dataset, p_grid, p_clear)
{
	var dataBody = jQuery(p_grid).find(".data_body");
	if (p_clear)
	{
		dataBody.children(":not(.row_struct)").remove();
	}

	var rowStruct = jQuery(p_grid).find(".row_struct");
	var rowTemp = rowStruct.clone();
	rowTemp.removeClass("row_struct");

	jQuery(p_dataset).each(function() {
		var datarec = this;
		var row = rowTemp.clone();

		//row.find("[@datafields]").each(function() {
		row.find("[datafields]").each(function() {
			var fieldSrc = $(this).html();
			var arrFields = $(this).attr("datafields").split(",");

			for (var idx = 0; idx < arrFields.length; idx++)
			{
				var fieldId = jQuery.trim(arrFields[idx]);
				//var val = eval("datarec." + fieldId);
				var val = datarec[fieldId];
				if (val == undefined)
				{
					val = "";
				}

				if (jQuery(this).attr("bef_callback"))
				{
					val = eval(jQuery(this).attr("bef_callback") + "('" + fieldId + "', '" + val + "', this)");
					//document.scripts[jQuery(this).attr("bef_callback")](val);
				}

				var regexp = new RegExp("%" + fieldId + "%", "ig");
				fieldSrc = fieldSrc.replace(regexp, val);

				if (jQuery(this).attr("aft_callback"))
				{
					eval(jQuery(this).attr("aft_callback") + "('" + fieldId + "', '" + val + "', this)");
				}
			}

			jQuery(this).removeAttr("datafields");
			jQuery(this).empty();
			jQuery(this).html(fieldSrc);
			//jQuery(this).html(fieldSrc);
		});

		row.appendTo(dataBody);
        row.show();
	});
}

function dvf_toggleGrid(p_dataset, p_grid, p_rowBg, p_clear)
{
	var dataBody = jQuery(p_grid).find(".data_body");
	if (p_clear)
	{
		dataBody.children(":not(.row_struct)").remove();
	}

	var rowStruct = jQuery(p_grid).find(".row_struct");
	var rowTemp = rowStruct.clone();
	rowTemp.removeClass("row_struct");

	jQuery(p_dataset).each(function() {
		var datarec = this;
		var row = rowTemp.clone();
		//alert("row_struct=[" + row.html() + "]");

		row.find("[@datafields]").each(function() {
			var fieldSrc = $(this).html();
			var arrFields = $(this).attr("datafields").split(",");

			for (var idx = 0; idx < arrFields.length; idx++)
			{
				var fieldId = jQuery.trim(arrFields[idx]);
				//var val = eval("datarec." + fieldId);
				var val = datarec[fieldId];
				if (val == undefined)
				{
					val = "";
				}

				if (jQuery(this).attr("bef_callback"))
				{
					val = eval(jQuery(this).attr("bef_callback") + "('" + fieldId + "', '" + val + "', this)");
					//document.scripts[jQuery(this).attr("bef_callback")](val);
				}

				var regexp = new RegExp("%" + fieldId + "%", "ig");
				fieldSrc = fieldSrc.replace(regexp, val);

				if (jQuery(this).attr("aft_callback"))
				{
					eval(jQuery(this).attr("aft_callback") + "('" + fieldId + "', '" + val + "', this)");
				}
			}

			jQuery(this).removeAttr("datafields");
			jQuery(this).empty();
			jQuery(this).html(fieldSrc);
			//jQuery(this).html(fieldSrc);
		});

		row.appendTo(dataBody);
	});
}

function dvf_simpleGridClear(p_grid)
{
	var dataBody = jQuery(p_grid).find(".data_body");
	dataBody.children(":not(.row_struct)").remove();
}

function dvf_checkDateChar(check)
{
    var inputVal = escape(check);
	var dateReg = /[^0-9\-\/.]+/g;
	return !dateReg.test(inputVal);
}

function dvf_dateCheck(dateVal) {
    var ymd = dateVal;
    var year;
    var month;
    var day;
    var febEndday;

    if( dateVal.length == 0 )   return true;
    if( dateVal.length != 8 )   return false;

    year = ymd.substring(0,4);                  // 년도
    month = ymd.substring(4,6);                 // 월
    day = ymd.substring(6,8);                       // 일

    if (month > 12 || month < 01 || ymd.length < 08 || isNaN(ymd) || day <= 00)
    {
        return false;                           // 월>12,월<1,년월일:8자리이하,년월일:Non Numeric, 일:00 이하     -> return false
    }
    else if (month == 01 || month == 03 || month == 05 || month == 07 ||
        month == 08 || month == 10 || month == 12)
    {
        if (day > 31)
            return false;                       // 1월 3월 5월 7월 8월 10월 12월: 일 -> 31 초과이면 return false
    }
    else if (month == 04 || month == 06 || month == 09 || month == 11)
    {
        if (day > 30)
            return false;                       // 4월 6월 9월 11월: 일 -> 30 초과이면 return false
    }
    else if (month == 02)                       // 2월인 경우
    {
        if (year % 400 == 0)
            febEndday = 29;                     // 년도가 400으로 나눠질 경우 마지막날은 29일
        else if (year % 100 == 0)
            febEndday = 28;                     // 년도가 100으로 나눠질 경우 마지막날은 28일
        else if (year % 4   == 0)
            febEndday = 29;                     // 년도가   4  로 나눠질 경우 마지막날은 29일
        else
            febEndday = 28;                     // 나머지 경우의 마지막날은 28일

        if (day > febEndday)
            return false;                       // 일이 마지막날보다 크면 return false;
    }
    return true;
}

function dvf_dateCheck10(dateVal) {
    var ymd = dateVal;
    var year;
    var month;
    var day;
    var febEndday;

    if( dateVal.length == 0 )   return true;
    if( dateVal.length != 10 )  return false;

    year = ymd.substring(0,4);                  // 년도
    month = ymd.substring(5,7);                 // 월
    day = ymd.substring(8,10);                  // 일

    if ( !dvf_checkNumChar(year) )
        return false;

    if ( !dvf_checkNumChar(month) )
        return false;

    if ( !dvf_checkNumChar(day) )
        return false;

    if (month > 12 || month < 01 || ymd.length < 08 || day <= 00)
    {
        return false;                           // 월>12,월<1,년월일:8자리이하,년월일:Non Numeric, 일:00이하        -> return false
    }
    else if (month == 01 || month == 03 || month == 05 || month == 07 ||
        month == 08 || month == 10 || month == 12)
    {
        if (day > 31)
        {
            return false;                       // 1월 3월 5월 7월 8월 10월 12월: 일 -> 31 초과이면 return false
        }
    }
    else if (month == 04 || month == 06 || month == 09 || month == 11)
    {
        if (day > 30)
        {
            return false;                       // 4월 6월 9월 11월: 일 -> 30 초과이면 return false
        }
    }
    else if (month == 02)                       // 2월인 경우
    {
        if (year % 400 == 0)
            febEndday = 29;                     // 년도가 400으로 나눠질 경우 마지막날은 29일
        else if (year % 100 == 0)
            febEndday = 28;                     // 년도가 100으로 나눠질 경우 마지막날은 28일
        else if (year % 4   == 0)
            febEndday = 29;                     // 년도가   4  로 나눠질 경우 마지막날은 29일
        else
            febEndday = 28;                     // 나머지 경우의 마지막날은 28일

        if (day > febEndday)
        {
            return false;                       // 일이 마지막날보다 크면 return false;
        }
    }
    return true;
}

function dvf_pageload(p_hash)
{
	var loadtype = typeof(jQuery.iae_pageload);
	if (loadtype.toUpperCase() == "FUNCTION")
	{
		jQuery.iae_pageload(p_hash);
	}
}

function dvf_setHistory()
{
//	var loadtype = typeof(p_loadHandler);
//	if (loadtype.toUpperCase() == "FUNCTION")
//	{
//		// Initialize history plugin.
//		// The callback is called at once by present location.hash.
//		jQuery.historyInit(p_loadHandler);
//	}

	// jQuery.iad_pageload를 바로 historyInit에 적용 안하는 이유는
	// 아래 구문을 실행할 때 jQuery.iad_pageload 함수를 인식하지 못하면
	// 오류가 발생하므로 위에서 정의한 dvf_pageload 함수로 Initial 한다.
	jQuery.historyInit(dvf_pageload);
}

function dvf_historyHandler(p_href)
{
    //
    //var hash = this.href;
    //hash = hash.replace(/^.*#/, '');
	var hash = p_href.replace(/^.*#/, '');

    // moves to a new page.
    // pageload is called at once.
	window.setTimeout("jQuery.historyLoad('" + hash + "')", 50);
    //jQuery.historyLoad(hash);
    return false;
}

function dvf_pushHistory(p_url)
{
	var hash = p_url;
	var hash = hash.replace(/^.*#/, '');

    // moves to a new page.
    // pageload is called at once.
    jQuery.historyLoad(hash);
	return false;
}

// 외부에 open되는 함수라서 함수명 전치사 dvf_ 대신 f_로 함.
function f_openPopup(p_url, p_target, p_width, p_height, p_scrollbar)
{
	LeftPos = (screen.width) ? (screen.width-180)/2 : 0;
	TopPos = (screen.height) ? (screen.height-280)/2 : 0;
	var popup_win = window.open(p_url ,p_target, "left="+LeftPos+",top="+TopPos+",width="+p_width+",height="+p_height+",location=no,toolbar=no,menubar=no,status=no,resizable=no,scrollbars="+ p_scrollbar);

	return popup_win;
}

function f_openPopup2(p_url, p_target, p_width, p_height, p_scrollbar)
{
	LeftPos = (screen.width) ? (screen.width-1024)/2 : 0;
	TopPos = (screen.height) ? (screen.height-487)/2 : 0;
	var popup_win = window.open(p_url ,p_target, "left="+LeftPos+",top="+TopPos+",width="+p_width+",height="+p_height+",location=no,toolbar=no,menubar=no,status=no,resizable=no,scrollbars="+ p_scrollbar);

	return popup_win;
}

//p_idZipcode : 우편번호 받을 ID, p_idAddress : 주소 받을 ID
//p_intraGroupCode : 담당지사코드 받을 ID, p_intraGroupName : 담당지사이름 받을 ID,
function dvf_viewPopbestform(arg)
{
	$.ajax({
		url: "/service/login/svc_login_user.asp",
		type: 'POST',
		data: '',
		dataType: 'json',
		async: false,
		//timeout: 3000,
		error: function() {
			alert("Login 정보 확인 중 오류 발생.");
		},
		success: function(p_data) {
			if (p_data.is_login)
			{
            	window.open('/study_info/pop_sch_view.asp?best_cd='+arg,'','width=800,height=600,scrollbars=yes,resizable=yes');
			}
			else
			{
                // Login하지 않은 경우 로그인 popup을 띄워 Login 확인한 후
                // 다시 수행해야 할 부분을 aftLogin callback 함수에 정의한다.
                jQuery.extend({
                    aftLogin: function() {
                        window.open('/study_info/pop_sch_view.asp?best_cd='+arg,'','width=800,height=600,scrollbars=yes,resizable=yes');
                    }
                });

                // Login popup open. 페이지 load 시 로그인상태였기 때문에 lnk_login 개체가
                // hidden 상태임. 따라서 로그인 layer popup을 화면 중앙에 표시
                open_loginPop(null);
			}
        }
	});
}

function dvf_viewPoplangform(arg)
{
	$.ajax({
		url: "/service/login/svc_login_user.asp",
		type: 'POST',
		data: '',
		dataType: 'json',
		async: false,
		//timeout: 3000,
		error: function() {
			alert("Login 정보 확인 중 오류 발생.");
		},
		success: function(p_data) {
			if (p_data.is_login)
			{
                window.open('/study_info/pop_langsch_view.asp?school_index_code='+arg,'','width=852,height=600,scrollbars=yes,resizable=yes');
			}
			else
			{
                // Login하지 않은 경우 로그인 popup을 띄워 Login 확인한 후
                // 다시 수행해야 할 부분을 aftLogin callback 함수에 정의한다.
                jQuery.extend({
                    aftLogin: function() {
                        window.open('/study_info/pop_langsch_view.asp?school_index_code='+arg,'','width=852,height=600,scrollbars=yes,resizable=yes');
                    }
                });

                // Login popup open. 페이지 load 시 로그인상태였기 때문에 lnk_login 개체가
                // hidden 상태임. 따라서 로그인 layer popup을 화면 중앙에 표시
                open_loginPop(null);
			}
        }
	});
}

function dvf_viewPopunijapform(arg)
{
	$.ajax({
		url: "/service/login/svc_login_user.asp",
		type: 'POST',
		data: '',
		dataType: 'json',
		async: false,
		//timeout: 3000,
		error: function() {
			alert("Login 정보 확인 중 오류 발생.");
		},
		success: function(p_data) {
			if (p_data.is_login)
			{
                window.open('/study_info/pop_unisch_jp_view.asp?school_index_code='+arg,'','width=852,height=600,scrollbars=yes,resizable=yes');
			}
			else
			{
                // Login하지 않은 경우 로그인 popup을 띄워 Login 확인한 후
                // 다시 수행해야 할 부분을 aftLogin callback 함수에 정의한다.
                jQuery.extend({
                    aftLogin: function() {
                        window.open('/study_info/pop_unisch_jp_view.asp?school_index_code='+arg,'','width=852,height=600,scrollbars=yes,resizable=yes');
                    }
                });

                // Login popup open. 페이지 load 시 로그인상태였기 때문에 lnk_login 개체가
                // hidden 상태임. 따라서 로그인 layer popup을 화면 중앙에 표시
                open_loginPop(null);
			}
        }
	});
}

// 학교상세보기 popup 새로 정의
function dvf_viewPopSchool(p_url, p_w, p_h)
{
	$.ajax({
		url: "/service/login/svc_login_user.asp",
		type: 'POST',
		data: '',
		dataType: 'json',
		async: false,
		//timeout: 3000,
		error: function() {
			alert("Login 정보 확인 중 오류 발생.");
		},
		success: function(p_data) {
			if (p_data.is_login)
			{
                window.open(p_url,'','width=800,height=600,scrollbars=yes,resizable=yes');
			}
			else
			{
                // Login하지 않은 경우 로그인 popup을 띄워 Login 확인한 후
                // 다시 수행해야 할 부분을 aftLogin callback 함수에 정의한다.
                jQuery.extend({
                    aftLogin: function() {
                        window.open(p_url,'','width=800,height=600,scrollbars=yes,resizable=yes');
                    }
                });

                // Login popup open. 페이지 load 시 로그인상태였기 때문에 lnk_login 개체가
                // hidden 상태임. 따라서 로그인 layer popup을 화면 중앙에 표시
                open_loginPop(null);
			}
        }
	});
}

//학교상담팝업
function dvf_viewPopCounsel(schCd){
    var arrSchIndex = schCd.split(",");
    var popUrl;
    if (arrSchIndex.length > 1)
    {
    	popUrl = "/counsel/pop_qna_write.asp?qna_type=5&list_pickSch=" + schCd;
    }
    else
    {
    	popUrl = "/counsel/pop_qna_write.asp?school_index_code=" + schCd;
    }

	$.ajax({
		url: "/service/login/svc_login_user.asp",
		type: 'POST',
		data: '',
		dataType: 'json',
		async: false,
		//timeout: 3000,
		error: function() {
			alert("Login 정보 확인 중 오류 발생.");
		},
		success: function(p_data) {
			if (p_data.is_login)
			{
                var pop_Qwin = window.open(popUrl,"Qwin","width=640,height=760,scrollbars=yes");
                pop_Qwin.focus();
			}
			else
			{
                // Login하지 않은 경우 로그인 popup을 띄워 Login 확인한 후
                // 다시 수행해야 할 부분을 aftLogin callback 함수에 정의한다.
                jQuery.extend({
                    aftLogin: function() {
                        var pop_Qwin = window.open(popUrl,"Qwin","width=640,height=760,scrollbars=yes");
                        pop_Qwin.focus();
                    }
                });

                // Login popup open. 페이지 load 시 로그인상태였기 때문에 lnk_login 개체가
                // hidden 상태임. 따라서 로그인 layer popup을 화면 중앙에 표시
                open_loginPop(null);
			}
        }
	});
}

//학교자료요청팝업
function dvf_viewPopUserReq(schCd){
	$.ajax({
		url: "/service/login/svc_login_user.asp",
		type: 'POST',
		data: '',
		dataType: 'json',
		async: false,
		//timeout: 3000,
		error: function() {
			alert("Login 정보 확인 중 오류 발생.");
		},
		success: function(p_data) {
			if (p_data.is_login)
			{
                var pop_Rwin = window.open('/user_req/pop_sch_catalogue_req.asp?list_pickSch='+ schCd,'Rwin','width=640,height=760,scrollbars=yes');
                pop_Rwin.focus();
			}
			else
			{
                // Login하지 않은 경우 로그인 popup을 띄워 Login 확인한 후
                // 다시 수행해야 할 부분을 aftLogin callback 함수에 정의한다.
                jQuery.extend({
                    aftLogin: function() {
                        var pop_Rwin = window.open('/user_req/pop_sch_catalogue_req.asp?list_pickSch='+ schCd,'Rwin','width=640,height=760,scrollbars=yes');
                        pop_Rwin.focus();
                    }
                });

                // Login popup open. 페이지 load 시 로그인상태였기 때문에 lnk_login 개체가
                // hidden 상태임. 따라서 로그인 layer popup을 화면 중앙에 표시
                open_loginPop(null);
			}
        }
	});
}


function dvf_byteLength(p_val)
{
	return (p_val.length + (escape(p_val)+"%u").match(/%u/g).length - 1);
}

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

	return p_src
}

function dvf_ellipsisStr(p_src, p_len)
{
	var l = 0;
	for (var i=0; i < p_src.length; i++) {
		l += (p_src.charCodeAt(i) > 128) ? 2 : 1;
		if (l > p_len)
			return p_src.substring(0,i) + "..";
	}

	return p_src
}

function dvf_getCookieValue(p_cookieName)
{
    var allCookies=document.cookie.split('; ');  // cookies are separated by semicolons
    for (var idx = 0; idx < allCookies.length; idx++)
	{
        cookieArray = allCookies[idx].split('='); // a name/value pair (a crumb) is separated by an equal sign
        if (p_cookieName == cookieArray[0])
			return unescape(cookieArray[1]);
    }

	return null;
}

function dvf_webcall(p_url, p_callback)
{
	$.ajax({
		url: p_url,
		type: 'POST',
		data: '',
		dataType: 'json',
		async: false,
		//timeout: 3000,
		error: function() {
			alert("Login 정보 확인 중 오류 발생.");
		},
		success: function(p_data) {
			if (p_data.is_login)
			{
				//f_liveact_btn(p_data.now_hour, p_data.user_seq);
				if (typeof(p_callback) == "function")
				{
					p_callback();
				}
				else
				{
					// callback 함수가 지정안됐으면 default 함수가 정의됐는지 check하여 있으면 호출.
					if (typeof(open_webcall_win) == "function")
					{
						open_webcall_win();
					}
				}
			}
			else
			{
				//alert('로그인 또는 회원가입후 사용하실 수 있습니다');
                // Login하지 않은 경우 로그인 popup을 띄워 Login 확인한 후
                // 다시 수행해야 할 부분을 aftLogin callback 함수에 정의한다.
                jQuery.extend({
                    aftLogin: function() {
                        if (typeof(p_callback) == "function")
                        {
                            p_callback();
                        }
                        else
                        {
                            // callback 함수가 지정안됐으면 default 함수가 정의됐는지 check하여 있으면 호출.
                            if (typeof(open_webcall_win) == "function")
                            {
                                open_webcall_win();
                            }
                        }
                    }
                });

                // Login popup open. 페이지 load 시 로그인상태였기 때문에 lnk_login 개체가
                // hidden 상태임. 따라서 로그인 layer popup을 화면 중앙에 표시
                open_loginPop(null);
			}
        }
	});
}

function dvf_intSchProcSession(p_proc, p_schIndex, p_url)
{
	var param = "proc="+ p_proc +"&schIndex="+ p_schIndex;
	$.ajax({
		url: p_url,
		type: 'POST',
		data: param,
		dataType: 'json',
		error: function() {
			alert("Error loading");
		},
		success: function(p_data) {
			if (p_data.result == "Success"){
				alert("관심학교 리스트에 담았습니다.");
			}else if(p_data.result == "Fail1"){
				alert("DB저장 실패했습니다.");
			}
			else if(p_data.result == "Fail2"){
				alert("DB삭제 실패했습니다.");
			}
			else if(p_data.result == "Fail3"){
				alert("세션정보가 없습니다.");
			}
			else if(p_data.result == "Fail4"){
				alert("보관되어 있는 학교입니다.");
			}
		}
	});
}

function dvf_html2entity(p_src)
{
	var result = "";
	if (p_src != null && p_src != undefined)
	{
		result = p_src.replace(/&/g, "&amp;").replace(/\?/g, "&#63;").replace(/:/g, "&#58;").replace(/\//g, "&#47;").replace(/'/g, "&#39;").replace(/"/g, "&quot;").replace(/\./g, "&#46;");
	}

	return result;
}

function dvf_getPosition(obj){
	var curleft = obj.offsetLeft || 0;
	var curtop = obj.offsetTop || 0;
	while (obj = obj.offsetParent)
	{
		curleft += obj.offsetLeft
		curtop += obj.offsetTop
	}
	return {x:curleft,y:curtop};

}

jQuery.fn.extend({
	/*
	 * 메소드를 호출한 DOM 개체 위에 화면상의 중심 방향으로 확대되는 Popup widget의 좌측 상단 좌표 계산
	 *
	 * 작성자 : 홍재훈
	 * 작성일 : 2007. 09. 17
	 */
	dvf_extWindowPos: function(p_param) {
		var settings = jQuery.extend({
			srcContainer:jQuery("body"),
			extWgtWidth: 0,
			extWgtHeight: 0
		}, p_param);

		var srcWidget = jQuery(this);

		// Source Widget의 중앙 위치 계산
		var hCenter = (settings.srcContainer.width() / 2) + jQuery.iUtil.getPosition(settings.srcContainer[0]).x;
		var vCenter = (settings.srcContainer.height() / 2) + jQuery.iUtil.getPosition(settings.srcContainer[0]).y;

		var wgtPos = jQuery.iUtil.getPosition(srcWidget[0]);

		var popWinX = wgtPos.x;
		var popWinY = wgtPos.y;

		// widget의 left 위치가 widget 배열의 container 우측에 있을 경우엔 popup window가 좌측으로 확장되게 위치를 지정.
		if (wgtPos.x > hCenter)
		{
			if (settings.extWgtWidth > 0)
			{
				popWinX = wgtPos.x - settings.extWgtWidth + srcWidget.width();
			}
		}

		if (wgtPos.y > vCenter)
		{
			if (settings.extWgtHeight > 0)
			{
				popWinY = wgtPos.y - settings.extWgtHeight + srcWidget.height();
			}
		}

		var result = new Array();
		result[0] = popWinX;
		result[1] = popWinY;
		//extWin.css("top", String(popWinY) + "px");
		//extWin.css("left", String(popWinX) + "px");

		return result;
	},

	/*
	 * 이 메소드를 호출한 개체에 scroll event를 설정하여 수직방향으로 개체의 가장 밑바닥까지 scroll 되었을 경우
	 * parameter로 전달된 callback 함수를 호출한다.
	 *
	 * 사용 plug-in :
	 * 작성자 : 홍재훈
	 * 작성일 : 2007. 09. 17
	 */
	dvf_vScrollBottom: function(p_callback) {
		jQuery(this).scroll(function(p_event) {
			// p_event.stopPropagation();
			if ( (p_event.target.scrollHeight - p_event.target.scrollTop) <= p_event.target.offsetHeight )
			{
				if (p_callback != undefined && !jQuery.isPaging)
				{
					if (jQuery.isPaging == undefined)
					{
						jQuery.extend({ isPaging: true });
					}
					else
					{
						jQuery.isPaging = true;
					}

					p_callback(p_event);
				}
				else
				{
					//alert("paging...");
				}
			}
		});
	},

	/*
	 * 데이터쌍을 셀렉트박스 형식으로 반환
	 *
	 * 작성자 : 김학성
	 * 작성일 : 2007. 10. 07
	 *
	 *    $(this).dvf_getSelectTag({
	 *			srcContainer:jQuery("#codeSelectBox"),
	 *			serviceSrc: '/service/common/svc_code_list.asp',
	 *			param: "code=1087&lang_div=0&notInCodes=",
	 *			jsonName: "codeDatas",
	 *			codeField: "code",
	 *			dataField: "codeName",
	 *          selectTagID: "",
	 *			ment: "",
	 *          changeHandler: function(_arg){ alert(_arg);}
	 *    });
	 *
	 *     <div id="codeSelectBox"></div>
	 */
	dvf_getSelectTag: function(p_param) {
		var settings = jQuery.extend({
			srcContainer: null,
			serviceSrc: "",
			param: "",
			jsonName: "",
			codeField: "",
			dataField: "",
            selectTagID: "",
			ment: "",
            changeHandler: function(_arg){
                                return;
                           }
		}, p_param);

        $.ajax({
            url: settings.serviceSrc,
            type: 'POST',
            data: settings.param,
            dataType: 'json',
            //timeout: 3000,
			async: false,
            error: function() {
                alert("Error loading SelectBox List");
            },
            success: function(_data) {
                fnGetContent(_data, settings);
            }
        });

        function fnGetContent(p_data, p_settings){
            p_settings.srcContainer.empty();

            if (eval("p_data."+p_settings.jsonName) != undefined){
                var select = $("<select id='"+ p_settings.selectTagID +"'></select>");
                var option, code, codeName;

                if (p_settings.ment != "")
                {
                    select.append($("<option value=''>"+ p_settings.ment +"</option>"));
                }

                $(eval("p_data."+p_settings.jsonName)).each(function() {
                    code = eval("this."+p_settings.codeField);
                    codeName = unescape(eval("this."+p_settings.dataField));

                    option = $("<option value='"+ code +"'>"+ codeName +"</option>");

                    select.append(option);
                });
                if (p_settings.changeHandler != undefined)
                {
                    //select.change(p_settings.changeHandler);
                    select.change(function() { p_settings.changeHandler(select.val()); });
                }

                select[0].selectedIndex = 0;

                p_settings.srcContainer.append(select);
                p_settings.srcContainer.show();
            }else{
                p_settings.srcContainer.hide();
            }
        }
    }
});

/*
 * 툴팁 띄워주는 스크립트
 * "김학성과장님"이 만는것을 수정.....
 * 작성자 : 김경의
 * 작성일 : 2007. 11. 14
 */
function dvf_read_help(p_target, p_helpCd, p_boxWidth, p_boxheight, p_title, p_contents)
{
    var tooltipWin;
    $("#"+ p_target).bind("mouseover", function(e){
        tooltipWin = dvf_help_contents(e, p_helpCd, p_boxWidth, p_boxheight, p_title, p_contents);
        tooltipWin.show();
    }).css("cursor", "pointer");

    $("#"+ p_target).mouseout(function(){
		//$(this).unbind("mouseover");
		tooltipWin.hide();
    });
}

function dvf_read_help_click(p_target, p_helpCd, p_boxWidth, p_boxheight, p_title, p_contents)
{
    var tooltipWin;
    $("#"+ p_target).toggle(function(e) {
        tooltipWin = dvf_help_contents(e, p_helpCd, p_boxWidth, p_boxheight, p_title, p_contents);
        tooltipWin.show();
    }, function(){tooltipWin.hide();}).css("cursor", "pointer");
}

function dvf_help_contents(e, p_helpCd, p_boxWidth, p_boxheight, p_title, p_contents)
{
    var mouseEvt = e ? e : window.event;
    var x = mouseEvt.clientX;
    var y = mouseEvt.clientY;
	var topOffset;
	var leftOffset;
	topOffset = y + document.body.scrollTop;
	leftOffset = x + document.body.scrollLeft;
	var winTop = (y > p_boxheight ? topOffset - p_boxheight - 10 : topOffset + 10);
	var winLeft = (x > p_boxWidth/2 ? leftOffset - p_boxWidth/2 : leftOffset);
	// 툴팁이 1024를 벗어날 경우 위치 이동
	var ttRightPoint = winLeft + p_boxWidth;
	if (ttRightPoint > 1024){
		winLeft = winLeft - (ttRightPoint - 1000);
	}
	//툴팁화살표 표시 유동적으로
	var ttArrowPos = x - winLeft;

	winLeft += "px";
	winTop += "px";
	//alert(winLeft +'|'+ttRightPoint);
    var brHelp = $("<div style='display:none;z-index:102;'></div>");
    var brHelpHtml="<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"+
                    "  <tr>"+
                    "    <td width=\"4\" height=\"4\"><img src=\"http://image.eduhouse.net/iaeweb/img/ball_box_tl.gif\" width=\"4\" height=\"4\"></td>"+
                    "    <td height=\"4\" background=\"http://image.eduhouse.net/iaeweb/img/ball_box_tbg.gif\"><img src=\"http://image.eduhouse.net/iaeweb/img/ball_box_tbg.gif\" width=\"4\" height=\"4\"></td>"+
                    "    <td width=\"4\" height=\"4\"><img src=\"http://image.eduhouse.net/iaeweb/img/ball_box_tr.gif\" width=\"4\" height=\"4\"></td>"+
                    "  </tr>"+
                    "  <tr>"+
                    "    <td width=\"4\" background=\"http://image.eduhouse.net/iaeweb/img/ball_box_lbg.gif\"><img src=\"http://image.eduhouse.net/iaeweb/img/ball_box_lbg.gif\" width=\"4\" height=\"4\"></td>"+
                    "    <td><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">"+
                    "        <tr>"+
                    "          <td height=\"30\" background=\"http://image.eduhouse.net/iaeweb/img/ball_box_gra.gif\"  style=\"padding:5 5 5 5\" class=\"qa_sch_line\">%help_title%</td>"+
                    "        </tr>"+
                    "        <tr>"+
                    "          <td height=\"2\" background=\"http://image.eduhouse.net/iaeweb/img/ball_box_line.gif\"><img src=\"http://image.eduhouse.net/iaeweb/img/ball_box_line.gif\" width=\"2\" height=\"2\"></td>"+
                    "        </tr>"+
                    "        <tr>"+
                    "          <td style=\"padding:5 5 5 5\" class=\"co_list\">%help_contents%</td>"+
                    "        </tr>"+
                    "      </table></td>"+
                    "    <td width=\"4\" background=\"http://image.eduhouse.net/iaeweb/img/ball_box_rbg.gif\"><img src=\"http://image.eduhouse.net/iaeweb/img/ball_box_rbg.gif\" width=\"4\" height=\"4\"></td>"+
                    "  </tr>"+
                    "  <tr>"+
                    "    <td width=\"4\" height=\"7\"><img src=\"http://image.eduhouse.net/iaeweb/img/ball_box_bl.gif\" width=\"4\" height=\"6\"></td>"+
                    "    <td height=\"7\" background=\"http://image.eduhouse.net/iaeweb/img/ball_box_bbg.gif\"><img style=\"margin-left: "+ ttArrowPos +"px;\" src=\"http://image.eduhouse.net/iaeweb/img/ball_box_barr.gif\" width=\"8\" height=\"7\"></td>"+
                    "    <td width=\"4\" height=\"7\"><img src=\"http://image.eduhouse.net/iaeweb/img/ball_box_br.gif\" width=\"4\" height=\"6\"></td>"+
                    "  </tr>"+
                    "</table>";

    brHelpHtml = brHelpHtml.replace(/%help_title%/ig, p_title);
    brHelpHtml = brHelpHtml.replace(/%help_contents%/ig, p_contents);

    brHelp.append(brHelpHtml);
	var brHelpPan = "<iframe id='brHelpFrm' src='about:blank' mce_src='about:blank' scrolling='no' frameborder='0'></iframe>";
	brHelp.before(brHelpPan);
	$("body").append(brHelp);
	$("#brHelpFrm").css({width:p_boxWidth,
                       height:p_boxheight,
                       top:winTop,
                       left:winLeft,
						position:"absolute"});

	return brHelp.css({width:p_boxWidth,
                       height:p_boxheight,
                       top:winTop,
                       left:winLeft,
					   backgroundColor:"#fff",
                       position:"absolute"});
}


//에러 발생시 메일 발송
function dvf_sendErrMsg(p_user_msg,p_real_msg){
	//if (confirm(p_user_msg +"\n불편을 드려 죄송합니다.\n관리자에게 오류 알림 메일을 발송하시겠습니까?"))
	//{
		alert(p_user_msg);
		var param = "errUserMsg="+ String(p_user_msg);
		param += "&errRealMsg="+ String(p_real_msg);
		$.ajax({
			url: '/service/svc_transferErr.asp',
			type: 'POST',
			async: false,
			data: param,
			dataType: 'json',
			error: function() {
				alert("관리자에게 메일 발송 실패하였습니다.\n고객게시판이나 전화(1588-1377)를 통해서 문의바랍니다.");
			},
			success: function(p_data) {
				if (p_data.result != undefined && p_data.result.length > 0)
				{
					if (p_data.result == "y")
					{
						alert("관리자에게 메일 발송 하였습니다.");
					}
					else
					{
						alert("관리자에게 메일 발송 실패하였습니다.\n고객게시판이나 전화(1588-1377)를 통해서 문의바랍니다.");
					}

				}
				else
				{
					alert("관리자에게 메일 발송 실패하였습니다.\n고객게시판이나 전화(1588-1377)를 통해서 문의바랍니다.");
				}
			}
		});
	//}
}

function dvf_commify(p_numdata)
{
	var reg = /(^[+-]?\d+)(\d{3})/;   // 정규식
	p_numdata += '';                          // 숫자를 문자열로 변환

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

	return p_numdata;
}

/**
 * 입력값이 NULL인지 체크
 * @param string
 * @return : ""
 */
function dvf_nvl(str, cstr) {
    if (str == null || str == "") {
        return cstr;
    }else{
        return str;
    }
}

function dvf_testUserID(p_userID)
{
    var uidExp = /^[a-zA-Z]\w{3,11}$/;
    return uidExp.test(p_userID);
}

function dvf_testPasswd(p_pwd)
{
    var pwdLen = p_pwd.split(" ").join("").length;
    if (pwdLen < 6 || pwdLen > 20)
        return false;

    return true;
}

function dvf_testEngData(p_str)
{
    var engExp = /^[a-zA-Z]+$/;
    return engExp.test(p_str);
}

function dvf_testEngName(p_str)
{
    var engExp = /^[A-Z][a-z]+ [A-Za-z][a-z]*([- ][A-Za-z]?[a-z]*)?$/;
    return engExp.test(p_str);
}

function dvf_testNumData(p_num)
{
    var numExp = /^[0-9]+$/;
    return numExp.test(p_num);
}

function dvf_testTelno(p_phoneNum)
{
    var telnoRgExp = /^0[0-9]{1,2}-[0-9]{3,4}-[0-9]{4}$/;
    return telnoRgExp.test(p_phoneNum);
}

function dvf_testMPhoneNum(p_phoneNum)
{
    var hpRgExp = /^01[016789]-[0-9]{3,4}-[0-9]{4}$/;
    return hpRgExp.test(p_phoneNum);
}

function dvf_testEmail(p_email){
    //var emailExp = /^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~\-]+)+\s*$/g;
	var emailExp = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[0-9a-zA-Z]{2,3}$/i;
    return emailExp.test(p_email);
}

/* 툴팁
	(출처: http://sixrevisions.com/tutorials/javascript_tutorial/create_lightweight_javascript_tooltip/)
	id (string) – id of the tooltip
	top (integer) – number of pixels to offset the tooltip from the top of the cursor
	left (integer) – offset to the right of the cursor
	maxw (integer) – maximum width in pixels of the tooltip
	speed (integer) – value to increment the tooltip opacity during transition
	timer (integer) – represents the speed at which the fade function in performed
	endalpha (integer) – target opacity of the tooltip
	alpha (integer) – current alpha of the tooltip
	tt, t, c, b, h – these represent global variables to be set later
	ie (boolean) – global variable based on browser vendor
*/
var tooltip=function(){
	var id = 'tip';
	var top = 3;
	var left = 3;
	var maxw = 500;
	var speed = 20;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + '_top');
				c = document.createElement('div');
				c.setAttribute('id',id + '_cont');
				b = document.createElement('div');
				b.setAttribute('id',id + '_bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			if((l + left + tt.offsetWidth) > document.documentElement.clientWidth){
				tt.style.left = (l + left - tt.offsetWidth) + 'px';
			}else{
				tt.style.left = (l + left) + 'px';
			}
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

function trace(p_str)
{
    // trace.js를 제거하면서 trace 함수 호출에서 javascript 오류 발생을 
    // 방지하기 위해 dummy 함수를 정의
}

