function CForm( )
{
}

CForm.prototype.checkCount = function( obj ) 
{
	var m_Count = 0;
	//alert ( document.theForm.elements[i].name );			
	for( var i=0; i<document.theForm.elements.length; i++ ) {
		var target = document.theForm.elements[i];
		if( true == target.checked ){
			m_Count++;
			if ( m_Count > 3 ) {
				alert ( "3°³ÀÌ»ó Ã¼Å©ÇÏ½Ç ¼ö ¾ø½À´Ï´Ù. " );			
				obj.checked = false;
			}
		}	
	}
}

CForm.prototype.setColor = function( ev ) 
{
	var sEv = window.event.srcElement.parentElement;
	if (ev == 'over') {
		sEv.style.cursor = 'hand';
		sEv.style.backgroundColor = 'blue';
	}
	else {
		sEv.style.backgroundColor = '';
	}		
}

CForm.prototype.setColor2 = function( ev ) 
{
	this.showMSG( color );
	
	var sEv = window.event.srcElement.parentElement;
	if (ev == 'over') {
		sEv.style.cursor = 'hand';
		sEv.style.backgroundColor = '#F3FCFF';
	}
	else {
		sEv.style.backgroundColor = '';
	}		
}


CForm.prototype.setColor2= function( ev ) 
{
	var sEv = window.event.srcElement.parentElement;
	if (ev == 'over') {
		sEv.style.cursor = 'hand';
		sEv.style.backgroundColor = 'beige';
	}
	else {
		sEv.style.backgroundColor = '';
	}		
}

CForm.prototype.focusToHear = function( obj )
{
	obj.focus();
}

CForm.prototype.clearQuery = function( obj ) 
{
	obj.value='';
}

CForm.prototype.showMSG = function( msg )
{
	alert( msg );
}

CForm.prototype.initialize = function( obj )
{
	obj.value = "";
	obj.focus();
	obj.select();
}

CForm.prototype.isSpace = function( obj, errmsg )
{
	var bResult = false;
	
	if ( !obj.value ) { 
		this.showMSG( errmsg );
		bResult = true;
	}
	else  {
		bResult = false;
	}
	
	return bResult;
}


CForm.prototype.isHangeul = function( obj )
{
	var bResult = false;

	for ( i=0; i<obj.value.length; i++ ) {
		var code = obj.value.charCodeAt(i)
		var chr = obj.value.substr(i, 1).toUpperCase()
		code = parseInt( code )
		if ( (chr < "0" || chr > "9") && (chr < "A" || chr > "Z") && ( (code > 255) || (code < 0) ) ) {
			bResult = true;
			break;
		}
		else {
			bResult = false;
			break;
		}
	}
	
	return bResult;
}


CForm.prototype.isEMail = function( value )
{
	var bResult = false;
	
	/*
	var supported = 0; 
	
	if ( window.RegExp ) { 
		var tempStr = "a"; 
		var tempReg = new RegExp( tempStr ); 
		if ( tempReg.test(tempStr) ) 
			supported = 1; 
	} 

	if (!supported) {
		if ( true == ( ( value.indexOf(".") > 1 ) && ( value.indexOf("@") > 0) )  ) {
			bResult = true;
		}
		else {
			bReuslt = false;
		} 
	}
	*/

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)"); 
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"); 
	
	if ( true == (!r1.test(value) && r2.test(value) )  )
		bResult = true;
	else 
		bResult = false;
	
	return bResult;
}

CForm.prototype.selectEMailCompany = function( objSource, objTarget )
{
	objTarget.value = objSource[objSource.selectedIndex].text;
	//form.tfEMail2.value = form.stEMail3[form.stEMail3.selectedIndex].text;
}

CForm.prototype.checkRange = function( obj, value1, value2 )
{
	var bResult = false;
	
	sum = 0;

	for(var i = 0; i < obj.value.length; i++){
		var k = obj.value.charCodeAt(i) ; 

		if(k >= 0 && k <= 255) 
			sum += 1;
		else
			sum += 2;
	}

	if ( sum >= value1 && sum <= value2 ) {
		bResult =  true;
	}
	else {
		bResult =  false;
	}
	
	return bResult;
}

CForm.prototype.isEqual = function( obj1, obj2 )
{
	var bResult = false;
	
	if ( obj1.value != obj2.value ) {
		this.initialize( obj2 );
		bResult = false;
	}
	else {
		bResult = true;
	  }

	return bResult;
}

CForm.prototype.isNumber = function( obj )
{
	var bResult = false;
	
	/*
	if ( obj.isNaN() )
		bResult = true;
	else
		bResult = false;
		
	return bResult;
	*/
	
	for ( var i=0; i < obj.value.length; i++ ) {
		var chr = obj.value.substr(i, 1);
		if ( chr < '0' || chr > '9' ) 
			return false;
		else
			return true;
	}
}


CForm.prototype.checkSNo = function( obj1, obj2 )
{
	// ÁÖ¹Îµî·Ï¹øÈ£ °Ë»ç
	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) )  ) {	
		return false;
	}
	else
		return true;
}	

CForm.prototype.formSubmit = function( form, URL ) 
{
	form.method = "get";
	form.action = URL;
	form.submit();
}


CForm.prototype.openWin = 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 + ',' + 'status=no scrollbars=yes' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);
}

CForm.prototype.openWin2= 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 + ',' + 'status=no scrollbars=no' + ',' + 'top=' + topY + ',' + 'left=' + leftX + '' 
	);
}


CForm.prototype.checkIdDuplicated = function( obj, URL, w, h)
{
	var ref = URL + obj.value;
	var winHandle = this.openWin2( ref, "¾ÆÀÌµðÁßº¹È®ÀÎ", w, h );
	winHandle = this;
}

CForm.prototype.searchZipcode = function( URL, w, h)
{
	var winHandle = this.openWin( URL, "¿ìÆí¹øÈ£Ã£±â", w, h );
	winHandle = this;
}

var objForm = new CForm();

