/*****************************************************
 ////////////////////////////////////////////////////
 * ?????????? ???? ???? ???? ?????????? ????.
 * ?????? ???????????? ?????? ???? ?????? ????.
 * form ?? ???????? ?????? ???? ???? ????.
 ///////////////////////////////////////////////////
 ***************************************************/
var form = document.form;
var properties_common = 'status=no,toolbar=no,location=no,scrollbars=no,menubar=no,titlebar=no,';
/**
 * <body> ???????? onLoad ?????? ????. ???? ?????? ?????? ?????? ????.
 */
function initForm()
{
	form = document.form;
}
/***************************************************
 ///////////////////////////////////////////////////
 * CheckBox
 //////////////////////////////////////////////////
 **************************************************/
/**
  * CheckBox?? ?????? ???????? ???????? ???????? ?????? ???? ????.
  *
  * @ param name - CheckBox?? ?????? ????
  * @ return - ?????? ???????? ????
  */
function checkSelectedCount(name)
{
	var count = 0;
	for(i = 0; i < form.elements.length; i++ )
	{
		if( form.elements[i].name == name && form.elements[i].checked == true )
		{
			count++;
		}
	}
	return count;
}
/**
  * CheckBox?? ?????? ???????? ???????? ????????.
  *
  * @ param name - CheckBox?? ?????? ????
  */
function checkSelected(name)
{
	var form = document.form;
	var flag = false;
	for(i=0; i<form.elements.length; i++ )
	{
		if( form.elements[i].name == name )
		{
			if( form.elements[i].checked == true )
			{
				flag = true;
				break;
			}
		}
	}
	return flag;
}
/*
 * must insert number
 */
function checkOnlyNumber(str){
		for(var j=0; j < str.length ; j++)
		{
			if( str.charCodeAt(j) < 48 || str.charCodeAt(j) > 57 )
			{
				alert("숫자만 입력이 가능합니다.");
				return false;
			}
		}
		return true;
}
/**
  * CheckBox?? ???? ???? ????.
  */
function selectAll()
{
	var i =0;
	var form = document.form;
	while (i < form.elements.length) {
		if (form.elements[i].type=='checkbox') {
			if(form.checkTo.checked){
				form.elements[i].checked=0;
			}else{
				form.elements[i].checked=1;
			}
		}
		i++;
	}
}

/**
  * CheckBox ???? ????
  */
function deselectAll()
{
	var checkBox = document.form.logNum;
	for(i=0; i<checkBox.length; i++)
	{
		checkBox[i].checked = false;
	}
}
/***************************************************
 ///////////////////////////////////////////////////
 * Popup Window
 //////////////////////////////////////////////////
 **************************************************/
/**
  * popup windwo open ?????? ???? ???? ????????.
  *
  * @ param height - ???? ???????? ????, width - ???? ???????? ????
  * @ return - ???? ???????? ???? ????
  */
function determinePopUpAtCenter(height, width)
{
	var properties= "";
	var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		screenY= document.body.offsetHeight;
		screenX= window.screen.availWidth;
	}
	else
	{
		screenY= window.outerHeight
		screenX= window.outerWidth
	}
	leftvar= (screenX - width) / 2;
	rightvar= (screenY - height) / 2;
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		leftprop= leftvar;
		topprop= rightvar;
	}
	else
	{
		leftprop= (leftvar - pageXOffset);
		topprop= (rightvar - pageYOffset);
	}
	properties= properties + ", left = " + leftprop;
	properties= properties + ", top = " + topprop;
	return properties;
}
function getCenter(width, loc)
{
	var screenSpan, screenLoc, result;
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		if(loc == 'X'){
			screenSpan= window.screen.availWidth;
		}
		else if(loc == 'Y'){
			//screenSpan= document.body.offsetHeight;
			screenSpan = window.screen.availHeight;
		}
	}
	else
	{
		if(loc == 'X')
			screenSpan= window.outerWidth
		else if(loc == 'Y')
			screenSpan= window.outerHeight
	}
	screenLoc = (screenSpan - width)/2;
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		result = screenLoc;
	}
	else
	{
		if(loc == 'X')
			result = screenLoc - pageXOffset;
		else if(loc == 'Y')
			result = screenLoc - pageYOffset;
	}
	return result;
}
/***************************************************
 ///////////////////////////////////////////////////
 * Paging
 //////////////////////////////////////////////////
 **************************************************/
/**
  * ?????? ?????? ?????? ?????? ???? ???? ????
  *
  * @ param curpage - ???? ??????
  */
function pageMove(form, curpage)
{
	form.curpage.value = curpage;
	form.target = "_self";
	form.submit();
}
/***************************************************
 ///////////////////////////////////////////////////
 * Textfild
 //////////////////////////////////////////////////
 **************************************************/
 /**
  * ?????? ?????? ?????? ?????? ???? ???? ????
  *
  * @ param curpage - ???? ??????
  */
function setFocus(name)
{
	name.focus();
}
/***************************************************
 ///////////////////////////////////////////////////
 * String
 //////////////////////////////////////////////////
 **************************************************/
	//??? ???? ?? ????? ????.
	function trim(str){
		var cnt = str.length;
		for( var i=0 ; i < cnt ; i++){
			str = str.replace(' ', '');
		}
		return str;
	}
	function selectAllChk()
	{
		initForm();
		var i =0;
		while (i < form.elements.length) {
			if (form.elements[i].type=='checkbox') {
				if(form.checkTo.value == 'none')
				{
					form.elements[i].checked=1;
				}else{
					form.elements[i].checked=0;
				}
			}
			i++;
		}

		if(form.checkTo.value == 'none')
			form.checkTo.value = 'block';
		else
			form.checkTo.value = 'none';
	}
	function showMessage(msg){
		if(msg != ''){
			alert(msg);
	  	}
  	}


	extArray = new Array(".jpg", ".gif", ".txt",".hwp",".doc",".ppt",".xls",".pdf",".zip",".xlsx", ".pptx", ".docx", ".avi", ".mpg", ".asf");
	movieArray = new Array(".wmv");
	thumArray = new Array(".jpg", ".gif");
	function thumnailFile(f){
			var f, s, hapsu = 0;
            file =eval("document.form.THUMNAIL_filename1.value");
            filespec = eval("document.form.THUMNAIL_filename1.value");
            // ?? ?? ??? ??
            if( filespec != "") {
	            while (file.indexOf("\\") != -1)
	            file = file.slice(file.indexOf("\\") + 1);
	            ext = file.slice(file.lastIndexOf(".")).toLowerCase();
				var check=false;
	            for (var j = 0; j < thumArray.length; j++) {
	                if (thumArray[j] == ext) {
	                    check = true;
	                }
	            }
				if(check == false){
					alert('썸네일은 Jpg, gif만 등록이 가능합니다.');
	                return false;
				}
            }
              return true;
	}
	
	function movieCheckFile(f){
			var f, s, hapsu = 0;
            file =eval("document.form.MOVIE_filename1.value");
            filespec = eval("document.form.MOVIE_filename1.value");
            // ?? ?? ??? ??
            if( filespec != "") {
	            while (file.indexOf("\\") != -1)
	            file = file.slice(file.indexOf("\\") + 1);
	            ext = file.slice(file.lastIndexOf(".")).toLowerCase();
				var check=false;
	            for (var j = 0; j < movieArray.length; j++) {
	                if (movieArray[j] == ext) {
	                    check = true;
	                }
	            }
				if(check == false){
					alert('wmv 파일만 등록이 가능합니다.');
	                return false;
				}
            }
              return true;
	}
	
    function checkFileSize(f){
        for(i=1 ; i<f.rowCount.value+1;i++){
            if(i > f.rowCount.value)  break;
            var f, s, hapsu = 0;
            file =eval("document.form.filename"+ i +".value");
            filespec = eval("document.form.filename"+ i +".value");
            // ?? ?? ??? ??
            if( filespec != "") {
	            while (file.indexOf("\\") != -1)
	            file = file.slice(file.indexOf("\\") + 1);
	            ext = file.slice(file.lastIndexOf(".")).toLowerCase();
							var check=false;
	            for (var j = 0; j < extArray.length; j++) {
	                if (extArray[j] == ext) {
	                    check = true;
	                }
	            }
							if(check == false){
											alert('보안상 업로드 할 수 없는 파일입니다.!');
	                    return false;
	                    break;
							}
            }
        }
        return true;
    }
		
		function checkFileSize2(f){
        for(i=1 ; i<f.fileCount.value+1;i++){
            if(i > f.fileCount.value)  break;
            var f, s, hapsu = 0;
             file =eval("document.form.fileName.value");
			       filespec = eval("document.form.fileName.value");

            // ?? ?? ??? ??
            if( filespec != "") {
	            while (file.indexOf("\\") != -1)
	            file = file.slice(file.indexOf("\\") + 1);
	             ext = file.slice(file.lastIndexOf(".")).toLowerCase();
				var check=false;
	            for (var j = 0; j < extArray.length; j++) {
	                if (extArray[j] == ext) {
	                    check = true;
	                }
	            }
							if(check == false){
											alert('보안상 업로드 할 수 없는 파일입니다.!');
	                    return false;
	                    break;
							}
            }
        }
        return true;
    }
		
		img_extArray = new Array(".jpg", ".gif", ".txt",".hwp",".doc",".ppt",".xls",".pdf",".zip",".xlsx", ".pptx", ".docx", ".avi", ".mpg", ".asf");
    function img_checkFileSize(f){
        for(i=1 ; i<f.rowCount.value+1;i++){
            var flag = false;
            if(i > f.rowCount.value)  break;
            var f, s, hapsu = 0;
            file =eval("document.form.filename"+ i +".value");
            filespec = eval("document.form.filename"+ i +".value");
            while (file.indexOf("\\") != -1)
            file = file.slice(file.indexOf("\\") + 1);
            ext = file.slice(file.lastIndexOf(".")).toLowerCase();
            if(file != ""){
                for (var j = 0; j < img_extArray.length; j++) {
                    if (img_extArray[j] == ext) {
                        flag = true;
                        break;
                    }
                }
                if(!flag){
                    alert('보안상 업로드 할 수 없는 파일입니다.!');
                    return false;
                }
            }
        }
        return true;
    }
		
		function img_checkFileSize2(f){
        for(i=1 ; i<f.fileCount.value+1;i++){
            var flag = false;
            if(i > f.fileCount.value)  break;
            var f, s, hapsu = 0;
            file =eval("document.form.fileName.value");
       			filespec = eval("document.form.fileName.value");
            while (file.indexOf("\\") != -1)
            file = file.slice(file.indexOf("\\") + 1);
             ext = file.slice(file.lastIndexOf(".")).toLowerCase();
            if(file != ""){
                for (var j = 0; j < img_extArray.length; j++) {
                    if (img_extArray[j] == ext) {
                        flag = true;
                        break;
                    }
                }
                if(!flag){
                    alert('보안상 업로드 할 수 없는 파일입니다.!');
                    return false;
                }
            }
        }
        return true;
    }
