// notnull
// minlength, maxlength
// emailonly
// hangeulonly, hangeuldeny
// integeronly, numberonly, minnum, maxnum
// equalgroup
//trackback

function CForm()
{
}

CForm.prototype.setFocus = function( what )
{
	what.focus();
	// errsel ÀÌ¸é...
	if (what.errsel != null) 
		what.select();
}            

CForm.prototype.isEmpty = function( value )
{
	for (var i = 0; i < value.length; i++)
		if (value.substring(i, i+1) != " ")
			return false;
	return true;
}            

CForm.prototype.isNumber = function( value )
{
	return !isNaN(value);
}

CForm.prototype.isInteger = function( value )
{
	if ( !this.isNumber( value ) )
		return false;

	if ( value.indexOf(".") != -1)
		return false;

	return true;
}

CForm.prototype.stringLengthForHangeul = function(str)
{
	var charCnt = 0;

	for(var i = 0; i < str.length; i++)
	{
		var chr = str.substr(i,1);
		chr = escape(chr);
		var key_eg = chr.charAt(1);

		switch(key_eg)
		{
			case "u":
				key_num = chr.substr(2,(chr.length - 1));
				/*
					if((key_num < "AC00") || (key_num > "D7A3"))
						return -1;
					else
				*/
				charCnt += 2;
				break;
			case "B":
				charCnt += 2;
				break;
			default:
				charCnt += 1;
		}
	}

	return charCnt;
}

CForm.prototype.notNullCheck = function( what )
{
	if (
		what.type == "text"     || what.type == "password" || 
		what.type == "textarea" || what.type == "file"
	) {
		if (what.notnull != null) {
			if ( this.isEmpty(what.value) ) {
				alert(what.errname + "À»(¸¦) ÀÔ·ÂÇÏ½Ê½Ã¿À");
				this.setFocus( what );
				return false;
			}
		}
	}

	return true;
}            

CForm.prototype.lengthCheck = function( what )
{
	if ( 
		what.type == "text"     || what.type == "password" || 
		what.type == "textarea" || what.type == "file"
	) {

		var	str_len, errname ;

		// ºÒÇÊ¿äÇÑ °è»ê ÇÇÇÔ
		if ( !what.minlength && !what.xmaxLength )
			return true ;

		// ºó ¹®ÀÚ¿­ÀÏ °æ¿ì ±æÀÌ°Ë»ç¸¦ ÇÇÇÔ
		if ( what.value == "" )
			return true ;

		if ( what.type == "file" ) {
			var	rslash_pos, fname ;

			rslash_pos = what.value.lastIndexOf ("\\", what.value.length) ;
			if ( rslash_pos == -1 ) {
				alert (what.errname + "ÀÇ ÆÄÀÏÀÌ¸§ÀÌ " + "Àß¸øµÇ¾ú½À´Ï´Ù\n" + "´Ù½ÃÇÑ¹ø È®ÀÎÇÏ¼¼¿ä") ;
				return false ;
			}

			fname = what.value.substr (rslash_pos + 1) ;
			str_len = this.stringLengthForHangeul(fname) ;
			errname = what.errname + " ÆÄÀÏÀÌ¸§" ;
		}
		else {
			str_len = this.stringLengthForHangeul (what.value) ;
			errname = what.errname ;
		}

		// ÃÖ¼Ò ±æÀÌ °Ë»ç
		if (what.minlength != null)
		{
			if (str_len < what.minlength)
			{
				alert (errname + "Àº(´Â) ¿µ¹® " + what.minlength + "ÀÚ, ÇÑ±Û " + Math.ceil(what.minlength / 2) + "ÀÚ ÀÌ»ó ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù");
				this.setFocus(what);
				return false;
			}
		}

		// ÃÖ´ë ±æÀÌ °Ë»ç
		if (str_len > what.xmaxLength)
		{
			alert (errname + "Àº(´Â) ¿µ¹® " + what.xmaxLength + "ÀÚ, ÇÑ±Û " + parseInt(what.xmaxLength / 2) + "ÀÚ ±îÁö ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù");
			this.setFocus(what);
			return false;
		}
	}
	return true;
}

CForm.prototype.numberCheck = function( what )
{
	if (what.type == "text" || what.type == "password" || what.type == "textarea") {
		// ¼ýÀÚÀÎÁö °Ë»ç
		if (what.numberonly != null) {
			if (!this.isNumber( what.value ) ){
				alert (what.errname + "Àº(´Â) " +  "¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù");
				this.setFocus(what);
				return false;
			}
		}

		// Á¤¼öÀÎÁö °Ë»ç
		if ( what.integeronly != null ) {
			if ( !this.isInteger( what.value ) ) {
				alert (what.errname + "Àº(´Â) " +  "Á¤¼ö¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù");
				this.setFocus(what);
				return false;
			}
		}

		// ÃÖ¼Ò°ª °Ë»ç
		if ( what.minnum != null ) {
			if ( parseFloat(what.value) < parseFloat(what.minnum) ) {
				alert (what.errname + "Àº(´Â) " + what.minnum + " ÀÌ»óÀÇ ¼ýÀÚ¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù");
				this.setFocus( what );
				return false;
		   }
		}

		// ÃÖ´ë°ª °Ë»ç
		if ( what.maxnum != null )
		{
			if (parseFloat(what.value) > parseFloat(what.maxnum))
			{
				alert (what.errname + "Àº(´Â) " +  what.maxnum + " ÀÌÇÏÀÇ ¼ýÀÚ¸¸À» ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù");
				this.setFocus(what);
				return false;
			}
		}
	}

	return true;
}


CForm.prototype.emailCheck = function( what )
{
	var	emailexp = new RegExp ("^[A-Za-z0-9-_\\.]{2,}@[A-Za-z0-9-_\\.]{2,}\\.[A-Za-z0-9-_]{2,}$") ;

	if ( what.emailonly != null ) {
		if ( what.type == "text" ) {
			if ( what.value == "" || what.value == "null" )
				return true ;

			// ÇÑ±ÛÀÌ Æ÷ÇÔµÅ ÀÖ°Å³ª ÀÌ¸ÞÀÏ Çü½ÄÀÌ ¾Æ´Ñ °æ¿ì
			if ( (this.stringLengthForHangeul(what.value) != what.value.length) || !emailexp.test ( what.value ) ) {
				alert (what.errname + "(°¡)ÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù") ;
				this.setFocus (what) ;
				return false ;
			}
		}
	}

	return true ;
}

CForm.prototype.hangeulOnly = function( what ) 
{
	if (what.type == "text" || what.type == "password" || what.type == "textarea")
	{
		if (what.hangeulonly != null)
		{
			// ÇÑ±Û¸¸ Æ÷ÇÔµÇ¾î ÀÖ´ÂÁö °Ë»ç
			if (this.stringLengthForHangeul(what.value) != what.value.length*2) 
			{
			  alert (what.errname + "Àº(´Â) " + "ÇÑ±Û¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù");
			  this.setFocus(what);
			  return false;
		  }

		}
	}

	return true;
}

CForm.prototype.hangeulDeny = function( what ) 
{
	if (what.type == "text" || what.type == "password" || what.type == "textarea")
	{
		if (what.hangeuldeny != null)
		{
			// ÇÑ±Û¸¸ Æ÷ÇÔµÇ¾î ÀÖ´ÂÁö °Ë»ç
			if (this.stringLengthForHangeul(what.value) != what.value.length) 
			{
			  alert (what.errname + "Àº(´Â) " + "ÇÑ±ÛÀº ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù");
			  this.setFocus(what);
			  return false;
		  }

		}
	}

	return true;
}

CForm.prototype.trackBack = function( what ) 
{
	if (what.type == "text" || what.type == "password" || what.type == "textarea")
	{
		if (what.trackback != null)
		{
			if( what.value.length > 0 ) {
				// ÁÖ¼Ò·Î µÇ¾î ÀÖ´ÂÁö È®ÀÎ
				if (what.value.indexOf("http://") == -1) 
				{
				  alert (what.errname + "ÀÇ " + " ÁÖ¼Ò Çü½Ä Àß¸øµÇ¾ú½À´Ï´Ù");
				  what.value = "";
				  this.setFocus(what);
				  return false;
				}
				
			}
		}
	}

	return true;
}

CForm.prototype.equalCheck = function ( form, what )
{
	if (what.type == "text" || what.type == "password" || what.type == "textarea")
	{
		if (what.equalgroup != null) 
		{
			// ±× ¾È¿¡¼­ ´Ù¸¥ °Í°ú ¶Ç °Ë»ç ½ÃÀÛ
			for (var j=0; j<form.length; j++)
			{
				var what2 = form.elements[j];
				if (what2.type == "text" || what2.type == "password" || what2.type == "textarea")
				{
					if (what2.equalgroup == what.equalgroup) 
					{
						if (what2.value != what.value) // °ªÀÌ ´Ù¸£¸é false ¸®ÅÏ
						{
							alert (what.errname + "°ú(¿Í) " + what2.errname + "ÀÌ(°¡) °¡ ¼­·Î ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù");
							this.setFocus( what2 );
							return false;
						}
					}
				}
			}
		}
	}

	return true;
}

CForm.prototype.snoCheck = function ( form )
{	
	if ( undefined == form.tfSNO1 || null == form.tfSNO1 ) return true;

	// ÁÖ¹Îµî·Ï¹øÈ£ °Ë»ç
	var total = form.tfSNO1.value + form.tfSNO2.value;
	var result = null;
	
	for (var i=0; i < 12; i++ )  {
		result += (i%8+2)*total.substring(i, i+1);		
	}
	
   result = ( 11-(result%11) ) % 10;
   
   if ( parseInt(result) != parseInt( total.substring(12, 13) )  ) {	
		alert ("½Ç¸í DB°¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù. \nÀÔ·ÂÇÏ½Å ÁÖ¹Îµî·Ï¹øÈ£¿Í ½Ç¸íÀÌ ÇØ´ç ÀÚ·á°¡ ¾ø±â ¶§¹®¿¡, \n½Ç¸íDB¿¡ Á÷Á¢ È®ÀÎÇÏ´Â ÀÛ¾÷ÀÌ ÇÊ¿äÇÕ´Ï´Ù.\n\n ÇÑ±¹½Å¿ëÆò°¡Á¤º¸¿øÀ» ¹æ¹®ÇÏ¼Å¼­ ¾Æ·¡ÀÇ ¹æ¹ýÀ¸·Î È®ÀÎÇØÁÖ¼¼¿ä. \n\n- ¿Â¶óÀÎ ½Ç¸íÈ®ÀÎ ½ÅÃ» : http://namecheck.co.kr/per/p00.asp \n- º»ÀÎ È®ÀÎ ÀÚ·á : ÁÖ¹Îµî·ÏÁõ, ¿îÀü¸éÇãÁõ, ¿©±Ç, ÁÖ¹Îµî·Ïµîº») \n- ¹®ÀÇ »ó´ã : ÀüÈ­ (1600-1522) ÆÑ½º(02-3771-4818) ¸ÞÀÏ (callcenter@kisinfo.com)");
		this.setFocus( form.tfSNO2 );
		return false;
	}
	else 
		return true;
}

CForm.prototype.snoCheck2 = function ( form, obj1, obj2 )
{	
	//if ( undefined == obj1 ) return true;
	//if ( undefined == obj2 ) return true;

	// ÁÖ¹Îµî·Ï¹øÈ£ °Ë»ç
	var total = obj1.value + obj2.value;
	var result = null;
	
	for (var i=0; i < 12; i++ )  {
		result += (i%8+2)*total.substring(i, i+1);		
	}
	
   result = ( 11-(result%11) ) % 10;
   
   if ( parseInt(result) != parseInt( total.substring(12, 13) )  ) {	
		alert ("½Ç¸í DB°¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù. \nÀÔ·ÂÇÏ½Å ÁÖ¹Îµî·Ï¹øÈ£¿Í ½Ç¸íÀÌ ÇØ´ç ÀÚ·á°¡ ¾ø±â ¶§¹®¿¡, \n½Ç¸íDB¿¡ Á÷Á¢ È®ÀÎÇÏ´Â ÀÛ¾÷ÀÌ ÇÊ¿äÇÕ´Ï´Ù.\n\n ÇÑ±¹½Å¿ëÆò°¡Á¤º¸¿øÀ» ¹æ¹®ÇÏ¼Å¼­ ¾Æ·¡ÀÇ ¹æ¹ýÀ¸·Î È®ÀÎÇØÁÖ¼¼¿ä. \n\n- ¿Â¶óÀÎ ½Ç¸íÈ®ÀÎ ½ÅÃ» : http://namecheck.co.kr/per/p00.asp \n- º»ÀÎ È®ÀÎ ÀÚ·á : ÁÖ¹Îµî·ÏÁõ, ¿îÀü¸éÇãÁõ, ¿©±Ç, ÁÖ¹Îµî·Ïµîº») \n- ¹®ÀÇ »ó´ã : ÀüÈ­ (1600-1522) ÆÑ½º(02-3771-4818) ¸ÞÀÏ (callcenter@kisinfo.com)");
		obj1.focus() ;
		return false;
	}
	else 
		return true;
}	

	
CForm.prototype.snoCheckForeign = function ( form, obj1, obj2 )
{	
	//if ( undefined == obj1 ) return true;
	//if ( undefined == obj2 ) return true;

	// ÁÖ¹Îµî·Ï¹øÈ£ °Ë»ç
	var total = obj1.value + obj2.value;
	var result = null;
	
	for (var i=0; i < 12; i++ )  {
		result += (i%8+2)*total.substring(i, i+1);		
	}
	
   result = ( 11-(result%11) ) % 10;

   if(result >= 10) { result -= 10; }
   result += 2;
   if(result >= 10) { result -= 10; }
   
   if ( parseInt(result) != parseInt( total.substring(12, 13) )  ) {	
		alert ("ÀûÇÕÇÑ ¿Ü±¹ÀÎµî·Ï¹øÈ£°¡ ¾Æ´Õ´Ï´Ù.");
		obj1.focus() ;
		return false;
	}
	else 
		return true;
}	



CForm.prototype.splitEmailCheck = function( form )
{
	//if ( undefined == form.tfEmail1 ) return true;
	//if ( undefined == form.tfEmail2 ) return true;

	var	emailexp = new RegExp ("^[A-Za-z0-9-_\\.]{2,}@[A-Za-z0-9-_\\.]{2,}\\.[A-Za-z0-9-_]{2,}$") ;
	var email = form.tfEmail1.value + "@" + form.tfEmail2.value;

	if ( !emailexp.test ( email ) ) {
		alert ( "ÀÌ¸ÞÀÏÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù") ;
		form.tfEmail2.value = "";
		form.tfEmail1.focus ( ) ;
		return false;
   }
   else 
	   return true;

}



CForm.prototype.checkSubmit = function( form, url )
{
	var what, i;

	for (i = 0; i < form.length; i++ ) {
		what = form.elements[i];
		
		if (
			!this.notNullCheck(what)    ||
			!this.lengthCheck(what)     ||    
			!this.numberCheck(what)		||
			!this.emailCheck(what)      ||
			!this.hangeulOnly(what)     ||
			!this.hangeulDeny(what)     ||
			!this.trackBack(what)		||
			!this.equalCheck(form, what)
		)  
		{
			return false;
		}
	}

	this.goURL( form, url );
	return true;
}

CForm.prototype.checkSubmit2 = function( form, url )
{
	var what, i;

	for (i = 0; i < form.length; i++ ) {
		what = form.elements[i];
		
		if (
			!this.notNullCheck(what)    ||
			!this.lengthCheck(what)     ||    
			!this.numberCheck(what)		||
			!this.emailCheck(what)      ||
			!this.hangeulOnly(what)     ||
			!this.hangeulDeny(what)     ||
			!this.trackBack(what)		||
			!this.equalCheck(form, what)
		)  
		{
			return false;
		}
	}

	this.goURL2( form, url );
	return true;
}

CForm.prototype.checkSubmit3 = function( form, url )
{
	var what, i;

	for (i = 0; i < form.length; i++ ) {
		what = form.elements[i];
		
		if (
			!this.notNullCheck(what)    ||
			!this.lengthCheck(what)     ||    
			!this.numberCheck(what)		||
			!this.emailCheck(what)      ||
			!this.hangeulOnly(what)     ||
			!this.hangeulDeny(what)     ||
			!this.trackBack(what)		||
			!this.equalCheck(form, what)
		)  
		{
			return false;
		}
	}

	this.goURL2( form, url, "_top" );
	return true;
}

//checkbox 1°³ ÀÌ»ó Ã¼Å© µÇ¾î ÀÖ³ª È®ÀÎ
CForm.prototype.checkedCheck = function(obj){
	
	var isChecked = false;
	
	
	if(typeof obj.length == 'undefined'){ //checkbox°¡ 1°³ÀÎ °æ¿ì
		if(obj.checked == true) isChecked = true;
	}
	else{
		for(var i=0; i<obj.length;i++){
			if(obj[i].checked == true){
				isChecked = true;
				break;
			}
		}
	}

	if(!isChecked){
		alert('¼±ÅÃµÈ Ç×¸ñÀÌ ¾ø½À´Ï´Ù.');
		return isChecked;
	}

	return isChecked;
}

CForm.prototype.onCheckSubmit = function( form, url )
{
	var what, i;

	for (i = 0; i < form.length; i++ ) {
		what = form.elements[i];
		
		if (
			!this.notNullCheck(what)    ||
			!this.lengthCheck(what)     ||    
			!this.numberCheck(what)		||
			!this.emailCheck(what)      ||
			!this.hangeulOnly(what)     ||
			!this.hangeulDeny(what)     ||
			!this.trackBack(what)		||
			!this.equalCheck(form, what)
		)  
		{
			return false;
		}
	}

	form.method = "post";
	form.action = url;

	return true;
}

CForm.prototype.openWin = function(ref, title, w, h)
{
	var leftX = (screen.width  - w)/2;
	var topY  = (screen.height - h)/2;

	var win = window.open ( 
		ref, 
		title, 
		'' + 'width=' + w + ',' +  'height=' + h + ',' + 'status=no,scrollbars=no' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);

	return win;
}

CForm.prototype.openWin2 = function(ref, title, w, h)
{
	var leftX = (screen.width  - w)/2;
	var topY  = (screen.height - h)/2;

	var win = window.open ( 
		ref, 
		title, 
		'' + 'width=' + w + ',' +  'height=' + h + ',' + 'status=no,scrollbars=yes' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);

	return win;
}


CForm.prototype.openWin3 = function(ref, title, w, h)
{
	var leftX = 0;
	var topY  = 0;

	window.open ( 
		ref, 
		title, 
		'' + 'width=' + w + ',' +  'height=' + h + ',' + 'status=no,scrollbars=yes' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);
}

CForm.prototype.openWin4 = function(ref)
{
	var leftX = 0;
	var topY  = 0;
	var url = "/webapp/jcgi-bin/myroom/album/popup/pop.jsp?F_PATH=" + ref;
	var title = "blog";

	window.open ( 
		url, 
		title, 
		'' + 'width=' + 100 + ',' +  'height=' + 100 + ',' + 'status=no,scrollbars=yes' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);
}

CForm.prototype.openWinEhom = function(ref, title, w, h)
{
	var leftX = (screen.width  - w)/2;
	var topY  = (screen.height - h)/2;

	window.open ( 
		ref, 
		title, 
		'' + 'width=' + w + ',' +  'height=' + h + ',' + 'toolbar=no,location=no,directories=no, status=no,menubar=no,resizable=no,scrolling=no' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);
}

CForm.prototype.openWinEhom1 = function(ref, title, w, h)
{
	var leftX = 0;
	var topY  = 0;

	window.open ( 
		ref, 
		title, 
		'' + 'width=' + w + ',' +  'height=' + h + ',' + 'toolbar=no,location=no,directories=no, status=no,menubar=no,resizable=no,scrolling=no' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);
}

CForm.prototype.openWinEhom2 = function(ref, title, w, h)
{
	var leftX = (screen.width  - w)/4;
	var topY  = (screen.height - h)/4;

	window.open ( 
		ref, 
		title, 
		'' + 'width=' + w + ',' +  'height=' + h + ',' + 'toolbar=no,location=no,directories=no, status=no,menubar=no,resizable=no,scrolling=no' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);
}

CForm.prototype.enterKey = function( form, url)
{
	if ( event.keyCode==13 )
	{ 
		this.check(form, url )
	}	
}

CForm.prototype.isConfirm = function( form, url)
{
	var result = confirm( "Á¤¸»»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?" );
	if ( result ) {
		this.goURL( form, url );
	}
	else {
		//alert( result);
		return false;
	}
}


CForm.prototype.isConfirm1 = function( form, url, msg)
{
	var result = confirm( msg );
	if ( result ) {
		this.goURL( form, url );
	}
	else {
		//alert( result);
		return false;
	}
}

CForm.prototype.isConfirm2 = function( form, url, msg)
{
	var result = confirm( msg );
	if ( result ) {
		this.check( form, url );
	}
	else {
		//alert( result );
		return false;
	}
}

CForm.prototype.showMessageBox = function( msg )
{
	 alert( msg );
	 history.back();
}

CForm.prototype.goURL = function( form, url )
{
	form.method = "post";
	form.action = url;
	form.submit();
}         

CForm.prototype.goURL2 = function( form, url, target )
{
	form.method = "post";
	form.action = url;
	form.target = target;
	form.toolbar="no";
	form.location="no";
	form.directories="no";
	form.status="no";
	form.menubar="no";
	form.resizable="no";
	form.scrolling="no";
	form.width="1000";
	form.submit();
}       

//onChange="javascript:objForm.selectEMailCompany(document.Memjoin_Form.stEmail3, document.Memjoin_Form.tfMEmail2);"
CForm.prototype.selectEMailCompany = function( objSource, objTarget )
{
	objTarget.value = objSource[objSource.selectedIndex].text;
}

// ¿©±â¼­ ºÎÅÍ ÀÚµ¿ÅÇ
//<input onKeyUp="return autoTab(this, 6, event);" size="7" maxlength="6"> - 
//<input onKeyUp="return autoTab(this, 7, event);" size="8" maxlength="7">
CForm.prototype.autoTab = function( input, len, e) 
{
	var isNN = ( navigator.appName.indexOf("Netscape") !=-1 );
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0, 8, 9] : [0, 8, 9, 16, 17, 18, 37, 38, 39, 40, 46];
	if( input.value.length >= len && !this.containsElement(filter,keyCode) ) {
		input.value = input.value.slice( 0, len );
		input.form[ ( this.getIndex(input) + 1 ) % input.form.length].focus();
	}

	return true;
}

CForm.prototype.containsElement = function( arr, ele ) 
{
	 var found = false, index = 0;
     while( !found && index < arr.length ) {
		 if(arr[index] == ele)
			found = true;
		 else
			index++;
	 }
     return found;
}

CForm.prototype.getIndex = function( input ) 
{
	var index = -1, i = 0, found = false;
	while ( i < input.form.length && index == -1 ) {
		if (input.form[i] == input)
			index = i;
		else 
			i++;
	}
	return index;
}
// ¿©±â±îÁö ºÎÅÍ ÀÚµ¿ÅÇ

CForm.prototype.setCookie = function(  name, value, path, domain ) 
{
	document.cookie = name + "=" + value;
	document.cookie += "path=" + path;
	document.cookie += "domain=" + domain;
}


CForm.prototype.closeWin = function(   ) 
{
	var domain = window.location.hostname;
	if ( "www.mywiki.co.kr" != domain) {
		alert( window.location.hostname );
		var result = confirm( "»çÀÌÆ®¸¦ Á¾·á ÇÏ½Ã°Ú½À´Ï±î? " );
		if ( result ) {
			//this.setCookie( "id", "", "/", "www.mywiki.co.kr");
		}
	}
}

CForm.prototype.showModal = function( url, title, w, h  ) 
{
        window.showModalDialog(  
			url,
            title, 
            "dialogWidth:" + w + "px;dialogHeight:" + h + "px; center:yes; help:no; status:no; scroll:no; resizable:no"
		); 
}

CForm.prototype.showModalScroll = function( url, title, w, h  ) 
{
        window.showModalDialog(  
			url,
            title, 
            "dialogWidth:" + w + "px;dialogHeight:" + h + "px; center:yes; help:no; status:no; scroll:no; resizable:no"
		); 
}

CForm.prototype.changePage = function( main, left  ) 
{
	parent.main.location.href	= main;
	parent.left.location.href		= left;
}

CForm.prototype.denyRightMouse = function(  ) 
{
	// ¿ìÃø ¸¶¿ì½º ±ÝÁö
	document.oncontextmenu = function(){return false} 
	if(document.layers) { 
		window.captureEvents(Event.MOUSEDOWN); 
		window.onmousedown = function(e) { 
			if(e.target==document)return false; 
		} 
	} 
	else { 
		document.onmousedown = function(){return false} 
	} 
}

//#################################
CForm.prototype.selectToggle = 	function( obj )
{
	if ( !obj ) return;

	if ( obj.length >0 ) {
		for(var i=0;  i<obj.length; i++) {

			if (  !obj[i].disabled ) {
				if( obj[i].checked )
					obj[i].checked = false;
				else
					obj[i].checked = true;
			}
		}
	}
	else {
		if (  obj.disabled ) return;

		if( obj.checked )
			obj.checked = false;
		else
			obj.checked = true;
	}
}

// divObj¸í, event, divObjMsg¸í, '³»¿ë', 1:show 0:hidden
CForm.prototype.toolTip =	function (obj, evt, objmsg, msg, flag) 
{
	if ( flag == 1 ) {
		obj.style.pixelLeft	= evt.clientX + 10;
		obj.style.pixelTop	= evt.clientY - 30;
		objmsg.innerHTML	= msg;
		obj.style.visibility	= "visible";
	}
	else
		obj.style.visibility = "hidden";
}
	
	
	
CForm.prototype.getRadioButtonValue = function( obj )
{
	var result = "";
	for( i=0; i< obj.length; i++ ) {
		if ( true == obj[i].checked ) {
			result = obj[i].value;
		}
	}
	return result;
}


CForm.prototype.getSelection = function( form, obj, index )
{
	return obj[index].value;
}

//ÇÏ³ª Ã¼Å©µÉ¶§ ÀüÃ¼ Ã¼Å©
CForm.prototype.swapCheckBox = function (srcObj, tarObj){
	if(tarObj !=null){
		if(typeof tarObj.length == 'undefined'){
			tarObj.checked = srcObj.checked;
		}
		else{
			for(var i=0;i<tarObj.length; i++){
				tarObj[i].checked = srcObj.checked;
			}
		}
	}
}

//±æÀÌ Ã¼Å©(byte´ÜÀ§)
CForm.prototype.checkAllowLength = function (objView, objTar, max_cnt){
	if(event.keyCode > 31 || event.keyCode == "") {
		if(objTar.value.bytes() > max_cnt){
			alert("ÃÖ´ë " + max_cnt + "byte¸¦ ³Ñ±æ ¼ö ¾ø½À´Ï´Ù.");
			objTar.value = objTar.value.cut(max_cnt);
			objTar.focus();
		}
	}

	if(objView != null && objView != "") objView.value = objTar.value.bytes();
}

	
var objForm = new CForm();
//objForm.denyRightMouse();
//window.onUnload = objForm.closeWin();
