
function autoGrowField(f, max) {
   /* Default max height */
   var max = (typeof max == 'undefined')?1000:max;
   /* Don't let it grow over the max height */
   if (f.scrollHeight > max) {
      /* Add the scrollbar back and bail */
      if (f.style.overflowY != 'scroll') { f.style.overflowY = 'scroll' }
      return;
   }
   /* Make sure element does not have scroll bar to prevent jumpy-ness */
   if (f.style.overflowY != 'hidden') { f.style.overflowY = 'hidden' }
   /* Now adjust the height */
   var scrollH = f.scrollHeight;
   if (300 <= scrollH)
   {
	   if( scrollH > f.style.height.replace(/[^0-9]/g,'') ){
      f.style.height = scrollH+'px';
	  }
   }
   
}

function autoGrowFieldSmall(f, max) {
   /* Default max height */
   var max = (typeof max == 'undefined')?1000:max;
   /* Don't let it grow over the max height */
   if (f.scrollHeight > max) {
      /* Add the scrollbar back and bail */
      if (f.style.overflowY != 'scroll') { f.style.overflowY = 'scroll' }
      return;
   }
   /* Make sure element does not have scroll bar to prevent jumpy-ness */
   if (f.style.overflowY != 'hidden') { f.style.overflowY = 'hidden' }
   /* Now adjust the height */
   var scrollH = f.scrollHeight;
   if (50 <= scrollH)
   {
	   if( scrollH > f.style.height.replace(/[^0-9]/g,'') ){
      f.style.height = scrollH+'px';
	  }
   }
   
}

function autoGrowFieldSmallReply(f, max) {
   /* Default max height */
   var max = (typeof max == 'undefined')?800:max;
   /* Don't let it grow over the max height */
   if (f.scrollHeight > max) {
      /* Add the scrollbar back and bail */
      if (f.style.overflowY != 'scroll') { f.style.overflowY = 'scroll' }
      return;
   }
   /* Make sure element does not have scroll bar to prevent jumpy-ness */
   if (f.style.overflowY != 'hidden') { f.style.overflowY = 'hidden' }
   /* Now adjust the height */
   var scrollH = f.scrollHeight;
   if (50 <= scrollH)
   {
	   if( scrollH > f.style.height.replace(/[^0-9]/g,'') ){
      f.style.height = scrollH+'px';
	  }
   }
   
}

// form.reset
function formClear(Obj)
{
	Obj.reset();
}

//°´Ã¼ È°¼º,ºñÈ°¼º ¼³Á¤ ÇÔ¼ö
function showObject(Obj,Boolen)
{
	if(Boolen){					//È°¼ºÈ­
		Obj.disabled = false;
		Obj.style.background = "#ffffff";
	}
	else{						//ºñÈ°¼ºÈ­
		Obj.disabled = true;
		Obj.style.background = "#dddddd";
	}
}
//°´Ã¼ È°¼º,ºñÈ°¼º ¼³Á¤ ÇÔ¼ö
function checkshowObject(Obj,Boolen)
{
	Boolen ? Obj.disabled = false: Obj.disabled = true;
}

/* ¹è¿­ Ã³¸® ÇÔ¼ö */
//Ãß°¡
function addArray(Obj,Val)
{
	var arrLength= Obj.length;
	Obj[arrLength] = Val;
}

//»èÁ¦
function delArray(Obj,Index)
{
	var temp=new Array();
	var nextIndex = Index +1;

	for(i=0,j=0;i<Obj.length;i++){
		if(i!=Index){
			temp[j] = Obj[i];
			j++;
		}
	}
	for(i=0;i<temp.length;i++)
		Obj[i]=temp[i];
	return temp.length;
}

//Á¤·Ä   0:³»¸²Â÷¼ø  1:¿À¸§Â÷¼ø
function sortArray(Obj,Method)
{
	Obj.sort();
	if(!Method)
		Obj.reverse();
}

//ÇÑ±ÛÃ¼Å©
function hanCheck(Str)
{
	var Re=false;
	for(i=0;i<Str.length;i++){
		var a=Str.charCodeAt(i);
		if (a > 128) {
			Re=true;
		}
	}
	return Re;
}

//ÆÄÀÏ¸í ÇÑ±Û Ã¼Å©
function filehanCheck(Str)
{
	var Arr = new Array();
	var Re=false;
	Arr=Str.split("\\");
	return hanCheck(Arr[Arr.length-1]);
}

//¼ýÀÚÃ¼Å©
function numCheck(Str)
{
    var Re=true;
	for(i=0;i<Str.length;i++){
		var a=Str.charCodeAt(i);
		if(a<48 || a>57)
			Re=false;
	}
	return Re;		
}

//¿¬¶ôÃ³Ã¼Å©
function telCheck(Tel1, Tel2, Tel3){
	var Re=true;
	if(!numCheck(Tel1) ||!numCheck(Tel2) ||!numCheck(Tel3) )
		Re = false;
	else if(Tel1.length <2 || Tel1.length >3)
		Re = false;
	else if(Tel2.length <3 || Tel2.length >4)
		Re = false;
	else if(Tel3.length <4 || Tel3.length >4)
		Re = false;
	return Re;
}
//°ü·ÃÀÌ¹ÌÁö ¿Ã¸®±â »õÃ¢
function inputImg(Part,Code)
{
	var form=document.writeForm;
	window.open("input_img.asp?part="+Part+"&code="+Code,"","scrollbars=yes,left=200,top=200,width=467,height=500");
}
//ÀÌ¹ÌÁöÈ®´ë
function zoom(File,Width,Height)
{
	if(!Width || !Height){
		alert("Image information is wrong");
	}else{
		window.open("zoom.asp?img="+File,"","scrollbars=no,width="+Width+",height="+Height+",top=200,left=200");
	}
}
function zoom2(File,Width,Height)
{
	if(!Width || !Height){
		alert("Image information is wrong");
	}else{
		window.open("/zoom2.asp?prod_cd="+File,"","scrollbars=no,width="+Width+",height="+Height+",top=200,left=200");
	}
}
function zoom3(File,Width,Height)
{
	if(!Width || !Height){
		alert("Image information is wrong");
	}else{
		window.open("zoom3.asp?idx="+File,"","scrollbars=no,width="+Width+",height="+Height+",top=200,left=200");
	}
}
//ÀÌ¹ÌÁöÈ®´ë (Å¸ÀÌÆ²)
function zoomTitle(File,Width,Height,Title)
{
	if(!Width || !Height){
		alert("Image information is wrong");
	}else{
		window.open("zoom.asp?img="+File+"&title="+Title,"","scrollbars=no,width="+Width+",height="+Height+",top=200,left=200");
	}
}

//<tr> ¹è°æ»ö ¹Ù²Ù±â
function bgcolorChange(Obj,Color)
{
	Obj.backgroundColor = Color;
}

//ÀÌ¸ÞÀÏÃ¼Å©
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=/;";
}

//Ä®·¯ ¹Ú½º
//       setColor(string mul|sin, string bg|style  string  id)
function setColor(Part1,Part2,Obj)
{
	window.open("color.asp?part1="+Part1+"&part2="+Part2+"&target="+Obj,"","scrollbars=yes,width=350,height=110,left=300,top=300");
}
function subsetColor(Part1,Part2,Obj,tForm)
{
	window.open("sub_color.asp?part1="+Part1+"&part2="+Part2+"&target="+Obj+"&tForm="+tForm,"","scrollbars=yes,width=350,height=110,left=300,top=300");
}
//1Â÷Ä«Å×°í¸® ¸¶¿ì½º ¾Æ¿ô ¼³Á¤
function layerImgOut(Name,Src)
{
	Name.src=Src;
}


//¸ÞÀÏº¸³»±â
function sendMail(To)
{
	window.open("./email/mail.asp?To="+To,"","scrollbars=yes,left=200,top=200,width=400,height=483");
}
//°ü·ÃÀÌ¹ÌÁö ¿Ã¸®±â »õÃ¢
function inputImg(Part,Code)
{
	var form=document.writeForm;
	window.open("input_img.asp?part="+Part+"&code="+Code,"","scrollbars=yes,left=200,top=200,width=467,height=500");
}
function askloginErr()
{
	alert("This page is member page. Log-in Please");
}


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 funcSearch(oText, strBoxNM, strBoxID, strBoxEM)
		{
			
		}

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;
}

	   
var winAddNew=null;
function OpenCalendar(arg1,arg2)
{
	windowCalUnLoad();
	//URLÀ» ÁöÁ¤ÇÒ ¶§ ÆäÀÌÁö¹®Á¦...
	argUrl = '/Calendar/PC_MainCalFrame.asp?arg1='+ arg1 + '&arg2=' +arg2 +'&POPUP=Y';
	winproperty = 'width=220,height=180,status=no,resizable=no,scrollbars=no,menubar=no,location=no,toolbar=no, MaxButton=no;left=550;';
	winAddNew = window.open(argUrl,"",winproperty);
}

function windowCalUnLoad()
{
   if (winAddNew != null ){
		winAddNew.close();
	}
}



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 bookmark(sUrl, sTitle)
{
   window.external.AddFavorite(sUrl, "[podonamoo.org]Podonamoo Church Weekly Sermon - "+sTitle)
}



//-------------------------------------------------------------------------------------------------------------------------------------