//ÀÌ¸ÞÀÏÃ¼Å©
function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

//ÄíÅ°ÀúÀå
function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	//document.cookie = name + "=" + escape( value ) + "; path=/;";
}

function funcPopup(file_path, windowName, WindWidth, WindHeight, isScroll)
	{
		myWindow = window.open(file_path, windowName, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+isScroll+',resizable=0, copyhistory=0, width='+WindWidth+',height='+WindHeight+',left='+"100"+',top='+"50"+"'");
		myWindow.opener = self;
	}  

function funcPopupResizable(file_path, windowName, WindWidth, WindHeight, isScroll)
	{
		myWindow = window.open(file_path, windowName, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+isScroll+',resizable=1, copyhistory=0, width='+WindWidth+',height='+WindHeight+',left='+"100"+',top='+"50"+"'");
		myWindow.opener = self;
	}  

function funcPopupDownLoad(file_path, windowName, WindWidth, WindHeight, isScroll)
	{
		myWindow = window.open(file_path, windowName, 'toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars='+isScroll+',resizable=1, copyhistory=0, width='+WindWidth+',height='+WindHeight+',left='+"100"+',top='+"50"+"'");
		myWindow.opener = self;
	}

//ÇöÀç ÆäÀÌÁö ÀÎ¼â
function funcPrint()
	{
		window.print();
	}

//Value Check =============================================================================================================
function funcValidLength(item, len)
		{
			return(item.length >= len);
		}

function funcError(text) 
		{
			alert(text);
		}

function funcCheckVal(strFormParam, strMessage) //String Check
	{
		
		if (!funcValidLength(strFormParam.value,0)) {
					funcError(strMessage);
					strFormParam.focus();
					return;
				}
	}

function funcCheckValList(strFormParam, strMessage) //List Box Check
	{
		if (strFormParam.options[strFormParam.selectedIndex].value == 0)
			   {
					funcError(strMessage);
					strFormParam.focus();
					return;
				}
	}

function funcCheckValRadio(strFormParam, strMessage) //Radio Button Check
	{
		
		var num = strFormParam.length - 1
		var count = 0
		for (i = 0; i <= num; i++) 
				{ 
					if (strFormParam[i].checked == true) { 
						count = count + 1
					}
				}
		
		if (count == 0)
			   {
					funcError(strMessage);
					strFormParam.focus();
					return;
				}
		
	}

function funcSubmit(strFormParam)
	{
	strFormParam.submit();
	}
				

function funcOnlyNumber(keycode)
{
	if(keycode != 46 && keycode != 8 && keycode != 9 && (keycode < 48 || keycode > 57)){ 
		return false;
	}
	return true;
}

function addComma(obj,fLen)
{ 
	if(event.keyCode == 37 || event.keyCode == 39 ) 
	{ 
	return;
	}

	var fLen = fLen || 2; 
	var strValue = obj.value.replace(/,|\s+/g,'');
	var strBeforeValue = (strValue.indexOf('.') != -1)? strValue.substring(0,strValue.indexOf('.')) :strValue ;
	var strAfterValue = (strValue.indexOf('.') != -1)? strValue.substr(strValue.indexOf('.'),fLen+1) : '' ;

	if(isNaN(strValue))
	{
	alert(strValue.concat(' -> You should use numeric.'));
	return false;
	}

	var intLast = strBeforeValue.length-1;
	var arrValue = new Array;
	var strComma = '';

	for(var i=intLast,j=0; i >= 0; i--,j++)
	{ 
	if( j !=0 && j%3 == 0) 
	{ 
	strComma = ',';
	}
	else
	{
	strComma = '';
	} 
	arrValue[arrValue.length] = strBeforeValue.charAt(i) + strComma ;
	} 
	obj.value= arrValue.reverse().join('') + strAfterValue;
}

function setComma(v) {
        v = v.toString();
        if (v.length > 3) {
                var mod = v.length % 3;
                var retval = (mod > 0 ? (v.substring(0,mod)) : "");
                for (i=0 ; i < Math.floor(v.length / 3); i++) {
                        if ((mod == 0) && (i == 0)) {
                                retval += v.substring(mod+ 3 * i, mod + 3 * i + 3);
                        } else {
                                retval+= "," + v.substring(mod + 3 * i, mod + 3 * i + 3);
                        }
                }
                return retval;
        } else {
                return v;
        }
}

function openWin(theURL,listForm,features)	
{		
window.open(theURL,listForm,features);	
}	


function funcInStr(strSearch, charSearchFor)
{
    for (i=0; i < strSearch.length; i++)
    {
          if (charSearchFor == Mid(strSearch, i, 1))
          {
                return i;
          }
    }
    return -1;
}

